提交 c6a2ebcb 编写于 作者: S skytribe

Bug 911913 - Squiggle location for Unimplemented Interface Method diagnostic...

 Bug 911913 - Squiggle location for Unimplemented Interface Method diagnostic changed to reflect interface rather than class - matching VB implementation. (changeset 1252208)
上级 a6357a27
......@@ -41,6 +41,13 @@ internal override AttributeUsageInfo GetAttributeUsageInfo()
return AttributeUsageInfo.Null;
}
protected override Location GetCorrespondingBaseListLocation(NamedTypeSymbol @base)
{
// A script class may implement interfaces in hosted scenarios.
// The interface definitions are specified via API, not in compilation source.
return NoLocation.Singleton;
}
internal override NamedTypeSymbol BaseTypeNoUseSiteDiagnostics
{
get
......
// 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.
// 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.Immutable;
......@@ -213,7 +213,7 @@ private void CheckAbstractClassImplementations(DiagnosticBag diagnostics)
// Suppress for bogus properties and events and for indexed properties.
if (!interfaceMember.MustCallMethodsDirectly() && !interfaceMember.IsIndexedProperty())
{
diagnostics.Add(ErrorCode.ERR_UnimplementedInterfaceMember, this.Locations[0], this, interfaceMember);
diagnostics.Add(ErrorCode.ERR_UnimplementedInterfaceMember, GetImplementsLocation(@interface) ?? this.Locations[0], this, interfaceMember);
}
}
}
......@@ -253,6 +253,47 @@ private void CheckAbstractClassImplementations(DiagnosticBag diagnostics)
return synthesizedImplementations.ToImmutableAndFree();
}
protected abstract Location GetCorrespondingBaseListLocation(NamedTypeSymbol @base);
private Location GetImplementsLocation(NamedTypeSymbol implementedInterface)
{
// We ideally want to identify the interface location in the baselist with an exact match but
// will fall back and use the first derived interface if exact interface is not present.
// this is the similar logic as the VB Implementation.
Debug.Assert(this.InterfacesAndTheirBaseInterfacesNoUseSiteDiagnostics.Contains(implementedInterface));
NamedTypeSymbol directInterface = null;
foreach (var iface in this.InterfacesNoUseSiteDiagnostics)
{
if (iface == implementedInterface)
{
directInterface = iface;
break;
}
else if ((object)directInterface == null && ImplementsInterface(iface, implementedInterface))
{
directInterface = iface;
}
}
Debug.Assert((object)directInterface != null);
return GetCorrespondingBaseListLocation(directInterface);
}
private bool ImplementsInterface(TypeSymbol subType, TypeSymbol superInterface)
{
HashSet<DiagnosticInfo> unusedDiagnostics = null;
foreach (NamedTypeSymbol @interface in subType.AllInterfacesWithDefinitionUseSiteDiagnostics(ref unusedDiagnostics))
{
if (@interface.IsInterface && @interface == superInterface)
{
return true;
}
}
return false;
}
/// <summary>
/// It's not interesting to report diagnostics on implementation of interface accessors
/// if the corresponding events or properties are not implemented (i.e. we want to suppress
......
// 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.
// 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.Collections.Generic;
using System.Collections.Immutable;
......@@ -32,6 +32,44 @@ internal sealed partial class SourceNamedTypeSymbol : SourceMemberContainerTypeS
private ThreeState lazyIsExplicitDefinitionOfNoPiaLocalType = ThreeState.Unknown;
protected override Location GetCorrespondingBaseListLocation(NamedTypeSymbol @base)
{
Location backupLocation = null;
var unusedDiagnostics = DiagnosticBag.GetInstance();
foreach (SyntaxReference part in SyntaxReferences)
{
TypeDeclarationSyntax typeBlock = (TypeDeclarationSyntax)part.GetSyntax();
BaseListSyntax bases = typeBlock.BaseList;
if (bases == null)
{
continue;
}
SeparatedSyntaxList<TypeSyntax> inheritedTypeDecls = typeBlock.BaseList.Types;
var baseBinder = this.DeclaringCompilation.GetBinder(bases);
baseBinder = baseBinder.WithAdditionalFlagsAndContainingMemberOrLambda(BinderFlags.SuppressConstraintChecks, this);
if ((object) backupLocation == null)
{
backupLocation = ((TypeSyntax)inheritedTypeDecls[0]).GetLocation();
}
foreach (TypeSyntax t in inheritedTypeDecls)
{
TypeSymbol bt = baseBinder.BindType(t, unusedDiagnostics);
if (bt == @base)
{
unusedDiagnostics.Free();
return t.GetLocation();
}
}
}
unusedDiagnostics.Free();
return backupLocation;
}
internal SourceNamedTypeSymbol(NamespaceOrTypeSymbol containingSymbol, MergedTypeDeclaration declaration, DiagnosticBag diagnostics)
: base(containingSymbol, declaration, diagnostics)
{
......
......@@ -4188,7 +4188,7 @@ public void MissingAssemblyReference01()
referencedCompilations: new[] { B, C }).VerifyDiagnostics(
// (1,14): error CS0535: 'D' does not implement interface member 'B.M(A)'
// public class D : C, B { }
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "D").WithArguments("D", "B.M(A)")
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "B").WithArguments("D", "B.M(A)")
);
}
......
......@@ -343,9 +343,13 @@ class CBar : IFoo // CS0535 * 2
var asm = TestReferences.SymbolsTests.CustomModifiers.ModoptTests;
CreateCompilationWithMscorlib(text, new[] { asm }).VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CFoo").WithArguments("CFoo", "Metadata.IFooAmbiguous<string, long>.M(?)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CBar").WithArguments("CBar", "Metadata.IFoo.M<T>(T)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CBar").WithArguments("CBar", "Metadata.IFoo.M<T>(T)"));
// (4,38): warning CS0473: Explicit interface implementation 'CFoo.Metadata.IFooAmbiguous<string, long>.M(string)' matches more than one interface member. Which interface member is actually chosen is implementation-dependent. Consider using a non-explicit implementation instead.
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IFoo").WithArguments("CBar", "Metadata.IFoo.M<T>(T)"),
// (2,14): error CS0535: 'CFoo' does not implement interface member
// 'Metadata.IFooAmbiguous<string, long>.M(?)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IFoo").WithArguments("CBar", "Metadata.IFoo.M<T>(T)"),
// (2,14): error CS0535: 'CFoo' does not implement interface member 'Metadata.IFooAmbiguous<string, long>.M(string)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IFooAmbiguous<string, long>").WithArguments("CFoo", "Metadata.IFooAmbiguous<string, long>.M(?)"));
}
[WorkItem(540518, "DevDiv")]
......@@ -362,12 +366,14 @@ public class CFoo : IFooAmbiguous<string, long> // CS0535 *2
CreateCompilationWithMscorlib(text, new[] { asm }).VerifyDiagnostics(
// (4,38): warning CS0473: Explicit interface implementation 'CFoo.Metadata.IFooAmbiguous<string, long>.M(string)' matches more than one interface member. Which interface member is actually chosen is implementation-dependent. Consider using a non-explicit implementation instead.
Diagnostic(ErrorCode.WRN_ExplicitImplCollision, "M").WithArguments("CFoo.Metadata.IFooAmbiguous<string, long>.M(string)"),
// (2,14): error CS0535: 'CFoo' does not implement interface member
// 'Metadata.IFooAmbiguous<string, long>.M(?)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CFoo").WithArguments("CFoo", "Metadata.IFooAmbiguous<string, long>.M(?)"),
// (2,14): error CS0535: 'CFoo' does not implement interface member 'Metadata.IFooAmbiguous<string, long>.M(string)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CFoo").WithArguments("CFoo", "Metadata.IFooAmbiguous<string, long>.M(string)"));
// long IFooAmbiguous<string, long>.M(string t) { return -128; } // W CS0437
Diagnostic(ErrorCode.WRN_ExplicitImplCollision, "M").WithArguments("CFoo.Metadata.IFooAmbiguous<string, long>.M(string)").WithLocation(4, 38),
// (2,21): error CS0535: 'CFoo' does not implement interface member 'Metadata.IFooAmbiguous<string, long>.M(string)'
// public class CFoo : IFooAmbiguous<string, long> // CS0535 *2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IFooAmbiguous<string, long>").WithArguments("CFoo", "Metadata.IFooAmbiguous<string, long>.M(string)").WithLocation(2, 21),
// (2,21): error CS0535: 'CFoo' does not implement interface member 'Metadata.IFooAmbiguous<string, long>.M(?)'
// public class CFoo : IFooAmbiguous<string, long> // CS0535 *2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IFooAmbiguous<string, long>").WithArguments("CFoo", "Metadata.IFooAmbiguous<string, long>.M(?)").WithLocation(2, 21));
}
[Fact]
......
......@@ -830,6 +830,528 @@ public class Test
// <fine-name>(4,16): error CS0012: The type 'BaseAssembly.BaseClass' is defined in an assembly that is not referenced. You must add a reference to assembly 'BaseAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_Typical()
{
string scenarioCode = @"
public class ITT
: IInterfaceBase
{ }
public interface IInterfaceBase
{
void bar();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (3,7): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase.bar()'
// : IInterfaceBase
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase").WithArguments("ITT", "IInterfaceBase.bar()").WithLocation(3, 7));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_FullyQualified()
{
// Using fully Qualified names
string scenarioCode = @"
public class ITT
: test.IInterfaceBase
{ }
namespace test
{
public interface IInterfaceBase
{
void bar();
}
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (3,7): error CS0535: 'ITT' does not implement interface member 'test.IInterfaceBase.bar()'
// : test.IInterfaceBase
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "test.IInterfaceBase").WithArguments("ITT", "test.IInterfaceBase.bar()").WithLocation(3, 7));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_WithAlias()
{
// Using Alias
string scenarioCode = @"
using a1 = test;
public class ITT
: a1.IInterfaceBase
{ }
namespace test
{
public interface IInterfaceBase
{
void bar();
}
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (5,7): error CS0535: 'ITT' does not implement interface member 'test.IInterfaceBase.bar()'
// : a1.IInterfaceBase
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "a1.IInterfaceBase").WithArguments("ITT", "test.IInterfaceBase.bar()").WithLocation(5, 7));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario01()
{
// Two interfaces, neither implemented with alias - should have 2 errors each squiggling a different interface type.
string scenarioCode = @"
using a1 = test;
public class ITT
: a1.IInterfaceBase, a1.IInterfaceBase2
{ }
namespace test
{
public interface IInterfaceBase
{
void xyz();
}
public interface IInterfaceBase2
{
void xyz();
}
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (5,7): error CS0535: 'ITT' does not implement interface member 'test.IInterfaceBase.xyz()'
// : a1.IInterfaceBase, a1.IInterfaceBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "a1.IInterfaceBase").WithArguments("ITT", "test.IInterfaceBase.xyz()").WithLocation(5, 7),
// (5,26): error CS0535: 'ITT' does not implement interface member 'test.IInterfaceBase2.xyz()'
// : a1.IInterfaceBase, a1.IInterfaceBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "a1.IInterfaceBase2").WithArguments("ITT", "test.IInterfaceBase2.xyz()").WithLocation(5, 26));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario02()
{
// Two interfaces, only the second is implemented
string scenarioCode = @"
public class ITT
: IInterfaceBase, IInterfaceBase2
{
void IInterfaceBase2.abc()
{ }
}
public interface IInterfaceBase
{
void xyz();
}
public interface IInterfaceBase2
{
void abc();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (3,7): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase.xyz()'
// : IInterfaceBase, IInterfaceBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase").WithArguments("ITT", "IInterfaceBase.xyz()").WithLocation(3, 7));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario03()
{
// Two interfaces, only the first is implemented
string scenarioCode = @"
public class ITT
: IInterfaceBase, IInterfaceBase2
{
void IInterfaceBase.xyz()
{ }
}
public interface IInterfaceBase
{
void xyz();
}
public interface IInterfaceBase2
{
void abc();
}
";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (3,23): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase2.abc()'
// : IInterfaceBase, IInterfaceBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase2").WithArguments("ITT", "IInterfaceBase2.abc()").WithLocation(3, 23));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario04()
{
// Two interfaces, neither implemented but formatting of interfaces are on different lines
string scenarioCode = @"
public class ITT
: IInterfaceBase,
IInterfaceBase2
{ }
public interface IInterfaceBase
{
void xyz();
}
public interface IInterfaceBase2
{
void xyz();
}
";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (3,7): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase.xyz()'
// : IInterfaceBase,
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase").WithArguments("ITT", "IInterfaceBase.xyz()").WithLocation(3, 7),
// (4,6): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase2.xyz()'
// IInterfaceBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase2").WithArguments("ITT", "IInterfaceBase2.xyz()").WithLocation(4, 6));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario05()
{
// Inherited Interface scenario
// With methods not implemented in both base and derived.
// Should reflect 2 diagnostics but both with be squiggling the derived as we are not
// explicitly implementing base.
string scenarioCode = @"
public class ITT: IDerived
{ }
interface IInterfaceBase
{
void xyzb();
}
interface IDerived : IInterfaceBase
{
void xyzd();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,19): error CS0535: 'ITT' does not implement interface member 'IDerived.xyzd()'
// public class ITT: IDerived
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived").WithArguments("ITT", "IDerived.xyzd()").WithLocation(2, 19),
// (2,19): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase.xyzb()'
// public class ITT: IDerived
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived").WithArguments("ITT", "IInterfaceBase.xyzb()").WithLocation(2, 19));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario06()
{
// Inherited Interface scenario
string scenarioCode = @"
public class ITT: IDerived, IInterfaceBase
{ }
interface IInterfaceBase
{
void xyz();
}
interface IDerived : IInterfaceBase
{
void xyzd();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,19): error CS0535: 'ITT' does not implement interface member 'IDerived.xyzd()'
// public class ITT: IDerived, IInterfaceBase
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived").WithArguments("ITT", "IDerived.xyzd()").WithLocation(2, 19),
// (2,29): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase.xyz()'
// public class ITT: IDerived, IInterfaceBase
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase").WithArguments("ITT", "IInterfaceBase.xyz()").WithLocation(2, 29));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario07()
{
// Inherited Interface scenario - different order.
string scenarioCode = @"
public class ITT: IInterfaceBase, IDerived
{ }
interface IDerived : IInterfaceBase
{
void xyzd();
}
interface IInterfaceBase
{
void xyz();
}
";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,35): error CS0535: 'ITT' does not implement interface member 'IDerived.xyzd()'
// public class ITT: IInterfaceBase, IDerived
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived").WithArguments("ITT", "IDerived.xyzd()").WithLocation(2, 35),
// (2,19): error CS0535: 'ITT' does not implement interface member 'IInterfaceBase.xyz()'
// public class ITT: IInterfaceBase, IDerived
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IInterfaceBase").WithArguments("ITT", "IInterfaceBase.xyz()").WithLocation(2, 19));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario08()
{
// Inherited Interface scenario
string scenarioCode = @"
public class ITT: IDerived2
{}
interface IBase
{
void method1();
}
interface IBase2
{
void Method2();
}
interface IDerived2: IBase, IBase2
{}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,19): error CS0535: 'ITT' does not implement interface member 'IBase.method1()'
// public class ITT: IDerived2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived2").WithArguments("ITT", "IBase.method1()").WithLocation(2, 19),
// (2,19): error CS0535: 'ITT' does not implement interface member 'IBase2.Method2()'
// public class ITT: IDerived2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived2").WithArguments("ITT", "IBase2.Method2()").WithLocation(2, 19));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation13UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario09()
{
// Inherited Interface scenario.
string scenarioCode = @"
public class ITT : IDerived
{
void IBase2.method2()
{ }
void IDerived.method3()
{ }
}
public interface IBase
{
void method1();
}
public interface IBase2
{
void method2();
}
public interface IDerived : IBase, IBase2
{
void method3();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,20): error CS0535: 'ITT' does not implement interface member 'IBase.method1()'
// public class ITT : IDerived
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived").WithArguments("ITT", "IBase.method1()").WithLocation(2, 20));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_InterfaceInheritenceScenario10()
{
// Inherited Interface scenario.
string scenarioCode = @"
public class ITT : IDerived
{
void IBase2.method2()
{ }
void IBase3.method3()
{ }
void IDerived.method4()
{ }
}
public interface IBase
{
void method1();
}
public interface IBase2 : IBase
{
void method2();
}
public interface IBase3 : IBase
{
void method3();
}
public interface IDerived : IBase2, IBase3
{
void method4();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,20): error CS0535: 'ITT' does not implement interface member 'IBase.method1()'
// public class ITT : IDerived
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IDerived").WithArguments("ITT", "IBase.method1()").WithLocation(2, 20));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_WithPartialClass01()
{
// partial class - missing method.
// each partial implements interface but one is missing method.
string scenarioCode = @"
public partial class Foo : IBase
{
void IBase.method1()
{ }
void IBase2.method2()
{ }
}
public partial class Foo : IBase2
{
}
public partial class Foo : IBase3
{
}
public interface IBase
{
void method1();
}
public interface IBase2
{
void method2();
}
public interface IBase3
{
void method3();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (15,28): error CS0535: 'Foo' does not implement interface member 'IBase3.method3()'
// public partial class Foo : IBase3
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IBase3").WithArguments("Foo", "IBase3.method3()").WithLocation(15, 28));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_WithPartialClass02()
{
// partial class - missing method. diagnostic is reported in correct partial class
// one partial class specifically does include any inherited interface
string scenarioCode = @"
public partial class Foo : IBase, IBase2
{
void IBase.method1()
{ }
}
public partial class Foo
{
}
public partial class Foo : IBase3
{
}
public interface IBase
{
void method1();
}
public interface IBase2
{
void method2();
}
public interface IBase3
{
void method3();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,35): error CS0535: 'Foo' does not implement interface member 'IBase2.method2()'
// public partial class Foo : IBase, IBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IBase2").WithArguments("Foo", "IBase2.method2()").WithLocation(2, 35),
// (13,28): error CS0535: 'Foo' does not implement interface member 'IBase3.method3()'
// public partial class Foo : IBase3
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IBase3").WithArguments("Foo", "IBase3.method3()").WithLocation(13, 28));
}
[WorkItem(911913, "DevDiv")]
[Fact]
public void UnimplementedInterfaceSquiggleLocation_WithPartialClass03()
{
// Partial class scenario
// One class implements multiple interfaces and is missing method.
string scenarioCode = @"
public partial class Foo : IBase, IBase2
{
void IBase.method1()
{ }
}
public partial class Foo : IBase3
{
}
public interface IBase
{
void method1();
}
public interface IBase2
{
void method2();
}
public interface IBase3
{
void method3();
}";
var testAssembly = CreateCompilationWithMscorlib(scenarioCode);
testAssembly.VerifyDiagnostics(
// (2,35): error CS0535: 'Foo' does not implement interface member 'IBase2.method2()'
// public partial class Foo : IBase, IBase2
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IBase2").WithArguments("Foo", "IBase2.method2()").WithLocation(2, 35),
// (9,28): error CS0535: 'Foo' does not implement interface member 'IBase3.method3()'
// public partial class Foo : IBase3
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IBase3").WithArguments("Foo", "IBase3.method3()").WithLocation(9, 28)
);
}
[WorkItem(541466, "DevDiv")]
[Fact]
public void UseSiteErrorViaAliasTest04()
......
......@@ -167,10 +167,10 @@ class C : CSharpErrors.InterfaceMethods
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceMethods.ParameterType1(UnavailableClass)'
// class C : CSharpErrors.InterfaceMethods
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType1(UnavailableClass)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceMethods").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType1(UnavailableClass)"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceMethods.ParameterType2(UnavailableClass[])'
// class C : CSharpErrors.InterfaceMethods
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType2(UnavailableClass[])"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceMethods").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType2(UnavailableClass[])"));
}
[Fact]
......@@ -244,16 +244,16 @@ class C : CSharpErrors.InterfaceMethods
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceMethods.ReturnType1()'
// class C : CSharpErrors.InterfaceMethods
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceMethods.ReturnType1()"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceMethods").WithArguments("C", "CSharpErrors.InterfaceMethods.ReturnType1()"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceMethods.ReturnType2()'
// class C : CSharpErrors.InterfaceMethods
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceMethods.ReturnType2()"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceMethods").WithArguments("C", "CSharpErrors.InterfaceMethods.ReturnType2()"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceMethods.ParameterType1(UnavailableClass)'
// class C : CSharpErrors.InterfaceMethods
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType1(UnavailableClass)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceMethods").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType1(UnavailableClass)"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceMethods.ParameterType2(UnavailableClass[])'
// class C : CSharpErrors.InterfaceMethods
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType2(UnavailableClass[])"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceMethods").WithArguments("C", "CSharpErrors.InterfaceMethods.ParameterType2(UnavailableClass[])"));
}
[Fact]
......@@ -559,22 +559,22 @@ class C : CSharpErrors.InterfaceProperties
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceProperties.GetSet1'
// class C : CSharpErrors.InterfaceProperties
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceProperties.GetSet1"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceProperties").WithArguments("C", "CSharpErrors.InterfaceProperties.GetSet1"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceProperties.GetSet2'
// class C : CSharpErrors.InterfaceProperties
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceProperties.GetSet2"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceProperties").WithArguments("C", "CSharpErrors.InterfaceProperties.GetSet2"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceProperties.Get1'
// class C : CSharpErrors.InterfaceProperties
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceProperties.Get1"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceProperties").WithArguments("C", "CSharpErrors.InterfaceProperties.Get1"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceProperties.Get2'
// class C : CSharpErrors.InterfaceProperties
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceProperties.Get2"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceProperties").WithArguments("C", "CSharpErrors.InterfaceProperties.Get2"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceProperties.Set1'
// class C : CSharpErrors.InterfaceProperties
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceProperties.Set1"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceProperties").WithArguments("C", "CSharpErrors.InterfaceProperties.Set1"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceProperties.Set2'
// class C : CSharpErrors.InterfaceProperties
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceProperties.Set2"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceProperties").WithArguments("C", "CSharpErrors.InterfaceProperties.Set2"));
}
[Fact]
......@@ -927,16 +927,15 @@ class C : CSharpErrors.InterfaceEvents
// (6,87): error CS0539: 'C.Event3' in explicit interface declaration is not a member of interface
// event CSharpErrors.EventDelegate<UnavailableClass[]> CSharpErrors.InterfaceEvents.Event3 { add { } remove { } }
Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "Event3").WithArguments("C.Event3"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceEvents.Event1'
// (2,11): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceEvents.Event3'
// class C : CSharpErrors.InterfaceEvents
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceEvents.Event1"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceEvents.Event2'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceEvents").WithArguments("C", "CSharpErrors.InterfaceEvents.Event3"),
// (2,11): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceEvents.Event1'
// class C : CSharpErrors.InterfaceEvents
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceEvents.Event2"),
// (2,7): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceEvents.Event3'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceEvents").WithArguments("C", "CSharpErrors.InterfaceEvents.Event1"),
// (2,11): error CS0535: 'C' does not implement interface member 'CSharpErrors.InterfaceEvents.Event2'
// class C : CSharpErrors.InterfaceEvents
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "CSharpErrors.InterfaceEvents.Event3"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CSharpErrors.InterfaceEvents").WithArguments("C", "CSharpErrors.InterfaceEvents.Event2"));
}
[Fact]
......@@ -1279,10 +1278,10 @@ class B : ILErrors.ModReqClassEventsNonVirtual, ILErrors.ModReqInterfaceEvents {
Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "B").WithArguments("B", "ILErrors.ModReqInterfaceEvents.Event1", "ILErrors.ModReqClassEventsNonVirtual.Event1", "?"),
// (2,7): error CS0535: 'B' does not implement interface member 'ILErrors.ModReqInterfaceEvents.remove_Event1(?)'
// class B : ILErrors.ModReqClassEventsNonVirtual, ILErrors.ModReqInterfaceEvents { }
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "B").WithArguments("B", "ILErrors.ModReqInterfaceEvents.remove_Event1(?)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "ILErrors.ModReqInterfaceEvents").WithArguments("B", "ILErrors.ModReqInterfaceEvents.remove_Event1(?)"),
// (2,7): error CS0535: 'B' does not implement interface member 'ILErrors.ModReqInterfaceEvents.add_Event1(?)'
// class B : ILErrors.ModReqClassEventsNonVirtual, ILErrors.ModReqInterfaceEvents { }
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "B").WithArguments("B", "ILErrors.ModReqInterfaceEvents.add_Event1(?)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "ILErrors.ModReqInterfaceEvents").WithArguments("B", "ILErrors.ModReqInterfaceEvents.add_Event1(?)"));
}
[Fact]
......
......@@ -519,7 +519,7 @@ class Derived : Base, I //CS0535
compilation.VerifyDiagnostics(
// (12,7): error CS0535: 'Derived' does not implement interface member 'I.P.set'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Derived").WithArguments("Derived", "I.P.set"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("Derived", "I.P.set"));
var global = compilation.GlobalNamespace;
......
......@@ -536,9 +536,9 @@ class C : I<string>
}";
CreateCompilationWithMscorlib(source).VerifyDiagnostics(
// (7,20): error CS0539: 'C.M2<U>()' in explicit interface declaration is not a member of interface
Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "M2").WithArguments("C.M2<U>()").WithLocation(7, 20),
// (5,7): error CS0535: 'C' does not implement interface member 'I<string>.M1<U>()'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "I<string>.M1<U>()").WithLocation(5, 7));
Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "M2").WithArguments("C.M2<U>()"),
// (5,11): error CS0535: 'C' does not implement interface member 'I<string>.M1<U>()'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I<string>").WithArguments("C", "I<string>.M1<U>()"));
}
/// <summary>
......@@ -2011,13 +2011,13 @@ class B4 : A4, I { }
class B5 : A5, I { }";
CreateCompilationWithCustomILSource(csharpSource, ilSource).VerifyDiagnostics(
// (2,7): error CS0425: The constraints for type parameter 'T' of method 'A2.M<T>()' must match the constraints for type parameter 'T' of interface method 'I.M<T>()'. Consider using an explicit interface implementation instead.
Diagnostic(ErrorCode.ERR_ImplBadConstraints, "B2").WithArguments("T", "A2.M<T>()", "T", "I.M<T>()").WithLocation(2, 7),
Diagnostic(ErrorCode.ERR_ImplBadConstraints, "B2").WithArguments("T", "A2.M<T>()", "T", "I.M<T>()"),
// (3,7): error CS0425: The constraints for type parameter 'T' of method 'A3.M<T>()' must match the constraints for type parameter 'T' of interface method 'I.M<T>()'. Consider using an explicit interface implementation instead.
Diagnostic(ErrorCode.ERR_ImplBadConstraints, "B3").WithArguments("T", "A3.M<T>()", "T", "I.M<T>()").WithLocation(3, 7),
Diagnostic(ErrorCode.ERR_ImplBadConstraints, "B3").WithArguments("T", "A3.M<T>()", "T", "I.M<T>()"),
// (4,7): error CS0425: The constraints for type parameter 'T' of method 'A4.M<T>()' must match the constraints for type parameter 'T' of interface method 'I.M<T>()'. Consider using an explicit interface implementation instead.
Diagnostic(ErrorCode.ERR_ImplBadConstraints, "B4").WithArguments("T", "A4.M<T>()", "T", "I.M<T>()").WithLocation(4, 7),
Diagnostic(ErrorCode.ERR_ImplBadConstraints, "B4").WithArguments("T", "A4.M<T>()", "T", "I.M<T>()"),
// (5,7): error CS0535: 'B5' does not implement interface member 'I.M<T>()'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "B5").WithArguments("B5", "I.M<T>()").WithLocation(5, 7));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I").WithArguments("B5", "I.M<T>()"));
}
/// <summary>
......
......@@ -2503,7 +2503,7 @@ class D : CodeModule
comp.VerifyDiagnostics(
// (4,7): error CS0535: 'C' does not implement interface member 'Microsoft.Vbe.Interop._CodeModule.ProcOfLine[int, out Microsoft.Vbe.Interop.vbext_ProcKind].get'
// class C : CodeModule
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "Microsoft.Vbe.Interop._CodeModule.ProcOfLine[int, out Microsoft.Vbe.Interop.vbext_ProcKind].get"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "CodeModule").WithArguments("C", "Microsoft.Vbe.Interop._CodeModule.ProcOfLine[int, out Microsoft.Vbe.Interop.vbext_ProcKind].get"));
var interfaceProperty = comp.GlobalNamespace
.GetMember<NamespaceSymbol>("Microsoft")
......
// 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.
// 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;
......@@ -536,7 +536,7 @@ class C : I1
// (4,12): warning CS0473: Explicit interface implementation 'C.I1.this[int]' matches more than one interface member. Which interface member is actually chosen is implementation-dependent. Consider using a non-explicit implementation instead.
Diagnostic(ErrorCode.WRN_ExplicitImplCollision, "this").WithArguments("C.I1.this[int]"),
// (2,7): error CS0535: 'C' does not implement interface member 'I1.this[int]'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "I1.this[int]"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("C", "I1.this[int]"));
var @interface = compilation.GlobalNamespace.GetMember<NamedTypeSymbol>("I1");
var interfaceIndexers = @interface.Indexers;
......@@ -1371,9 +1371,9 @@ class Test : IRefIndexer
// Normally, we wouldn't see errors for the accessors, but here we do because the indexer is bogus.
compilation.VerifyDiagnostics(
// (2,7): error CS0535: 'Test' does not implement interface member 'IRefIndexer.get_Item(ref int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Test").WithArguments("Test", "IRefIndexer.get_Item(ref int)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IRefIndexer").WithArguments("Test", "IRefIndexer.get_Item(ref int)"),
// (2,7): error CS0535: 'Test' does not implement interface member 'IRefIndexer.set_Item(ref int, int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Test").WithArguments("Test", "IRefIndexer.set_Item(ref int, int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IRefIndexer").WithArguments("Test", "IRefIndexer.set_Item(ref int, int)"));
}
/// <summary>
......@@ -1395,9 +1395,9 @@ class Test : IRefIndexer
// (4,21): error CS0539: 'Test.this[int]' in explicit interface declaration is not a member of interface
Diagnostic(ErrorCode.ERR_InterfaceMemberNotFound, "this").WithArguments("Test.this[int]"),
// (2,7): error CS0535: 'Test' does not implement interface member 'IRefIndexer.get_Item(ref int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Test").WithArguments("Test", "IRefIndexer.get_Item(ref int)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IRefIndexer").WithArguments("Test", "IRefIndexer.get_Item(ref int)"),
// (2,7): error CS0535: 'Test' does not implement interface member 'IRefIndexer.set_Item(ref int, int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Test").WithArguments("Test", "IRefIndexer.set_Item(ref int, int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IRefIndexer").WithArguments("Test", "IRefIndexer.set_Item(ref int, int)"));
}
[Fact]
......
......@@ -1213,7 +1213,7 @@ static void Main()
var comp = CreateCompilationWithMscorlib(csharp);
comp.VerifyDiagnostics(
// (15,7): error CS0535: 'Derived' does not implement interface member 'Interface.M(ref int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Derived").WithArguments("Derived", "Interface.M(ref int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Derived", "Interface.M(ref int)"));
var global = comp.GlobalNamespace;
Assert.Null(global.GetMember<NamedTypeSymbol>("Derived").FindImplementationForInterfaceMember(
global.GetMember<NamedTypeSymbol>("Interface").GetMember<MethodSymbol>("M")));
......@@ -1284,7 +1284,7 @@ .maxstack 8
var comp = CreateCompilationWithCustomILSource(csharp, il);
comp.VerifyDiagnostics(
// (7,7): error CS0535: 'Derived' does not implement interface member 'Interface.M(ref int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Derived").WithArguments("Derived", "Interface.M(ref int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Derived", "Interface.M(ref int)"));
var global = comp.GlobalNamespace;
Assert.Null(global.GetMember<NamedTypeSymbol>("Derived").FindImplementationForInterfaceMember(
global.GetMember<NamedTypeSymbol>("Interface").GetMember<MethodSymbol>("M")));
......@@ -1340,7 +1340,7 @@ static void Main()
var comp = CreateCompilationWithCustomILSource(csharp, il);
comp.VerifyDiagnostics(
// (10,7): error CS0535: 'Derived' does not implement interface member 'Interface.M(ref int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Derived").WithArguments("Derived", "Interface.M(ref int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Derived", "Interface.M(ref int)"));
var global = comp.GlobalNamespace;
Assert.Null(global.GetMember<NamedTypeSymbol>("Derived").FindImplementationForInterfaceMember(
global.GetMember<NamedTypeSymbol>("Interface").GetMember<MethodSymbol>("M")));
......@@ -1415,7 +1415,7 @@ .maxstack 8
var comp = CreateCompilationWithCustomILSource(csharp, il);
comp.VerifyDiagnostics(
// (2,7): error CS0535: 'Derived' does not implement interface member 'Interface.M(ref int)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Derived").WithArguments("Derived", "Interface.M(ref int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Derived", "Interface.M(ref int)"));
var global = comp.GlobalNamespace;
Assert.Null(global.GetMember<NamedTypeSymbol>("Derived").FindImplementationForInterfaceMember(
global.GetMember<NamedTypeSymbol>("Interface").GetMember<MethodSymbol>("M")));
......@@ -1558,7 +1558,7 @@ class C1 : I1
}
";
CreateCompilationWithMscorlib(text).VerifyDiagnostics(
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C1").WithArguments("C1", "I1.Foo(out int)"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("C1", "I1.Foo(out int)"));
}
[Fact]
......@@ -2108,10 +2108,10 @@ class Derived2 : Base2, Interface
CreateCompilationWithMscorlib(source, new[] { ilRef }).VerifyDiagnostics(
// (6,7): error CS0535: 'Base2' does not implement interface member 'Interface.M()'
// class Base2 : Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Base2").WithArguments("Base2", "Interface.M()"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Base2", "Interface.M()"),
// (10,7): error CS0535: 'Derived2' does not implement interface member 'Interface.M()'
// class Derived2 : Base2, Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Derived2").WithArguments("Derived2", "Interface.M()"));
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Derived2", "Interface.M()"));
}
[WorkItem(718115, "DevDiv")]
......
......@@ -569,10 +569,10 @@ class Explicit : Interface
comp.VerifyDiagnostics(
// (2,7): error CS0535: 'Empty' does not implement interface member 'Interface.SetterIsGap'
// class Empty : Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Empty").WithArguments("Empty", "Interface.SetterIsGap"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Empty", "Interface.SetterIsGap"),
// (2,7): error CS0535: 'Empty' does not implement interface member 'Interface.GetterIsGap'
// class Empty : Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Empty").WithArguments("Empty", "Interface.GetterIsGap"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("Empty", "Interface.GetterIsGap"),
// (17,33): error CS0550: 'Explicit.Interface.GetterIsGap.get' adds an accessor not found in interface member 'Interface.GetterIsGap'
// int Interface.GetterIsGap { get; set; }
Diagnostic(ErrorCode.ERR_ExplicitPropertyAddingAccessor, "get").WithArguments("Explicit.Interface.GetterIsGap.get", "Interface.GetterIsGap"),
......
......@@ -606,13 +606,13 @@ class E : Interface
CreateCompilationWithCustomILSource(csharpSource, ilSource).VerifyDiagnostics(
// (2,7): error CS0535: 'C' does not implement interface member 'Interface.raise_e(object, object)'
// class C : Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "Interface.raise_e(object, object)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("C", "Interface.raise_e(object, object)"),
// (2,7): error CS0535: 'C' does not implement interface member 'Interface.e'
// class C : Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "C").WithArguments("C", "Interface.e"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("C", "Interface.e"),
// (7,7): error CS0535: 'D' does not implement interface member 'Interface.raise_e(object, object)'
// class D : Interface
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "D").WithArguments("D", "Interface.raise_e(object, object)"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "Interface").WithArguments("D", "Interface.raise_e(object, object)"),
// (15,32): warning CS0067: The event 'E.e' is never used
// public event System.Action e;
......
......@@ -7456,7 +7456,7 @@ class MyClass : I
}
";
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription { Code = (int)ErrorCode.ERR_UnimplementedInterfaceMember, Line = 6, Column = 7 }, //Dev10 doesn't include this
new ErrorDescription { Code = (int)ErrorCode.ERR_UnimplementedInterfaceMember, Line = 6, Column = 17 }, //Dev10 doesn't include this
new ErrorDescription { Code = (int)ErrorCode.ERR_MethodImplementingAccessor, Line = 8, Column = 16 });
}
......@@ -8913,7 +8913,7 @@ public void CS0535ERR_UnimplementedInterfaceMember()
public class B : A { } // CS0535 A::F is not implemented
";
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription { Code = (int)ErrorCode.ERR_UnimplementedInterfaceMember, Line = 6, Column = 14 });
new ErrorDescription { Code = (int)ErrorCode.ERR_UnimplementedInterfaceMember, Line = 6, Column = 18 });
}
[Fact]
......@@ -9737,7 +9737,7 @@ public static void Main()
}
";
var comp = DiagnosticsUtils.VerifyErrorsAndGetCompilationWithMscorlib(text,
new ErrorDescription { Code = (int)ErrorCode.ERR_UnimplementedInterfaceMember, Line = 10, Column = 14 }, //CONSIDER: dev10 suppresses this
new ErrorDescription { Code = (int)ErrorCode.ERR_UnimplementedInterfaceMember, Line = 10, Column = 18 }, //CONSIDER: dev10 suppresses this
new ErrorDescription { Code = (int)ErrorCode.ERR_ExplicitPropertyMissingAccessor, Line = 12, Column = 12 });
}
......@@ -11442,16 +11442,11 @@ struct SFoo : IFoo<Void>
}
}";
CreateCompilationWithMscorlib(source).VerifyDiagnostics(
// (14,28): error CS0673: System.Void cannot be used from C# -- use typeof(void) to get the void type object
Diagnostic(ErrorCode.ERR_SystemVoid, "Void").WithLocation(14, 28),
// (7,9): error CS0673: System.Void cannot be used from C# -- use typeof(void) to get the void type object
Diagnostic(ErrorCode.ERR_SystemVoid, "Void").WithLocation(7, 9),
// (12,16): error CS0673: System.Void cannot be used from C# -- use typeof(void) to get the void type object
Diagnostic(ErrorCode.ERR_SystemVoid, "Void").WithLocation(12, 16),
// (14,16): error CS0535: 'NS.Foo.SFoo' does not implement interface member 'NS.IFoo<System.Void>.M(System.Void)'
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "SFoo").WithArguments("NS.Foo.SFoo", "NS.IFoo<System.Void>.M(System.Void)").WithLocation(14, 16),
// (12,21): warning CS0626: Method, operator, or accessor 'NS.Foo.GetVoid()' is marked external and has no attributes on it. Consider adding a DllImport attribute to specify the external implementation.
Diagnostic(ErrorCode.WRN_ExternMethodNoImplementation, "GetVoid").WithArguments("NS.Foo.GetVoid()").WithLocation(12, 21));
Diagnostic(ErrorCode.ERR_SystemVoid, "Void"),
Diagnostic(ErrorCode.ERR_SystemVoid, "Void"),
Diagnostic(ErrorCode.ERR_SystemVoid, "Void"),
Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "IFoo<Void>").WithArguments("NS.Foo.SFoo", "NS.IFoo<System.Void>.M(System.Void)"),
Diagnostic(ErrorCode.WRN_ExternMethodNoImplementation, "GetVoid").WithArguments("NS.Foo.GetVoid()")) ;
}
[Fact]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册