diff --git a/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs b/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs index b5e10b5976182a2885418e107d55cdb3915c9a00..1f31b1f708e84de44746246d19811fdcea320238 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs +++ b/src/Compilers/CSharp/Portable/CSharpResources.Designer.cs @@ -179,7 +179,7 @@ internal class CSharpResources { } /// - /// Looks up a localized string similar to The abstract method '{0}' cannot be marked virtual. + /// Looks up a localized string similar to The abstract {0} '{1}' cannot be marked virtual. /// internal static string ERR_AbstractNotVirtual { get { diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 5f0519051e06f911ffab038a1f74523e26f638b8..87b10c6fb2a5cd8734fcbc4f05976c629d8b8f0c 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -1422,7 +1422,7 @@ If such a class is used as a base class and if the deriving class defines a dest '{0}' cannot be both abstract and sealed - The abstract method '{0}' cannot be marked virtual + The abstract {0} '{1}' cannot be marked virtual The constant '{0}' cannot be marked static diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs index a000efeee1a83dd23c7936d08874e697459350b9..ac1ca753dd7f78cad84969dab4e778a24eca9bf4 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceEventSymbol.cs @@ -485,7 +485,7 @@ protected void CheckModifiersAndType(DiagnosticBag diagnostics) } else if (IsAbstract && IsVirtual) { - diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this); + diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this); } else if (ContainingType.IsSealed && this.DeclaredAccessibility.HasProtected() && !this.IsOverride) { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs index ca4209b5ef006803a018183b8dc7cb313fba91fb..ed087ca8c5c490c62ebd9e184948607d1fceff94 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberMethodSymbol.cs @@ -940,7 +940,7 @@ private void CheckModifiers(Location location, DiagnosticBag diagnostics) } else if (IsAbstract && IsVirtual) { - diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this); + diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this); } else if (IsAbstract && ContainingType.TypeKind == TypeKind.Struct) { diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs index ff722fb26c8bb0f6b9cd5fb28e115d5b631b9271..c5d3d9a38944b70eefcc1c868ab9ef368476d430 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourcePropertySymbol.cs @@ -848,7 +848,7 @@ private void CheckModifiers(Location location, bool isIndexer, DiagnosticBag dia } else if (IsAbstract && IsVirtual) { - diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this); + diagnostics.Add(ErrorCode.ERR_AbstractNotVirtual, location, this.Kind.Localize(), this); } else if (ContainingType.IsSealed && this.DeclaredAccessibility.HasProtected() && !this.IsOverride) { diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs index f435a75d61f505f50b3f4723e1c3e714ea2cf5f7..872faea30658b0d29961a387e06491c26d4a56bc 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/SymbolErrorTests.cs @@ -7746,7 +7746,7 @@ abstract public class cly : clx [Fact] public void CS0503ERR_AbstractNotVirtual01() { - var text = @"namespace NS + var source = @"namespace NS { abstract public class clx { @@ -7757,14 +7757,24 @@ abstract public class clx } // class clx } "; - var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text, - new ErrorDescription { Code = (int)ErrorCode.ERR_AbstractNotVirtual, Line = 5, Column = 40 }, - new ErrorDescription { Code = (int)ErrorCode.ERR_AbstractNotVirtual, Line = 6, Column = 41 }, - new ErrorDescription { Code = (int)ErrorCode.ERR_AbstractNotVirtual, Line = 7, Column = 40 }, - new ErrorDescription { Code = (int)ErrorCode.ERR_AbstractNotVirtual, Line = 8, Column = 53 }); - var ns = comp.SourceModule.GlobalNamespace.GetMembers("NS").Single() as NamespaceSymbol; - // TODO... + var comp = CreateStandardCompilation(source).VerifyDiagnostics( + // (7,40): error CS0503: The abstract property 'clx.P' cannot be marked virtual + // virtual abstract public object P { get; set; } + Diagnostic(ErrorCode.ERR_AbstractNotVirtual, "P").WithArguments("property", "NS.clx.P").WithLocation(7, 40), + // (6,41): error CS0503: The abstract method 'clx.M2(T)' cannot be marked virtual + // abstract virtual protected void M2(T t); + Diagnostic(ErrorCode.ERR_AbstractNotVirtual, "M2").WithArguments("method", "NS.clx.M2(T)").WithLocation(6, 41), + // (5,40): error CS0503: The abstract method 'clx.M1()' cannot be marked virtual + // abstract virtual internal void M1(); + Diagnostic(ErrorCode.ERR_AbstractNotVirtual, "M1").WithArguments("method", "NS.clx.M1()").WithLocation(5, 40), + // (8,53): error CS0503: The abstract event 'clx.E' cannot be marked virtual + // virtual abstract public event System.Action E; + Diagnostic(ErrorCode.ERR_AbstractNotVirtual, "E").WithArguments("event", "NS.clx.E").WithLocation(8, 53)); + + var nsNamespace = comp.SourceModule.GlobalNamespace.GetMembers("NS").Single() as NamespaceSymbol; + var clxClass = nsNamespace.GetMembers("clx").Single() as NamedTypeSymbol; + Assert.Equal(9, clxClass.GetMembers().Length); } [Fact]