Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⬆️ Bump files with dotnet-file sync #438

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading