Skip to content

Commit

Permalink
aelij#19: add GeneratedCodeAttribute to IgnoresAccessChecksToAttribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Tadej Koderman committed Oct 17, 2024
1 parent 47fbd6e commit 81ba417
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<LangVersion>latest</LangVersion>
<PackageId>IgnoresAccessChecksToGenerator</PackageId>
<Version>0.7.0</Version>
<DevelopmentDependency>true</DevelopmentDependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,13 @@ public override bool Execute()

private void GenerateAttributes(string path, IEnumerable<string> 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
{
Expand All @@ -86,7 +89,8 @@ public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}";
}
""";
File.WriteAllText(GeneratedCodeFilePath, content);

Log.LogMessageFromText("Generated IgnoresAccessChecksTo attributes", MessageImportance.Low);
Expand Down

0 comments on commit 81ba417

Please sign in to comment.