From 313e6da23426f1b734aafaa24c0d4dc515e13655 Mon Sep 17 00:00:00 2001 From: devlooped-bot Date: Sun, 15 Sep 2024 19:02:06 +0000 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Bump=20files=20with=20dotn?= =?UTF-8?q?et-file=20sync=20#=20devlooped/oss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Simplify .gitattributes https://github.com/devlooped/oss/commit/5f92a68 # devlooped/SponsorLink - Add overload to simplify getting or setting status https://github.com/devlooped/SponsorLink/commit/efda32a --- .gitattributes | 22 +++---------------- .netconfig | 16 +++++++------- .../Analyzer/StatusReportingGenerator.cs | 7 +++--- .../SponsorLink/DiagnosticsManager.cs | 7 ++++++ src/SponsorLink/SponsorLink/SponsorLink.cs | 14 ++++++++++++ 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/.gitattributes b/.gitattributes index 7c375796..4f891486 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,24 +1,8 @@ -# sln, csproj files (and friends) are always CRLF, even on linux -*.sln text eol=crlf -*.proj text eol=crlf -*.csproj text eol=crlf +# normalize by default +* text=auto encoding=UTF-8 +*.sh text eol=lf # These are windows specific files which we may as well ensure are # always crlf on checkout *.bat text eol=crlf *.cmd text eol=crlf - -# Opt in known filetypes to always normalize line endings on checkin -# and always use native endings on checkout -*.c text -*.config text -*.h text -*.cs text -*.md text -*.tt text -*.txt text - -# Some must always be checked out as lf so enforce that for those files -# If these are not lf then bash/cygwin on windows will not be able to -# excute the files -*.sh text eol=lf \ No newline at end of file diff --git a/.netconfig b/.netconfig index 1ae2c68b..c340cb2e 100644 --- a/.netconfig +++ b/.netconfig @@ -20,9 +20,9 @@ sha = e81ab754b366d52d92bd69b24bef1d5b1c610634 [file ".gitattributes"] url = https://github.com/devlooped/oss/blob/main/.gitattributes - etag = 7acb32f5fa6d4ccd9c824605a7c2b8538497f0068c165567807d393dcf4d6bb7 + etag = 338ba6d92c8d1774363396739c2be4257bfc58026f4b0fe92cb0ae4460e1eff7 weak - sha = 0683ee777d7d878d4bf013d7deea352685135a05 + sha = 5f92a68e302bae675b394ef343114139c075993e [file ".github/dependabot.yml"] url = https://github.com/devlooped/oss/blob/main/.github/dependabot.yml etag = c147ea2f3431ca0338c315c4a45b56ee233c4d30f8d6ab698d0e1980a257fd6a @@ -146,8 +146,8 @@ weak [file "src/SponsorLink/Analyzer/StatusReportingGenerator.cs"] url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Analyzer/StatusReportingGenerator.cs - sha = 38a11504cc9cbd994fb7380fd580102e7514b3b5 - etag = 8a457fdb6d22be34740ae474f4dfc32e55696093d315519e08dd2280c8cb3745 + sha = efda32a6eaaeffa485fb480e31adfd2f8130bd48 + etag = 34dd69526941ce9c6eb8fe259020333b2b55c8422d1d620eb431a8ba7125b3f9 weak [file "src/SponsorLink/Analyzer/buildTransitive/SponsorableLib.targets"] url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/Analyzer/buildTransitive/SponsorableLib.targets @@ -191,8 +191,8 @@ weak [file "src/SponsorLink/SponsorLink/DiagnosticsManager.cs"] url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/DiagnosticsManager.cs - sha = 46e9abe02e5a6abadda66ef050ddc5b9859aa2b8 - etag = 72fe901dd67f30c1b78990599303ec6f409b2021a6da20edd66cc57f5d6e299c + sha = efda32a6eaaeffa485fb480e31adfd2f8130bd48 + etag = 76c240a3677af6c7f474ec65f0d883a746137a122ad986f8356753e2d03372c3 weak [file "src/SponsorLink/SponsorLink/ManifestStatus.cs"] url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/ManifestStatus.cs @@ -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 = f6fd85da07d1b52922fb48676d9aed9f1aef782b - etag = 0904bd22c6abf4a5a4f6334ee38413eddcf2af8540901b3541f68ae0c20ce6d3 + sha = efda32a6eaaeffa485fb480e31adfd2f8130bd48 + etag = 555128f4279241225b4dc8bb2ec8835894edfe9f6b9223399ee8cb3dc7adaf06 weak [file "src/SponsorLink/SponsorLink/SponsorLink.csproj"] url = https://github.com/devlooped/SponsorLink/blob/main/samples/dotnet/SponsorLink/SponsorLink.csproj diff --git a/src/SponsorLink/Analyzer/StatusReportingGenerator.cs b/src/SponsorLink/Analyzer/StatusReportingGenerator.cs index 964a2fd8..d0124278 100644 --- a/src/SponsorLink/Analyzer/StatusReportingGenerator.cs +++ b/src/SponsorLink/Analyzer/StatusReportingGenerator.cs @@ -12,15 +12,14 @@ public void Initialize(IncrementalGeneratorInitializationContext context) context.RegisterSourceOutput( // this is required to ensure status is registered properly independently // of analyzer runs. - context.GetSponsorAdditionalFiles().Combine(context.AnalyzerConfigOptionsProvider), + context.GetStatusOptions(), (spc, source) => { - var (manifests, options) = source; - var status = Diagnostics.GetOrSetStatus(manifests, options); + var status = Diagnostics.GetOrSetStatus(source); spc.AddSource("StatusReporting.cs", $""" // Status: {status} - // DesignTimeBuild: {options.IsDesignTimeBuild()} + // DesignTimeBuild: {source.GlobalOptions.IsDesignTimeBuild()} """); spc.ReportDiagnostic(Diagnostic.Create("SL200", "Compiler", "Don't disable me!", DiagnosticSeverity.Warning, diff --git a/src/SponsorLink/SponsorLink/DiagnosticsManager.cs b/src/SponsorLink/SponsorLink/DiagnosticsManager.cs index 48533a13..4e411669 100644 --- a/src/SponsorLink/SponsorLink/DiagnosticsManager.cs +++ b/src/SponsorLink/SponsorLink/DiagnosticsManager.cs @@ -68,6 +68,13 @@ ConcurrentDictionary Diagnostics public SponsorStatus GetOrSetStatus(ImmutableArray manifests, AnalyzerConfigOptionsProvider options) => GetOrSetStatus(() => manifests, () => options.GlobalOptions); + /// + /// Gets the status of the , or sets it from + /// the given set of if not already set. + /// + public SponsorStatus GetOrSetStatus(StatusOptions options) + => GetOrSetStatus(() => options.AdditionalFiles, () => options.GlobalOptions); + /// /// Gets the status of the , or sets it from /// the given analyzer if not already set. diff --git a/src/SponsorLink/SponsorLink/SponsorLink.cs b/src/SponsorLink/SponsorLink/SponsorLink.cs index e0a708f4..eecd2185 100644 --- a/src/SponsorLink/SponsorLink/SponsorLink.cs +++ b/src/SponsorLink/SponsorLink/SponsorLink.cs @@ -18,6 +18,12 @@ namespace Devlooped.Sponsors; static partial class SponsorLink { + public record StatusOptions(ImmutableArray AdditionalFiles, AnalyzerConfigOptions GlobalOptions); + + /// + /// Statically cached dictionary of sponsorable accounts and their public key (in JWK format), + /// retrieved from assembly metadata attributes starting with "Funding.GitHub.". + /// public static Dictionary Sponsorables { get; } = typeof(SponsorLink).Assembly .GetCustomAttributes() .Where(x => x.Key.StartsWith("Funding.GitHub.")) @@ -93,6 +99,14 @@ public static IncrementalValueProvider> GetSponso .Select((source, c) => source.Left) .Collect(); + /// + /// Gets the status options for use within an incremental generator, to avoid depending on + /// analyzer runs. Used in combination with . + /// + public static IncrementalValueProvider GetStatusOptions(this IncrementalGeneratorInitializationContext context) + => context.GetSponsorAdditionalFiles().Combine(context.AnalyzerConfigOptionsProvider) + .Select((source, _) => new StatusOptions(source.Left, source.Right.GlobalOptions)); + static bool IsSponsorManifest(this AdditionalText text, AnalyzerConfigOptionsProvider provider) => provider.GetOptions(text).TryGetValue("build_metadata.SponsorManifest.ItemType", out var itemType) && itemType == "SponsorManifest" &&