Skip to content

Commit

Permalink
Make sure to reference NS2.0 analyzers for tests debugging
Browse files Browse the repository at this point in the history
Since analyzers cannot target anything else.
  • Loading branch information
kzu committed Dec 3, 2024
1 parent 3f72a9f commit df44ccc
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions samples/dotnet/SponsorLink.Analyzer.Tests.targets
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@
<ReferenceCopyLocalAssemblies Include="@(ReferenceCopyLocalPaths)" Condition="'%(Extension)' == '.dll'
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').EndsWith('.resources', StringComparison.OrdinalIgnoreCase))
And !$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('ThisAssembly', StringComparison.OrdinalIgnoreCase))" />
<Analyzer Include="@(ReferenceCopyLocalAssemblies)" Condition="

<CandidateAnalyzer Include="@(ReferenceCopyLocalAssemblies)" Condition="
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CodeAnalysis', StringComparison.OrdinalIgnoreCase)) And
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.CSharp', StringComparison.OrdinalIgnoreCase)) And
!$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.', StringComparison.OrdinalIgnoreCase))"
/>
<!-- Brings in System/Microsoft.IdentityModel, System.Text.Encodings.Web, System.Text.Json, Humanizer -->
<Analyzer Include="@(ReferenceCopyLocalAssemblies)" Condition="
<CandidateAnalyzer Include="@(ReferenceCopyLocalAssemblies)" Condition="
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Microsoft.IdentityModel', StringComparison.OrdinalIgnoreCase)) Or
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('System.Text', StringComparison.OrdinalIgnoreCase)) Or
$([MSBuild]::ValueOrDefault('%(FileName)', '').StartsWith('Humanizer', StringComparison.OrdinalIgnoreCase))"
/>
</ItemGroup>

<ItemGroup>
<UniqueCandidateAnalyzer Include="@(CandidateAnalyzer -> Distinct())" />
<UniqueCandidateAnalyzer>
<NetStandard>$([MSBuild]::ValueOrDefault('%(FullPath)', '').Replace('net6.0', 'netstandard2.0').Replace('net8.0', 'netstandard2.0').Replace('netcoreapp3.1', 'netstandard2.0'))</NetStandard>
</UniqueCandidateAnalyzer>
<!-- Analyzer assemblies cannot target anything other than NS2.0 -->
<Analyzer Include="@(UniqueCandidateAnalyzer -> '%(NetStandard)')" Condition="Exists('%(UniqueCandidateAnalyzer.NetStandard)')"/>
</ItemGroup>
</Target>

</Project>

0 comments on commit df44ccc

Please sign in to comment.