diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs index 78b10c1158de57dba3ec3db26ca40467c48c64dd..c5daf0932facf929b04503599c707f024f0e80af 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceAssemblySymbol.cs @@ -1969,7 +1969,8 @@ private void DecodeTypeForwardedToAttribute(ref DecodeWellKnownAttributeArgument return; } - const AssemblyIdentityParts allowedParts = AssemblyIdentityParts.Name | AssemblyIdentityParts.PublicKey; + // Allow public key token due to compatibility reasons, but we are not going to use its value. + const AssemblyIdentityParts allowedParts = AssemblyIdentityParts.Name | AssemblyIdentityParts.PublicKey | AssemblyIdentityParts.PublicKeyToken; if ((parts & ~allowedParts) != 0) { diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs index 6b777f91656cae78d0dde9dd052eb0ed35ee65cf..5dd5c6ec288aeea2e3fc8fd3ec36108b2c0e7d45 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs @@ -14808,7 +14808,7 @@ class C ); } - [Fact] + [Fact, WorkItem(1116455, "DevDiv")] public void CS1725ERR_FriendAssemblyBadArgs() { var text = @" @@ -14828,6 +14828,7 @@ public void CS1725ERR_FriendAssemblyBadArgs() [assembly: InternalsVisibleTo(""Test, Version=1.1.1.*"")] // error [assembly: InternalsVisibleTo(""Test, ProcessorArchitecture=MSIL"")] // error [assembly: InternalsVisibleTo(""Test, CuLTure=EN"")] // error +[assembly: InternalsVisibleTo(""Test, PublicKeyToken=null"")] // ok "; // Tested against Dev12 CreateCompilationWithMscorlib(text).VerifyDiagnostics( diff --git a/src/Compilers/VisualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb b/src/Compilers/VisualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb index 52d8ddc471558554fb9d008e112d0e2c1a9465b4..4d82a3138db9e015aafd44ba9048c0ca9a207960 100644 --- a/src/Compilers/VisualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb +++ b/src/Compilers/VisualBasic/Portable/Symbols/Source/SourceAssemblySymbol.vb @@ -929,7 +929,8 @@ Namespace Microsoft.CodeAnalysis.VisualBasic.Symbols Return False End If - Const allowedParts = AssemblyIdentityParts.Name Or AssemblyIdentityParts.PublicKey + ' Allow public key token due to compatibility reasons, but we are not going to use its value. + Const allowedParts = AssemblyIdentityParts.Name Or AssemblyIdentityParts.PublicKey Or AssemblyIdentityParts.PublicKeyToken If (parts And Not allowedParts) <> 0 Then diagnostics.Add(ERRID.ERR_FriendAssemblyBadArguments, If(nodeOpt IsNot Nothing, nodeOpt.GetLocation(), NoLocation.Singleton), displayName) diff --git a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb index f1d6eee7b2a94b04639498a39ca1d75d415cc2f4..79ddf9cb3267081e0075571de782be0220cb4ed4 100644 --- a/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb +++ b/src/Compilers/VisualBasic/Test/Symbol/SymbolsTests/SymbolErrorTests.vb @@ -13240,7 +13240,7 @@ BC31527: 'Microsoft.VisualBasic.ComClassAttribute' cannot be applied to a class ' BC31531ERR_DllImportNotLegalOnEventMethod ' see AttributeTests - + Public Sub BC31534ERR_FriendAssemblyBadArguments() Dim compilation = CompilationUtils.CreateCompilationWithMscorlibAndReferences( @@ -13261,6 +13261,7 @@ Imports System.Runtime.CompilerServices ' error ' error ' error + ' ok ]]> , {SystemCoreRef})