Skip to content

Commit

Permalink
Merge pull request #29 from Sergio0694/dev/fix-multiline-properties
Browse files Browse the repository at this point in the history
Fix multiline properties for generator
  • Loading branch information
Sergio0694 authored Nov 22, 2022
2 parents 53c6a8c + b575d10 commit 84942e8
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/PolySharp.SourceGenerators/PolySharp.targets
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@
<Analyzer Remove="@(_PolySharpAnalyzer)"/>
</ItemGroup>

<!-- Mark the MSBuild properties to configure the generator visible for the compiler, so the analyzer can see them -->
<ItemGroup>
<CompilerVisibleProperty Include="PolySharpUsePublicAccessibilityForGeneratedTypes"/>
<CompilerVisibleProperty Include="PolySharpIncludeRuntimeSupportedAttributes"/>
<CompilerVisibleProperty Include="PolySharpExcludeGeneratedTypes"/>
<CompilerVisibleProperty Include="PolySharpIncludeGeneratedTypes"/>
</ItemGroup>

<!--
If the source generators are disabled, also emit an error. This would've been produced by MSBuild itself as well, but
emitting this manually lets us customize the message to inform developers as to why exactly the generators have been
Expand All @@ -65,4 +57,23 @@
</ItemGroup>
</Target>

<!-- Configure the MSBuild properties used to control PolySharp's generator -->
<Target Name="ConfigurePolySharpMSBuildProperties"
BeforeTargets="PrepareForBuild">

<!-- Mark the MSBuild properties to configure the generator visible for the compiler, so the analyzer can see them -->
<ItemGroup>
<CompilerVisibleProperty Include="PolySharpUsePublicAccessibilityForGeneratedTypes"/>
<CompilerVisibleProperty Include="PolySharpIncludeRuntimeSupportedAttributes"/>
<CompilerVisibleProperty Include="PolySharpExcludeGeneratedTypes"/>
<CompilerVisibleProperty Include="PolySharpIncludeGeneratedTypes"/>
</ItemGroup>

<!-- Adds necessary fixups for multiline properties (replaces ';' characters with ',' and strip new lines) -->
<PropertyGroup>
<PolySharpExcludeGeneratedTypes>$([System.Text.RegularExpressions.Regex]::Replace($(PolySharpExcludeGeneratedTypes.Replace(';', ',')), '[\r\n]', ''))</PolySharpExcludeGeneratedTypes>
<PolySharpIncludeGeneratedTypes>$([System.Text.RegularExpressions.Regex]::Replace($(PolySharpIncludeGeneratedTypes.Replace(';', ',')), '[\r\n]', ''))</PolySharpIncludeGeneratedTypes>
</PropertyGroup>
</Target>

</Project>

0 comments on commit 84942e8

Please sign in to comment.