/Src/Compilers/CSharp/Test/Emit/Attributes/AttributeTests.cs
C# | 7205 lines | 6075 code | 628 blank | 502 comment | 13 complexity | e1fd731c9f769cd979fe6505e83e503a MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- // Copyright (c) Microsoft Open Technologies, Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
- using System;
- using System.Collections.Generic;
- using System.Collections.Immutable;
- using System.IO;
- using System.Linq;
- using System.Reflection;
- using Microsoft.CodeAnalysis.CSharp.Symbols;
- using Microsoft.CodeAnalysis.CSharp.Symbols.Metadata.PE;
- using Microsoft.CodeAnalysis.CSharp.Syntax;
- using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
- using Microsoft.CodeAnalysis.Test.Utilities;
- using Roslyn.Test.Utilities;
- using Xunit;
- namespace Microsoft.CodeAnalysis.CSharp.UnitTests
- {
- public class AttributeTests : CompilingTestBase
- {
- #region Function Tests
- [Fact]
- public void TestAssemblyAttributes()
- {
- var source = CreateCompilationWithMscorlib(@"
- using System;
- using System.Runtime.CompilerServices;
- [assembly: InternalsVisibleTo(""Roslyn.Compilers.UnitTests"")]
- [assembly: InternalsVisibleTo(""Roslyn.Compilers.CSharp"")]
- [assembly: InternalsVisibleTo(""Roslyn.Compilers.CSharp.UnitTests"")]
- [assembly: InternalsVisibleTo(""Roslyn.Compilers.CSharp.Test.Utilities"")]
- [assembly: InternalsVisibleTo(""Roslyn.Compilers.VisualBasic"")]
- class C
- {
- public static void Main() {}
- }
- ");
- Action<ModuleSymbol> attributeValidator = (ModuleSymbol m) =>
- {
- Symbol assembly = m.ContainingSymbol;
- var attrs = assembly.GetAttributes();
- Assert.Equal(5, attrs.Length);
- attrs[0].VerifyValue(0, TypedConstantKind.Primitive, "Roslyn.Compilers.UnitTests");
- Assert.Equal(@"System.Runtime.CompilerServices.InternalsVisibleToAttribute(""Roslyn.Compilers.UnitTests"")", attrs[0].ToString());
- attrs[1].VerifyValue(0, TypedConstantKind.Primitive, "Roslyn.Compilers.CSharp");
- Assert.Equal(@"System.Runtime.CompilerServices.InternalsVisibleToAttribute(""Roslyn.Compilers.CSharp"")", attrs[1].ToString());
- attrs[2].VerifyValue(0, TypedConstantKind.Primitive, "Roslyn.Compilers.CSharp.UnitTests");
- Assert.Equal(@"System.Runtime.CompilerServices.InternalsVisibleToAttribute(""Roslyn.Compilers.CSharp.UnitTests"")", attrs[2].ToString());
- attrs[3].VerifyValue(0, TypedConstantKind.Primitive, "Roslyn.Compilers.CSharp.Test.Utilities");
- Assert.Equal(@"System.Runtime.CompilerServices.InternalsVisibleToAttribute(""Roslyn.Compilers.CSharp.Test.Utilities"")", attrs[3].ToString());
- attrs[4].VerifyValue(0, TypedConstantKind.Primitive, "Roslyn.Compilers.VisualBasic");
- Assert.Equal(@"System.Runtime.CompilerServices.InternalsVisibleToAttribute(""Roslyn.Compilers.VisualBasic"")", attrs[4].ToString());
- };
- // Verify attributes from source and then load metadata to see attributes are written correctly.
- CompileAndVerify(source, sourceSymbolValidator: attributeValidator, symbolValidator: null);
- }
- [WorkItem(984896)]
- [Fact]
- public void TestAssemblyAttributesErr()
- {
- string code = @"
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using M = System.Math;
- namespace My
- {
- using A.B;
- // TODO: <Insert justification for suppressing TestId>
- [System.Diagnostics.CodeAnalysis.SuppressMessageAttribute(""Test"",""TestId"",Justification=""<Pending>"")]
- public unsafe partial class A : C, I
- {
- }
- }
- ";
- var source = CreateCompilationWithMscorlibAndSystemCore(code);
- // the following should not crash
- source.GetDiagnosticsForSyntaxTree(CompilationStage.Compile, source.SyntaxTrees[0], null, true);
- }
- [Fact, WorkItem(545326, "DevDiv")]
- public void TestAssemblyAttributes_Bug13670()
- {
- var source = @"
- using System;
- [assembly: A(Derived.Str)]
- public class A: Attribute
- {
- public A(string x){}
- public static void Main() {}
- }
- public class Derived: Base
- {
- internal const string Str = ""temp"";
- public override int Foo { get { return 1; } }
- }
- public class Base
- {
- public virtual int Foo { get { return 0; } }
- }
- ";
- CompileAndVerify(source);
- }
- [Fact]
- public void TestAssemblyAttributesReflection()
- {
- var compilation = CreateCompilationWithMscorlib(@"
- using System.Reflection;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- // These are not pseduo attributes, but encoded as bits in metadata
- [assembly: AssemblyAlgorithmId(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)]
- [assembly: AssemblyCultureAttribute("""")]
- [assembly: AssemblyDelaySign(true)]
- [assembly: AssemblyFlags(AssemblyNameFlags.Retargetable)]
- [assembly: AssemblyKeyFile(""MyKey.snk"")]
- [assembly: AssemblyKeyName(""Key Name"")]
- [assembly: AssemblyVersion(""1.2.*"")]
- [assembly: AssemblyFileVersionAttribute(""4.3.2.100"")]
- class C
- {
- public static void Main() {}
- }
- ");
- var attrs = compilation.Assembly.GetAttributes();
- Assert.Equal(8, attrs.Length);
- foreach (var a in attrs)
- {
- switch (a.AttributeClass.Name)
- {
- case "AssemblyAlgorithmIdAttribute":
- a.VerifyValue(0, TypedConstantKind.Enum, (int)System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5);
- Assert.Equal(@"System.Reflection.AssemblyAlgorithmIdAttribute(System.Configuration.Assemblies.AssemblyHashAlgorithm.MD5)", a.ToString());
- break;
- case "AssemblyCultureAttribute":
- a.VerifyValue(0, TypedConstantKind.Primitive, "");
- Assert.Equal(@"System.Reflection.AssemblyCultureAttribute("""")", a.ToString());
- break;
- case "AssemblyDelaySignAttribute":
- a.VerifyValue(0, TypedConstantKind.Primitive, true);
- Assert.Equal(@"System.Reflection.AssemblyDelaySignAttribute(true)", a.ToString());
- break;
- case "AssemblyFlagsAttribute":
- a.VerifyValue(0, TypedConstantKind.Enum, (int)AssemblyNameFlags.Retargetable);
- Assert.Equal(@"System.Reflection.AssemblyFlagsAttribute(System.Reflection.AssemblyNameFlags.Retargetable)", a.ToString());
- break;
- case "AssemblyKeyFileAttribute":
- a.VerifyValue(0, TypedConstantKind.Primitive, "MyKey.snk");
- Assert.Equal(@"System.Reflection.AssemblyKeyFileAttribute(""MyKey.snk"")", a.ToString());
- break;
- case "AssemblyKeyNameAttribute":
- a.VerifyValue(0, TypedConstantKind.Primitive, "Key Name");
- Assert.Equal(@"System.Reflection.AssemblyKeyNameAttribute(""Key Name"")", a.ToString());
- break;
- case "AssemblyVersionAttribute":
- a.VerifyValue(0, TypedConstantKind.Primitive, "1.2.*");
- Assert.Equal(@"System.Reflection.AssemblyVersionAttribute(""1.2.*"")", a.ToString());
- break;
- case "AssemblyFileVersionAttribute":
- a.VerifyValue(0, TypedConstantKind.Primitive, "4.3.2.100");
- Assert.Equal(@"System.Reflection.AssemblyFileVersionAttribute(""4.3.2.100"")", a.ToString());
- break;
- default:
- Assert.Equal("Unexpected Attr", a.AttributeClass.Name);
- break;
- }
- }
- }
- // Verify that resolving an attribute defined within a class on a class does not cause infinite recursion
- [Fact]
- public void TestAttributesOnClassDefinedInClass()
- {
- var compilation = CreateCompilationWithMscorlib(@"
- using System;
- using System.Runtime.CompilerServices;
- [A.X()]
- public class A
- {
- [AttributeUsage(AttributeTargets.All, allowMultiple = true)]
- public class XAttribute : Attribute
- {
- }
- }
- class C
- {
- public static void Main() {}
- }
- ");
- var attrs = compilation.SourceModule.GlobalNamespace.GetMember("A").GetAttributes();
- Assert.Equal(1, attrs.Length);
- Assert.Equal("A.XAttribute", attrs.First().AttributeClass.ToDisplayString());
- }
- [Fact]
- public void TestAttributesOnClassWithConstantDefinedInClass()
- {
- var compilation = CreateCompilationWithMscorlib(@"
- using System;
- [Attr(Foo.p)]
- class Foo
- {
- private const object p = null;
- }
- internal class AttrAttribute : Attribute
- {
- public AttrAttribute(object p) { }
- }
- class C
- {
- public static void Main() { }
- }
- ");
- var attrs = compilation.SourceModule.GlobalNamespace.GetMember("Foo").GetAttributes();
- Assert.Equal(1, attrs.Length);
- attrs.First().VerifyValue<object>(0, TypedConstantKind.Primitive, null);
- }
- [Fact]
- public void TestAttributeEmit()
- {
- var compilation = CreateCompilationWithMscorlib(@"
- using System;
- public enum e1
- {
- a,
- b,
- c
- }
- [AttributeUsage(AttributeTargets.All, AllowMultiple = true)]
- class XAttribute : Attribute
- {
- public XAttribute(int i)
- {
- }
- public XAttribute(int i, string s)
- {
- }
- public XAttribute(int i, string s, e1 e)
- {
- }
- public XAttribute(object[] o)
- {
- }
- public XAttribute(int[] i)
- {
- }
- public XAttribute(int[] i, string[] s)
- {
- }
- public XAttribute(int[] i, string[] s, e1[] e)
- {
- }
- public int pi { get; set; }
- public string ps { get; set; }
- public e1 pe { get; set; }
- }
- [X(1, ""hello"", e1.a)]
- [X(new int[] { 1 }, new string[] { ""hello"" }, new e1[] { e1.a, e1.b, e1.c })]
- [X(new object[] { 1, ""hello"", e1.a })]
- class C
- {
- public static void Main() {}
- }
- ");
- var verifier = CompileAndVerify(compilation, emitOptions: EmitOptions.RefEmitUnsupported_640494);
- verifier.VerifyIL("XAttribute..ctor(int)", @"{
- // Code size 7 (0x7)
- .maxstack 1
- IL_0000: ldarg.0
- IL_0001: call ""System.Attribute..ctor()""
- IL_0006: ret
- }");
- }
- [Fact]
- public void TestAttributesOnClassProperty()
- {
- var compilation = CreateCompilationWithMscorlib(@"
- using System;
- public class A
- {
- [CLSCompliant(true)]
- public string Prop
- {
- get { return null; }
- }
- }
- class C
- {
- public static void Main() {}
- }
- ");
- Action<ModuleSymbol> attributeValidator = (ModuleSymbol m) =>
- {
- var type = (NamedTypeSymbol)m.GlobalNamespace.GetMember("A");
- var prop = type.GetMember("Prop");
- var attrs = prop.GetAttributes();
- Assert.Equal(1, attrs.Length);
- attrs.First().VerifyValue(0, TypedConstantKind.Primitive, true);
- Assert.Equal("System.CLSCompliantAttribute", attrs.First().AttributeClass.ToDisplayString());
- };
- // Verify attributes from source and then load metadata to see attributes are written correctly.
- CompileAndVerify(compilation, sourceSymbolValidator: attributeValidator, symbolValidator: null);
- }
- [WorkItem(688268, "DevDiv")]
- [Fact]
- public void Bug688268()
- {
- var compilation = CreateCompilationWithMscorlib(@"
- using System;
- using System.Runtime.InteropServices;
- using System.Security;
- public interface I
- {
- void _VtblGap1_30();
- void _VtblGaP1_30();
- }
- ");
- System.Action<ModuleSymbol> metadataValidator =
- delegate (ModuleSymbol module)
- {
- var metadata = ((PEModuleSymbol)module).Module;
- var typeI = (PENamedTypeSymbol)module.GlobalNamespace.GetTypeMembers("I").Single();
- var methods = metadata.GetMethodsOfTypeOrThrow(typeI.Handle);
- Assert.Equal(2, methods.Count);
- var e = methods.GetEnumerator();
- e.MoveNext();
- var flags = metadata.GetMethodDefFlagsOrThrow(e.Current);
- Assert.Equal(
- MethodAttributes.PrivateScope |
- MethodAttributes.Public |
- MethodAttributes.Virtual |
- MethodAttributes.HideBySig |
- MethodAttributes.VtableLayoutMask |
- MethodAttributes.Abstract |
- MethodAttributes.SpecialName |
- MethodAttributes.RTSpecialName,
- flags);
- e.MoveNext();
- flags = metadata.GetMethodDefFlagsOrThrow(e.Current);
- Assert.Equal(
- MethodAttributes.PrivateScope |
- MethodAttributes.Public |
- MethodAttributes.Virtual |
- MethodAttributes.HideBySig |
- MethodAttributes.VtableLayoutMask |
- MethodAttributes.Abstract,
- flags);
- };
- CompileAndVerify(
- compilation,
- sourceSymbolValidator: null,
- symbolValidator: metadataValidator);
- }
- [Fact]
- public void TestAttributesOnPropertyAndGetSet()
- {
- string source = @"
- using System;
- [AObject(typeof(object), O = A.obj)]
- public class A
- {
- internal const object obj = null;
- public string RProp
- {
- [AObject(new object[] { typeof(string) })]
- get { return null; }
- }
- [AObject(new object[] {
- 1,
- ""two"",
- typeof(string),
- 3.1415926
- })]
- public object WProp
- {
- [AObject(new object[] { new object[] { typeof(string) } })]
- set { }
- }
- }
- ";
- var references = new[] { new MetadataImageReference(TestResources.SymbolsTests.Metadata.MDTestAttributeDefLib.AsImmutableOrNull()) };
- CSharpCompilationOptions opt = TestOptions.Dll;
- var compilation = CreateCompilationWithMscorlib(source, references, compOptions: opt);
- Action<ModuleSymbol> attributeValidator = (ModuleSymbol m) =>
- {
- var type = (NamedTypeSymbol)m.GlobalNamespace.GetMember("A");
- var attrs = type.GetAttributes();
- Assert.Equal("AObjectAttribute(typeof(object), O = null)", attrs.First().ToString());
- attrs.First().VerifyValue<object>(0, TypedConstantKind.Type, typeof(object));
- attrs.First().VerifyNamedArgumentValue<object>(0, "O", TypedConstantKind.Primitive, null);
- var prop = type.GetMember<PropertySymbol>("RProp");
- attrs = prop.GetMethod.GetAttributes();
- Assert.Equal("AObjectAttribute({typeof(string)})", attrs.First().ToString());
- attrs.First().VerifyValue(0, TypedConstantKind.Array, new object[] { typeof(string) });
- prop = type.GetMember<PropertySymbol>("WProp");
- attrs = prop.GetAttributes();
- Assert.Equal(@"AObjectAttribute({1, ""two"", typeof(string), 3.1415926})", attrs.First().ToString());
- attrs.First().VerifyValue(0, TypedConstantKind.Array, new object[] { 1, "two", typeof(string), 3.1415926 });
- attrs = prop.SetMethod.GetAttributes();
- Assert.Equal(@"AObjectAttribute({{typeof(string)}})", attrs.First().ToString());
- attrs.First().VerifyValue(0, TypedConstantKind.Array, new object[] { new object[] { typeof(string) } });
- };
- // Verify attributes from source and then load metadata to see attributes are written correctly.
- CompileAndVerify(compilation, sourceSymbolValidator: attributeValidator, symbolValidator: attributeValidator);
- }
- [Fact]
- public void TestAttributesOnEvents()
- {
- string source = @"
- public class AA : System.Attribute { }
- public class BB : System.Attribute { }
- public class CC : System.Attribute { }
- public class DD : System.Attribute { }
- public class EE : System.Attribute { }
- public class FF : System.Attribute { }
- public class GG : System.Attribute { }
- public class HH : System.Attribute { }
- public class II : System.Attribute { }
- public class JJ : System.Attribute { }
- public class Test
- {
- [AA] //in event decl
- public event System.Action E1;
- [event: BB] //in event decl
- public event System.Action E2;
- [method: CC] //in both accessors
- public event System.Action E3;
- [field: DD] //on field
- public event System.Action E4;
- [EE] //in event decl
- public event System.Action E5 { add { } remove { } }
- [event: FF] //in event decl
- public event System.Action E6 { add { } remove { } }
- public event System.Action E7 { [GG] add { } remove { } } //in accessor
- public event System.Action E8 { [method: HH] add { } remove { } } //in accessor
- public event System.Action E9 { [param: II] add { } remove { } } //on parameter (after .param[1])
- public event System.Action E10 { [return: JJ] add { } remove { } } //on return (after .param[0])
- }
- ";
- Func<bool, Action<ModuleSymbol>> symbolValidator = isFromSource => moduleSymbol =>
- {
- var @class = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("Test");
- var event1 = @class.GetMember<EventSymbol>("E1");
- var event2 = @class.GetMember<EventSymbol>("E2");
- var event3 = @class.GetMember<EventSymbol>("E3");
- var event4 = @class.GetMember<EventSymbol>("E4");
- var event5 = @class.GetMember<EventSymbol>("E5");
- var event6 = @class.GetMember<EventSymbol>("E6");
- var event7 = @class.GetMember<EventSymbol>("E7");
- var event8 = @class.GetMember<EventSymbol>("E8");
- var event9 = @class.GetMember<EventSymbol>("E9");
- var event10 = @class.GetMember<EventSymbol>("E10");
- var accessorsExpected = isFromSource ? new string[0] : new[] { "CompilerGeneratedAttribute" };
- Assert.Equal("AA", GetSingleAttributeName(event1));
- AssertEx.SetEqual(accessorsExpected, GetAttributeNames(event1.AddMethod.GetAttributes()));
- AssertEx.SetEqual(accessorsExpected, GetAttributeNames(event1.RemoveMethod.GetAttributes()));
- if (isFromSource)
- {
- AssertNoAttributes(event1.AssociatedField);
- Assert.Equal(0, event1.GetFieldAttributes().Length);
- }
- Assert.Equal("BB", GetSingleAttributeName(event2));
- AssertEx.SetEqual(accessorsExpected, GetAttributeNames(event2.AddMethod.GetAttributes()));
- AssertEx.SetEqual(accessorsExpected, GetAttributeNames(event2.RemoveMethod.GetAttributes()));
- if (isFromSource)
- {
- AssertNoAttributes(event2.AssociatedField);
- Assert.Equal(0, event2.GetFieldAttributes().Length);
- }
- AssertNoAttributes(event3);
- AssertEx.SetEqual(accessorsExpected.Concat(new[] { "CC" }), GetAttributeNames(event3.AddMethod.GetAttributes()));
- AssertEx.SetEqual(accessorsExpected.Concat(new[] { "CC" }), GetAttributeNames(event3.RemoveMethod.GetAttributes()));
- if (isFromSource)
- {
- AssertNoAttributes(event3.AssociatedField);
- Assert.Equal(0, event3.GetFieldAttributes().Length);
- }
- AssertNoAttributes(event4);
- AssertEx.SetEqual(accessorsExpected, GetAttributeNames(event4.AddMethod.GetAttributes()));
- AssertEx.SetEqual(accessorsExpected, GetAttributeNames(event4.RemoveMethod.GetAttributes()));
- if (isFromSource)
- {
- Assert.Equal("DD", GetSingleAttributeName(event4.AssociatedField));
- Assert.Equal("DD", event4.GetFieldAttributes().Single().AttributeClass.Name);
- }
- Assert.Equal("EE", GetSingleAttributeName(event5));
- AssertNoAttributes(event5.AddMethod);
- AssertNoAttributes(event5.RemoveMethod);
- Assert.Equal("FF", GetSingleAttributeName(event6));
- AssertNoAttributes(event6.AddMethod);
- AssertNoAttributes(event6.RemoveMethod);
- AssertNoAttributes(event7);
- Assert.Equal("GG", GetSingleAttributeName(event7.AddMethod));
- AssertNoAttributes(event7.RemoveMethod);
- AssertNoAttributes(event8);
- Assert.Equal("HH", GetSingleAttributeName(event8.AddMethod));
- AssertNoAttributes(event8.RemoveMethod);
- AssertNoAttributes(event9);
- AssertNoAttributes(event9.AddMethod);
- AssertNoAttributes(event9.RemoveMethod);
- Assert.Equal("II", GetSingleAttributeName(event9.AddMethod.Parameters.Single()));
- AssertNoAttributes(event10);
- AssertNoAttributes(event10.AddMethod);
- AssertNoAttributes(event10.RemoveMethod);
- Assert.Equal("JJ", event10.AddMethod.GetReturnTypeAttributes().Single().AttributeClass.Name);
- };
- CompileAndVerify(source, sourceSymbolValidator: symbolValidator(true), symbolValidator: symbolValidator(false));
- }
- [Fact]
- public void TestAttributesOnEvents_NoDuplicateDiagnostics()
- {
- string source = @"
- public class AA : System.Attribute { }
- public class BB : System.Attribute { }
- public class CC : System.Attribute { }
- public class DD : System.Attribute { }
- public class EE : System.Attribute { }
- public class FF : System.Attribute { }
- public class GG : System.Attribute { }
- public class HH : System.Attribute { }
- public class II : System.Attribute { }
- public class JJ : System.Attribute { }
- public class Test
- {
- [AA(0)] //in event decl
- public event System.Action E1;
- [event: BB(0)] //in event decl
- public event System.Action E2;
- [method: CC(0)] //in both accessors
- public event System.Action E3;
- [field: DD(0)] //on field
- public event System.Action E4;
- [EE(0)] //in event decl
- public event System.Action E5 { add { } remove { } }
- [event: FF(0)] //in event decl
- public event System.Action E6 { add { } remove { } }
- public event System.Action E7 { [GG(0)] add { } remove { } } //in accessor
- public event System.Action E8 { [method: HH(0)] add { } remove { } } //in accessor
- public event System.Action E9 { [param: II(0)] add { } remove { } } //on parameter (after .param[1])
- public event System.Action E10 { [return: JJ(0)] add { } remove { } } //on return (after .param[0])
- }
- ";
- CreateCompilationWithMscorlib(source).VerifyDiagnostics(
- // (15,6): error CS1729: 'AA' does not contain a constructor that takes 1 arguments
- // [AA(0)] //in event decl
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "AA(0)").WithArguments("AA", "1"),
- // (17,13): error CS1729: 'BB' does not contain a constructor that takes 1 arguments
- // [event: BB(0)] //in event decl
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "BB(0)").WithArguments("BB", "1"),
- // (19,14): error CS1729: 'CC' does not contain a constructor that takes 1 arguments
- // [method: CC(0)] //in both accessors
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "CC(0)").WithArguments("CC", "1"),
- // (21,13): error CS1729: 'DD' does not contain a constructor that takes 1 arguments
- // [field: DD(0)] //on field
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "DD(0)").WithArguments("DD", "1"),
- // (24,6): error CS1729: 'EE' does not contain a constructor that takes 1 arguments
- // [EE(0)] //in event decl
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "EE(0)").WithArguments("EE", "1"),
- // (26,13): error CS1729: 'FF' does not contain a constructor that takes 1 arguments
- // [event: FF(0)] //in event decl
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "FF(0)").WithArguments("FF", "1"),
- // (29,38): error CS1729: 'GG' does not contain a constructor that takes 1 arguments
- // public event System.Action E7 { [GG(0)] add { } remove { } } //in accessor
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "GG(0)").WithArguments("GG", "1"),
- // (30,46): error CS1729: 'HH' does not contain a constructor that takes 1 arguments
- // public event System.Action E8 { [method: HH(0)] add { } remove { } } //in accessor
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "HH(0)").WithArguments("HH", "1"),
- // (31,45): error CS1729: 'II' does not contain a constructor that takes 1 arguments
- // public event System.Action E9 { [param: II(0)] add { } remove { } } //on parameter (after .param[1])
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "II(0)").WithArguments("II", "1"),
- // (32,47): error CS1729: 'JJ' does not contain a constructor that takes 1 arguments
- // public event System.Action E10 { [return: JJ(0)] add { } remove { } } //on return (after .param[0])
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "JJ(0)").WithArguments("JJ", "1"),
- // (22,32): warning CS0067: The event 'Test.E4' is never used
- // public event System.Action E4;
- Diagnostic(ErrorCode.WRN_UnreferencedEvent, "E4").WithArguments("Test.E4"),
- // (18,32): warning CS0067: The event 'Test.E2' is never used
- // public event System.Action E2;
- Diagnostic(ErrorCode.WRN_UnreferencedEvent, "E2").WithArguments("Test.E2"),
- // (20,32): warning CS0067: The event 'Test.E3' is never used
- // public event System.Action E3;
- Diagnostic(ErrorCode.WRN_UnreferencedEvent, "E3").WithArguments("Test.E3"),
- // (16,32): warning CS0067: The event 'Test.E1' is never used
- // public event System.Action E1;
- Diagnostic(ErrorCode.WRN_UnreferencedEvent, "E1").WithArguments("Test.E1"));
- }
- [Fact]
- public void TestAttributesOnIndexer_NoDuplicateDiagnostics()
- {
- string source = @"
- public class AA : System.Attribute { }
- public class BB : System.Attribute { }
- public class CC : System.Attribute { }
- public class DD : System.Attribute { }
- public class EE : System.Attribute { }
- public class Test
- {
- public int this[[AA(0)]int x]
- {
- [return: BB(0)]
- [CC(0)]
- get { return x; }
- [param: DD(0)]
- [EE(0)]
- set { }
- }
- }
- ";
- CreateCompilationWithMscorlib(source).VerifyDiagnostics(
- // (10,22): error CS1729: 'AA' does not contain a constructor that takes 1 arguments
- // public int this[[AA(0)]int x]
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "AA(0)").WithArguments("AA", "1"),
- // (13,10): error CS1729: 'CC' does not contain a constructor that takes 1 arguments
- // [CC(0)]
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "CC(0)").WithArguments("CC", "1"),
- // (12,18): error CS1729: 'BB' does not contain a constructor that takes 1 arguments
- // [return: BB(0)]
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "BB(0)").WithArguments("BB", "1"),
- // (16,17): error CS1729: 'DD' does not contain a constructor that takes 1 arguments
- // [param: DD(0)]
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "DD(0)").WithArguments("DD", "1"),
- // (17,10): error CS1729: 'EE' does not contain a constructor that takes 1 arguments
- // [EE(0)]
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "EE(0)").WithArguments("EE", "1"));
- }
- private static string GetSingleAttributeName(Symbol symbol)
- {
- return symbol.GetAttributes().Single().AttributeClass.Name;
- }
- private static void AssertNoAttributes(Symbol symbol)
- {
- Assert.Equal(0, symbol.GetAttributes().Length);
- }
- [Fact]
- public void TestAttributesOnDelegates()
- {
- string source = @"
- using System;
- public class TypeAttribute : System.Attribute { }
- public class ParamAttribute : System.Attribute { }
- public class ReturnTypeAttribute : System.Attribute { }
- public class TypeParamAttribute : System.Attribute { }
- class C
- {
- [TypeAttribute]
- [return: ReturnTypeAttribute]
- public delegate T Delegate<[TypeParamAttribute]T> ([ParamAttribute]T p1, [param: ParamAttribute]ref T p2, [ParamAttribute]out T p3);
-
- public delegate int Delegate2 ([ParamAttribute]int p1 = 0, [param: ParamAttribute]params int[] p2);
- static void Main()
- {
- typeof(Delegate<int>).GetCustomAttributes(false);
- }
- }";
- Action<ModuleSymbol> symbolValidator = moduleSymbol =>
- {
- var type = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
- var typeAttrType = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("TypeAttribute");
- var paramAttrType = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("ParamAttribute");
- var returnTypeAttrType = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("ReturnTypeAttribute");
- var typeParamAttrType = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("TypeParamAttribute");
- // Verify delegate type attribute
- var delegateType = type.GetTypeMember("Delegate");
- Assert.Equal(1, delegateType.GetAttributes(typeAttrType).Count());
- // Verify type parameter attribute
- var typeParameters = delegateType.TypeParameters;
- Assert.Equal(1, typeParameters.Length);
- Assert.Equal(1, typeParameters[0].GetAttributes(typeParamAttrType).Count());
- // Verify delegate methods (return type/parameters) attributes
- // Invoke method
- // 1) Has return type attributes from delegate declaration syntax
- // 2) Has parameter attributes from delegate declaration syntax
- var invokeMethod = (MethodSymbol)delegateType.GetMember("Invoke");
- Assert.Equal(1, invokeMethod.GetReturnTypeAttributes().Where(a => a.AttributeClass == returnTypeAttrType).Count());
- Assert.Equal(typeParameters[0], invokeMethod.ReturnType);
- var parameters = invokeMethod.GetParameters();
- Assert.Equal(3, parameters.Length);
- Assert.Equal("p1", parameters[0].Name);
- Assert.Equal(1, parameters[0].GetAttributes(paramAttrType).Count());
- Assert.Equal("p2", parameters[1].Name);
- Assert.Equal(1, parameters[1].GetAttributes(paramAttrType).Count());
- Assert.Equal("p3", parameters[2].Name);
- Assert.Equal(1, parameters[2].GetAttributes(paramAttrType).Count());
- // Delegate Constructor:
- // 1) Doesn't have any return type attributes
- // 2) Doesn't have any parameter attributes
- var ctor = (MethodSymbol)delegateType.GetMember(".ctor");
- Assert.Equal(0, ctor.GetReturnTypeAttributes().Length);
- parameters = ctor.GetParameters();
- Assert.Equal(2, parameters.Length);
- Assert.Equal(0, parameters[0].GetAttributes().Length);
- Assert.Equal(0, parameters[1].GetAttributes().Length);
- // BeginInvoke method:
- // 1) Doesn't have any return type attributes
- // 2) Has parameter attributes from delegate declaration parameters syntax
- var beginInvokeMethod = (MethodSymbol)delegateType.GetMember("BeginInvoke");
- Assert.Equal(0, beginInvokeMethod.GetReturnTypeAttributes().Length);
- parameters = beginInvokeMethod.GetParameters();
- Assert.Equal(5, parameters.Length);
- Assert.Equal("p1", parameters[0].Name);
- Assert.Equal(1, parameters[0].GetAttributes(paramAttrType).Count());
- Assert.Equal("p2", parameters[1].Name);
- Assert.Equal(1, parameters[1].GetAttributes(paramAttrType).Count());
- Assert.Equal("p3", parameters[2].Name);
- Assert.Equal(1, parameters[2].GetAttributes(paramAttrType).Count());
- Assert.Equal(0, parameters[3].GetAttributes(paramAttrType).Count());
- Assert.Equal(0, parameters[4].GetAttributes(paramAttrType).Count());
- // EndInvoke method:
- // 1) Has return type attributes from delegate declaration syntax
- // 2) Has parameter attributes from delegate declaration syntax
- // only for ref/out parameters.
- var endInvokeMethod = (MethodSymbol)delegateType.GetMember("EndInvoke");
- Assert.Equal(1, endInvokeMethod.GetReturnTypeAttributes().Where(a => a.AttributeClass == returnTypeAttrType).Count());
- parameters = endInvokeMethod.GetParameters();
- Assert.Equal(3, parameters.Length);
- Assert.Equal("p2", parameters[0].Name);
- Assert.Equal(1, parameters[0].GetAttributes(paramAttrType).Count());
- Assert.Equal("p3", parameters[1].Name);
- Assert.Equal(1, parameters[1].GetAttributes(paramAttrType).Count());
- Assert.Equal(0, parameters[2].GetAttributes(paramAttrType).Count());
- };
- CompileAndVerify(source, sourceSymbolValidator: symbolValidator, symbolValidator: symbolValidator);
- }
- [Fact]
- public void TestAttributesOnDelegates_NoDuplicateDiagnostics()
- {
- string source = @"
- public class TypeAttribute : System.Attribute { }
- public class ParamAttribute1 : System.Attribute { }
- public class ParamAttribute2 : System.Attribute { }
- public class ParamAttribute3 : System.Attribute { }
- public class ParamAttribute4 : System.Attribute { }
- public class ParamAttribute5 : System.Attribute { }
- public class ReturnTypeAttribute : System.Attribute { }
- public class TypeParamAttribute : System.Attribute { }
- class C
- {
- [TypeAttribute(0)]
- [return: ReturnTypeAttribute(0)]
- public delegate T Delegate<[TypeParamAttribute(0)]T> ([ParamAttribute1(0)]T p1, [param: ParamAttribute2(0)]ref T p2, [ParamAttribute3(0)]out T p3);
- public delegate int Delegate2 ([ParamAttribute4(0)]int p1 = 0, [param: ParamAttribute5(0)]params int[] p2);
- }";
- CreateCompilationWithMscorlib(source).VerifyDiagnostics(
- // (13,6): error CS1729: 'TypeAttribute' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "TypeAttribute(0)").WithArguments("TypeAttribute", "1"),
- // (15,33): error CS1729: 'TypeParamAttribute' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "TypeParamAttribute(0)").WithArguments("TypeParamAttribute", "1"),
- // (15,60): error CS1729: 'ParamAttribute1' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "ParamAttribute1(0)").WithArguments("ParamAttribute1", "1"),
- // (15,93): error CS1729: 'ParamAttribute2' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "ParamAttribute2(0)").WithArguments("ParamAttribute2", "1"),
- // (15,123): error CS1729: 'ParamAttribute3' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "ParamAttribute3(0)").WithArguments("ParamAttribute3", "1"),
- // (14,14): error CS1729: 'ReturnTypeAttribute' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "ReturnTypeAttribute(0)").WithArguments("ReturnTypeAttribute", "1"),
- // (17,37): error CS1729: 'ParamAttribute4' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "ParamAttribute4(0)").WithArguments("ParamAttribute4", "1"),
- // (17,76): error CS1729: 'ParamAttribute5' does not contain a constructor that takes 1 arguments
- Diagnostic(ErrorCode.ERR_BadCtorArgCount, "ParamAttribute5(0)").WithArguments("ParamAttribute5", "1"));
- }
- [Fact]
- public void TestAttributesOnDelegateWithOptionalAndParams()
- {
- string source = @"
- using System;
- public class ParamAttribute : System.Attribute { }
- class C
- {
- public delegate int Delegate ([ParamAttribute]int p1 = 0, [param: ParamAttribute]params int[] p2);
- static void Main()
- {
- typeof(Delegate).GetCustomAttributes(false);
- }
- }";
- Func<bool, Action<ModuleSymbol>> symbolValidator = isFromSource => moduleSymbol =>
- {
- var type = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("C");
- var paramAttrType = moduleSymbol.GlobalNamespace.GetMember<NamedTypeSymbol>("ParamAttribute");
- // Verify delegate type attribute
- var delegateType = type.GetTypeMember("Delegate");
- // Verify delegate methods (return type/parameters) attributes
- // Invoke method has parameter attributes from delegate declaration syntax
- var invokeMethod = (MethodSymbol)delegateType.GetMember("Invoke");
- var parameters = invokeMethod.GetParameters();
- Assert.Equal(2, parameters.Length);
- Assert.Equal("p1", parameters[0].Name);
- Assert.Equal(1, parameters[0].GetAttributes(paramAttrType).Count());
- Assert.Equal("p2", parameters[1].Name);
- Assert.Equal(1, parameters[1].GetAttributes(paramAttrType).Count());
- // verify ParamArrayAttribute on p2
- if (isFromSource)
- {
- WellKnownAttributesTestBase.VerifyParamArrayAttribute(parameters[1], (SourceModuleSymbol)moduleSymbol);
- }
- // Delegate Constructor: Doesn't have any parameter attributes
- var ctor = (MethodSymbol)delegateType.GetMember(".ctor");
- parameters = ctor.GetParameters();
- Assert.Equal(2, parameters.Length);
- Assert.Equal(0, parameters[0].GetAttributes().Length);
- Assert.Equal(0, parameters[1].GetAttributes().Length);
- Assert.Equal(0, parameters[0].GetSynthesizedAttributes().Length);
- Assert.Equal(0, parameters[1].GetSynthesizedAttributes().Length);
- // BeginInvoke method: Has parameter attributes from delegate declaration parameters syntax
- var beginInvokeMethod = (MethodSymbol)delegateType.GetMember("BeginInvoke");
- parameters = beginInvokeMethod.GetParameters();
- Assert.Equal(4, parameters.Length);
- Assert.Equal("p1", parameters[0].Name);
- Assert.Equal(1, parameters[0].GetAttributes(paramAttrType).Count());
- Assert.Equal("p2", parameters[1].Name);
- Assert.Equal(1, parameters[1].GetAttributes(paramAttrType).Count());
- Assert.Equal(0, parameters[2].GetAttributes(paramAttrType).Count());
- Assert.Equal(0, parameters[3].GetAttributes(paramAttrType).Count());
- // verify no ParamArrayAttribute on p2
- if (isFromSource)
- {
- WellKnownAttributesTestBase.VerifyParamArrayAttribute(parameters[1], (SourceModuleSymbol)moduleSymbol, expected: false);
- }
- };
- CompileAndVerify(source, sourceSymbolValidator: symbolValidator(true), symbolValidator: symbolValidator(false));
- }
- [Fact]
- public void TestAttributesOnEnumField()
- {
- string source = @"
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using CustomAttribute;
- using AN = CustomAttribute.AttrName;
- // Use AttrName without Attribute suffix
- [assembly: AN(UShortField = 4321)]
- [assembly: AN(UShortField = 1234)]
- // TODO: below attribute seems to be an ambiguous attribute specification
- // TODO: modify the test assembly to remove ambiguity
- // [module: AttrName(TypeField = typeof(System.IO.FileStream))]
- namespace AttributeTest
- {
- class Foo
- {
- public class NestedClass
- {
- // enum as object
- [AllInheritMultiple(System.IO.FileMode.Open, BindingFlags.DeclaredOnly | BindingFlags.Public, UIntField = 123 * Field)]
- internal const uint Field = 10;
- }
- [AllInheritMultiple(new char[] { 'q', 'c' }, """")]
- [AllInheritMultiple()]
- enum NestedEnum
- {
- zero,
- one = 1,
- [AllInheritMultiple(null, 256, 0f, -1, AryField = new ulong[] { 0, 1, 12345657 })]
- [AllInheritMultipleAttribute(typeof(Dictionary<string, int>), 255 + NestedClass.Field, -0.0001f, 3 - (short)NestedEnum.oneagain)]
- three = 3,
- oneagain = one
- }
- }
- }
- ";
- var references = new[] { new MetadataImageReference(TestResources.SymbolsTests.Metadata.AttributeTestDef01.AsImmutableOrNull()) };
- CSharpCompilationOptions opt = TestOptions.Dll;
- var compilation = CreateCompilationWithMscorlib(source, references, compOptions: opt);
- Action<ModuleSymbol> attributeValidator = (ModuleSymbol m) =>
- {
- var attrs = m.GetAttributes();
- // Assert.Equal(1, attrs.Count);
- // Assert.Equal("CustomAttribute.AttrName", attrs[0].AttributeClass.ToDisplayString());
- // attrs[0].VerifyValue<Type>(0, "TypeField", TypedConstantKind.Type, typeof(System.IO.FileStream));
- var assembly = m.ContainingSymbol;
- attrs = assembly.GetAttributes();
- Assert.Equal(2, attrs.Length);
- Assert.Equal("CustomAttribute.AttrName", attrs[0].AttributeClass.ToDisplayString());
- attrs[1].VerifyNamedArgumentValue<ushort>(0, "UShortField", TypedConstantKind.Primitive, 1234);
- var ns = (NamespaceSymbol)m.GlobalNamespace.GetMember("AttributeTest");
- var top = (NamedTypeSymbol)ns.GetMember("Foo");
- var type = top.GetMember<NamedTypeSymbol>("NestedClass");
- var field = type.GetMember<FieldSymbol>("Field");
- attrs = field.GetAttributes();
- Assert.Equal("CustomAttribute.AllInheritMultipleAttribute", attrs[0].AttributeClass.ToDisplayString());
- attrs[0].VerifyValue(0, TypedConstantKind.Enum, (int)FileMode.Open);
- attrs[0].VerifyValue(1, TypedConstantKind.Enum, (int)(BindingFlags.DeclaredOnly | BindingFlags.Public));
- attrs[0].VerifyNamedArgumentValue<uint>(0, "UIntField", TypedConstantKind.Primitive, 1230);
- var nenum = top.GetMember<TypeSymbol>("NestedEnum");
- attrs = nenum.GetAttributes();
- Assert.Equal(2, attrs.Length);
- attrs[0].VerifyValue(0, TypedConstantKind.Array, new char[] { 'q', 'c' });
- Assert.Equal(SyntaxKind.Attribute, attrs[0].ApplicationSyntaxReference.GetSyntax().CSharpKind());
- var syntax = (AttributeSyntax)attrs[0].ApplicationSyntaxReference.GetSyntax();
- Assert.Equal(2, syntax.ArgumentList.Arguments.Count());
- syntax = (AttributeSyntax)attrs[1].ApplicationSyntaxReference.GetSyntax();
- Assert.Equal(0, syntax.ArgumentList.Arguments.Count());
- attrs = nenum.GetMember("three").GetAttributes();
- Assert.Equal(2, attrs.Length);
- attrs[0].VerifyValue<object>(0, TypedConstantKind.Primitive, null);
- attrs[0].VerifyValue<long>(1, TypedConstantKind.Primitive, 256);
- attrs[0].VerifyValue<float>(2, TypedConstantKind.Primitive, 0);
- attrs[0].VerifyValue<short>(3, TypedConstantKind.Primitive, -1);
- attrs[0].VerifyNamedArgumentValue<ulong[]>(0, "AryField", TypedConstantKind.Array, new ulong[] { 0, 1, 12345657 });
- attrs[1].VerifyValue<object>(0, TypedConstantKind.Type, typeof(Dictionary<string, int>));
- attrs[1].VerifyValue<long>(1, TypedConstantKind.Primitive, 265);
- attrs[1].VerifyValue<float>(2, TypedConstantKind.Primitive, -0.0001f);
- attrs[1].VerifyValue<short>(3, TypedConstantKind.Primitive, 2);
- };
- // Verify attributes from source and then load metadata to see attributes are written correctly.
- CompileAndVerify(compilation, sourceSymbolValidator: attributeValidator, symbolValidator: null);
- }
- [Fact]
- public void TestAttributesOnDelegate()
- {
- string source = @"
- using System;
- using System.Collections.Generic;
- using CustomAttribute;
- namespace AttributeTest
- {
- public class Foo
- {
- [AllInheritMultiple(new object[] { 0, """", null }, 255, -127 - 1, AryProp = new object[] { new object[] { """", typeof(IList<string>) } })]
- public delegate void NestedSubDele([AllInheritMultiple()]string p1, [Derived(typeof(string[, ,]))]string p2);
- }
- }
- ";
- var references = new[] { new MetadataImageReference(TestResources.SymbolsTests.Metadata.AttributeTestDef01.AsImmutableOrNull()) };
- CSharpCompilationOptions opt = TestOptions.Dll;
- var compilation = CreateCompilationWithMscorlib(source, references, compOptions: opt);
- Action<ModuleSymbol> attributeValidator = (ModuleSymbol m) =>
- {
- var ns = (NamespaceSymbol)m.GlobalNamespace.GetMember("AttributeTest");
- var type = (NamedTypeSymbol)ns.GetMember("Foo");
- var dele = (NamedTypeSymbol)type.GetTypeMember("NestedSubDele");
- var attrs = dele.GetAttributes();
- attrs.First().VerifyValue<object>(0, TypedConstantKind.Array, new object[] { 0, "", null });
- attrs.First().VerifyValue<byte>(1, TypedConstantKind.Primitive, 255);
- attrs.First().VerifyValue<sbyte>(2, TypedConstantKind.Primitive, -128);
- attrs.First().VerifyNamedArgumentValue<object[]>(0, "AryProp", TypedConstantKind.Array, new object[] { new object[] { "", typeof(IList<string>) } });
- var mem = dele.GetMember<MethodSymbol>("Invoke");
- attrs = mem.Parameters[0].GetAttributes();
- Assert.Equal(1, attrs.Length);
- attrs = mem.Parameters[1].GetAttributes();
- Assert.Equal(1, attrs.Length);
- attrs[0].VerifyValue<object>(0, TypedConstantKind.Type, typeof(string[,,]));
- };
- // Verify attributes from source and then load metadata to see attributes are written correctly.
- CompileAndVerify(compilation, sourceSymbolValidator: attributeValidator, symbolValidator: attributeValidator);
- }
- [Fact]
- public void TestAttributesUseBaseAttributeField()
- {
- string source = @"
- using System;
- namespace AttributeTest
- {
- public interface IFoo
- {
- [CustomAttribute.Derived(new object[] { 1, null, ""Hi"" }, ObjectField = 2)]
- int F(int p);
- }
- }
- ";
- var references = new[] { new MetadataImageReference(TestResources.SymbolsTests.Metadata.AttributeTestDef01.AsImmutableOrNull()) };
- CSharpCompilationOptions opt = TestOptions.Dll;
- var compilation = CreateCompilationWithMscorlib(source, references, compOptions: opt);
- Action<ModuleSymbol> attributeValidator = (ModuleSymbol m) =>
- {
- var ns = (NamespaceSymbol)m.GlobalNamespace.GetMember("AttributeTest");
- var type = (NamedTypeSymbol)ns.GetMember("IFoo");
- var attrs = type.GetMember<MethodSymbol>("F").GetAttributes();
- Assert.Equal(@"CustomAttribute.DerivedAttribute({1, null, ""Hi""}, ObjectField = 2)", attrs.First().ToString());
- attrs.First().VerifyValue<object>(0, TypedConstantKind.Array, new object[] { 1, null, "Hi" });
- attrs.First().VerifyNamedArgumentValue<object>(0, "ObjectField", TypedConstantKind.Primitive, 2);
- };
- // Verify attributes from source and then load metadata to see attributes are written correctly.
- CompileAndVerify(compilation, sourceSymbolValidator: attributeValidator, symbolValidator: null);
- }
- [WorkItem(688007, "DevDiv")]
- [Fact]
- public void Bug688007a()
- {
- string source = @"
- using System;
- using X;
- using Z;
- namespace X
- {
- public class At…
Large files files are truncated, but you can click here to view the full file