From c5833b4a03a7af44dba489ca7060b3f2cb9f612c Mon Sep 17 00:00:00 2001 From: Tadej Koderman Date: Thu, 17 Oct 2024 13:51:03 +0200 Subject: [PATCH] #19: add GeneratedCodeAttribute to IgnoresAccessChecksToAttribute --- .../IgnoresAccessChecksToGenerator.Tasks.csproj | 3 ++- .../PublicizeInternals.cs | 8 ++++++-- .../IgnoresAccessChecksToGenerator.Test.csproj | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.Tasks.csproj b/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.Tasks.csproj index 52637d8..26aec9c 100644 --- a/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.Tasks.csproj +++ b/src/IgnoresAccessChecksToGenerator.Tasks/IgnoresAccessChecksToGenerator.Tasks.csproj @@ -2,8 +2,9 @@ netstandard2.0;net462 + latest IgnoresAccessChecksToGenerator - 0.7.0 + 0.7.1 true Eli Arbel https://github.com/aelij/IgnoresAccessChecksToGenerator diff --git a/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs b/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs index a93c781..110d1e5 100644 --- a/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs +++ b/src/IgnoresAccessChecksToGenerator.Tasks/PublicizeInternals.cs @@ -72,10 +72,13 @@ public override bool Execute() private void GenerateAttributes(string path, IEnumerable assemblyNames) { + var version = typeof(PublicizeInternals).Assembly.GetName().Version; var attributes = string.Join(Environment.NewLine, assemblyNames.Select(a => $@"[assembly: System.Runtime.CompilerServices.IgnoresAccessChecksTo(""{a}"")]")); - var content = attributes + @" + var content = $$""" +[assembly: System.CodeDom.Compiler.GeneratedCode("{{nameof(IgnoresAccessChecksToGenerator)}}", "{{version:4}}")] +{{attributes}} namespace System.Runtime.CompilerServices { @@ -86,7 +89,8 @@ public IgnoresAccessChecksToAttribute(string assemblyName) { } } -}"; +} +"""; File.WriteAllText(GeneratedCodeFilePath, content); Log.LogMessageFromText("Generated IgnoresAccessChecksTo attributes", MessageImportance.Low); diff --git a/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj b/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj index 26ccf29..d9b1db8 100644 --- a/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj +++ b/test/IgnoresAccessChecksToGenerator.Test/IgnoresAccessChecksToGenerator.Test.csproj @@ -13,7 +13,7 @@ - +