From 9be92526f53f7d7603e579ccda856fa3e357003e Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Wed, 23 Sep 2026 00:12:26 +0100 Subject: [PATCH 1/3] refactor: source gen update --- AGENTS.md | 2 +- Directory.Packages.props | 2 +- README.md | 2 +- docs/release-process.md | 2 +- package.json | 2 +- purview-build.json | 50 ++++++++++--------- src/Directory.Build.props | 8 +-- .../SourceGenerator.Refactorings.csproj | 1 - ...ActivitySourceTargetClassEmitter.Fields.cs | 27 ++++------ ...ctivitySourceTargetClassEmitter.Methods.cs | 5 -- .../Emitters/ConstructorEmitter.cs | 1 - .../DependencyInjectionClassEmitter.cs | 1 - .../Emitters/GeneratedTypesEmitter.cs | 9 +--- .../LoggerGenTargetClassEmitter.Methods.cs | 35 ++----------- .../Emitters/LoggerGenTargetClassEmitter.cs | 1 - .../LoggerTargetClassEmitter.Fields.cs | 2 - .../LoggerTargetClassEmitter.Methods.cs | 3 -- .../MeterTargetClassEmitter.Fields.cs | 11 +--- ...TargetClassEmitter.InitializationMethod.cs | 2 - .../MeterTargetClassEmitter.Methods.cs | 2 - .../SourceGenerator/Helpers/IsExternalInit.cs | 15 ------ .../SourceGenerator/SourceGenerator.csproj | 12 ++--- .../IncludeLoggerTypes.cs | 4 +- .../Polyfills/Net48Polyfills.cs | 4 +- .../SourceGenerator.IntegrationTests.csproj | 8 +-- 25 files changed, 61 insertions(+), 150 deletions(-) delete mode 100644 src/src/SourceGenerator/Helpers/IsExternalInit.cs diff --git a/AGENTS.md b/AGENTS.md index 9f3b611e..0d66524c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -62,7 +62,7 @@ conventional-commits check. | `just update-version` | Runs `.build/update-version.ts` to sync the version into docs/samples. | | `just pack` | Updates the version then packs the NuGet package into `artifacts/`. | -The version lives in `package.json`. **Current Version:** 5.0.0-prerelease.11 — applied to `Version` / +The version lives in `package.json`. **Current Version:** 5.0.0-prerelease.13 — applied to `Version` / `PackageVersion` via the SDK's package.json version detection. ### Pipelines (reusable `purview-build` tool) diff --git a/Directory.Packages.props b/Directory.Packages.props index ac8f4f16..19dea8a3 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -3,7 +3,7 @@ true 5.9.0 1.67.0 - 1.0.0-prerelease.47 + 1.0.0-prerelease.48 10.0.12 10.10.0 1.18.0 diff --git a/README.md b/README.md index 59ea2397..f58f269d 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ Generates [`ActivitySource`](https://learn.microsoft.com/en-us/dotnet/api/system Add to your `Directory.Build.props` or `.csproj` file: ```xml - + all analyzers diff --git a/docs/release-process.md b/docs/release-process.md index cb93aeff..cd16d4b7 100644 --- a/docs/release-process.md +++ b/docs/release-process.md @@ -70,7 +70,7 @@ Merging to `main` triggers `release.yml`, which runs the reusable `purview-relea ## Versioning -- The version lives in `package.json`. **Current Version:** 5.0.0-prerelease.11 +- The version lives in `package.json`. **Current Version:** 5.0.0-prerelease.13 - It is applied to `Version` / `PackageVersion` by `Purview.BuildSdk` via package.json version detection (`UsePackageJsonVersion`, default `true`). - `just version` prints the current version. diff --git a/package.json b/package.json index 338edb99..763f66e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purview-telemetry-sourcegenerator", - "version": "5.0.0-prerelease.12", + "version": "5.0.0-prerelease.13", "description": "Generates [`ActivitySource`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activitysource), [`ILogger`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger), and [`Metrics`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics) based on interface methods.", "readme": "README.md", "repository": { diff --git a/purview-build.json b/purview-build.json index db41cdc0..60850c66 100644 --- a/purview-build.json +++ b/purview-build.json @@ -1,27 +1,29 @@ { - "Build": { - "Solution": "src/Telemetry.SourceGenerator.slnx", - "TestRoot": "src/tests", - "TestPatterns": "*Tests.csproj", - "TestFilter": "/*/*/*/*" - }, - "PackValidation": { - "RequireSymbolPackage": true, - "RequireSymbolFiles": true, - "RequiredContent": { - "purview.valueobjects": [ - "README.md", - "purview-logo-light.png", - "buildTransitive/Purview.ValueObjects.targets", - "analyzers/dotnet/cs/Purview.SourceGeneratorFramework.dll", - "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.dll", - "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.Refactorings.dll", - "lib/netstandard2.0/Purview.Telemetry.SourceGenerator.Refactorings.dll" - ] + "Build": { + "Solution": "src/Telemetry.SourceGenerator.slnx", + "TestRoot": "src/tests", + "TestPatterns": "*Tests.csproj", + "TestFilter": "/*/*/*/*" }, - "ForbiddenContent": {} - }, - "Release": { - "Mode": "None" - } + "PackValidation": { + "RequireSymbolPackage": true, + "RequireSymbolFiles": true, + "RequiredContent": { + "purview.telemetry.sourcegenerator": [ + "README.md", + "purview-logo-light.png", + "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.dll", + "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.Refactorings.dll", + "lib/netstandard2.0/Purview.Telemetry.SourceGenerator.dll" + ] + }, + "ForbiddenContent": { + "purview.telemetry.sourcegenerator": [ + "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.pdb" + ] + } + }, + "Release": { + "Mode": "None" + } } diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 0b4c0457..89cc6a4a 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,7 +3,7 @@ Purview.Telemetry true - false + - - preview - - https://purview.dev/ $(PurviewHomepage)projects/telemetry-sourcegenerator/ diff --git a/src/src/SourceGenerator.Refactorings/SourceGenerator.Refactorings.csproj b/src/src/SourceGenerator.Refactorings/SourceGenerator.Refactorings.csproj index fb9caf5d..99f46359 100644 --- a/src/src/SourceGenerator.Refactorings/SourceGenerator.Refactorings.csproj +++ b/src/src/SourceGenerator.Refactorings/SourceGenerator.Refactorings.csproj @@ -13,7 +13,6 @@ - diff --git a/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Fields.cs b/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Fields.cs index 9cb77b06..456037a1 100644 --- a/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Fields.cs +++ b/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Fields.cs @@ -19,22 +19,17 @@ static void EmitFields(ActivityOutputContext output, CodeWriter writer, SourcePr activitySourceName = PropertyLibrary.Activities.DefaultActivitySourceName; } -#pragma warning disable IDE0002 // Simplify Member Access - writer - .Field( - new FieldDeclarationOptions( - PropertyLibrary.Activities.ActivitySourceFieldName, - TypeLibrary.System.Diagnostics.ActivitySource.AsTypeReference() - ) - { - IsStatic = true, - IsReadOnly = true, - Initializer = - $"new {(string)TypeLibrary.System.Diagnostics.ActivitySource}({activitySourceName!.Wrap()})", - IncludeGeneratedAttributes = false, - } + writer.Field( + new( + PropertyLibrary.Activities.ActivitySourceFieldName, + TypeLibrary.System.Diagnostics.ActivitySource.AsTypeReference() ) - .NewLine(); -#pragma warning restore IDE0002 // Simplify Member Access + { + IsStatic = true, + IsReadOnly = true, + Initializer = + $"new {(string)TypeLibrary.System.Diagnostics.ActivitySource}({activitySourceName!.Wrap()})", + } + ); } } diff --git a/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Methods.cs b/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Methods.cs index 631b3229..68cb51cd 100644 --- a/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Methods.cs +++ b/src/src/SourceGenerator/Emitters/ActivitySourceTargetClassEmitter.Methods.cs @@ -63,7 +63,6 @@ SourceProductionContext context new ParameterDeclarationOptions("exception", TypeLibrary.System.Exception.MakeNullable(writer)), new ParameterDeclarationOptions("escape", TypeLibrary.System.Boolean.AsTypeReference()), ], - IncludeGeneratedAttributes = false, } ) ) @@ -166,7 +165,6 @@ static void EmitThrowStub(CodeWriter writer, ActivityBasedGenerationTarget metho ], GenericTypes = [.. methodTarget.TypeParameters], ExpressionBody = "throw new global::System.NotSupportedException()", - IncludeGeneratedAttributes = false, } ) ) @@ -252,7 +250,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) @@ -297,7 +294,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) @@ -380,7 +376,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) diff --git a/src/src/SourceGenerator/Emitters/ConstructorEmitter.cs b/src/src/SourceGenerator/Emitters/ConstructorEmitter.cs index 754d1187..c1b1a993 100644 --- a/src/src/SourceGenerator/Emitters/ConstructorEmitter.cs +++ b/src/src/SourceGenerator/Emitters/ConstructorEmitter.cs @@ -34,7 +34,6 @@ GenerationContext generationContext new ConstructorDeclarationOptions(classNameToGenerate, TypeDeclarationAccessibility.Public) { Parameters = BuildParameters(generationType, interfaceType, generationContext), - IncludeGeneratedAttributes = false, }, body => EmitBody(generationType, body, generationContext) ); diff --git a/src/src/SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs b/src/src/SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs index 8275e28b..cf98428f 100644 --- a/src/src/SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs +++ b/src/src/SourceGenerator/Emitters/DependencyInjectionClassEmitter.cs @@ -133,7 +133,6 @@ CancellationToken token IsThis = true, }, ], - IncludeGeneratedAttributes = false, } ) ) diff --git a/src/src/SourceGenerator/Emitters/GeneratedTypesEmitter.cs b/src/src/SourceGenerator/Emitters/GeneratedTypesEmitter.cs index caf1e7d6..24301e86 100644 --- a/src/src/SourceGenerator/Emitters/GeneratedTypesEmitter.cs +++ b/src/src/SourceGenerator/Emitters/GeneratedTypesEmitter.cs @@ -393,18 +393,13 @@ static void WriteNullableStringProperty(CodeWriter writer, string name, string s hashWriter .XmlSummary(summary) .Property( - new(name, TypeLibrary.System.String, TypeDeclarationAccessibility.Public) - { - HasSetter = true, - IncludeGeneratedAttributes = false, - } + new(name, TypeLibrary.System.String, TypeDeclarationAccessibility.Public) { HasSetter = true } ) .HashElse() .Property( new(name, TypeLibrary.System.String.MakeNullable(writer), TypeDeclarationAccessibility.Public) { HasSetter = true, - IncludeGeneratedAttributes = false, } ) ); @@ -424,7 +419,7 @@ static void WritePlainStringProperty(CodeWriter writer, string name, string summ new(name, TypeLibrary.System.String, TypeDeclarationAccessibility.Public) { HasSetter = true, - IncludeGeneratedAttributes = false, + Initializer = initializer, } ); diff --git a/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.Methods.cs b/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.Methods.cs index d504207b..cb6198dc 100644 --- a/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.Methods.cs +++ b/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.Methods.cs @@ -126,7 +126,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) @@ -138,7 +137,7 @@ SourceProductionContext context // exception and output it as the exception parameter in // the Log method. - List existingParamNames = [with(methodTarget.Parameters.Count)]; + List existingParamNames = new(methodTarget.Parameters.Count); foreach (var param in methodTarget.Parameters) { existingParamNames.Add(param.Name); @@ -868,7 +867,6 @@ static void EmitLogStateStruct(CodeWriter writer, LogMethodTarget methodTarget, { IsReadOnly = true, Interfaces = [new TypeReference(new TypeIdentity(iReadOnlyListType, null))], - IncludeGeneratedAttributes = false, } ) ) @@ -879,7 +877,6 @@ static void EmitLogStateStruct(CodeWriter writer, LogMethodTarget methodTarget, IsStatic = true, IsReadOnly = true, Initializer = methodTarget.MessageTemplate.Wrap(), - IncludeGeneratedAttributes = false, } ); @@ -896,7 +893,6 @@ static void EmitLogStateStruct(CodeWriter writer, LogMethodTarget methodTarget, { Accessibility = TypeDeclarationAccessibility.Public, IsReadOnly = true, - IncludeGeneratedAttributes = false, } ); } @@ -910,7 +906,6 @@ static void EmitLogStateStruct(CodeWriter writer, LogMethodTarget methodTarget, [ .. nonExceptionParams.Select(p => new ParameterDeclarationOptions(p.Name, p.ParameterType)), ], - IncludeGeneratedAttributes = false, }, ctor => { @@ -935,7 +930,6 @@ static void EmitLogStateStruct(CodeWriter writer, LogMethodTarget methodTarget, ) { ExpressionBody = count.ToString(CultureInfo.InvariantCulture), - IncludeGeneratedAttributes = false, } ) .NewLine(); @@ -947,7 +941,6 @@ static void EmitLogStateStruct(CodeWriter writer, LogMethodTarget methodTarget, ) { Accessibility = TypeDeclarationAccessibility.Public, - IncludeGeneratedAttributes = false, }, getter => { @@ -1022,7 +1015,6 @@ string ienumerableKvpType writer.StructScope( new TypeDeclarationOptions("Enumerator", TypeDeclarationAccessibility.Public) { - IncludeGeneratedAttributes = false, Interfaces = [new TypeReference(new TypeIdentity(ienumeratorType, null))], } ) @@ -1032,16 +1024,10 @@ string ienumerableKvpType new FieldDeclarationOptions("_state", new TypeReference(new TypeIdentity(structName, null))) { IsReadOnly = true, - IncludeGeneratedAttributes = false, } ); - writer.Field( - new FieldDeclarationOptions("_index", TypeLibrary.System.Int32.AsTypeReference()) - { - IncludeGeneratedAttributes = false, - } - ); + writer.Field("_index", TypeLibrary.System.Int32); writer.NewLine(); @@ -1052,7 +1038,6 @@ string ienumerableKvpType [ new ParameterDeclarationOptions("state", new TypeReference(new TypeIdentity(structName, null))), ], - IncludeGeneratedAttributes = false, }, ctor => { @@ -1071,7 +1056,6 @@ string ienumerableKvpType ) { ExpressionBody = "_state[_index]", - IncludeGeneratedAttributes = false, } ) .NewLine() @@ -1089,7 +1073,6 @@ string ienumerableKvpType ) { ExpressionBody = "++_index < _state.Count", - IncludeGeneratedAttributes = false, } ) .NewLine() @@ -1102,7 +1085,6 @@ string ienumerableKvpType ) { ExpressionBody = "_index = -1", - IncludeGeneratedAttributes = false, } ) .NewLine() @@ -1113,9 +1095,7 @@ string ienumerableKvpType TypeLibrary.System.Void.AsTypeReference(), TypeDeclarationAccessibility.Public ) - { - IncludeGeneratedAttributes = false, - }, + { }, _ => { } ); } @@ -1131,7 +1111,6 @@ string ienumerableKvpType ) { ExpressionBody = "new Enumerator(this)", - IncludeGeneratedAttributes = false, } ) .NewLine() @@ -1165,7 +1144,6 @@ static void EmitScopeStateStruct(CodeWriter writer, LogMethodTarget methodTarget { IsReadOnly = true, Interfaces = [new TypeReference(new(iReadOnlyListType, null))], - IncludeGeneratedAttributes = false, } ) ) @@ -1176,7 +1154,6 @@ static void EmitScopeStateStruct(CodeWriter writer, LogMethodTarget methodTarget IsStatic = true, IsReadOnly = true, Initializer = methodTarget.MessageTemplate.Wrap(), - IncludeGeneratedAttributes = false, } ); @@ -1193,7 +1170,6 @@ static void EmitScopeStateStruct(CodeWriter writer, LogMethodTarget methodTarget { Accessibility = TypeDeclarationAccessibility.Public, IsReadOnly = true, - IncludeGeneratedAttributes = false, } ); } @@ -1207,7 +1183,6 @@ static void EmitScopeStateStruct(CodeWriter writer, LogMethodTarget methodTarget [ .. nonExceptionParams.Select(p => new ParameterDeclarationOptions(p.Name, p.ParameterType)), ], - IncludeGeneratedAttributes = false, }, ctor => { @@ -1240,7 +1215,6 @@ [.. methodTarget.Parameters] ) { IsOverride = true, - IncludeGeneratedAttributes = false, }, body => body.HashDefines( @@ -1270,7 +1244,6 @@ [.. methodTarget.Parameters] ) { ExpressionBody = count.ToString(CultureInfo.InvariantCulture), - IncludeGeneratedAttributes = false, } ) .NewLine(); @@ -1282,7 +1255,6 @@ [.. methodTarget.Parameters] ) { Accessibility = TypeDeclarationAccessibility.Public, - IncludeGeneratedAttributes = false, }, getter => { @@ -1369,7 +1341,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) diff --git a/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.cs b/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.cs index 6df2bd5f..cbcfd5ae 100644 --- a/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.cs +++ b/src/src/SourceGenerator/Emitters/LoggerGenTargetClassEmitter.cs @@ -88,7 +88,6 @@ static void EmitFields(LoggerOutputContext output, CodeWriter writer, SourceProd ) { IsReadOnly = true, - IncludeGeneratedAttributes = false, } ) .NewLine(); diff --git a/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Fields.cs b/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Fields.cs index 9af1e8ab..33aa57cd 100644 --- a/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Fields.cs +++ b/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Fields.cs @@ -21,7 +21,6 @@ static void EmitFields(LoggerOutputContext output, CodeWriter writer, SourceProd ) { IsReadOnly = true, - IncludeGeneratedAttributes = false, } ) .NewLine() @@ -137,7 +136,6 @@ internal static void EmitLogActionField(CodeWriter writer, LogMethodTarget metho IsStatic = true, IsReadOnly = true, Initializer = initializer, - IncludeGeneratedAttributes = false, } ); } diff --git a/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Methods.cs b/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Methods.cs index f9d193c6..efff6721 100644 --- a/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Methods.cs +++ b/src/src/SourceGenerator/Emitters/LoggerTargetClassEmitter.Methods.cs @@ -25,7 +25,6 @@ internal static void EmitThrowStub(CodeWriter writer, LogMethodTarget methodTarg )), ], ExpressionBody = "throw new global::System.NotSupportedException()", - IncludeGeneratedAttributes = false, } ) ) @@ -129,7 +128,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) @@ -209,7 +207,6 @@ SourceProductionContext context p.ParameterType )), ], - IncludeGeneratedAttributes = false, } ) ) diff --git a/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Fields.cs b/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Fields.cs index aceb7e37..f908ac9e 100644 --- a/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Fields.cs +++ b/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Fields.cs @@ -29,7 +29,6 @@ static void EmitFields( ) { IsReadOnly = true, - IncludeGeneratedAttributes = false, } ) .NewLine(); @@ -44,7 +43,6 @@ static void EmitFields( ) { Initializer = writer.IsNullableContextEnabled is null or true ? "default!" : "default", - IncludeGeneratedAttributes = false, } ) .NewLine(); @@ -74,13 +72,7 @@ static void EmitFields( if (emitReadonly) { - writer.Field( - new FieldDeclarationOptions(method.FieldName, type) - { - IsReadOnly = true, - IncludeGeneratedAttributes = false, - } - ); + writer.Field(new FieldDeclarationOptions(method.FieldName, type) { IsReadOnly = true }); } else { @@ -88,7 +80,6 @@ static void EmitFields( new FieldDeclarationOptions(method.FieldName, type) { Initializer = writer.IsNullableContextEnabled is null or true ? "default!" : "default", - IncludeGeneratedAttributes = false, } ); } diff --git a/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.InitializationMethod.cs b/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.InitializationMethod.cs index d9f4894b..88bd3433 100644 --- a/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.InitializationMethod.cs +++ b/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.InitializationMethod.cs @@ -30,7 +30,6 @@ static void EmitInitializationMethod(MeterOutputContext output, CodeWriter write ), ] : [], - IncludeGeneratedAttributes = false, } ) ) @@ -76,7 +75,6 @@ static void EmitInlineConstructor(MeterOutputContext output, CodeWriter writer, ), ] : [], - IncludeGeneratedAttributes = false, } ) ) diff --git a/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs b/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs index 1faba459..8f8ca75d 100644 --- a/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs +++ b/src/src/SourceGenerator/Emitters/MeterTargetClassEmitter.Methods.cs @@ -27,7 +27,6 @@ static void EmitThrowStub(CodeWriter writer, InstrumentTarget methodTarget) )), ], ExpressionBody = "throw new global::System.NotSupportedException()", - IncludeGeneratedAttributes = false, } ) ) @@ -157,7 +156,6 @@ SourceProductionContext context { Attributes = [EmitterHelpers.AggressiveInliningAttribute()], Parameters = parameters, - IncludeGeneratedAttributes = false, } ) ) diff --git a/src/src/SourceGenerator/Helpers/IsExternalInit.cs b/src/src/SourceGenerator/Helpers/IsExternalInit.cs deleted file mode 100644 index 37fe3b10..00000000 --- a/src/src/SourceGenerator/Helpers/IsExternalInit.cs +++ /dev/null @@ -1,15 +0,0 @@ -#if NETSTANDARD2_0 || NETSTANDARD2_1 || NETCOREAPP2_0 || NETCOREAPP2_1 || NETCOREAPP2_2 || NETCOREAPP3_0 || NETCOREAPP3_1 || NET45 || NET451 || NET452 || NET6 || NET461 || NET462 || NET47 || NET471 || NET472 || NET48 - -using System.ComponentModel; - -// Compilation error of CS0518 IsExternalInit is not defined when using .NET Standard. -// re: https://mking.net/blog/error-cs0518-isexternalinit-not-defined -#pragma warning disable IDE0130 // Namespace does not match folder structure -namespace System.Runtime.CompilerServices; - -#pragma warning restore IDE0130 // Namespace does not match folder structure - -[EditorBrowsable(EditorBrowsableState.Never)] -static class IsExternalInit; - -#endif diff --git a/src/src/SourceGenerator/SourceGenerator.csproj b/src/src/SourceGenerator/SourceGenerator.csproj index d81b7aa8..e6a49f95 100644 --- a/src/src/SourceGenerator/SourceGenerator.csproj +++ b/src/src/SourceGenerator/SourceGenerator.csproj @@ -1,11 +1,10 @@ - + true true - + true false true @@ -14,7 +13,6 @@ XML doc file is not shipped, and IDE0005 is suppressed rather than failing the build. --> false $(NoWarn);IDE0005;EnableGenerateDocumentationFile; - Purview Telemetry Source Generator .NET Source Generator for interface-based telemetry generating tracing, logs, and metrics. logs;log;logger;logging;source-generator;high-performance-logging;otel;open-telemetry;telemetry;traces;tracing;metric;metrics;meter;meters;instrumentation;instruments;events;distributed-traces;distributed-tracing;melt;dotnet;aspnet; @@ -40,8 +38,6 @@ into analyzers/dotnet/cs; only the refactorings assembly is added here. --> - + true + From 9c16697c34bdf647d08d45a86116f5cab6072e96 Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Wed, 23 Sep 2026 11:02:07 +0100 Subject: [PATCH 2/3] build: new build updates --- Justfile | 7 +++++++ LICENSE.md | 9 --------- global.json | 2 +- package.json | 4 ++-- purview-build.json | 8 ++++---- src/Directory.Build.props | 2 +- src/src/SourceGenerator/SourceGenerator.csproj | 7 +------ 7 files changed, 16 insertions(+), 23 deletions(-) delete mode 100644 LICENSE.md diff --git a/Justfile b/Justfile index 31a16f76..cdb1cd31 100644 --- a/Justfile +++ b/Justfile @@ -63,6 +63,13 @@ pipeline-tests *args: echo "Running tests pipeline..." "{{ pipeline_tool }}" --Build:RunTests=true --Release:Mode=None {{ args }} +# Run the pipeline through pack + validate (restore, build, lint, tests, pack, validate pack contents) without publishing/releasing +[group('Pipeline')] +pipeline-pack-validate *args: + just ensure-pipeline-tool + echo "Running pack + validate pipeline..." + "{{ pipeline_tool }}" --Build:RunPack=true --Build:ValidatePack=true --Release:Mode=None {{ args }} + # ----------------------------------------------------------------------------- # Build and Test # ----------------------------------------------------------------------------- diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 9ea2dfca..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -The MIT License (MIT) - -Copyright © 2026 Kieron Lanning - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/global.json b/global.json index f8c7bbaf..cef1f45e 100644 --- a/global.json +++ b/global.json @@ -3,7 +3,7 @@ "allowPrerelease": false }, "msbuild-sdks": { - "Purview.BuildSdk": "1.0.0-prerelease.57" + "Purview.BuildSdk": "1.0.0-prerelease.58" }, "test": { "runner": "Microsoft.Testing.Platform" diff --git a/package.json b/package.json index 763f66e1..0e6a390b 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,15 @@ "name": "purview-telemetry-sourcegenerator", "version": "5.0.0-prerelease.13", "description": "Generates [`ActivitySource`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.activitysource), [`ILogger`](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger), and [`Metrics`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.metrics) based on interface methods.", + "license": "MIT", "readme": "README.md", "repository": { "type": "git", "url": "git+https://github.com/purview-dev/telemetry-sourcegenerator.git" }, "author": "Kieron Lanning (https://github.com/kieronlanning/)", - "license": "MIT", "bugs": { "url": "https://github.com/purview-dev/telemetry-sourcegenerator/issues" }, "homepage": "https://purview.dev/projects/telemetry-sourcegenerator/" -} +} \ No newline at end of file diff --git a/purview-build.json b/purview-build.json index 60850c66..e5c7f37c 100644 --- a/purview-build.json +++ b/purview-build.json @@ -10,11 +10,11 @@ "RequireSymbolFiles": true, "RequiredContent": { "purview.telemetry.sourcegenerator": [ - "README.md", - "purview-logo-light.png", + ".agents/**/*", "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.dll", "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.Refactorings.dll", - "lib/netstandard2.0/Purview.Telemetry.SourceGenerator.dll" + "README.md", + "purview-logo-light.png" ] }, "ForbiddenContent": { @@ -26,4 +26,4 @@ "Release": { "Mode": "None" } -} +} \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 89cc6a4a..0e4df7fb 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -13,7 +13,7 @@ DefaultItemExcludes and emitted generator files get globbed into , causing duplicate-symbol errors during host builds. --> - + false diff --git a/src/src/SourceGenerator/SourceGenerator.csproj b/src/src/SourceGenerator/SourceGenerator.csproj index e6a49f95..2b53e199 100644 --- a/src/src/SourceGenerator/SourceGenerator.csproj +++ b/src/src/SourceGenerator/SourceGenerator.csproj @@ -1,14 +1,9 @@  true + true true - - true false - true - snupkg false From 57582e60fe6777383128cf28d3d1cc66b0528323 Mon Sep 17 00:00:00 2001 From: Kieron Lanning Date: Wed, 23 Sep 2026 11:11:02 +0100 Subject: [PATCH 3/3] build: fixed symbols package requirement --- purview-build.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/purview-build.json b/purview-build.json index e5c7f37c..e29fae1f 100644 --- a/purview-build.json +++ b/purview-build.json @@ -6,8 +6,7 @@ "TestFilter": "/*/*/*/*" }, "PackValidation": { - "RequireSymbolPackage": true, - "RequireSymbolFiles": true, + "RequireSymbolPackage": false, "RequiredContent": { "purview.telemetry.sourcegenerator": [ ".agents/**/*", @@ -16,11 +15,6 @@ "README.md", "purview-logo-light.png" ] - }, - "ForbiddenContent": { - "purview.telemetry.sourcegenerator": [ - "analyzers/dotnet/cs/Purview.Telemetry.SourceGenerator.pdb" - ] } }, "Release": {