diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx
index 32905cab47ea7..a2eb1092665ce 100644
--- a/src/Compilers/CSharp/Portable/CSharpResources.resx
+++ b/src/Compilers/CSharp/Portable/CSharpResources.resx
@@ -6077,7 +6077,7 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
The modifier '{0}' is not valid for this item in C# {1}. Please use language version '{2}' or greater.
- '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member.
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
Interface member '{0}' does not have a most specific implementation. Neither '{1}', nor '{2}' are most specific.
diff --git a/src/Compilers/CSharp/Portable/Errors/MessageID.cs b/src/Compilers/CSharp/Portable/Errors/MessageID.cs
index 6523f5d3323aa..50a2a6dc96cda 100644
--- a/src/Compilers/CSharp/Portable/Errors/MessageID.cs
+++ b/src/Compilers/CSharp/Portable/Errors/MessageID.cs
@@ -228,6 +228,7 @@ internal enum MessageID
IDS_FeatureStaticAbstractMembersInInterfaces = MessageBase + 12803,
IDS_FeatureLambdaReturnType = MessageBase + 12804,
IDS_AsyncMethodBuilderOverride = MessageBase + 12805,
+ IDS_FeatureImplicitImplementationOfNonPublicMemebers = MessageBase + 12806,
}
// Message IDs may refer to strings that need to be localized.
@@ -352,6 +353,7 @@ internal static LanguageVersion RequiredVersion(this MessageID feature)
case MessageID.IDS_FeatureLambdaReturnType: // semantic check
case MessageID.IDS_AsyncMethodBuilderOverride: // semantic check
case MessageID.IDS_FeatureConstantInterpolatedStrings: // semantic check
+ case MessageID.IDS_FeatureImplicitImplementationOfNonPublicMemebers: // semantic check
return LanguageVersion.CSharp10;
// C# 9.0 features.
diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol_ImplementationChecks.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol_ImplementationChecks.cs
index 7c3097ae45a3c..dbad9f95ff24b 100644
--- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol_ImplementationChecks.cs
+++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceMemberContainerSymbol_ImplementationChecks.cs
@@ -1588,18 +1588,9 @@ private void CheckInterfaceUnification(BindingDiagnosticBag diagnostics)
private (SynthesizedExplicitImplementationForwardingMethod? ForwardingMethod, (MethodSymbol Body, MethodSymbol Implemented)? MethodImpl)
SynthesizeInterfaceMemberImplementation(SymbolAndDiagnostics implementingMemberAndDiagnostics, Symbol interfaceMember)
{
- if (interfaceMember.DeclaredAccessibility != Accessibility.Public)
- {
- // Non-public interface members cannot be implemented implicitly,
- // appropriate errors are reported elsewhere. Let's not synthesize
- // forwarding methods, or modify metadata virtualness of the
- // implementing methods.
- return default;
- }
-
foreach (Diagnostic diagnostic in implementingMemberAndDiagnostics.Diagnostics.Diagnostics)
{
- if (diagnostic.Severity == DiagnosticSeverity.Error)
+ if (diagnostic.Severity == DiagnosticSeverity.Error && diagnostic.Code is not (int)ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember)
{
return default;
}
@@ -1616,15 +1607,6 @@ private void CheckInterfaceUnification(BindingDiagnosticBag diagnostics)
MethodSymbol interfaceMethod = (MethodSymbol)interfaceMember;
MethodSymbol implementingMethod = (MethodSymbol)implementingMember;
- // Interface properties/events with non-public accessors cannot be implemented implicitly,
- // appropriate errors are reported elsewhere. Let's not synthesize
- // forwarding methods, or modify metadata virtualness of the
- // implementing accessors, even for public ones.
- if (interfaceMethod.AssociatedSymbol?.IsEventOrPropertyWithImplementableNonPublicAccessor() == true)
- {
- return default;
- }
-
//explicit implementations are always respected by the CLR
if (implementingMethod.ExplicitInterfaceImplementations.Contains(interfaceMethod, ExplicitInterfaceImplementationTargetMemberEqualityComparer.Instance))
{
diff --git a/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
index 06d225496c753..755781e851806 100644
--- a/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
+++ b/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs
@@ -834,7 +834,7 @@ private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMe
Symbol implicitImpl = null;
Symbol closestMismatch = null;
- bool canBeImplementedImplicitly = interfaceMember.DeclaredAccessibility == Accessibility.Public && !interfaceMember.IsEventOrPropertyWithImplementableNonPublicAccessor();
+ bool canBeImplementedImplicitlyInCSharp9 = interfaceMember.DeclaredAccessibility == Accessibility.Public && !interfaceMember.IsEventOrPropertyWithImplementableNonPublicAccessor();
TypeSymbol implementingBaseOpt = null; // Calculated only if canBeImplementedImplicitly == false
bool implementingTypeImplementsInterface = false;
CSharpCompilation compilation = implementingType.DeclaringCompilation;
@@ -891,7 +891,7 @@ private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMe
}
if (!seenTypeDeclaringInterface ||
- (!canBeImplementedImplicitly && (object)implementingBaseOpt == null))
+ (!canBeImplementedImplicitlyInCSharp9 && (object)implementingBaseOpt == null))
{
if (currType.InterfacesAndTheirBaseInterfacesWithDefinitionUseSiteDiagnostics(ref useSiteInfo).ContainsKey(interfaceType))
{
@@ -905,7 +905,7 @@ private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMe
{
implementingTypeImplementsInterface = true;
}
- else if (!canBeImplementedImplicitly && (object)implementingBaseOpt == null)
+ else if (!canBeImplementedImplicitlyInCSharp9 && (object)implementingBaseOpt == null)
{
implementingBaseOpt = currType;
}
@@ -941,7 +941,7 @@ private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMe
}
}
- Debug.Assert(!canBeImplementedImplicitly || (object)implementingBaseOpt == null);
+ Debug.Assert(!canBeImplementedImplicitlyInCSharp9 || (object)implementingBaseOpt == null);
bool tryDefaultInterfaceImplementation = !interfaceMember.IsStatic;
@@ -1002,24 +1002,26 @@ private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMe
{
if ((object)implicitImpl != null)
{
- if (!canBeImplementedImplicitly)
+ if (!canBeImplementedImplicitlyInCSharp9)
{
if (interfaceMember.Kind == SymbolKind.Method &&
(object)implementingBaseOpt == null) // Otherwise any approprite errors are going to be reported for the base.
{
- diagnostics.Add(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, GetInterfaceLocation(interfaceMember, implementingType),
- implementingType, interfaceMember, implicitImpl);
+ LanguageVersion requiredVersion = MessageID.IDS_FeatureImplicitImplementationOfNonPublicMemebers.RequiredVersion();
+ LanguageVersion? availableVersion = implementingType.DeclaringCompilation?.LanguageVersion;
+ if (requiredVersion > availableVersion)
+ {
+ diagnostics.Add(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, GetInterfaceLocation(interfaceMember, implementingType),
+ implementingType, interfaceMember, implicitImpl,
+ availableVersion.GetValueOrDefault().ToDisplayString(), new CSharpRequiredLanguageVersion(requiredVersion));
+ }
}
}
- else
- {
- ReportImplicitImplementationMatchDiagnostics(interfaceMember, implementingType, implicitImpl, diagnostics);
- }
+
+ ReportImplicitImplementationMatchDiagnostics(interfaceMember, implementingType, implicitImpl, diagnostics);
}
else if ((object)closestMismatch != null)
{
- Debug.Assert(interfaceMember.DeclaredAccessibility == Accessibility.Public);
- Debug.Assert(!interfaceMember.IsEventOrPropertyWithImplementableNonPublicAccessor());
ReportImplicitImplementationMismatchDiagnostics(interfaceMember, implementingType, closestMismatch, diagnostics);
}
}
@@ -2063,11 +2065,7 @@ private static void FindPotentialImplicitImplementationMemberDeclaredInType(
}
// If we haven't found a match, do a weaker comparison that ignores static-ness, accessibility, and return type.
- // But do this only if interface member is public because language doesn't allow implicit implementations for
- // non-public members and, since candidate's signature doesn't match, runtime will never pick it up either.
- else if ((object)closeMismatch == null && implementingTypeIsFromSomeCompilation &&
- interfaceMember.DeclaredAccessibility == Accessibility.Public &&
- !interfaceMember.IsEventOrPropertyWithImplementableNonPublicAccessor())
+ else if ((object)closeMismatch == null && implementingTypeIsFromSomeCompilation)
{
// We can ignore custom modifiers here, because our goal is to improve the helpfulness
// of an error we're already giving, rather than to generate a new error.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
index e148163377fb8..5617d2a2ba02a 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf
@@ -11023,8 +11023,8 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference
-
- {0} neimplementuje člen rozhraní {1}. {2} nemůže implicitně implementovat neveřejný člen rozhraní.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
index fc7e5d90eef93..bda4f0305a61e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf
@@ -11023,8 +11023,8 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett
-
- Der Schnittstellenmember "{1}" wird von "{0}" nicht implementiert. Ein nicht öffentlicher Member kann von "{2}" nicht implizit implementiert werden.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
index 917ffcde8bc17..7c47f1b21ec70 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf
@@ -11023,8 +11023,8 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe
-
- "{0}" no implementa el miembro de interfaz "{1}". "{2}" no puede implementar implícitamente un miembro que no sea público.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
index 7e9a6b6778f73..2c96fd69b2d45 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf
@@ -11023,8 +11023,8 @@ Pour supprimer l'avertissement, vous pouvez utiliser la commande /reference (dé
-
- '{0}' n'implémente pas le membre d'interface '{1}'. '{2}' ne peut pas implémenter implicitement un membre non public.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
index 3d26f3c6693a0..ea692312a6f0e 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf
@@ -11023,8 +11023,8 @@ Per rimuovere l'avviso, è invece possibile usare /reference (impostare la propr
-
- '{0}' non implementa il membro di interfaccia '{1}'. '{2}' non può implementare implicitamente un membro non pubblico.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
index 07fb5e6b6b0a4..278d3cde73a0d 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf
@@ -11023,8 +11023,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
-
- '{0}' は、インターフェイス メンバー '{1}' を実装していません。'{2}' はパブリックでないメンバーを暗黙的に実装できません。
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
index d3c3b9a9433af..973947689b802 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf
@@ -11022,8 +11022,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
-
- '{0}'은(는) 인터페이스 멤버 '{1}'을(를) 구현하지 않습니다. '{2}'은(는) public이 아닌 멤버를 암시적으로 구현할 수 없습니다.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
index 69501f3389fb0..da57baed32ee8 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf
@@ -11023,8 +11023,8 @@ Aby usunąć ostrzeżenie, możesz zamiast tego użyć opcji /reference (ustaw w
-
- Element „{0}” nie implementuje składowej interfejsu „{1}”. Element „{2}” nie może jawnie implementować składowej niepublicznej.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
index 3745be4a141de..68d01997d245c 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf
@@ -11023,8 +11023,8 @@ Para incorporar informações de tipo de interoperabilidade para os dois assembl
-
- '{0}' não implementa o membro de interface '{1}'. '{2}' não pode implementar implicitamente um membro não público.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
index 72aeb7cb55729..90a03dd53b273 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf
@@ -11023,8 +11023,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
-
- "{0}" не реализует член интерфейса "{1}". "{2}" не может неявно реализовать необщедоступный член.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
index 305af8c797c2c..94ff88181d22a 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf
@@ -11023,8 +11023,8 @@ Uyarıyı kaldırmak için, /reference kullanabilirsiniz (Birlikte Çalışma T
-
- '{0}, '{1}' arabirim üyesini uygulamıyor. '{2}' genel olmayan bir üyeyi örtük olarak uygulayamaz.
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
index 42bd67831bc92..96ff457d20ade 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf
@@ -11028,8 +11028,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
-
- “{0}”不实现接口成员“{1}”。“{2}”无法无法隐式实现非公共成员。
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
index 15683780f6906..50dcc6d4e7292 100644
--- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
+++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf
@@ -11023,8 +11023,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ
-
- '{0}' 未實作介面成員 '{1}'。'{2}' 無法隱含地實作非公開成員。
+
+ '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member in C# {3}. Please use language version '{4}' or greater.
diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs
index 9323bd7bc7aaf..9e1bc151e8bfb 100644
--- a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs
+++ b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs
@@ -7247,17 +7247,25 @@ public void M1()
}
";
var compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(
- // (9,15): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (9,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(9, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(9, 15)
);
ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.Internal);
+ compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular10,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.Internal)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.Internal);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -7266,29 +7274,6 @@ public void M1()
ValidateMethodModifiers_10(compilation2.GetTypeByMetadataName("I1").GetMember("M1"), Accessibility.Internal);
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation3.VerifyDiagnostics(
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
- // class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15)
- );
-
- ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Internal);
-
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation4.VerifyDiagnostics(
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
- // class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15)
- );
-
- ValidateMethodModifiersImplicit_10(compilation4.SourceModule, Accessibility.Internal);
var source3 =
@"
@@ -7297,29 +7282,40 @@ class Test2 : I1
}
";
- var compilation5 = CreateCompilation(source3, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation5.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation5.VerifyDiagnostics(
- // (2,15): error CS0535: 'Test2' does not implement interface member 'I1.M1()'
- // class Test2 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test2", "I1.M1()").WithLocation(2, 15)
- );
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation3.VerifyDiagnostics(
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : I1
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15)
+ );
- ValidateI1M1NotImplemented(compilation5, "Test2");
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Internal);
- var compilation6 = CreateCompilation(source3, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular,
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular10,
targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation6.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation6.VerifyDiagnostics(
- // (2,15): error CS0535: 'Test2' does not implement interface member 'I1.M1()'
- // class Test2 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test2", "I1.M1()").WithLocation(2, 15)
- );
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.Internal)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Internal);
+
+ var compilation5 = CreateCompilation(source3, new[] { reference }, options: TestOptions.DebugDll,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation5.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation5.VerifyDiagnostics(
+ // (2,15): error CS0535: 'Test2' does not implement interface member 'I1.M1()'
+ // class Test2 : I1
+ Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test2", "I1.M1()").WithLocation(2, 15)
+ );
- ValidateI1M1NotImplemented(compilation6, "Test2");
+ ValidateI1M1NotImplemented(compilation5, "Test2");
+ }
}
private static void ValidateI1M1NotImplemented(CSharpCompilation compilation, string className)
@@ -7361,11 +7357,7 @@ private static void ValidateMethodModifiers_10(ModuleSymbol m, bool implementedB
Assert.NotNull(implementation);
Assert.Same(implementation, test1.FindImplementationForInterfaceMember(m1));
- var i2 = test1.InterfacesNoUseSiteDiagnostics().Where(i => i.Name == "I2").SingleOrDefault();
- Assert.Equal(implementation.IsVirtual || implementation.IsAbstract || isExplicit ||
- (!implementedByBase && (object)i2 != null &&
- (object)implementation == test1.FindImplementationForInterfaceMember(i2.GetMember("M1"))),
- implementation.IsMetadataVirtual());
+ Assert.True(implementation.IsMetadataVirtual());
}
private static void ValidateMethodModifiers_10(MethodSymbol m1, Accessibility accessibility)
@@ -7408,27 +7400,34 @@ static void Main()
public virtual void M1()
{
- System.Console.WriteLine(""M1"");
+ System.Console.WriteLine(""Test1.M1"");
}
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15)
);
}
private void ValidateMethodModifiers_10_02(string source1, string source2,
Accessibility accessibility,
- params DiagnosticDescription[] expected)
+ params DiagnosticDescription[] expectedIn9)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation1.VerifyDiagnostics(expected);
+ compilation1.VerifyDiagnostics(expectedIn9);
+
+ ValidateMethodModifiersImplicit_10(compilation1.SourceModule, accessibility);
+
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "Test1.M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, accessibility)).VerifyDiagnostics();
ValidateMethodModifiersImplicit_10(compilation1.SourceModule, accessibility);
@@ -7440,21 +7439,23 @@ private void ValidateMethodModifiers_10_02(string source1, string source2,
ValidateMethodModifiers_10(compilation2.GetTypeByMetadataName("I1").GetMember("M1"), accessibility);
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation3.VerifyDiagnostics(expected);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation3.VerifyDiagnostics(expectedIn9);
- ValidateMethodModifiersImplicit_10(compilation3.SourceModule, accessibility);
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, accessibility);
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation4.VerifyDiagnostics(expected);
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "Test1.M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, accessibility)).VerifyDiagnostics();
- ValidateMethodModifiersImplicit_10(compilation4.SourceModule, accessibility);
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, accessibility);
+ }
}
[Fact]
@@ -7565,9 +7566,9 @@ public void M1()
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -7611,9 +7612,9 @@ public virtual void M1()
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -7657,14 +7658,14 @@ class Test3 : Test1
{
public override void M1()
{
- System.Console.WriteLine(""Test3.M1"");
+ System.Console.WriteLine(""Test1.M1"");
}
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -7713,9 +7714,9 @@ public interface I2
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -7823,9 +7824,9 @@ public virtual int M1()
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(
- // (9,15): error CS0535: 'Test1' does not implement interface member 'I1.M1()'
+ // (9,15): error CS0738: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implement 'I1.M1()' because it does not have the matching return type of 'void'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.M1()").WithLocation(9, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "void").WithLocation(9, 15)
);
ValidateI1M1NotImplemented(compilation1, "Test1");
@@ -7843,9 +7844,9 @@ public virtual int M1()
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation3.VerifyDiagnostics(
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.M1()'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implement 'I1.M1()' because it does not have the matching return type of 'void'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.M1()").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "void").WithLocation(2, 15)
);
ValidateI1M1NotImplemented(compilation3, "Test1");
@@ -7855,9 +7856,9 @@ public virtual int M1()
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation4.VerifyDiagnostics(
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.M1()'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implement 'I1.M1()' because it does not have the matching return type of 'void'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.M1()").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "void").WithLocation(2, 15)
);
ValidateI1M1NotImplemented(compilation4, "Test1");
@@ -7871,6 +7872,8 @@ public void MethodModifiers_10_10()
public interface I1
{
internal abstract void M1();
+
+ void M2() {M1();}
}
";
@@ -7886,47 +7889,63 @@ public void M1()
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.M2();
+ }
}
";
- var compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ var compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
compilation1.VerifyDiagnostics(
- // (7,15): error CS8504: 'Test2' does not implement interface member 'I1.M1()'. 'Test2.M1()' cannot implicitly implement a non-public member.
+ // (9,15): error CS8704: 'Test2' does not implement interface member 'I1.M1()'. 'Test2.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()").WithLocation(7, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()", "9.0", "10.0").WithLocation(9, 15)
);
ValidateMethodModifiersImplicitInTest2_10(compilation1.SourceModule, Accessibility.Internal);
+ compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicitInTest2_10(compilation1.SourceModule, Accessibility.Internal);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
compilation2.VerifyDiagnostics();
ValidateMethodModifiers_10(compilation2.GetTypeByMetadataName("I1").GetMember("M1"), Accessibility.Internal);
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation3.VerifyDiagnostics(
- // (2,15): error CS8504: 'Test2' does not implement interface member 'I1.M1()'. 'Test2.M1()' cannot implicitly implement a non-public member.
- // class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()")
- );
+ compilation3.VerifyDiagnostics(
+ // (2,15): error CS8704: 'Test2' does not implement interface member 'I1.M1()'. 'Test2.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test2 : I1
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()", "9.0", "10.0").WithLocation(2, 15)
+ );
- ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal);
+ ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal);
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation4.VerifyDiagnostics(
- // (2,15): error CS8504: 'Test2' does not implement interface member 'I1.M1()'. 'Test2.M1()' cannot implicitly implement a non-public member.
- // class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()")
- );
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics();
- ValidateMethodModifiersImplicitInTest2_10(compilation4.SourceModule, Accessibility.Internal);
+ ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal);
+ }
}
[Fact]
@@ -7937,6 +7956,8 @@ public void MethodModifiers_10_11()
public interface I1
{
internal abstract void M1();
+
+ void M2() {M1();}
}
public class Test2 : I1
@@ -7952,30 +7973,35 @@ public void M1()
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.M2();
+ }
}
";
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp,
assemblyName: "MethodModifiers_10_11");
- compilation2.VerifyDiagnostics(
- // (7,22): error CS8504: 'Test2' does not implement interface member 'I1.M1()'. 'Test2.M1()' cannot implicitly implement a non-public member.
- // public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()").WithLocation(7, 22)
- );
+ compilation2.VerifyDiagnostics();
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation3.VerifyDiagnostics();
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics();
ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal);
- var compilation3Ref = compilation3.EmitToImageReference();
- var compilation4 = CreateCompilation("", new[] { compilation2.ToMetadataReference(), compilation3Ref }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
- ValidateMethodModifiersImplicitInTest2_10(compilation4.GetReferencedAssemblySymbol(compilation3Ref).Modules[0], Accessibility.Internal);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal);
}
[Fact]
@@ -9738,10 +9764,11 @@ public void MethodModifiers_34()
public interface I1
{
protected abstract void M1();
+ public void M2() => M1();
}
";
- var source2 =
+ var source21 =
@"
class Test1 : I1
{
@@ -9757,15 +9784,15 @@ public void M1()
}
}
";
- var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ var compilation1 = CreateCompilation(source21 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
var expected = new DiagnosticDescription[] {
- // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15),
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15),
// (7,11): error CS1540: Cannot access protected member 'I1.M1()' via a qualifier of type 'I1'; the qualifier must be of type 'Test1' (or derived from it)
// x.M1();
Diagnostic(ErrorCode.ERR_BadProtectedAccess, "M1").WithArguments("I1.M1()", "I1", "Test1").WithLocation(7, 11)
@@ -9775,6 +9802,32 @@ public void M1()
ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.Protected);
+ var source22 =
+@"
+class Test1 : I1
+{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.M2();
+ }
+
+ public void M1()
+ {
+ System.Console.WriteLine(""M1"");
+ }
+}
+";
+ compilation1 = CreateCompilation(source22 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.Protected)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.Protected);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -9793,14 +9846,22 @@ class Test2 : I1
foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
{
- var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ var compilation3 = CreateCompilation(source21, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation3.VerifyDiagnostics(expected);
ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Protected);
+ compilation3 = CreateCompilation(source22, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.Protected)).VerifyDiagnostics();
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Protected);
+
var compilation5 = CreateCompilation(source3, new[] { reference }, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -9823,10 +9884,11 @@ public void MethodModifiers_35()
public interface I1
{
protected internal abstract void M1();
+ public void M2() => M1();
}
";
- var source2 =
+ var source21 =
@"
class Test1 : I1
{
@@ -9842,19 +9904,46 @@ public virtual void M1()
}
}
";
- var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+
+ var source22 =
+@"
+class Test1 : I1
+{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.M2();
+ }
+
+ public virtual void M1()
+ {
+ System.Console.WriteLine(""M1"");
+ }
+}
+";
+
+ var compilation1 = CreateCompilation(source21 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(
- // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15)
);
ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.ProtectedOrInternal);
+ compilation1 = CreateCompilation(source21 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.ProtectedOrInternal)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.ProtectedOrInternal);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -9873,14 +9962,14 @@ class Test2 : I1
foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
{
- var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ var compilation3 = CreateCompilation(source21, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation3.VerifyDiagnostics(
- // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15),
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15),
// (7,11): error CS1540: Cannot access protected member 'I1.M1()' via a qualifier of type 'I1'; the qualifier must be of type 'Test1' (or derived from it)
// x.M1();
Diagnostic(ErrorCode.ERR_BadProtectedAccess, "M1").WithArguments("I1.M1()", "I1", "Test1").WithLocation(7, 11)
@@ -9888,6 +9977,13 @@ class Test2 : I1
ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.ProtectedOrInternal);
+ compilation3 = CreateCompilation(source22, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.ProtectedOrInternal)).VerifyDiagnostics();
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.ProtectedOrInternal);
+
var compilation5 = CreateCompilation(source3, new[] { reference }, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -9910,10 +10006,11 @@ public void MethodModifiers_36()
public interface I1
{
private protected abstract void M1();
+ public void M2() => M1();
}
";
- var source2 =
+ var source21 =
@"
class Test1 : I1
{
@@ -9929,15 +10026,32 @@ public void M1()
}
}
";
- var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+
+ var source22 =
+@"
+class Test1 : I1
+{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.M2();
+ }
+
+ public void M1()
+ {
+ System.Console.WriteLine(""M1"");
+ }
+}
+";
+ var compilation1 = CreateCompilation(source21 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(
- // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15),
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15),
// (7,11): error CS1540: Cannot access protected member 'I1.M1()' via a qualifier of type 'I1'; the qualifier must be of type 'Test1' (or derived from it)
// x.M1();
Diagnostic(ErrorCode.ERR_BadProtectedAccess, "M1").WithArguments("I1.M1()", "I1", "Test1").WithLocation(7, 11)
@@ -9945,6 +10059,15 @@ public void M1()
ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.ProtectedAndInternal);
+ compilation1 = CreateCompilation(source22 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.ProtectedAndInternal)).VerifyDiagnostics();
+
+ ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.ProtectedAndInternal);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -9963,14 +10086,14 @@ class Test2 : I1
foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
{
- var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ var compilation3 = CreateCompilation(source21, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation3.VerifyDiagnostics(
- // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 15),
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15),
// (7,11): error CS0122: 'I1.M1()' is inaccessible due to its protection level
// x.M1();
Diagnostic(ErrorCode.ERR_BadAccess, "M1").WithArguments("I1.M1()").WithLocation(7, 11)
@@ -9978,6 +10101,14 @@ class Test2 : I1
ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.ProtectedAndInternal);
+ compilation3 = CreateCompilation(source22, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.ProtectedAndInternal)).VerifyDiagnostics();
+ ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.ProtectedAndInternal);
+
var compilation5 = CreateCompilation(source3, new[] { reference }, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -10185,6 +10316,7 @@ public void MethodModifiers_40()
public interface I1
{
protected abstract void M1();
+ public void M2() => M1();
}
public class Test2 : I1
@@ -10201,17 +10333,20 @@ class Test1 : Test2, I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public void M1()
{
+ System.Console.WriteLine(""Test1.M1"");
}
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.Protected,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -10223,6 +10358,7 @@ public void MethodModifiers_41()
public interface I1
{
protected internal abstract void M1();
+ public void M2() => M1();
}
public class Test2 : I1
@@ -10239,17 +10375,20 @@ class Test1 : Test2, I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public void M1()
{
+ System.Console.WriteLine(""Test1.M1"");
}
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.ProtectedOrInternal,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -10261,6 +10400,7 @@ public void MethodModifiers_42()
public interface I1
{
private protected abstract void M1();
+ public void M2() => M1();
}
public class Test2 : I1
@@ -10277,17 +10417,20 @@ class Test1 : Test2, I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public virtual void M1()
{
+ System.Console.WriteLine(""Test1.M1"");
}
}
";
ValidateMethodModifiers_10_02(source1, source2, Accessibility.ProtectedAndInternal,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.M1()'. 'Test1.M1()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -12583,12 +12726,12 @@ public int P1
ValidatePropertyModifiers_11_01(source1, source2, Accessibility.Internal,
new DiagnosticDescription[] {
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15)
},
// (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1'
// class Test2 : I1
@@ -12601,13 +12744,25 @@ private void ValidatePropertyModifiers_11_01(string source1, string source2, Acc
params DiagnosticDescription[] expected2)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(expected1);
ValidatePropertyModifiers_11(compilation1.SourceModule, accessibility);
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyModifiers_11(m, accessibility)).VerifyDiagnostics();
+
+ ValidatePropertyModifiers_11(compilation1.SourceModule, accessibility);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
@@ -12625,22 +12780,6 @@ private void ValidatePropertyModifiers_11_01(string source1, string source2, Acc
ValidatePropertyAccessorModifiers_11(p1set, accessibility);
}
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation3.VerifyDiagnostics(expected1);
-
- ValidatePropertyModifiers_11(compilation3.SourceModule, accessibility);
-
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation4.VerifyDiagnostics(expected1);
-
- ValidatePropertyModifiers_11(compilation4.SourceModule, accessibility);
-
var source3 =
@"
class Test2 : I1
@@ -12648,21 +12787,35 @@ class Test2 : I1
}
";
- var compilation5 = CreateCompilation(source3, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation5.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation5.VerifyDiagnostics(expected2);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation3.VerifyDiagnostics(expected1);
- ValidatePropertyNotImplemented_11(compilation5, "Test2");
+ ValidatePropertyModifiers_11(compilation3.SourceModule, accessibility);
- var compilation6 = CreateCompilation(source3, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugDll,
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation6.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation6.VerifyDiagnostics(expected2);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyModifiers_11(m, accessibility)).VerifyDiagnostics();
+
+ ValidatePropertyModifiers_11(compilation3.SourceModule, accessibility);
+
+ var compilation5 = CreateCompilation(source3, new[] { reference }, options: TestOptions.DebugDll,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation5.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation5.VerifyDiagnostics(expected2);
- ValidatePropertyNotImplemented_11(compilation6, "Test2");
+ ValidatePropertyNotImplemented_11(compilation5, "Test2");
+ }
}
private static void ValidatePropertyModifiers_11(ModuleSymbol m, Accessibility accessibility)
@@ -12757,12 +12910,12 @@ public virtual int P1
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -12770,34 +12923,51 @@ private void ValidatePropertyModifiers_11_02(string source1, string source2,
params DiagnosticDescription[] expected)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(expected);
ValidatePropertyImplementation_11(compilation1.SourceModule);
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyImplementation_11(m)).VerifyDiagnostics();
+
+ ValidatePropertyImplementation_11(compilation1.SourceModule);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation2.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation2.VerifyDiagnostics();
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation3.VerifyDiagnostics(expected);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation3.VerifyDiagnostics(expected);
- ValidatePropertyImplementation_11(compilation3.SourceModule);
+ ValidatePropertyImplementation_11(compilation3.SourceModule);
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugExe,
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation4.VerifyDiagnostics(expected);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyImplementation_11(m)).VerifyDiagnostics();
- ValidatePropertyImplementation_11(compilation4.SourceModule);
+ ValidatePropertyImplementation_11(compilation3.SourceModule);
+ }
}
private static void ValidatePropertyImplementation_11(ModuleSymbol m)
@@ -12825,10 +12995,8 @@ private static void ValidatePropertyImplementation_11(ModuleSymbol m, bool imple
Assert.Same(test1P1.SetMethod, test1.FindImplementationForInterfaceMember(p1set));
var i2 = test1.InterfacesNoUseSiteDiagnostics().Where(i => i.Name == "I2").SingleOrDefault();
- bool isMetadataVirtual = test1P1.IsVirtual || test1P1.IsAbstract || test1P1.IsExplicitInterfaceImplementation ||
- (!implementedByBase && (object)i2 != null && (object)test1P1 == test1.FindImplementationForInterfaceMember(GetSingleProperty(i2)));
- Assert.Equal(isMetadataVirtual, test1P1.GetMethod.IsMetadataVirtual());
- Assert.Equal(isMetadataVirtual, test1P1.SetMethod.IsMetadataVirtual());
+ Assert.True(test1P1.GetMethod.IsMetadataVirtual());
+ Assert.True(test1P1.SetMethod.IsMetadataVirtual());
}
[Fact]
@@ -12962,24 +13130,24 @@ public int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -13029,24 +13197,24 @@ public virtual int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -13101,24 +13269,24 @@ public override int P1
{
get
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -13168,12 +13336,12 @@ public int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -13185,12 +13353,12 @@ public interface I2
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -13330,9 +13498,9 @@ public virtual long P1
";
ValidatePropertyModifiers_11_09(source1, source2,
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.P1'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.P1'. 'Test1.P1' cannot implement 'I1.P1' because it does not have the matching return type of 'int'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.P1").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.P1", "Test1.P1", "int").WithLocation(2, 15)
);
}
@@ -13374,6 +13542,11 @@ public void PropertyModifiers_11_10()
public interface I1
{
internal abstract int P1 {get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
";
@@ -13385,23 +13558,32 @@ public int P1
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_10(source1, source2,
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -13409,30 +13591,51 @@ private void ValidatePropertyModifiers_11_10(string source1, string source2,
params DiagnosticDescription[] expected)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
compilation1.VerifyDiagnostics(expected);
ValidatePropertyImplementationByBase_11(compilation1.SourceModule);
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyImplementationByBase_11(m)).VerifyDiagnostics();
+
+ ValidatePropertyImplementationByBase_11(compilation1.SourceModule);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
compilation2.VerifyDiagnostics();
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugDll,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation3.VerifyDiagnostics(expected);
+ compilation3.VerifyDiagnostics(expected);
- ValidatePropertyImplementationByBase_11(compilation3.SourceModule);
+ ValidatePropertyImplementationByBase_11(compilation3.SourceModule);
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation4.VerifyDiagnostics(expected);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyImplementationByBase_11(m)).VerifyDiagnostics();
- ValidatePropertyImplementationByBase_11(compilation4.SourceModule);
+ ValidatePropertyImplementationByBase_11(compilation3.SourceModule);
+ }
}
[Fact]
@@ -13443,6 +13646,11 @@ public void PropertyModifiers_11_11()
public interface I1
{
internal abstract int P1 {get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
public class Test2 : I1
{
@@ -13450,9 +13658,13 @@ public int P1
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
@@ -13461,16 +13673,21 @@ public int P1
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_11(source1, source2,
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member.
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set").WithLocation(6, 22),
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(11, 22),
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get").WithLocation(6, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(11, 22)
);
}
@@ -13478,23 +13695,29 @@ private void ValidatePropertyModifiers_11_11(string source1, string source2,
params DiagnosticDescription[] expected)
{
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp,
assemblyName: "PropertyModifiers_11_11");
compilation2.VerifyDiagnostics(expected);
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp,
+ assemblyName: "PropertyModifiers_11_11");
- compilation3.VerifyDiagnostics();
+ compilation2.VerifyDiagnostics();
- ValidatePropertyImplementationByBase_11(compilation3.SourceModule);
+ var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
- var compilation3Ref = compilation3.EmitToImageReference();
- var compilation4 = CreateCompilation("", new[] { compilation2.ToMetadataReference(), compilation3Ref }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidatePropertyImplementationByBase_11(m)).VerifyDiagnostics();
- ValidatePropertyImplementationByBase_11(compilation4.GetReferencedAssemblySymbol(compilation3Ref).Modules[0]);
+ ValidatePropertyImplementationByBase_11(compilation3.SourceModule);
}
[Fact]
@@ -15927,6 +16150,8 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int P1
@@ -15944,22 +16169,33 @@ public int P1
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.Internal, Accessibility.Public,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
);
}
private void ValidatePropertyModifiers_23(string source1, string source2, Accessibility getAccess, Accessibility setAccess, params DiagnosticDescription[] expected)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All),
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(expected);
Validate1(compilation1.SourceModule);
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All),
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => Validate1(m)).VerifyDiagnostics();
+
+ Validate1(compilation1.SourceModule);
+
void Validate1(ModuleSymbol m)
{
var test1 = m.GlobalNamespace.GetTypeMember("Test1");
@@ -15976,23 +16212,29 @@ void Validate1(ModuleSymbol m)
ValidateProperty23(GetSingleProperty(compilation2, "I1"), true, getAccess, setAccess);
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() },
- options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All),
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation3.VerifyDiagnostics(expected);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference },
+ options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All),
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation3.VerifyDiagnostics(expected);
- Validate1(compilation3.SourceModule);
+ Validate1(compilation3.SourceModule);
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() },
+ compilation3 = CreateCompilation(source2, new[] { reference },
options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All),
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation4.VerifyDiagnostics(expected);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => Validate1(m)).VerifyDiagnostics();
- Validate1(compilation4.SourceModule);
+ Validate1(compilation3.SourceModule);
+ }
}
[Fact]
@@ -16036,9 +16278,9 @@ public virtual int P1
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -16135,21 +16377,21 @@ public int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16199,21 +16441,21 @@ public virtual int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16268,21 +16510,21 @@ public override int P1
{
get
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16332,12 +16574,12 @@ public int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -16349,9 +16591,9 @@ public interface I2
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 22)
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16456,9 +16698,9 @@ public virtual long P1
";
ValidatePropertyModifiers_11_09(source1, source2,
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.P1'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.P1'. 'Test1.P1' cannot implement 'I1.P1' because it does not have the matching return type of 'int'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.P1").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.P1", "Test1.P1", "int").WithLocation(2, 15)
);
}
@@ -16470,6 +16712,11 @@ public void PropertyModifiers_23_10()
public interface I1
{
abstract int P1 {internal get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
";
@@ -16481,20 +16728,29 @@ public int P1
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_10(source1, source2,
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16506,6 +16762,11 @@ public void PropertyModifiers_23_11()
public interface I1
{
abstract int P1 {internal get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
public class Test2 : I1
{
@@ -16513,9 +16774,13 @@ public int P1
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
@@ -16524,13 +16789,18 @@ public int P1
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_11(source1, source2,
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member.
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.get'. 'Test2.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get").WithLocation(6, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(11, 22)
);
}
@@ -16556,6 +16826,8 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int P1
@@ -16573,9 +16845,9 @@ public int P1
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.Public, Accessibility.Internal,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -16620,9 +16892,9 @@ public virtual int P1
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -16719,21 +16991,21 @@ public int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16783,21 +17055,21 @@ public virtual int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16852,21 +17124,21 @@ public override int P1
{
get
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -16916,12 +17188,12 @@ public int P1
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -16933,9 +17205,9 @@ public interface I2
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1, I2
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -17040,9 +17312,9 @@ public virtual long P1
";
ValidatePropertyModifiers_11_09(source1, source2,
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.P1'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.P1'. 'Test1.P1' cannot implement 'I1.P1' because it does not have the matching return type of 'int'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.P1").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.P1", "Test1.P1", "int").WithLocation(2, 15)
);
}
@@ -17054,6 +17326,11 @@ public void PropertyModifiers_23_60()
public interface I1
{
abstract int P1 {get; internal set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
";
@@ -17065,20 +17342,29 @@ public int P1
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_10(source1, source2,
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -17090,6 +17376,11 @@ public void PropertyModifiers_23_61()
public interface I1
{
abstract int P1 {get; internal set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
public class Test2 : I1
{
@@ -17097,9 +17388,13 @@ public int P1
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
@@ -17108,13 +17403,18 @@ public int P1
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_11(source1, source2,
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member.
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.set'. 'Test2.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set").WithLocation(6, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(11, 22)
);
}
@@ -17881,6 +18181,11 @@ public void PropertyModifiers_29()
public interface I1
{
protected abstract int P1 {get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
";
@@ -17890,24 +18195,33 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.Test();
}
public int P1
{
- get => 0;
- set {}
+ get
+ {
+ System.Console.WriteLine(""get_P1"");
+ return 0;
+ }
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
ValidatePropertyModifiers_11_01(source1, source2, Accessibility.Protected,
new DiagnosticDescription[] {
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
},
// (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1'
// class Test2 : I1
@@ -17923,6 +18237,11 @@ public void PropertyModifiers_30()
public interface I1
{
protected internal abstract int P1 {get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
";
@@ -17932,24 +18251,33 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.Test();
}
public int P1
{
- get => 0;
- set {}
+ get
+ {
+ System.Console.WriteLine(""get_P1"");
+ return 0;
+ }
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
ValidatePropertyModifiers_11_01(source1, source2, Accessibility.ProtectedOrInternal,
new DiagnosticDescription[] {
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
},
// (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1'
// class Test2 : I1
@@ -17965,6 +18293,11 @@ public void PropertyModifiers_31()
public interface I1
{
private protected abstract int P1 {get; set;}
+
+ sealed void Test()
+ {
+ P1 = P1;
+ }
}
";
@@ -17974,24 +18307,33 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.Test();
}
public int P1
{
- get => 0;
- set {}
+ get
+ {
+ System.Console.WriteLine(""get_P1"");
+ return 0;
+ }
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
ValidatePropertyModifiers_11_01(source1, source2, Accessibility.ProtectedAndInternal,
new DiagnosticDescription[] {
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
},
// (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1'
// class Test2 : I1
@@ -18007,6 +18349,11 @@ public void PropertyModifiers_32()
public interface I1
{
abstract int P1 {protected get; set;}
+
+ void M2()
+ {
+ P1 = P1;
+ }
}
";
@@ -18016,19 +18363,28 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int P1
{
- get => 0;
- set {}
+ get
+ {
+ System.Console.WriteLine(""get_P1"");
+ return 0;
+ }
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.Protected, Accessibility.Public,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -18040,6 +18396,11 @@ public void PropertyModifiers_33()
public interface I1
{
abstract int P1 {protected internal get; set;}
+
+ void M2()
+ {
+ P1 = P1;
+ }
}
";
@@ -18049,19 +18410,28 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int P1
{
- get => 0;
- set {}
+ get
+ {
+ System.Console.WriteLine(""get_P1"");
+ return 0;
+ }
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.ProtectedOrInternal, Accessibility.Public,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.get'. 'Test1.P1.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -18073,6 +18443,11 @@ public void PropertyModifiers_34()
public interface I1
{
abstract int P1 {get; private protected set;}
+
+ void M2()
+ {
+ P1 = P1;
+ }
}
";
@@ -18082,19 +18457,28 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int P1
{
- get => 0;
- set {}
+ get
+ {
+ System.Console.WriteLine(""get_P1"");
+ return 0;
+ }
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.Public, Accessibility.ProtectedAndInternal,
- // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.set'. 'Test1.P1.set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -19916,12 +20300,12 @@ public int this[int x]
ValidatePropertyModifiers_11_01(source1, source2, Accessibility.Internal,
new DiagnosticDescription[] {
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 15)
},
// (2,15): error CS0535: 'Test2' does not implement interface member 'I1.this[int]'
// class Test2 : I1
@@ -19970,12 +20354,12 @@ public virtual int this[int x]
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -20072,24 +20456,24 @@ public int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -20139,24 +20523,24 @@ public virtual int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -20211,24 +20595,24 @@ public override int this[int x]
{
get
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -20278,12 +20662,12 @@ public int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -20295,12 +20679,12 @@ public interface I2
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1, I2
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1, I2
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -20405,9 +20789,9 @@ public virtual long this[int x]
";
ValidatePropertyModifiers_11_09(source1, source2,
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.this[int]'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.this[int]'. 'Test1.this[int]' cannot implement 'I1.this[int]' because it does not have the matching return type of 'int'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.this[int]").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.this[int]", "Test1.this[int]", "int").WithLocation(2, 15)
);
}
@@ -20419,6 +20803,11 @@ public void IndexerModifiers_11_10()
public interface I1
{
internal abstract int this[int x] {get; set;}
+
+ sealed void Test()
+ {
+ this[0] = this[0];
+ }
}
";
@@ -20430,23 +20819,32 @@ public int this[int x]
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_10(source1, source2,
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -20458,6 +20856,11 @@ public void IndexerModifiers_11_11()
public interface I1
{
internal abstract int this[int x] {get; set;}
+
+ sealed void Test()
+ {
+ this[0] = this[0];
+ }
}
public class Test2 : I1
{
@@ -20465,9 +20868,13 @@ public int this[int x]
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
@@ -20476,16 +20883,21 @@ public int this[int x]
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_11(source1, source2,
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member.
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set").WithLocation(6, 22),
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get", "9.0", "10.0").WithLocation(11, 22),
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get").WithLocation(6, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set", "9.0", "10.0").WithLocation(11, 22)
);
}
@@ -22268,6 +22680,8 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int this[int x]
@@ -22285,9 +22699,9 @@ public int this[int x]
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.Internal, Accessibility.Public,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -22332,9 +22746,9 @@ public virtual int this[int x]
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -22431,21 +22845,21 @@ public int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -22495,21 +22909,21 @@ public virtual int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -22564,21 +22978,21 @@ public override int this[int x]
{
get
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -22628,12 +23042,12 @@ public int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -22645,9 +23059,9 @@ public interface I2
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].get'. 'Test1.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1, I2
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -22752,9 +23166,9 @@ public virtual long this[int x]
";
ValidatePropertyModifiers_11_09(source1, source2,
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.this[int]'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.this[int]'. 'Test1.this[int]' cannot implement 'I1.this[int]' because it does not have the matching return type of 'int'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.this[int]").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.this[int]", "Test1.this[int]", "int").WithLocation(2, 15)
);
}
@@ -22766,6 +23180,11 @@ public void IndexerModifiers_23_10()
public interface I1
{
abstract int this[int x] {internal get; set;}
+
+ sealed void Test()
+ {
+ this[0] = this[0];
+ }
}
";
@@ -22777,20 +23196,29 @@ public int this[int x]
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_10(source1, source2,
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -22802,6 +23230,11 @@ public void IndexerModifiers_23_11()
public interface I1
{
abstract int this[int x] {internal get; set;}
+
+ sealed void Test()
+ {
+ this[0] = this[0];
+ }
}
public class Test2 : I1
{
@@ -22809,9 +23242,13 @@ public int this[int x]
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
@@ -22820,13 +23257,18 @@ public int this[int x]
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_11(source1, source2,
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member.
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].get'. 'Test2.this[int].get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get").WithLocation(6, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get", "9.0", "10.0").WithLocation(11, 22)
);
}
@@ -22852,6 +23294,8 @@ class Test1 : I1
{
static void Main()
{
+ I1 x = new Test1();
+ x.M2();
}
public int this[int x]
@@ -22869,9 +23313,9 @@ public int this[int x]
}
";
ValidatePropertyModifiers_23(source1, source2, Accessibility.Public, Accessibility.Internal,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -22916,9 +23360,9 @@ public virtual int this[int x]
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -23015,21 +23459,21 @@ public int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -23079,21 +23523,21 @@ public virtual int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -23148,21 +23592,21 @@ public override int this[int x]
{
get
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -23212,12 +23656,12 @@ public int this[int x]
{
get
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
return 0;
}
set
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -23229,9 +23673,9 @@ public interface I2
";
ValidatePropertyModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.this[int].set'. 'Test1.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1, I2
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -23336,9 +23780,9 @@ public virtual long this[int x]
";
ValidatePropertyModifiers_11_09(source1, source2,
- // (2,15): error CS0535: 'Test1' does not implement interface member 'I1.this[int]'
+ // (2,15): error CS0738: 'Test1' does not implement interface member 'I1.this[int]'. 'Test1.this[int]' cannot implement 'I1.this[int]' because it does not have the matching return type of 'int'.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_UnimplementedInterfaceMember, "I1").WithArguments("Test1", "I1.this[int]").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_CloseUnimplementedInterfaceMemberWrongReturnType, "I1").WithArguments("Test1", "I1.this[int]", "Test1.this[int]", "int").WithLocation(2, 15)
);
}
@@ -23350,6 +23794,11 @@ public void IndexerModifiers_23_60()
public interface I1
{
abstract int this[int x] {get; internal set;}
+
+ sealed void Test()
+ {
+ this[0] = this[0];
+ }
}
";
@@ -23361,20 +23810,29 @@ public int this[int x]
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_10(source1, source2,
- // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -23386,6 +23844,11 @@ public void IndexerModifiers_23_61()
public interface I1
{
abstract int this[int x] {get; internal set;}
+
+ sealed void Test()
+ {
+ this[0] = this[0];
+ }
}
public class Test2 : I1
{
@@ -23393,9 +23856,13 @@ public int this[int x]
{
get
{
+ System.Console.WriteLine(""get_P1"");
return 0;
}
- set {}
+ set
+ {
+ System.Console.WriteLine(""set_P1"");
+ }
}
}
";
@@ -23404,13 +23871,18 @@ public int this[int x]
@"
class Test1 : Test2, I1
{
+ static void Main()
+ {
+ I1 x = new Test1();
+ x.Test();
+ }
}
";
ValidatePropertyModifiers_11_11(source1, source2,
- // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member.
+ // (11,22): error CS8704: 'Test2' does not implement interface member 'I1.this[int].set'. 'Test2.this[int].set' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// public class Test2 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set").WithLocation(6, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set", "9.0", "10.0").WithLocation(11, 22)
);
}
@@ -25354,12 +25826,12 @@ public event System.Action P1
ValidateEventModifiers_11(source1, source2, Accessibility.Internal,
new DiagnosticDescription[]
{
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 15)
},
// (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1'
// class Test2 : I1
@@ -25370,13 +25842,24 @@ public event System.Action P1
private void ValidateEventModifiers_11(string source1, string source2, Accessibility accessibility, DiagnosticDescription[] expected1, params DiagnosticDescription[] expected2)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
+ parseOptions: TestOptions.Regular9,
targetFramework: TargetFramework.NetCoreApp);
Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
compilation1.VerifyDiagnostics(expected1);
Validate1(compilation1.SourceModule);
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => Validate1(m)).VerifyDiagnostics();
+
+ Validate1(compilation1.SourceModule);
+
void Validate1(ModuleSymbol m)
{
var test1 = m.GlobalNamespace.GetTypeMember("Test1");
@@ -25432,22 +25915,6 @@ void ValidateMethod(MethodSymbol m1)
ValidateMethod(p1.RemoveMethod);
}
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation3.VerifyDiagnostics(expected1);
-
- Validate1(compilation3.SourceModule);
-
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation4.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation4.VerifyDiagnostics(expected1);
-
- Validate1(compilation4.SourceModule);
-
var source3 =
@"
class Test2 : I1
@@ -25455,21 +25922,35 @@ class Test2 : I1
}
";
- var compilation5 = CreateCompilation(source3, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular,
- targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation5.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation5.VerifyDiagnostics(expected2);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation3.VerifyDiagnostics(expected1);
- ValidateEventNotImplemented_11(compilation5, "Test2");
+ Validate1(compilation3.SourceModule);
- var compilation6 = CreateCompilation(source3, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugDll,
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
parseOptions: TestOptions.Regular,
targetFramework: TargetFramework.NetCoreApp);
- Assert.True(compilation6.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
- compilation6.VerifyDiagnostics(expected2);
+ Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => Validate1(m)).VerifyDiagnostics();
+
+ Validate1(compilation3.SourceModule);
+
+ var compilation5 = CreateCompilation(source3, new[] { reference }, options: TestOptions.DebugDll,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+ Assert.True(compilation5.Assembly.RuntimeSupportsDefaultInterfaceImplementation);
+ compilation5.VerifyDiagnostics(expected2);
- ValidateEventNotImplemented_11(compilation6, "Test2");
+ ValidateEventNotImplemented_11(compilation5, "Test2");
+ }
}
private static void ValidateEventNotImplemented_11(CSharpCompilation compilation, string className)
@@ -25526,12 +26007,12 @@ public virtual event System.Action P1
";
ValidateEventModifiers_11_02(source1, source2,
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member.
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove").WithLocation(2, 15),
- // (2,15): error CS8504: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "10.0").WithLocation(2, 15),
+ // (2,15): error CS8704: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add").WithLocation(2, 15)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 15)
);
}
@@ -25539,30 +26020,51 @@ private void ValidateEventModifiers_11_02(string source1, string source2,
params DiagnosticDescription[] expected)
{
var compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular);
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
compilation1.VerifyDiagnostics(expected);
ValidateEventImplementation_11(compilation1.SourceModule);
+ compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
+
+ CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateEventImplementation_11(m)).VerifyDiagnostics();
+
+ ValidateEventImplementation_11(compilation1.SourceModule);
+
var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll,
- parseOptions: TestOptions.Regular);
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
compilation2.VerifyDiagnostics();
- var compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular);
+ foreach (var reference in new[] { compilation2.ToMetadataReference(), compilation2.EmitToImageReference() })
+ {
+ var compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular9,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation3.VerifyDiagnostics(expected);
+ compilation3.VerifyDiagnostics(expected);
- ValidateEventImplementation_11(compilation3.SourceModule);
+ ValidateEventImplementation_11(compilation3.SourceModule);
- var compilation4 = CreateCompilation(source2, new[] { compilation2.EmitToImageReference() }, options: TestOptions.DebugExe,
- parseOptions: TestOptions.Regular);
+ compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe,
+ parseOptions: TestOptions.Regular,
+ targetFramework: TargetFramework.NetCoreApp);
- compilation4.VerifyDiagnostics(expected);
+ CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null :
+@"get_P1
+set_P1",
+ verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateEventImplementation_11(m)).VerifyDiagnostics();
- ValidateEventImplementation_11(compilation4.SourceModule);
+ ValidateEventImplementation_11(compilation3.SourceModule);
+ }
}
private static void ValidateEventImplementation_11(ModuleSymbol m)
@@ -25589,11 +26091,8 @@ private static void ValidateEventImplementation_11(ModuleSymbol m, bool implemen
Assert.Same(test1P1.AddMethod, test1.FindImplementationForInterfaceMember(p1Add));
Assert.Same(test1P1.RemoveMethod, test1.FindImplementationForInterfaceMember(p1Remove));
- var i2 = test1.InterfacesNoUseSiteDiagnostics().Where(i => i.Name == "I2").SingleOrDefault();
- bool isMetadataVirtual = test1P1.IsVirtual || test1P1.IsAbstract || test1P1.IsExplicitInterfaceImplementation ||
- (!implementedByBase && (object)i2 != null && (object)test1P1 == test1.FindImplementationForInterfaceMember(GetSingleEvent(i2)));
- Assert.Equal(isMetadataVirtual, test1P1.AddMethod.IsMetadataVirtual());
- Assert.Equal(isMetadataVirtual, test1P1.RemoveMethod.IsMetadataVirtual());
+ Assert.True(test1P1.AddMethod.IsMetadataVirtual());
+ Assert.True(test1P1.RemoveMethod.IsMetadataVirtual());
}
[Fact]
@@ -25729,23 +26228,23 @@ public event System.Action P1
{
add
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
}
remove
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidateEventModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -25797,23 +26296,23 @@ public virtual event System.Action P1
{
add
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
}
remove
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
";
ValidateEventModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -25870,11 +26369,11 @@ public override event System.Action P1
{
add
{
- System.Console.WriteLine(""Test3.get_P1"");
+ System.Console.WriteLine(""get_P1"");
}
remove
{
- System.Console.WriteLine(""Test3.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -25882,12 +26381,12 @@ public override event System.Action P1
";
ValidateEventModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member.
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member.
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
// class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add").WithLocation(2, 22)
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -25939,11 +26438,11 @@ public event System.Action P1
{
add
{
- System.Console.WriteLine(""Test1.get_P1"");
+ System.Console.WriteLine(""get_P1"");
}
remove
{
- System.Console.WriteLine(""Test1.set_P1"");
+ System.Console.WriteLine(""set_P1"");
}
}
}
@@ -25955,12 +26454,12 @@ public interface I2
";
ValidateEventModifiers_11_02(source1, source2,
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove").WithLocation(2, 22),
- // (2,22): error CS8504: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member.
- // class Test1 : Test2, I1
- Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add").WithLocation(2, 22)
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.remove'. 'Test1.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "10.0").WithLocation(2, 22),
+ // (2,22): error CS8704: 'Test1' does not implement interface member 'I1.P1.add'. 'Test1.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater.
+ // class Test1 : Test2, I1, I2
+ Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22)
);
}
@@ -26104,9 +26603,9 @@ public virtual event System.Action