From 630f4876504a9d933ba1661bb20f0be842c758d1 Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Thu, 17 Jun 2021 11:13:01 -0700 Subject: [PATCH 1/3] Allow implicit implementation of non-public interface members Closes #53566. --- .../CSharp/Portable/CSharpResources.resx | 2 +- .../CSharp/Portable/Errors/MessageID.cs | 2 + ...berContainerSymbol_ImplementationChecks.cs | 20 +- .../CSharp/Portable/Symbols/TypeSymbol.cs | 26 +- .../Portable/xlf/CSharpResources.cs.xlf | 4 +- .../Portable/xlf/CSharpResources.de.xlf | 4 +- .../Portable/xlf/CSharpResources.es.xlf | 4 +- .../Portable/xlf/CSharpResources.fr.xlf | 4 +- .../Portable/xlf/CSharpResources.it.xlf | 4 +- .../Portable/xlf/CSharpResources.ja.xlf | 4 +- .../Portable/xlf/CSharpResources.ko.xlf | 4 +- .../Portable/xlf/CSharpResources.pl.xlf | 4 +- .../Portable/xlf/CSharpResources.pt-BR.xlf | 4 +- .../Portable/xlf/CSharpResources.ru.xlf | 4 +- .../Portable/xlf/CSharpResources.tr.xlf | 4 +- .../Portable/xlf/CSharpResources.zh-Hans.xlf | 4 +- .../Portable/xlf/CSharpResources.zh-Hant.xlf | 4 +- .../DefaultInterfaceImplementationTests.cs | 1744 +++++++++++------ .../UpgradeProject/UpgradeProjectTests.cs | 19 + .../CSharpUpgradeProjectCodeFixProvider.cs | 1 + 20 files changed, 1241 insertions(+), 625 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 4bd0ba1c1f8a2..90f8f59ebb615 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -6074,7 +6074,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 5b2950fde0247..3a43dbec19183 100644 --- a/src/Compilers/CSharp/Portable/Errors/MessageID.cs +++ b/src/Compilers/CSharp/Portable/Errors/MessageID.cs @@ -226,6 +226,7 @@ internal enum MessageID IDS_FeatureWithOnAnonymousTypes = MessageBase + 12801, IDS_FeatureExtendedPropertyPatterns = MessageBase + 12802, IDS_FeatureStaticAbstractMembersInInterfaces = MessageBase + 12803, + IDS_FeatureImplicitImplementationOfNonPublicMemebers = MessageBase + 12804, } // Message IDs may refer to strings that need to be localized. @@ -344,6 +345,7 @@ internal static LanguageVersion RequiredVersion(this MessageID feature) case MessageID.IDS_FeatureLambdaAttributes: // semantic check case MessageID.IDS_FeatureExtendedPropertyPatterns: case MessageID.IDS_FeatureStaticAbstractMembersInInterfaces: // semantic check + case MessageID.IDS_FeatureImplicitImplementationOfNonPublicMemebers: // semantic check return LanguageVersion.Preview; // 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..6d610519a9e19 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,19 +1002,23 @@ 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) { diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index b5ff532eba2e8..89e8fb8ca49e4 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -10988,8 +10988,8 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - {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. + '{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 07c6f14fe92b7..f87ee84e4c755 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -10988,8 +10988,8 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - 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. + '{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 24e859006a224..dfccd73a9499f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -10988,8 +10988,8 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - "{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. + '{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 ab43b93d40b3e..5d4460c7ddd74 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -10988,8 +10988,8 @@ Pour supprimer l'avertissement, vous pouvez utiliser la commande /reference (dé - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 609c78d59957e..d4bcb5677fede 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -10988,8 +10988,8 @@ Per rimuovere l'avviso, è invece possibile usare /reference (impostare la propr - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 82fac7d26b455..84d343b4bf860 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -10988,8 +10988,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 f032a025fb533..e0b4fb4f9d16b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -10987,8 +10987,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 46547ef8a331d..0d4f7ab363006 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -10988,8 +10988,8 @@ Aby usunąć ostrzeżenie, możesz zamiast tego użyć opcji /reference (ustaw w - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - 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. + '{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 4efe7d6a752f7..aa41d73b7534e 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -10988,8 +10988,8 @@ Para incorporar informações de tipo de interoperabilidade para os dois assembl - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 0768c0734bd88..0fd1da32cbd6c 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -10988,8 +10988,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - "{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. + '{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 9e0da73b9a425..67da5ac9e8623 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -10988,8 +10988,8 @@ Uyarıyı kaldırmak için, /reference kullanabilirsiniz (Birlikte Çalışma T - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 46b9cba19968d..bb750a93cac02 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -10993,8 +10993,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - “{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. + '{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 fcef9719d84c0..d013ffd3b4ee8 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -10988,8 +10988,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}' does not implement interface member '{1}'. '{2}' cannot implicitly implement a non-public member. - '{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. + '{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 de8c324c6e1b2..76c42e035bbda 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 'preview' 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", "preview").WithLocation(9, 15) ); ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.Internal); + compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, + 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 'preview' or greater. + // class Test1 : I1 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "preview").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.RegularPreview, 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 'preview' 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", "preview").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.RegularPreview, + 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.RegularPreview, + 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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").WithLocation(9, 15) ); ValidateMethodModifiersImplicitInTest2_10(compilation1.SourceModule, Accessibility.Internal); + compilation1 = CreateCompilation(source1 + source2, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, + 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 'preview' or greater. + // class Test2 : I1 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()", "9.0", "preview").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.RegularPreview, + 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, + parseOptions: TestOptions.RegularPreview, + 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.RegularPreview, + targetFramework: TargetFramework.NetCoreApp); + + CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics(); - ValidateMethodModifiersImplicitInTest2_10(compilation4.GetReferencedAssemblySymbol(compilation3Ref).Modules[0], Accessibility.Internal); + 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 'preview' 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", "preview").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.RegularPreview, + 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.RegularPreview, + 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 'preview' 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", "preview").WithLocation(2, 15) ); ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.ProtectedOrInternal); + compilation1 = CreateCompilation(source21 + source1, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, + 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 'preview' 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", "preview").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.RegularPreview, + 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 'preview' 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", "preview").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.RegularPreview, + 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 'preview' 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", "preview").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.RegularPreview, + 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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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.RegularPreview, + 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, - parseOptions: TestOptions.Regular, + compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, 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); - ValidatePropertyNotImplemented_11(compilation6, "Test2"); + 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(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 'preview' 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", "preview").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 'preview' 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", "preview").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.RegularPreview, + 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, - parseOptions: TestOptions.Regular, + compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, 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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").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 'preview' 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", "preview").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.RegularPreview, + 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.RegularPreview, + 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 'preview' 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", "preview").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 'preview' 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", "preview").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.RegularPreview, + 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 'preview' 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", "preview").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.RegularPreview, + 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, + parseOptions: TestOptions.RegularPreview, 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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].set", "Test1.this[int].set", "9.0", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.this[int].get", "Test1.this[int].get", "9.0", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 22) ); } @@ -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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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.RegularPreview, + 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,22 +25922,36 @@ 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, - parseOptions: TestOptions.Regular, + compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, 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(); - ValidateEventNotImplemented_11(compilation6, "Test2"); - } + 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(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 'preview' 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", "preview").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 'preview' 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", "preview").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.RegularPreview, + 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.RegularPreview, + 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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' 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", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.remove", "Test1.P1.remove", "9.0", "preview").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 'preview' or greater. + // class Test1 : Test2, I1, I2 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "preview").WithLocation(2, 22) ); } @@ -26148,6 +26647,12 @@ public void EventModifiers_11_10() public interface I1 { internal abstract event System.Action P1; + + sealed void Test() + { + P1 += null; + P1 -= null; + } } "; @@ -26157,22 +26662,33 @@ public class Test2 : I1 { public event System.Action P1 { - add {} - remove {} + add + { + System.Console.WriteLine(""get_P1""); + } + remove + { + System.Console.WriteLine(""set_P1""); + } } } class Test1 : Test2, I1 { + static void Main() + { + I1 x = new Test1(); + x.Test(); + } } "; ValidateEventModifiers_11_10(source1, source2, - // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' cannot implicitly implement a non-public member. + // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. // public class Test2 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.remove", "Test2.P1.remove").WithLocation(2, 22), - // (2,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' cannot implicitly implement a non-public member. + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.remove", "Test2.P1.remove", "9.0", "preview").WithLocation(2, 22), + // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. // public class Test2 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.add", "Test2.P1.add").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.add", "Test2.P1.add", "9.0", "preview").WithLocation(2, 22) ); } @@ -26180,30 +26696,51 @@ private void ValidateEventModifiers_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); ValidateEventImplementationByBase_11(compilation1.SourceModule); + compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, + targetFramework: TargetFramework.NetCoreApp); + + CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : +@"get_P1 +set_P1", + verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateEventImplementationByBase_11(m)).VerifyDiagnostics(); + + ValidateEventImplementationByBase_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); - ValidateEventImplementationByBase_11(compilation3.SourceModule); + ValidateEventImplementationByBase_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.RegularPreview, + targetFramework: TargetFramework.NetCoreApp); - compilation4.VerifyDiagnostics(expected); + CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : +@"get_P1 +set_P1", + verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateEventImplementationByBase_11(m)).VerifyDiagnostics(); - ValidateEventImplementationByBase_11(compilation4.SourceModule); + ValidateEventImplementationByBase_11(compilation3.SourceModule); + } } [Fact] @@ -26214,13 +26751,25 @@ public void EventModifiers_11_11() public interface I1 { internal abstract event System.Action P1; + + sealed void Test() + { + P1 += null; + P1 -= null; + } } public class Test2 : I1 { public event System.Action P1 { - add {} - remove {} + add + { + System.Console.WriteLine(""get_P1""); + } + remove + { + System.Console.WriteLine(""set_P1""); + } } } "; @@ -26229,16 +26778,21 @@ public event System.Action P1 @" class Test1 : Test2, I1 { + static void Main() + { + I1 x = new Test1(); + x.Test(); + } } "; ValidateEventModifiers_11_11(source1, source2, - // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' cannot implicitly implement a non-public member. + // (12,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. // public class Test2 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.remove", "Test2.P1.remove").WithLocation(6, 22), - // (6,22): error CS8504: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' cannot implicitly implement a non-public member. + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.remove", "Test2.P1.remove", "9.0", "preview").WithLocation(12, 22), + // (12,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. // public class Test2 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.add", "Test2.P1.add").WithLocation(6, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.add", "Test2.P1.add", "9.0", "preview").WithLocation(12, 22) ); } @@ -26246,23 +26800,29 @@ private void ValidateEventModifiers_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: "EventModifiers_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.RegularPreview, + targetFramework: TargetFramework.NetCoreApp, + assemblyName: "EventModifiers_11_11"); - compilation3.VerifyDiagnostics(); + compilation2.VerifyDiagnostics(); - ValidateEventImplementationByBase_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) => ValidateEventImplementationByBase_11(m)).VerifyDiagnostics(); - ValidateEventImplementationByBase_11(compilation4.GetReferencedAssemblySymbol(compilation3Ref).Modules[0]); + ValidateEventImplementationByBase_11(compilation3.SourceModule); } [Fact] @@ -28084,12 +28644,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.Protected, 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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 15) }, // (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1' // class Test2 : I1 @@ -28141,12 +28701,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.ProtectedOrInternal, 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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 15) }, // (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1' // class Test2 : I1 @@ -28198,12 +28758,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.ProtectedAndInternal, 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 'preview' 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", "preview").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 'preview' 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", "preview").WithLocation(2, 15) }, // (2,15): error CS0535: 'Test2' does not implement interface member 'I1.P1' // class Test2 : I1 @@ -55220,7 +55780,7 @@ static void Main() } } "; - var compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, targetFramework: TargetFramework.NetCoreApp); + var compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); var i1M = compilation1.GetMember("I1.M"); var c0 = compilation1.GetTypeByMetadataName("C0"); @@ -55230,9 +55790,57 @@ static void Main() Assert.Equal("System.String C0.M()", test.FindImplementationForInterfaceMember(i1M).ToTestDisplayString()); compilation1.VerifyDiagnostics( - // (15,19): error CS8704: 'C0' does not implement interface member 'I1.M()'. 'C0.M()' cannot implicitly implement a non-public member. + // (15,19): error CS8704: 'C0' does not implement interface member 'I1.M()'. 'C0.M()' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + // public class C0 : I1 + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.M()", "C0.M()", "9.0", "preview").WithLocation(15, 19) + ); + + compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularPreview, targetFramework: TargetFramework.NetCoreApp); + + i1M = compilation1.GetMember("I1.M"); + c0 = compilation1.GetTypeByMetadataName("C0"); + test = compilation1.GetTypeByMetadataName("Test"); + + Assert.Equal("System.String C0.M()", c0.FindImplementationForInterfaceMember(i1M).ToTestDisplayString()); + Assert.Equal("System.String C0.M()", test.FindImplementationForInterfaceMember(i1M).ToTestDisplayString()); + + CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "C0.M", verify: VerifyOnMonoOrCoreClr).VerifyDiagnostics(); + } + + [Fact] + public void ImplicitImplementationOfNonPublicMethod_04() + { + var source1 = +@" +public interface I1 +{ + internal int get_P(); +} + +public class C0 : I1 +{ + public virtual int P { get; } +} +"; + var compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, + parseOptions: TestOptions.Regular9, + targetFramework: TargetFramework.NetCoreApp); + compilation1.VerifyDiagnostics( + // (7,19): error CS8704: 'C0' does not implement interface member 'I1.get_P()'. 'C0.P.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. // public class C0 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.M()", "C0.M()").WithLocation(15, 19) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.get_P()", "C0.P.get", "9.0", "preview").WithLocation(7, 19), + // (9,28): error CS0686: Accessor 'C0.P.get' cannot implement interface member 'I1.get_P()' for type 'C0'. Use an explicit interface implementation. + // public virtual int P { get; } + Diagnostic(ErrorCode.ERR_AccessorImplementingMethod, "get").WithArguments("C0.P.get", "I1.get_P()", "C0").WithLocation(9, 28) + ); + + compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, + parseOptions: TestOptions.RegularPreview, + targetFramework: TargetFramework.NetCoreApp); + compilation1.VerifyDiagnostics( + // (9,28): error CS0686: Accessor 'C0.P.get' cannot implement interface member 'I1.get_P()' for type 'C0'. Use an explicit interface implementation. + // public virtual int P { get; } + Diagnostic(ErrorCode.ERR_AccessorImplementingMethod, "get").WithArguments("C0.P.get", "I1.get_P()", "C0").WithLocation(9, 28) ); } diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs index 53caa05b1a1f1..71cfa96670987 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs @@ -1026,6 +1026,25 @@ public record Base +", + expected: LanguageVersion.Preview, + new CSharpParseOptions(LanguageVersion.CSharp9)); + } + + [Fact] + public async Task UpgradeProjectForImplicitImplementationOfNonPublicMemebers_CS8704() + { + await TestLanguageVersionUpgradedAsync( +@" +public interface I1 +{ + protected void M01(); +} + +class C1 : [|I1|] +{ + public void M01() {} +} ", expected: LanguageVersion.Preview, new CSharpParseOptions(LanguageVersion.CSharp9)); diff --git a/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs b/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs index b79e74ef15c73..b3711c1ce46d9 100644 --- a/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs +++ b/src/Features/CSharp/Portable/UpgradeProject/CSharpUpgradeProjectCodeFixProvider.cs @@ -47,6 +47,7 @@ public CSharpUpgradeProjectCodeFixProvider() "CS8706", // error CS8706: '{0}' cannot implement interface member '{1}' in type '{2}' because feature '{3}' is not available in C# {4}. Please use language version '{5}' or greater. "CS8904", // error CS8904: Invalid variance: The type parameter 'T1' must be contravariantly valid on 'I2.M1(T1)' unless language version 'preview' or greater is used. 'T1' is covariant. "CS8912", // error CS8912: Inheriting from a record with a sealed 'Object.ToString' is not supported in C# {0}. Please use language version '{1}' or greater. + "CS8704", // 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 'preview' or greater. }); public override string UpgradeThisProjectResource => CSharpFeaturesResources.Upgrade_this_project_to_csharp_language_version_0; From d06bc252b04b7954a91eabf3dfbb1b1a1428064c Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Thu, 17 Jun 2021 13:28:29 -0700 Subject: [PATCH 2/3] Realign diagnostics for an implicit implementation signature mismatch case. --- .../CSharp/Portable/Symbols/TypeSymbol.cs | 8 +- .../DefaultInterfaceImplementationTests.cs | 182 ++++++++++++++++-- 2 files changed, 162 insertions(+), 28 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs index 6d610519a9e19..755781e851806 100644 --- a/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/TypeSymbol.cs @@ -1022,8 +1022,6 @@ private static Symbol ComputeImplementationForInterfaceMember(Symbol interfaceMe } else if ((object)closestMismatch != null) { - Debug.Assert(interfaceMember.DeclaredAccessibility == Accessibility.Public); - Debug.Assert(!interfaceMember.IsEventOrPropertyWithImplementableNonPublicAccessor()); ReportImplicitImplementationMismatchDiagnostics(interfaceMember, implementingType, closestMismatch, diagnostics); } } @@ -2067,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/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs index 76c42e035bbda..04cf0943dbf62 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs @@ -7824,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"); @@ -7844,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"); @@ -7856,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"); @@ -13498,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) ); } @@ -16698,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) ); } @@ -17312,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) ); } @@ -20789,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) ); } @@ -23166,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) ); } @@ -23780,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) ); } @@ -25951,7 +25951,7 @@ class Test2 : I1 ValidateEventNotImplemented_11(compilation5, "Test2"); } - } + } private static void ValidateEventNotImplemented_11(CSharpCompilation compilation, string className) { @@ -26603,9 +26603,9 @@ public virtual event System.Action P1 "; ValidateEventModifiers_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 'Action'. // 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", "System.Action").WithLocation(2, 15) ); } @@ -61132,5 +61132,145 @@ static void Main() expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "Test", verify: VerifyOnMonoOrCoreClr); } + + [Fact, WorkItem(53565, "https://github.com/dotnet/roslyn/issues/53565")] + public void PartialPropertyImplementation_01() + { + var source1 = +@" +interface I1 +{ + int P1 {get; set;} + int P2 {get => throw null; internal set{}} + int P3 {get => throw null; set{}} +} + +class C0 : I1 +{ + int I1.P1 {get; set;} +} + +class C1 : C0, I1 +{ + public int P1 + { + get + { + System.Console.WriteLine(""C1.get_P1""); + return 0; + } + } + public int P2 + { + get + { + System.Console.WriteLine(""C1.get_P2""); + return 0; + } + } + public int P3 + { + get + { + System.Console.WriteLine(""C1.get_P3""); + return 0; + } + } + + static void Main() + { + I1 x = new C1(); + _ = x.P1; + _ = x.P2; + _ = x.P3; + } +} +"; + foreach (var parseOptions in new[] { TestOptions.Regular8, TestOptions.Regular9, TestOptions.RegularPreview }) + { + var compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, + parseOptions: parseOptions, + targetFramework: TargetFramework.NetCoreApp); + + CompileAndVerify(compilation1, + expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : +@"C1.get_P1 +C1.get_P2 +C1.get_P3 +", + verify: VerifyOnMonoOrCoreClr); + + var c1 = compilation1.GetTypeByMetadataName("C1"); + + foreach (var p in c1.GetMembers().OfType()) + { + Assert.True(p.GetMethod.IsMetadataVirtual()); + Assert.True(p.GetMethod.IsMetadataFinal); + } + } + } + + [Fact, WorkItem(53565, "https://github.com/dotnet/roslyn/issues/53565")] + public void PartialPropertyImplementation_02() + { + var source1 = +@" +interface I1 +{ + internal int P1 {get; set;} + internal int P2 {get => throw null; set{}} +} + +class C0 : I1 +{ + int I1.P1 {get; set;} +} + +class C1 : C0, I1 +{ + public int P1 + { + get + { + System.Console.WriteLine(""C1.get_P1""); + return 0; + } + } + public int P2 + { + get + { + System.Console.WriteLine(""C1.get_P2""); + return 0; + } + } + + static void Main() + { + I1 x = new C1(); + _ = x.P1; + _ = x.P2; + } +} +"; + var compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, + parseOptions: TestOptions.RegularPreview, + targetFramework: TargetFramework.NetCoreApp); + + CompileAndVerify(compilation1, + expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : +@"C1.get_P1 +C1.get_P2 +", + verify: VerifyOnMonoOrCoreClr); + + var c1 = compilation1.GetTypeByMetadataName("C1"); + + foreach (var p in c1.GetMembers().OfType()) + { + Assert.True(p.GetMethod.IsMetadataVirtual()); + Assert.True(p.GetMethod.IsMetadataFinal); + } + } } } From 725cab5701774c73a721e8c79f9abfbb2741de64 Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Thu, 24 Jun 2021 22:39:32 -0700 Subject: [PATCH 3/3] Follow up on merge from main. --- .../DefaultInterfaceImplementationTests.cs | 524 +++++++++--------- .../UpgradeProject/UpgradeProjectTests.cs | 2 +- 2 files changed, 263 insertions(+), 263 deletions(-) diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs index 7627c5b797339..9e1bc151e8bfb 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/DefaultInterfaceImplementationTests.cs @@ -7251,15 +7251,15 @@ public void M1() targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); compilation1.VerifyDiagnostics( - // (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 'preview' or greater. + // (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()", "9.0", "preview").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.RegularPreview, + 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(); @@ -7289,15 +7289,15 @@ class Test2 : I1 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 'preview' or greater. + // (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", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15) ); ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Internal); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular10, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, Accessibility.Internal)).VerifyDiagnostics(); @@ -7406,9 +7406,9 @@ public virtual void M1() "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal, - // (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 'preview' or greater. + // (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", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 15) ); } @@ -7425,7 +7425,7 @@ private void ValidateMethodModifiers_10_02(string source1, string source2, ValidateMethodModifiersImplicit_10(compilation1.SourceModule, accessibility); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "Test1.M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, accessibility)).VerifyDiagnostics(); @@ -7450,7 +7450,7 @@ private void ValidateMethodModifiers_10_02(string source1, string source2, ValidateMethodModifiersImplicit_10(compilation3.SourceModule, accessibility); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "Test1.M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicit_10(m, accessibility)).VerifyDiagnostics(); @@ -7566,9 +7566,9 @@ public void M1() } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal, - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -7612,9 +7612,9 @@ public virtual void M1() } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal, - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -7663,9 +7663,9 @@ public override void M1() } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal, - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -7714,9 +7714,9 @@ public interface I2 } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.Internal, - // (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 'preview' or greater. + // (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", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -7901,15 +7901,15 @@ static void Main() targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(9, 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.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics(); @@ -7931,15 +7931,15 @@ static void Main() targetFramework: TargetFramework.NetCoreApp); 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 'preview' or greater. + // (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", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.M1()", "Test2.M1()", "9.0", "10.0").WithLocation(2, 15) ); ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics(); @@ -7981,7 +7981,7 @@ static void Main() } "; var compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp, assemblyName: "MethodModifiers_10_11"); @@ -7996,7 +7996,7 @@ static void Main() ValidateMethodModifiersImplicitInTest2_10(compilation3.SourceModule, Accessibility.Internal); compilation3 = CreateCompilation(source2, new[] { compilation2.ToMetadataReference() }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : "M1", verify: VerifyOnMonoOrCoreClr, symbolValidator: (m) => ValidateMethodModifiersImplicitInTest2_10(m, Accessibility.Internal)).VerifyDiagnostics(); @@ -9790,9 +9790,9 @@ public void M1() 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 in C# 9.0. Please use language version 'preview' or greater. + // (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", "preview").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) @@ -9819,7 +9819,7 @@ public void M1() } "; compilation1 = CreateCompilation(source22 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); @@ -9855,7 +9855,7 @@ class Test2 : I1 ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.Protected); compilation3 = CreateCompilation(source22, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); @@ -9928,15 +9928,15 @@ public virtual void M1() 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 in C# 9.0. Please use language version 'preview' or greater. + // (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", "preview").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.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); @@ -9967,9 +9967,9 @@ class Test2 : I1 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 'preview' or greater. + // (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", "preview").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) @@ -9978,7 +9978,7 @@ class Test2 : I1 ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.ProtectedOrInternal); compilation3 = CreateCompilation(source22, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + 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(); @@ -10049,9 +10049,9 @@ public void M1() 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 in C# 9.0. Please use language version 'preview' or greater. + // (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", "preview").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) @@ -10060,7 +10060,7 @@ public void M1() ValidateMethodModifiersImplicit_10(compilation1.SourceModule, Accessibility.ProtectedAndInternal); compilation1 = CreateCompilation(source22 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); @@ -10091,9 +10091,9 @@ class Test2 : I1 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 'preview' or greater. + // (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", "preview").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) @@ -10102,7 +10102,7 @@ class Test2 : I1 ValidateMethodModifiersImplicit_10(compilation3.SourceModule, Accessibility.ProtectedAndInternal); compilation3 = CreateCompilation(source22, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); @@ -10344,9 +10344,9 @@ public void M1() } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.Protected, - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -10386,9 +10386,9 @@ public void M1() } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.ProtectedOrInternal, - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -10428,9 +10428,9 @@ public virtual void M1() } "; ValidateMethodModifiers_10_02(source1, source2, Accessibility.ProtectedAndInternal, - // (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 'preview' or greater. + // (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()", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.M1()", "Test1.M1()", "9.0", "10.0").WithLocation(2, 22) ); } @@ -12726,12 +12726,12 @@ public int P1 ValidatePropertyModifiers_11_01(source1, source2, Accessibility.Internal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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 @@ -12752,7 +12752,7 @@ private void ValidatePropertyModifiers_11_01(string source1, string source2, Acc ValidatePropertyModifiers_11(compilation1.SourceModule, accessibility); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); @@ -12798,7 +12798,7 @@ class Test2 : I1 ValidatePropertyModifiers_11(compilation3.SourceModule, accessibility); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -12910,12 +12910,12 @@ public virtual int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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.get", "Test1.P1.get", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15) ); } @@ -12931,7 +12931,7 @@ private void ValidatePropertyModifiers_11_02(string source1, string source2, ValidatePropertyImplementation_11(compilation1.SourceModule); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -12958,7 +12958,7 @@ private void ValidatePropertyModifiers_11_02(string source1, string source2, ValidatePropertyImplementation_11(compilation3.SourceModule); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -13142,12 +13142,12 @@ public int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -13209,12 +13209,12 @@ public virtual int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -13281,12 +13281,12 @@ public override int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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 'preview' or greater. + 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", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -13353,12 +13353,12 @@ public interface I2 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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 'preview' or greater. + 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", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -13578,12 +13578,12 @@ static void Main() "; ValidatePropertyModifiers_11_10(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -13599,7 +13599,7 @@ private void ValidatePropertyModifiers_11_10(string source1, string source2, ValidatePropertyImplementationByBase_11(compilation1.SourceModule); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -13626,7 +13626,7 @@ private void ValidatePropertyModifiers_11_10(string source1, string source2, ValidatePropertyImplementationByBase_11(compilation3.SourceModule); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -13682,12 +13682,12 @@ static void Main() "; ValidatePropertyModifiers_11_11(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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.set", "Test2.P1.set", "9.0", "preview").WithLocation(11, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(11, 22) ); } @@ -13702,7 +13702,7 @@ private void ValidatePropertyModifiers_11_11(string source1, string source2, compilation2.VerifyDiagnostics(expected); compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp, assemblyName: "PropertyModifiers_11_11"); @@ -16169,9 +16169,9 @@ public int P1 } "; ValidatePropertyModifiers_23(source1, source2, Accessibility.Internal, Accessibility.Public, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15) ); } @@ -16186,7 +16186,7 @@ private void ValidatePropertyModifiers_23(string source1, string source2, Access Validate1(compilation1.SourceModule); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All), - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -16225,7 +16225,7 @@ void Validate1(ModuleSymbol m) compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe.WithMetadataImportOptions(MetadataImportOptions.All), - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -16278,9 +16278,9 @@ public virtual int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15) ); } @@ -16389,9 +16389,9 @@ public int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -16453,9 +16453,9 @@ public virtual int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -16522,9 +16522,9 @@ public override int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -16591,9 +16591,9 @@ public interface I2 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -16748,9 +16748,9 @@ static void Main() "; ValidatePropertyModifiers_11_10(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(2, 22) ); } @@ -16798,9 +16798,9 @@ static void Main() "; ValidatePropertyModifiers_11_11(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(11, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.get", "Test2.P1.get", "9.0", "10.0").WithLocation(11, 22) ); } @@ -16845,9 +16845,9 @@ public int P1 } "; ValidatePropertyModifiers_23(source1, source2, Accessibility.Public, Accessibility.Internal, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15) ); } @@ -16892,9 +16892,9 @@ public virtual int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15) ); } @@ -17003,9 +17003,9 @@ public int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22) ); } @@ -17067,9 +17067,9 @@ public virtual int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22) ); } @@ -17136,9 +17136,9 @@ public override int P1 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22) ); } @@ -17205,9 +17205,9 @@ public interface I2 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 22) ); } @@ -17362,9 +17362,9 @@ static void Main() "; ValidatePropertyModifiers_11_10(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(2, 22) ); } @@ -17412,9 +17412,9 @@ static void Main() "; ValidatePropertyModifiers_11_11(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(11, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.set", "Test2.P1.set", "9.0", "10.0").WithLocation(11, 22) ); } @@ -18216,12 +18216,12 @@ public int P1 ValidatePropertyModifiers_11_01(source1, source2, Accessibility.Protected, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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.get", "Test1.P1.get", "9.0", "preview").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 @@ -18272,12 +18272,12 @@ public int P1 ValidatePropertyModifiers_11_01(source1, source2, Accessibility.ProtectedOrInternal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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.get", "Test1.P1.get", "9.0", "preview").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 @@ -18328,12 +18328,12 @@ public int P1 ValidatePropertyModifiers_11_01(source1, source2, Accessibility.ProtectedAndInternal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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.get", "Test1.P1.get", "9.0", "preview").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 @@ -18382,9 +18382,9 @@ public int P1 } "; ValidatePropertyModifiers_23(source1, source2, Accessibility.Protected, Accessibility.Public, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15) ); } @@ -18429,9 +18429,9 @@ public int P1 } "; ValidatePropertyModifiers_23(source1, source2, Accessibility.ProtectedOrInternal, Accessibility.Public, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.get", "Test1.P1.get", "9.0", "10.0").WithLocation(2, 15) ); } @@ -18476,9 +18476,9 @@ public int 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 in C# 9.0. Please use language version 'preview' or greater. + // (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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.set", "Test1.P1.set", "9.0", "10.0").WithLocation(2, 15) ); } @@ -20300,12 +20300,12 @@ public int this[int x] ValidatePropertyModifiers_11_01(source1, source2, Accessibility.Internal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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 @@ -20354,12 +20354,12 @@ public virtual int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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) ); } @@ -20468,12 +20468,12 @@ public int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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) ); } @@ -20535,12 +20535,12 @@ public virtual int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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) ); } @@ -20607,12 +20607,12 @@ public override int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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 'preview' or greater. + 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", "preview").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) ); } @@ -20679,12 +20679,12 @@ public interface I2 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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 'preview' or greater. + 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", "preview").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) ); } @@ -20839,12 +20839,12 @@ static void Main() "; ValidatePropertyModifiers_11_10(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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) ); } @@ -20892,12 +20892,12 @@ static void Main() "; ValidatePropertyModifiers_11_11(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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].set", "Test2.this[int].set", "9.0", "preview").WithLocation(11, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set", "9.0", "10.0").WithLocation(11, 22) ); } @@ -22699,9 +22699,9 @@ public int this[int x] } "; ValidatePropertyModifiers_23(source1, source2, Accessibility.Internal, Accessibility.Public, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -22746,9 +22746,9 @@ public virtual int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -22857,9 +22857,9 @@ public int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -22921,9 +22921,9 @@ public virtual int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -22990,9 +22990,9 @@ public override int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23059,9 +23059,9 @@ public interface I2 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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) ); } @@ -23216,9 +23216,9 @@ static void Main() "; ValidatePropertyModifiers_11_10(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23266,9 +23266,9 @@ static void Main() "; ValidatePropertyModifiers_11_11(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(11, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].get", "Test2.this[int].get", "9.0", "10.0").WithLocation(11, 22) ); } @@ -23313,9 +23313,9 @@ public int this[int x] } "; ValidatePropertyModifiers_23(source1, source2, Accessibility.Public, Accessibility.Internal, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23360,9 +23360,9 @@ public virtual int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23471,9 +23471,9 @@ public int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23535,9 +23535,9 @@ public virtual int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23604,9 +23604,9 @@ public override int this[int x] "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23673,9 +23673,9 @@ public interface I2 "; ValidatePropertyModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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) ); } @@ -23830,9 +23830,9 @@ static void Main() "; ValidatePropertyModifiers_11_10(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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) ); } @@ -23880,9 +23880,9 @@ static void Main() "; ValidatePropertyModifiers_11_11(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").WithLocation(11, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.this[int].set", "Test2.this[int].set", "9.0", "10.0").WithLocation(11, 22) ); } @@ -25826,12 +25826,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.Internal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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 @@ -25850,7 +25850,7 @@ private void ValidateEventModifiers_11(string source1, string source2, Accessibi Validate1(compilation1.SourceModule); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation1.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -25933,7 +25933,7 @@ class Test2 : I1 Validate1(compilation3.SourceModule); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); Assert.True(compilation3.Assembly.RuntimeSupportsDefaultInterfaceImplementation); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -26007,12 +26007,12 @@ public virtual event System.Action P1 "; ValidateEventModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 15) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 15) ); } @@ -26028,7 +26028,7 @@ private void ValidateEventModifiers_11_02(string source1, string source2, ValidateEventImplementation_11(compilation1.SourceModule); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -26055,7 +26055,7 @@ private void ValidateEventModifiers_11_02(string source1, string source2, ValidateEventImplementation_11(compilation3.SourceModule); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -26239,12 +26239,12 @@ public event System.Action P1 "; ValidateEventModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22) ); } @@ -26307,12 +26307,12 @@ public virtual event System.Action P1 "; ValidateEventModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22) ); } @@ -26381,12 +26381,12 @@ public override event System.Action P1 "; ValidateEventModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22) ); } @@ -26454,12 +26454,12 @@ public interface I2 "; ValidateEventModifiers_11_02(source1, source2, - // (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 'preview' or greater. + // (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", "preview").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 'preview' or greater. + 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", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test1", "I1.P1.add", "Test1.P1.add", "9.0", "10.0").WithLocation(2, 22) ); } @@ -26683,12 +26683,12 @@ static void Main() "; ValidateEventModifiers_11_10(source1, source2, - // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' 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.remove", "Test2.P1.remove", "9.0", "preview").WithLocation(2, 22), - // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.remove", "Test2.P1.remove", "9.0", "10.0").WithLocation(2, 22), + // (2,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' 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.add", "Test2.P1.add", "9.0", "preview").WithLocation(2, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.add", "Test2.P1.add", "9.0", "10.0").WithLocation(2, 22) ); } @@ -26704,7 +26704,7 @@ private void ValidateEventModifiers_11_10(string source1, string source2, ValidateEventImplementationByBase_11(compilation1.SourceModule); compilation1 = CreateCompilation(source2 + source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -26731,7 +26731,7 @@ private void ValidateEventModifiers_11_10(string source1, string source2, ValidateEventImplementationByBase_11(compilation3.SourceModule); compilation3 = CreateCompilation(source2, new[] { reference }, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation3, expectedOutput: !ExecutionConditionUtil.IsMonoOrCoreClr ? null : @@ -26787,12 +26787,12 @@ static void Main() "; ValidateEventModifiers_11_11(source1, source2, - // (12,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + // (12,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.remove'. 'Test2.P1.remove' 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.remove", "Test2.P1.remove", "9.0", "preview").WithLocation(12, 22), - // (12,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.remove", "Test2.P1.remove", "9.0", "10.0").WithLocation(12, 22), + // (12,22): error CS8704: 'Test2' does not implement interface member 'I1.P1.add'. 'Test2.P1.add' 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.add", "Test2.P1.add", "9.0", "preview").WithLocation(12, 22) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("Test2", "I1.P1.add", "Test2.P1.add", "9.0", "10.0").WithLocation(12, 22) ); } @@ -26807,7 +26807,7 @@ private void ValidateEventModifiers_11_11(string source1, string source2, compilation2.VerifyDiagnostics(expected); compilation2 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp, assemblyName: "EventModifiers_11_11"); @@ -28644,12 +28644,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.Protected, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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 @@ -28701,12 +28701,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.ProtectedOrInternal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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 @@ -28758,12 +28758,12 @@ public event System.Action P1 ValidateEventModifiers_11(source1, source2, Accessibility.ProtectedAndInternal, new DiagnosticDescription[] { - // (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 'preview' or greater. + // (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", "9.0", "preview").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 'preview' or greater. + 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", "9.0", "preview").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 @@ -55790,12 +55790,12 @@ static void Main() Assert.Equal("System.String C0.M()", test.FindImplementationForInterfaceMember(i1M).ToTestDisplayString()); compilation1.VerifyDiagnostics( - // (15,19): error CS8704: 'C0' does not implement interface member 'I1.M()'. 'C0.M()' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + // (15,19): error CS8704: 'C0' does not implement interface member 'I1.M()'. 'C0.M()' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater. // public class C0 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.M()", "C0.M()", "9.0", "preview").WithLocation(15, 19) + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.M()", "C0.M()", "9.0", "10.0").WithLocation(15, 19) ); - compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, parseOptions: TestOptions.RegularPreview, targetFramework: TargetFramework.NetCoreApp); + compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); i1M = compilation1.GetMember("I1.M"); c0 = compilation1.GetTypeByMetadataName("C0"); @@ -55826,16 +55826,16 @@ public class C0 : I1 parseOptions: TestOptions.Regular9, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( - // (7,19): error CS8704: 'C0' does not implement interface member 'I1.get_P()'. 'C0.P.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version 'preview' or greater. + // (7,19): error CS8704: 'C0' does not implement interface member 'I1.get_P()'. 'C0.P.get' cannot implicitly implement a non-public member in C# 9.0. Please use language version '10.0' or greater. // public class C0 : I1 - Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.get_P()", "C0.P.get", "9.0", "preview").WithLocation(7, 19), + Diagnostic(ErrorCode.ERR_ImplicitImplementationOfNonPublicInterfaceMember, "I1").WithArguments("C0", "I1.get_P()", "C0.P.get", "9.0", "10.0").WithLocation(7, 19), // (9,28): error CS0686: Accessor 'C0.P.get' cannot implement interface member 'I1.get_P()' for type 'C0'. Use an explicit interface implementation. // public virtual int P { get; } Diagnostic(ErrorCode.ERR_AccessorImplementingMethod, "get").WithArguments("C0.P.get", "I1.get_P()", "C0").WithLocation(9, 28) ); compilation1 = CreateCompilation(source1, options: TestOptions.DebugDll, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); compilation1.VerifyDiagnostics( // (9,28): error CS0686: Accessor 'C0.P.get' cannot implement interface member 'I1.get_P()' for type 'C0'. Use an explicit interface implementation. @@ -61185,7 +61185,7 @@ static void Main() } } "; - foreach (var parseOptions in new[] { TestOptions.Regular8, TestOptions.Regular9, TestOptions.RegularPreview }) + foreach (var parseOptions in new[] { TestOptions.Regular8, TestOptions.Regular9, TestOptions.Regular }) { var compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, parseOptions: parseOptions, @@ -61253,7 +61253,7 @@ static void Main() } "; var compilation1 = CreateCompilation(source1, options: TestOptions.DebugExe, - parseOptions: TestOptions.RegularPreview, + parseOptions: TestOptions.Regular, targetFramework: TargetFramework.NetCoreApp); CompileAndVerify(compilation1, diff --git a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs index 683375c2f7c92..ef4139fe6426c 100644 --- a/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs +++ b/src/EditorFeatures/CSharpTest/Diagnostics/UpgradeProject/UpgradeProjectTests.cs @@ -1068,7 +1068,7 @@ class C1 : [|I1|] public void M01() {} } ", - expected: LanguageVersion.Preview, + expected: LanguageVersion.CSharp10, new CSharpParseOptions(LanguageVersion.CSharp9)); } }