From e815434c459bc82e5524e6cfdb004a643aa8a494 Mon Sep 17 00:00:00 2001 From: devlooped-bot Date: Sat, 29 Jun 2024 23:54:19 +0000 Subject: [PATCH 1/3] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Bump=20files=20with=20?= =?UTF-8?q?dotnet-file=20sync=20#=20devlooped/oss?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Make sure we report only once per product for entire solution https://github.com/devlooped/oss/commit/4b7f922 --- src/SponsorLink/Library/Library.csproj | 4 ++ .../SponsorLink/DiagnosticsManager.cs | 50 +++++++++++++++---- .../SponsorLink/SponsorLinkAnalyzer.cs | 4 +- 3 files changed, 46 insertions(+), 12 deletions(-) diff --git a/src/SponsorLink/Library/Library.csproj b/src/SponsorLink/Library/Library.csproj index f363648..6e79399 100644 --- a/src/SponsorLink/Library/Library.csproj +++ b/src/SponsorLink/Library/Library.csproj @@ -18,4 +18,8 @@ + + + + diff --git a/src/SponsorLink/SponsorLink/DiagnosticsManager.cs b/src/SponsorLink/SponsorLink/DiagnosticsManager.cs index 1d31b39..96e7e14 100644 --- a/src/SponsorLink/SponsorLink/DiagnosticsManager.cs +++ b/src/SponsorLink/SponsorLink/DiagnosticsManager.cs @@ -4,9 +4,12 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; +using System.Diagnostics; using System.Globalization; using System.IO; +using System.IO.MemoryMappedFiles; using System.Linq; +using System.Threading; using Humanizer; using Humanizer.Localisation; using Microsoft.CodeAnalysis; @@ -21,6 +24,8 @@ namespace Devlooped.Sponsors; /// class DiagnosticsManager { + static readonly Guid appDomainDiagnosticsKey = new(0x8d0e2670, 0xe6c4, 0x45c8, 0x81, 0xba, 0x5a, 0x36, 0x81, 0xd3, 0x65, 0x3e); + public static Dictionary KnownDescriptors { get; } = new() { // Requires: @@ -36,17 +41,31 @@ class DiagnosticsManager /// Acceses the diagnostics dictionary for the current . /// ConcurrentDictionary Diagnostics - => AppDomainDictionary.Get>(nameof(Diagnostics)); + => AppDomainDictionary.Get>(appDomainDiagnosticsKey.ToString()); /// /// Attemps to remove a diagnostic for the given product. /// /// The product diagnostic that might have been pushed previously. /// The removed diagnostic, or if none was previously pushed. - public Diagnostic? Pop(string product) + public void ReportOnce(Action report, string product = Funding.Product) { - Diagnostics.TryRemove(product, out var diagnostic); - return diagnostic; + if (Diagnostics.TryRemove(product, out var diagnostic)) + { + // Ensure only one such diagnostic is reported per product for the entire process, + // so that we can avoid polluting the error list with duplicates across multiple projects. + var id = string.Concat(Process.GetCurrentProcess().Id, product, diagnostic.Id); + using var mutex = new Mutex(false, "mutex" + id); + mutex.WaitOne(); + using var mmf = MemoryMappedFile.CreateOrOpen(id, 1); + using var accessor = mmf.CreateViewAccessor(); + if (accessor.ReadByte(0) == 0) + { + accessor.Write(0, 1); + report(diagnostic); + Tracing.Trace($"👈{diagnostic.Severity.ToString().ToLowerInvariant()}:{Process.GetCurrentProcess().Id}:{Process.GetCurrentProcess().ProcessName}:{product}:{diagnostic.Id}"); + } + } } /// @@ -103,7 +122,7 @@ SponsorStatus GetOrSetStatus(Func> getManifests) claims.GetExpiration() is not DateTime exp) { // report unknown, either unparsed manifest or one with no expiration (which we never emit). - Push(Funding.Product, Diagnostic.Create(KnownDescriptors[SponsorStatus.Unknown], null, + Push(Diagnostic.Create(KnownDescriptors[SponsorStatus.Unknown], null, properties: ImmutableDictionary.Create().Add(nameof(SponsorStatus), nameof(SponsorStatus.Unknown)), Funding.Product, Sponsorables.Keys.Humanize(Resources.Or))); return SponsorStatus.Unknown; @@ -114,14 +133,14 @@ SponsorStatus GetOrSetStatus(Func> getManifests) if (exp.AddDays(Funding.Grace) < DateTime.Now) { // report expiring soon - Push(Funding.Product, Diagnostic.Create(KnownDescriptors[SponsorStatus.Expiring], null, + Push(Diagnostic.Create(KnownDescriptors[SponsorStatus.Expiring], null, properties: ImmutableDictionary.Create().Add(nameof(SponsorStatus), nameof(SponsorStatus.Expiring)))); return SponsorStatus.Expiring; } else { // report expired - Push(Funding.Product, Diagnostic.Create(KnownDescriptors[SponsorStatus.Expired], null, + Push(Diagnostic.Create(KnownDescriptors[SponsorStatus.Expired], null, properties: ImmutableDictionary.Create().Add(nameof(SponsorStatus), nameof(SponsorStatus.Expired)))); return SponsorStatus.Expired; } @@ -129,7 +148,7 @@ SponsorStatus GetOrSetStatus(Func> getManifests) else { // report sponsor - Push(Funding.Product, Diagnostic.Create(KnownDescriptors[SponsorStatus.Sponsor], null, + Push(Diagnostic.Create(KnownDescriptors[SponsorStatus.Sponsor], null, properties: ImmutableDictionary.Create().Add(nameof(SponsorStatus), nameof(SponsorStatus.Sponsor)), Funding.Product)); return SponsorStatus.Sponsor; @@ -140,11 +159,22 @@ SponsorStatus GetOrSetStatus(Func> getManifests) /// Pushes a diagnostic for the given product. /// /// The same diagnostic that was pushed, for chained invocations. - Diagnostic Push(string product, Diagnostic diagnostic) + Diagnostic Push(Diagnostic diagnostic, string product = Funding.Product) { // We only expect to get one warning per sponsorable+product // combination, and first one to set wins. - Diagnostics.TryAdd(product, diagnostic); + if (Diagnostics.TryAdd(product, diagnostic)) + { + // Reset the process-wide flag for this diagnostic. + var id = string.Concat(Process.GetCurrentProcess().Id, product, diagnostic.Id); + using var mutex = new Mutex(false, "mutex" + id); + mutex.WaitOne(); + using var mmf = MemoryMappedFile.CreateOrOpen(id, 1); + using var accessor = mmf.CreateViewAccessor(); + accessor.Write(0, 0); + Tracing.Trace($"👉{diagnostic.Severity.ToString().ToLowerInvariant()}:{Process.GetCurrentProcess().Id}:{Process.GetCurrentProcess().ProcessName}:{product}:{diagnostic.Id}"); + } + return diagnostic; } diff --git a/src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs b/src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs index dc2a9d3..0cf507f 100644 --- a/src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs +++ b/src/SponsorLink/SponsorLink/SponsorLinkAnalyzer.cs @@ -45,7 +45,7 @@ public override void Initialize(AnalysisContext context) // NOTE: for multiple projects with the same product name, we only report one diagnostic, // so it's expected to NOT get a diagnostic back. Also, we don't want to report // multiple diagnostics for each project in a solution that uses the same product. - if (Diagnostics.Pop(Funding.Product) is Diagnostic diagnostic) + Diagnostics.ReportOnce(diagnostic => { // For unknown (never sync'ed), only report if install grace period is over if (status == SponsorStatus.Unknown) @@ -80,7 +80,7 @@ public override void Initialize(AnalysisContext context) } ctx.ReportDiagnostic(diagnostic); - } + }); }); } }); From 0ba38c6042a32f4c6100159f5f57c5d5936edcd1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 9 Jul 2024 00:43:02 +0000 Subject: [PATCH 2/3] Bump the tests group with 2 updates Bumps the tests group with 2 updates: xunit and xunit.runner.visualstudio. Updates `xunit` from 2.8.1 to 2.9.0 Updates `xunit.runner.visualstudio` from 2.8.1 to 2.8.2 --- updated-dependencies: - dependency-name: xunit dependency-type: direct:production update-type: version-update:semver-minor dependency-group: tests - dependency-name: xunit.runner.visualstudio dependency-type: direct:production update-type: version-update:semver-patch dependency-group: tests ... Signed-off-by: dependabot[bot] --- src/Tests/Tests.csproj | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index 26c39ec..da6b80d 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -1,27 +1,27 @@ - - - - net8.0 - false - true - - - - - - - - - - - - - - - - - - - - - + + + + net8.0 + false + true + + + + + + + + + + + + + + + + + + + + + From 72b70c85935dc27d739f73ac90a3acfa64892a35 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 24 Jul 2024 01:31:45 +0000 Subject: [PATCH 3/3] Bump the orleans group with 3 updates Bumps the orleans group with 3 updates: Microsoft.Orleans.Runtime, Microsoft.Orleans.Server and Microsoft.Orleans.TestingHost. Updates `Microsoft.Orleans.Runtime` from 8.1.0 to 8.2.0 Updates `Microsoft.Orleans.Server` from 8.1.0 to 8.2.0 Updates `Microsoft.Orleans.Runtime` from 8.1.0 to 8.2.0 Updates `Microsoft.Orleans.TestingHost` from 8.1.0 to 8.2.0 Updates `Microsoft.Orleans.Runtime` from 8.1.0 to 8.2.0 --- updated-dependencies: - dependency-name: Microsoft.Orleans.Runtime dependency-type: direct:production update-type: version-update:semver-minor dependency-group: orleans - dependency-name: Microsoft.Orleans.Server dependency-type: direct:production update-type: version-update:semver-minor dependency-group: orleans - dependency-name: Microsoft.Orleans.Runtime dependency-type: direct:production update-type: version-update:semver-minor dependency-group: orleans - dependency-name: Microsoft.Orleans.TestingHost dependency-type: direct:production update-type: version-update:semver-minor dependency-group: orleans - dependency-name: Microsoft.Orleans.Runtime dependency-type: direct:production update-type: version-update:semver-minor dependency-group: orleans ... Signed-off-by: dependabot[bot] --- .../CloudActors.Orleans.csproj | 34 +++++++------- .../CloudActors.Streamstone.csproj | 46 +++++++++---------- src/Tests/Tests.csproj | 4 +- 3 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/CloudActors.Orleans/CloudActors.Orleans.csproj b/src/CloudActors.Orleans/CloudActors.Orleans.csproj index b927ee4..3b2c2cc 100644 --- a/src/CloudActors.Orleans/CloudActors.Orleans.csproj +++ b/src/CloudActors.Orleans/CloudActors.Orleans.csproj @@ -1,17 +1,17 @@ - - - - Devlooped.CloudActors.Orleans - net8.0 - - - - - - - - - - - - + + + + Devlooped.CloudActors.Orleans + net8.0 + + + + + + + + + + + + diff --git a/src/CloudActors.Streamstone/CloudActors.Streamstone.csproj b/src/CloudActors.Streamstone/CloudActors.Streamstone.csproj index d9ec9b5..bb9bc5c 100644 --- a/src/CloudActors.Streamstone/CloudActors.Streamstone.csproj +++ b/src/CloudActors.Streamstone/CloudActors.Streamstone.csproj @@ -1,23 +1,23 @@ - - - - Devlooped.CloudActors.Streamstone - net8.0 - Devlooped.CloudActors.Streamstone - Cloud Native Actors: Streamstone storage for Azure Tables - dotnet orleans actor azure table - - - - - - - - - - - - - - - + + + + Devlooped.CloudActors.Streamstone + net8.0 + Devlooped.CloudActors.Streamstone + Cloud Native Actors: Streamstone storage for Azure Tables + dotnet orleans actor azure table + + + + + + + + + + + + + + + diff --git a/src/Tests/Tests.csproj b/src/Tests/Tests.csproj index da6b80d..ce39a15 100644 --- a/src/Tests/Tests.csproj +++ b/src/Tests/Tests.csproj @@ -8,12 +8,12 @@ - + - +