Skip to content

Commit

Permalink
⬆️ Bump files with dotnet-file sync
Browse files Browse the repository at this point in the history
# devlooped/SponsorLink

- Make sure to reference NS2.0 analyzers for tests debugging devlooped/SponsorLink@df44ccc
- Allow getting sponsors options for non-incremental generator devlooped/SponsorLink@3f72a9f
  • Loading branch information
devlooped-bot authored and kzu committed Jan 9, 2025
1 parent 6393427 commit e9179b2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
8 changes: 4 additions & 4 deletions .netconfig
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@
weak
[file "src/SponsorLink/SponsorLink/SponsorLink.cs"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.cs
sha = efda32a6eaaeffa485fb480e31adfd2f8130bd48
etag = 555128f4279241225b4dc8bb2ec8835894edfe9f6b9223399ee8cb3dc7adaf06
sha = 3f72a9fd35274a659dd380a7d5b747d71b9732a1
etag = 616598e0ecb6d2ce97660aa6ac049e2a31a1c953669743b7b612b61d40c37706
weak
[file "src/SponsorLink/SponsorLink/SponsorLink.csproj"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.csproj
Expand Down Expand Up @@ -356,8 +356,8 @@
weak
[file "src/SponsorLink/SponsorLink.Analyzer.Tests.targets"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink.Analyzer.Tests.targets
sha = fb82cf346cea86140a51ae49b9bc730d72f7c7ac
etag = 9944d7fe502d162aa06f6af00c027ece18ad10b595eb37a403fc42dfbbbac93c
sha = df44ccc14cc11b5674c55aca9ba8596bdbcf8438
etag = a3e9cbcc227dd56a7bed236eaded136f1b80f9f36a4fabce8be695ee844bf881
weak
[file "src/SponsorLink/SponsorLink/Resources.es-AR.resx"]
url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/Resources.es-AR.resx
Expand Down
14 changes: 12 additions & 2 deletions src/SponsorLink/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>
9 changes: 9 additions & 0 deletions src/SponsorLink/SponsorLink/SponsorLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,15 @@ public static IncrementalValueProvider<StatusOptions> GetStatusOptions(this Incr
=> context.GetSponsorAdditionalFiles().Combine(context.AnalyzerConfigOptionsProvider)
.Select((source, _) => new StatusOptions(source.Left, source.Right.GlobalOptions));

/// <summary>
/// Gets the status options for use within a source generator, to avoid depending on
/// analyzer runs. Used in combination with <see cref="DiagnosticsManager.GetOrSetStatus(StatusOptions)"/>.
/// </summary>
public static StatusOptions GetStatusOptions(this GeneratorExecutionContext context)
=> new StatusOptions(
context.AdditionalFiles.Where(x => x.IsSponsorManifest(context.AnalyzerConfigOptions) || x.IsSponsorableAnalyzer(context.AnalyzerConfigOptions)).ToImmutableArray(),
context.AnalyzerConfigOptions.GlobalOptions);

static bool IsSponsorManifest(this AdditionalText text, AnalyzerConfigOptionsProvider provider)
=> provider.GetOptions(text).TryGetValue("build_metadata.SponsorManifest.ItemType", out var itemType) &&
itemType == "SponsorManifest" &&
Expand Down

0 comments on commit e9179b2

Please sign in to comment.