提交 6fdefaff 编写于 作者: A AlekseyTs

Merge pull request #2451 from AlekseyTs/Bug1116455

Allow public key token in InternalsVisibleTo attribute due to compatibility reasons.
......@@ -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)
{
......
......@@ -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(
......
......@@ -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)
......
......@@ -13240,7 +13240,7 @@ BC31527: 'Microsoft.VisualBasic.ComClassAttribute' cannot be applied to a class
' BC31531ERR_DllImportNotLegalOnEventMethod
' see AttributeTests
<Fact>
<Fact, WorkItem(1116455, "DevDiv")>
Public Sub BC31534ERR_FriendAssemblyBadArguments()
Dim compilation = CompilationUtils.CreateCompilationWithMscorlibAndReferences(
<compilation name="FriendAssemblyBadArguments">
......@@ -13261,6 +13261,7 @@ Imports System.Runtime.CompilerServices
<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
]]></file>
</compilation>, {SystemCoreRef})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册