Skip to content

Commit b391c83

Browse files
xoofxCopilot
andcommitted
Fix CS1726: exclude InternalsVisibleTo from signed assembly build
Strong-name signed assemblies require a public key in InternalsVisibleTo declarations. Since Tomlyn.Tests is not signed, guard the attribute with a TOMLYN_SIGNED conditional defined in Tomlyn.Signed.csproj. Co-authored-by: Copilot <[email protected]>
1 parent fc10290 commit b391c83

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/Tomlyn.Signed/Tomlyn.Signed.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
66
<SignAssembly>true</SignAssembly>
77
<TargetFrameworks>net10.0;net8.0;netstandard2.0</TargetFrameworks>
8+
<DefineConstants>$(DefineConstants);TOMLYN_SIGNED</DefineConstants>
89
</PropertyGroup>
910

1011
<PropertyGroup Condition="'$(TargetFramework)' == 'net10.0' Or '$(TargetFramework)' == 'net8.0'">
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
using System.Runtime.CompilerServices;
22

3+
// InternalsVisibleTo is not compatible with strong-name signed assemblies unless the
4+
// friend assembly is also signed with a known public key. Exclude it for the signed build.
5+
#if !TOMLYN_SIGNED
36
[assembly: InternalsVisibleTo("Tomlyn.Tests")]
7+
#endif

0 commit comments

Comments
 (0)