From 93b14114cca77a9a5aba57e5e6f1f876ddee9994 Mon Sep 17 00:00:00 2001 From: Brandon Minnick <13558917+brminnick@users.noreply.github.com> Date: Sun, 22 Oct 2023 17:34:21 +0200 Subject: [PATCH] Add `[GeneratedCode]` and `[ExcludeFromCodeCoverage]` Attributes to SourceGenerators (#251) Add Attributes --- .../TextAlignmentExtensionsGenerator.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/CommunityToolkit.Maui.Markup.SourceGenerators/SourceGenerators/TextAlignmentExtensionsGenerator.cs b/src/CommunityToolkit.Maui.Markup.SourceGenerators/SourceGenerators/TextAlignmentExtensionsGenerator.cs index fb38005a..d000b4a6 100644 --- a/src/CommunityToolkit.Maui.Markup.SourceGenerators/SourceGenerators/TextAlignmentExtensionsGenerator.cs +++ b/src/CommunityToolkit.Maui.Markup.SourceGenerators/SourceGenerators/TextAlignmentExtensionsGenerator.cs @@ -84,13 +84,19 @@ static void Execute(SourceProductionContext context, [NotNull] TextAlignmentClas { throw new ArgumentNullException(nameof(textAlignmentClassMetadata)); } + + var className = typeof(TextAlignmentExtensionsGenerator).FullName; + var assemblyVersion = typeof(TextAlignmentExtensionsGenerator).Assembly.GetName().Version.ToString(); var genericTypeParameters = GetGenericTypeParametersDeclarationString(textAlignmentClassMetadata.GenericArguments); var genericArguments = GetGenericArgumentsString(textAlignmentClassMetadata.GenericArguments); var source = $$""" // // See: CommunityToolkit.Maui.Markup.SourceGenerators.TextAlignmentGenerator + #nullable enable +#pragma warning disable + using System; using Microsoft.Maui; using Microsoft.Maui.Controls; @@ -100,6 +106,8 @@ namespace CommunityToolkit.Maui.Markup /// /// Extension Methods for /// + [global::System.CodeDom.Compiler.GeneratedCode("{{className}}", "{{assemblyVersion}}")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] {{textAlignmentClassMetadata.ClassAcessModifier}} static partial class TextAlignmentExtensions_{{textAlignmentClassMetadata.ClassName}} { /// @@ -235,6 +243,8 @@ namespace LeftToRight /// /// Extension Methods for /// + [global::System.CodeDom.Compiler.GeneratedCode("{{className}}", "{{assemblyVersion}}")] + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] {{textAlignmentClassMetadata.ClassAcessModifier}} static partial class TextAlignmentExtensions_{{textAlignmentClassMetadata.ClassName}} { ///