From 1857731401f34016a1d1f7997dee55e588ac73ac Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Mon, 17 Jul 2023 04:33:33 -0700 Subject: [PATCH 1/2] =?UTF-8?q?Warn=20that=20a=20user-defined=20API=20on?= =?UTF-8?q?=20an=20inline=20array=20type=20won=E2=80=99t=20be=20used=20by?= =?UTF-8?q?=20the=20language=20for=20an=20element=20access=20expression?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #68868. --- .../Portable/Binder/Binder_Expressions.cs | 15 +- .../CSharp/Portable/CSharpResources.resx | 18 + .../CSharp/Portable/Errors/ErrorCode.cs | 3 + .../CSharp/Portable/Errors/ErrorFacts.cs | 6 + .../Generated/ErrorFacts.Generated.cs | 3 + .../Symbols/Source/SourceNamedTypeSymbol.cs | 44 ++ .../Portable/xlf/CSharpResources.cs.xlf | 30 ++ .../Portable/xlf/CSharpResources.de.xlf | 30 ++ .../Portable/xlf/CSharpResources.es.xlf | 30 ++ .../Portable/xlf/CSharpResources.fr.xlf | 30 ++ .../Portable/xlf/CSharpResources.it.xlf | 30 ++ .../Portable/xlf/CSharpResources.ja.xlf | 30 ++ .../Portable/xlf/CSharpResources.ko.xlf | 30 ++ .../Portable/xlf/CSharpResources.pl.xlf | 30 ++ .../Portable/xlf/CSharpResources.pt-BR.xlf | 30 ++ .../Portable/xlf/CSharpResources.ru.xlf | 30 ++ .../Portable/xlf/CSharpResources.tr.xlf | 30 ++ .../Portable/xlf/CSharpResources.zh-Hans.xlf | 30 ++ .../Portable/xlf/CSharpResources.zh-Hant.xlf | 30 ++ .../Test/Emit2/Semantics/InlineArrayTests.cs | 442 +++++++++++++++++- .../Test/Syntax/Diagnostics/DiagnosticTest.cs | 3 + 21 files changed, 912 insertions(+), 12 deletions(-) diff --git a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs index d51443f6c6b14..885c8a12b4d70 100644 --- a/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs +++ b/src/Compilers/CSharp/Portable/Binder/Binder_Expressions.cs @@ -9246,11 +9246,7 @@ candidate is PropertySymbol property && if (!candidate.IsStatic && IsAccessible(candidate, syntax, diagnostics) && candidate is MethodSymbol method && - method.OriginalDefinition is var original && - !original.ReturnsVoid && - original.ParameterCount == 2 && - original.Parameters[0] is { Type.SpecialType: SpecialType.System_Int32, RefKind: RefKind.None } && - original.Parameters[1] is { Type.SpecialType: SpecialType.System_Int32, RefKind: RefKind.None }) + MethodHasValidSliceSignature(method)) { makeCall(syntax, receiver, method, out indexerOrSliceAccess, out argumentPlaceholders); lookupResult.Free(); @@ -9289,6 +9285,15 @@ void makeCall(SyntaxNode syntax, BoundExpression receiver, MethodSymbol method, } } + internal static bool MethodHasValidSliceSignature(MethodSymbol method) + { + return method.OriginalDefinition is var original && + !original.ReturnsVoid && + original.ParameterCount == 2 && + original.Parameters[0] is { Type.SpecialType: SpecialType.System_Int32, RefKind: RefKind.None } && + original.Parameters[1] is { Type.SpecialType: SpecialType.System_Int32, RefKind: RefKind.None }; + } + private bool TryBindLengthOrCount( SyntaxNode syntax, BoundValuePlaceholderBase receiverPlaceholder, diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 664633ff34a90..65d8d1b8dd977 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -7682,4 +7682,22 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ Inline array element field cannot be declared required. + + Indexer will not be used for element access expression. + + + Indexer will not be used for element access expression. + + + Slice method will not be used for element access expression. + + + Slice method will not be used for element access expression. + + + Conversion operator will not be used for conversion from expression of the declaring type. + + + Conversion operator will not be used for conversion from expression of the declaring type. + \ No newline at end of file diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs index 145eef352a34c..d9deb5f4acc0a 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorCode.cs @@ -2243,6 +2243,9 @@ internal enum ErrorCode WRN_PrimaryConstructorParameterIsShadowedAndNotPassedToBase = 9179, ERR_InlineArrayRequiredElementField = 9180, + WRN_InlineArrayIndexerNotUsed = 9181, + WRN_InlineArraySliceNotUsed = 9182, + WRN_InlineArrayConversionOperatorNotUsed = 9183, #endregion diff --git a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs index 25c94831616bf..a3f082548f62c 100644 --- a/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs +++ b/src/Compilers/CSharp/Portable/Errors/ErrorFacts.cs @@ -537,6 +537,9 @@ internal static int GetWarningLevel(ErrorCode code) case ErrorCode.WRN_NullabilityMismatchInParameterTypeOnInterceptor: case ErrorCode.WRN_CapturedPrimaryConstructorParameterInFieldInitializer: case ErrorCode.WRN_PrimaryConstructorParameterIsShadowedAndNotPassedToBase: + case ErrorCode.WRN_InlineArrayIndexerNotUsed: + case ErrorCode.WRN_InlineArraySliceNotUsed: + case ErrorCode.WRN_InlineArrayConversionOperatorNotUsed: return 1; default: return 0; @@ -2363,6 +2366,9 @@ internal static bool IsBuildOnlyDiagnostic(ErrorCode code) case ErrorCode.ERR_CollectionLiteralNoTargetType: case ErrorCode.WRN_PrimaryConstructorParameterIsShadowedAndNotPassedToBase: case ErrorCode.ERR_InlineArrayRequiredElementField: + case ErrorCode.WRN_InlineArrayIndexerNotUsed: + case ErrorCode.WRN_InlineArraySliceNotUsed: + case ErrorCode.WRN_InlineArrayConversionOperatorNotUsed: return false; default: // NOTE: All error codes must be explicitly handled in this switch statement diff --git a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs index b8fdf8dba05c0..9f8683570ab1e 100644 --- a/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs +++ b/src/Compilers/CSharp/Portable/Generated/ErrorFacts.Generated.cs @@ -320,6 +320,9 @@ public static bool IsWarning(ErrorCode code) case ErrorCode.WRN_NullabilityMismatchInReturnTypeOnInterceptor: case ErrorCode.WRN_NullabilityMismatchInParameterTypeOnInterceptor: case ErrorCode.WRN_PrimaryConstructorParameterIsShadowedAndNotPassedToBase: + case ErrorCode.WRN_InlineArrayIndexerNotUsed: + case ErrorCode.WRN_InlineArraySliceNotUsed: + case ErrorCode.WRN_InlineArrayConversionOperatorNotUsed: return true; default: return false; diff --git a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs index 3b4803ce96553..f1e5c82442911 100644 --- a/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs +++ b/src/Compilers/CSharp/Portable/Symbols/Source/SourceNamedTypeSymbol.cs @@ -1758,6 +1758,50 @@ protected override void AfterMembersCompletedChecks(BindingDiagnosticBag diagnos { diagnostics.Add(ErrorCode.ERR_InlineArrayRequiredElementField, elementField.TryGetFirstLocation() ?? GetFirstLocation()); } + + if (TryGetInlineArrayElementField() is { TypeWithAnnotations: var elementType }) + { + NamedTypeSymbol? index = null; + NamedTypeSymbol? range = null; + + foreach (PropertySymbol indexer in Indexers) + { + if (indexer.Parameters is [{ Type: { } type }] && + (type.SpecialType == SpecialType.System_Int32 || + type.Equals(index ??= DeclaringCompilation.GetWellKnownType(WellKnownType.System_Index), TypeCompareKind.AllIgnoreOptions) || + type.Equals(range ??= DeclaringCompilation.GetWellKnownType(WellKnownType.System_Range), TypeCompareKind.AllIgnoreOptions))) + { + diagnostics.Add(ErrorCode.WRN_InlineArrayIndexerNotUsed, indexer.TryGetFirstLocation() ?? GetFirstLocation()); + } + } + + foreach (var slice in GetMembers(WellKnownMemberNames.SliceMethodName).OfType()) + { + if (Binder.MethodHasValidSliceSignature(slice)) + { + diagnostics.Add(ErrorCode.WRN_InlineArraySliceNotUsed, slice.TryGetFirstLocation() ?? GetFirstLocation()); + break; + } + } + + NamedTypeSymbol? span = null; + NamedTypeSymbol? readOnlySpan = null; + + foreach (var conversion in GetMembers().OfType()) + { + TypeSymbol returnType = conversion.ReturnType; + TypeSymbol returnTypeOriginalDefinition = returnType.OriginalDefinition; + + if (conversion.ParameterCount == 1 && + conversion.Parameters[0].Type.Equals(this, TypeCompareKind.AllIgnoreOptions) && + (returnTypeOriginalDefinition.Equals(span ??= DeclaringCompilation.GetWellKnownType(WellKnownType.System_Span_T), TypeCompareKind.AllIgnoreOptions) || + returnTypeOriginalDefinition.Equals(readOnlySpan ??= DeclaringCompilation.GetWellKnownType(WellKnownType.System_ReadOnlySpan_T), TypeCompareKind.AllIgnoreOptions)) && + Conversions.HasIdentityConversion(((NamedTypeSymbol)returnTypeOriginalDefinition).Construct(ImmutableArray.Create(elementType)), returnType)) + { + diagnostics.Add(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, conversion.TryGetFirstLocation() ?? GetFirstLocation()); + } + } + } } else { diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 3e9a44df19981..253a1505e48a7 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -2467,6 +2467,36 @@ Použití proměnné v tomto kontextu může vystavit odkazované proměnné mimo rozsah jejich oboru. + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Zachycuje se volání {0} s zachycovačem {1}, ale podpisy se neshodují. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index c08de2ff4bb9c..4ca64bef386a8 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -2467,6 +2467,36 @@ Die Verwendung der Variablen in diesem Kontext kann dazu führen, dass referenzierte Variablen außerhalb ihres Deklarationsbereichs verfügbar gemacht werden. + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Abfangen eines Aufrufs von "{0}" mit Interceptor "{1}", aber die Signaturen stimmen nicht überein. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index b9191cd8fed52..bc299e6302059 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -2467,6 +2467,36 @@ Usar la variable en este contexto puede exponer variables a las que se hace referencia fuera de su ámbito de declaración + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Intercepción de una llamada a '{0}' con el interceptor '{1}', pero las firmas no coinciden. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 23ded8c2890e3..361a064352ab6 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -2467,6 +2467,36 @@ Utiliser la variable dans ce contexte peut exposer des variables de référence en dehors de leur étendue de déclaration + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Interception d'un appel à '{0}' avec l'intercepteur '{1}', mais les signatures ne correspondent pas. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index de9914d5e0599..a5f6e5bf683e6 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -2467,6 +2467,36 @@ L'uso di variabili in questo contesto potrebbe esporre le variabili a cui si fa riferimento al di fuori dell'ambito della dichiarazione + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Intercettazione di una chiamata a '{0}' con l'intercettore '{1}', ma le firme non corrispondono. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 32e50eef4c103..452a88e1e3a8f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -2467,6 +2467,36 @@ このコンテキストでの変数の使用は、参照される変数が宣言のスコープ外に公開される可能性があります + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. インターセプター '{1}' を使用して'{0}' への呼び出しをインターセプトしていますが、署名が一致しません。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index ed5a7ee7d0eeb..d4c940696d3e8 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -2467,6 +2467,36 @@ 이 컨텍스트에서 변수를 사용하면 선언 범위 외부에서 참조된 변수가 노출될 수 있습니다. + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. '{1}' 인터셉터로 '{0}'에 대한 호출을 가로채지만 서명이 일치하지 않습니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index c3b6615701959..d4eb0fa0ec67c 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -2467,6 +2467,36 @@ Nie można używać zmiennej w tym kontekście, ponieważ może uwidaczniać odwoływane zmienne poza ich zakresem deklaracji + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Przechwytywanie wywołania do „{0}” za pomocą interceptora „{1}”, ale sygnatury nie są zgodne. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index db2a6a9c2a9b6..a7ff78a1bdccf 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -2467,6 +2467,36 @@ O uso de variável neste contexto pode expor variáveis referenciadas fora de seu escopo de declaração + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Interceptando uma chamada para '{0}' com interceptador '{1}', mas as assinaturas não coincidem. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 65e2cfa84a857..6a5118f6f9db1 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -2467,6 +2467,36 @@ Использование переменной в этом контексте может представить ссылочные переменные за пределами области их объявления. + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. Перехват вызова ' {0} ' с перехватчиком ' {1} ', но подписи не совпадают. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index aa6f30350a004..9e3c53c66eac7 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -2467,6 +2467,36 @@ Bu bağlamda değişken kullanımı, başvurulan değişkenleri bildirim kapsamının dışında gösterebilir. + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. '{0}' hedefine olan çağrı '{1}' engelleyicisi ile engelleniyor, ancak imzalar eşleşmiyor. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index 21d0770e7bf89..45c8aa3c80139 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -2467,6 +2467,36 @@ 在此上下文中使用变量可能会在变量声明范围以外公开所引用的变量 + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. 正在使用侦听器“{1}”截获对“{0}”的调用,但签名不匹配。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index 791b847d415a3..8120522f76432 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -2467,6 +2467,36 @@ 在此內容中使用變數,可能會將參考的變數公開在其宣告範圍外 + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Conversion operator will not be used for conversion from expression of the declaring type. + Conversion operator will not be used for conversion from expression of the declaring type. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Indexer will not be used for element access expression. + Indexer will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + + + Slice method will not be used for element access expression. + Slice method will not be used for element access expression. + + Intercepting a call to '{0}' with interceptor '{1}', but the signatures do not match. 正在使用攔截器 '{1}' 攔截對 '{0}' 的呼叫,但簽章不相符。 diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs index 624f5531824d8..b1fa18ea30c31 100644 --- a/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs @@ -1906,7 +1906,7 @@ public struct Buffer "; var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80); comp.VerifyDiagnostics( - // (5,25): error CS9179: Inline array element field cannot be declared required. + // (5,25): error CS9180: Inline array element field cannot be declared required. // required public int _element0; Diagnostic(ErrorCode.ERR_InlineArrayRequiredElementField, "_element0").WithLocation(5, 25) ); @@ -7759,7 +7759,11 @@ public T this[int i] "; var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); - var verifier = CompileAndVerify(comp, expectedOutput: "111", verify: Verification.Fails).VerifyDiagnostics(); + var verifier = CompileAndVerify(comp, expectedOutput: "111", verify: Verification.Fails).VerifyDiagnostics( + // (22,14): warning CS9181: Indexer will not be used for element access expression. + // public T this[int i] + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(22, 14) + ); verifier.VerifyIL("Program.M2", @" @@ -7847,7 +7851,10 @@ public T this[int i] comp.VerifyDiagnostics( // (14,37): error CS1913: Member '[^10]' cannot be initialized. It is not a field or property. // static C M2() => new C() { F = {[^10] = 111} }; - Diagnostic(ErrorCode.ERR_MemberCannotBeInitialized, "[^10]").WithArguments("[^10]").WithLocation(14, 37) + Diagnostic(ErrorCode.ERR_MemberCannotBeInitialized, "[^10]").WithArguments("[^10]").WithLocation(14, 37), + // (22,14): warning CS9181: Indexer will not be used for element access expression. + // public T this[int i] + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(22, 14) ); } @@ -16337,7 +16344,11 @@ public struct Buffer10 "; var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); - CompileAndVerify(comp, expectedOutput: "111", verify: Verification.Fails).VerifyDiagnostics(); + CompileAndVerify(comp, expectedOutput: "111", verify: Verification.Fails).VerifyDiagnostics( + // (17,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // public static implicit operator System.ReadOnlySpan(Buffer10 x) => new[] { -111 }; + Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.ReadOnlySpan").WithLocation(17, 37) + ); } [ConditionalFact(typeof(CoreClrOnly))] @@ -16908,7 +16919,11 @@ public T this[int i] "; var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); - var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics(); + var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics( + // (27,14): warning CS9181: Indexer will not be used for element access expression. + // public T this[int i] + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(27, 14) + ); verifier.VerifyIL("Program.M1", @" @@ -16978,7 +16993,11 @@ public T this[int i] "; var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); - var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics(); + var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics( + // (27,14): warning CS9181: Indexer will not be used for element access expression. + // public T this[int i] + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(27, 14) + ); verifier.VerifyIL("Program.M1", @" @@ -17049,7 +17068,14 @@ public T this[int i] "; var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); - var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics(); + var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics( + // (27,14): warning CS9181: Indexer will not be used for element access expression. + // public T this[int i] + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(27, 14), + // (34,29): warning CS9182: Slice method will not be used for element access expression. + // public System.Span Slice(int start, int length) => throw null; + Diagnostic(ErrorCode.WRN_InlineArraySliceNotUsed, "Slice").WithLocation(34, 29) + ); verifier.VerifyIL("Program.M2", @" @@ -20696,5 +20722,407 @@ .locals init (int V_0) comp = CreateCompilation(src + Buffer4Definition, targetFramework: TargetFramework.Net80, options: TestOptions.DebugExe); CompileAndVerify(comp, expectedOutput: "-1 111 112 113 114").VerifyDiagnostics(); } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedIndexer_Warning_01() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + string this[int i] => ""int""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + + comp.VerifyDiagnostics( + // (7,12): warning CS9181: Indexer will not be used for element access expression. + // string this[int i] => "int"; + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) + ); + + CompileAndVerify(comp, expectedOutput: "0").VerifyDiagnostics( + // (7,12): warning CS9181: Indexer will not be used for element access expression. + // string this[int i] => "int"; + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedIndexer_Warning_02() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + string this[System.Index i] => ""index""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[(System.Index)0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + + CompileAndVerify(comp, expectedOutput: "0").VerifyDiagnostics( + // (7,12): warning CS9181: Indexer will not be used for element access expression. + // string this[System.Index i] => "index"; + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedIndexer_Warning_03() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + string this[System.Range i] => ""range""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[..][0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + + CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( + // (7,12): warning CS9181: Indexer will not be used for element access expression. + // string this[System.Range i] => "range"; + Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedIndexer_Warning_04() + { + var src = @" +Buffer4 b = default; +System.Console.WriteLine(b[(nint)0]); + +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public string this[nint i] => ""nint""; +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80); + CompileAndVerify(comp, expectedOutput: "nint").VerifyDiagnostics(); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedIndexer_Warning_05() + { + var src = @" +Buffer4 b = default; +System.Console.WriteLine(b[0]); + +[System.Runtime.CompilerServices.InlineArray(4)] +ref struct Buffer4 +{ + private ref int _element0; + + public string this[int i] => ""int""; +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80); + CompileAndVerify(comp, expectedOutput: "int").VerifyDiagnostics(); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedIndexer_Warning_06() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 : I1 +{ + private int _element0; + + int I1.this[int i] => throw null; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[0]); + } +} + +interface I1 +{ + int this[int x] {get;} +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + CompileAndVerify(comp, expectedOutput: "0").VerifyDiagnostics(); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedSlice_Warning_01() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + int Length => 4; + string Slice(int i, int j) => ""int""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[..][0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + + comp.VerifyDiagnostics( + // (8,12): warning CS9182: Slice method will not be used for element access expression. + // string Slice(int i, int j) => "int"; + Diagnostic(ErrorCode.WRN_InlineArraySliceNotUsed, "Slice").WithLocation(8, 12) + ); + + CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( + // (8,12): warning CS9182: Slice method will not be used for element access expression. + // string Slice(int i, int j) => "int"; + Diagnostic(ErrorCode.WRN_InlineArraySliceNotUsed, "Slice").WithLocation(8, 12) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedSlice_Warning_02() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + int Length => 4; + string Slice(nint i, int j) => ""int""; + string Slice(int i, nint j) => ""int""; + string Slice(int i) => ""int""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[..][0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics(); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_01() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static implicit operator System.Span(Buffer4 b) => throw null; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.Span)b)[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + + comp.VerifyDiagnostics( + // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // public static implicit operator System.Span(Buffer4 b) => throw null; + Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.Span").WithLocation(7, 37) + ); + + CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( + // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // public static implicit operator System.Span(Buffer4 b) => throw null; + Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.Span").WithLocation(7, 37) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_02() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static explicit operator System.ReadOnlySpan(in Buffer4 b) => throw null; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.ReadOnlySpan)b)[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + + comp.VerifyDiagnostics( + // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // public static explicit operator System.ReadOnlySpan(in Buffer4 b) => throw null; + Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.ReadOnlySpan").WithLocation(7, 37) + ); + + CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( + // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // public static explicit operator System.ReadOnlySpan(in Buffer4 b) => throw null; + Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.ReadOnlySpan").WithLocation(7, 37) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_03() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static implicit operator System.ReadOnlySpan(Buffer4 b) => ""span""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.ReadOnlySpan)b)[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + CompileAndVerify(comp, expectedOutput: "s", verify: Verification.Fails).VerifyDiagnostics(); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_04() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static implicit operator System.Span(Buffer4? b) => new [] {1, 2, 3, 4}; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.Span)(Buffer4?)b)[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + CompileAndVerify(comp, expectedOutput: "1", verify: Verification.Fails).VerifyDiagnostics(); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_05() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static implicit operator System.Span?(Buffer4 b) => new [] {1, 2, 3, 4}; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.Span?)b).Value[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + comp.VerifyEmitDiagnostics( + // (7,37): error CS0306: The type 'Span' may not be used as a type argument + // public static implicit operator System.Span?(Buffer4 b) => new [] {1, 2, 3, 4}; + Diagnostic(ErrorCode.ERR_BadTypeArgument, "System.Span?").WithArguments("System.Span").WithLocation(7, 37), + // (12,36): error CS0306: The type 'Span' may not be used as a type argument + // System.Console.WriteLine(((System.Span?)b).Value[0]); + Diagnostic(ErrorCode.ERR_BadTypeArgument, "System.Span?").WithArguments("System.Span").WithLocation(12, 36) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_06() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static implicit operator System.Span(Buffer4 b, int i) => new [] {1, 2, 3, 4}; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.Span)b)[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + comp.VerifyEmitDiagnostics( + // (7,53): error CS1019: Overloadable unary operator expected + // public static implicit operator System.Span(Buffer4 b, int i) => new [] {1, 2, 3, 4}; + Diagnostic(ErrorCode.ERR_OvlUnaryOperatorExpected, "(Buffer4 b, int i)").WithLocation(7, 53) + ); + } + + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedConversion_Warning_07() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 +{ + private int _element0; + + public static implicit operator System.Span() => new [] {1, 2, 3, 4}; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(((System.Span)b)[0]); + } +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + comp.VerifyEmitDiagnostics( + // (7,53): error CS1019: Overloadable unary operator expected + // public static implicit operator System.Span() => new [] {1, 2, 3, 4}; + Diagnostic(ErrorCode.ERR_OvlUnaryOperatorExpected, "()").WithLocation(7, 53) + ); + } } } diff --git a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs index 3789af11e2271..eadd162ebc585 100644 --- a/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs +++ b/src/Compilers/CSharp/Test/Syntax/Diagnostics/DiagnosticTest.cs @@ -309,6 +309,9 @@ public void WarningLevel_2() case ErrorCode.WRN_NullabilityMismatchInParameterTypeOnInterceptor: case ErrorCode.WRN_CapturedPrimaryConstructorParameterInFieldInitializer: case ErrorCode.WRN_PrimaryConstructorParameterIsShadowedAndNotPassedToBase: + case ErrorCode.WRN_InlineArrayIndexerNotUsed: + case ErrorCode.WRN_InlineArraySliceNotUsed: + case ErrorCode.WRN_InlineArrayConversionOperatorNotUsed: Assert.Equal(1, ErrorFacts.GetWarningLevel(errorCode)); break; case ErrorCode.WRN_MainIgnored: From 975fba73d5b4687dd2f9a4dcef3af3ba46fc073b Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Mon, 17 Jul 2023 07:53:34 -0700 Subject: [PATCH 2/2] PR feedback --- .../CSharp/Portable/CSharpResources.resx | 12 ++-- .../Portable/xlf/CSharpResources.cs.xlf | 24 +++---- .../Portable/xlf/CSharpResources.de.xlf | 24 +++---- .../Portable/xlf/CSharpResources.es.xlf | 24 +++---- .../Portable/xlf/CSharpResources.fr.xlf | 24 +++---- .../Portable/xlf/CSharpResources.it.xlf | 24 +++---- .../Portable/xlf/CSharpResources.ja.xlf | 24 +++---- .../Portable/xlf/CSharpResources.ko.xlf | 24 +++---- .../Portable/xlf/CSharpResources.pl.xlf | 24 +++---- .../Portable/xlf/CSharpResources.pt-BR.xlf | 24 +++---- .../Portable/xlf/CSharpResources.ru.xlf | 24 +++---- .../Portable/xlf/CSharpResources.tr.xlf | 24 +++---- .../Portable/xlf/CSharpResources.zh-Hans.xlf | 24 +++---- .../Portable/xlf/CSharpResources.zh-Hant.xlf | 24 +++---- .../Test/Emit2/Semantics/InlineArrayTests.cs | 62 ++++++++++++++----- 15 files changed, 207 insertions(+), 179 deletions(-) diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 65d8d1b8dd977..e0738969eac15 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -7683,21 +7683,21 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ Inline array element field cannot be declared required. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. \ No newline at end of file diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 253a1505e48a7..2bf1b1bd2691d 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 4ca64bef386a8..b6e2ef3c3686b 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index bc299e6302059..6848c741b4d23 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 361a064352ab6..3aa6018da8c2f 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index a5f6e5bf683e6..838c7ab3c09fd 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 452a88e1e3a8f..7be1462ed259d 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index d4c940696d3e8..1d1244e513d89 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index d4eb0fa0ec67c..d5a12280bd4b0 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index a7ff78a1bdccf..5e98993448251 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 6a5118f6f9db1..f24e5431be5f2 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index 9e3c53c66eac7..b13eca47965a3 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index 45c8aa3c80139..b49feb4c82d12 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index 8120522f76432..674f1b96edad9 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -2468,33 +2468,33 @@ - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. - Conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. + Inline array conversion operator will not be used for conversion from expression of the declaring type. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Indexer will not be used for element access expression. - Indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. + Inline array indexer will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. - Slice method will not be used for element access expression. - Slice method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. + Inline array 'Slice' method will not be used for element access expression. diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs index b1fa18ea30c31..6fe78b78dbe6a 100644 --- a/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Semantics/InlineArrayTests.cs @@ -7760,7 +7760,7 @@ public T this[int i] var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); var verifier = CompileAndVerify(comp, expectedOutput: "111", verify: Verification.Fails).VerifyDiagnostics( - // (22,14): warning CS9181: Indexer will not be used for element access expression. + // (22,14): warning CS9181: Inline array indexer will not be used for element access expression. // public T this[int i] Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(22, 14) ); @@ -7852,7 +7852,7 @@ public T this[int i] // (14,37): error CS1913: Member '[^10]' cannot be initialized. It is not a field or property. // static C M2() => new C() { F = {[^10] = 111} }; Diagnostic(ErrorCode.ERR_MemberCannotBeInitialized, "[^10]").WithArguments("[^10]").WithLocation(14, 37), - // (22,14): warning CS9181: Indexer will not be used for element access expression. + // (22,14): warning CS9181: Inline array indexer will not be used for element access expression. // public T this[int i] Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(22, 14) ); @@ -16345,7 +16345,7 @@ public struct Buffer10 var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: "111", verify: Verification.Fails).VerifyDiagnostics( - // (17,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // (17,37): warning CS9183: Inline array conversion operator will not be used for conversion from expression of the declaring type. // public static implicit operator System.ReadOnlySpan(Buffer10 x) => new[] { -111 }; Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.ReadOnlySpan").WithLocation(17, 37) ); @@ -16920,7 +16920,7 @@ public T this[int i] var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics( - // (27,14): warning CS9181: Indexer will not be used for element access expression. + // (27,14): warning CS9181: Inline array indexer will not be used for element access expression. // public T this[int i] Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(27, 14) ); @@ -16994,7 +16994,7 @@ public T this[int i] var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics( - // (27,14): warning CS9181: Indexer will not be used for element access expression. + // (27,14): warning CS9181: Inline array indexer will not be used for element access expression. // public T this[int i] Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(27, 14) ); @@ -17069,10 +17069,10 @@ public T this[int i] var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); var verifier = CompileAndVerify(comp, expectedOutput: "0 111", verify: Verification.Fails).VerifyDiagnostics( - // (27,14): warning CS9181: Indexer will not be used for element access expression. + // (27,14): warning CS9181: Inline array indexer will not be used for element access expression. // public T this[int i] Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(27, 14), - // (34,29): warning CS9182: Slice method will not be used for element access expression. + // (34,29): warning CS9182: Inline array 'Slice' method will not be used for element access expression. // public System.Span Slice(int start, int length) => throw null; Diagnostic(ErrorCode.WRN_InlineArraySliceNotUsed, "Slice").WithLocation(34, 29) ); @@ -20744,13 +20744,13 @@ static void Main() var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics( - // (7,12): warning CS9181: Indexer will not be used for element access expression. + // (7,12): warning CS9181: Inline array indexer will not be used for element access expression. // string this[int i] => "int"; Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) ); CompileAndVerify(comp, expectedOutput: "0").VerifyDiagnostics( - // (7,12): warning CS9181: Indexer will not be used for element access expression. + // (7,12): warning CS9181: Inline array indexer will not be used for element access expression. // string this[int i] => "int"; Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) ); @@ -20777,7 +20777,7 @@ static void Main() var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: "0").VerifyDiagnostics( - // (7,12): warning CS9181: Indexer will not be used for element access expression. + // (7,12): warning CS9181: Inline array indexer will not be used for element access expression. // string this[System.Index i] => "index"; Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) ); @@ -20804,7 +20804,7 @@ static void Main() var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( - // (7,12): warning CS9181: Indexer will not be used for element access expression. + // (7,12): warning CS9181: Inline array indexer will not be used for element access expression. // string this[System.Range i] => "range"; Diagnostic(ErrorCode.WRN_InlineArrayIndexerNotUsed, "this").WithLocation(7, 12) ); @@ -20897,13 +20897,13 @@ static void Main() var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics( - // (8,12): warning CS9182: Slice method will not be used for element access expression. + // (8,12): warning CS9182: Inline array 'Slice' method will not be used for element access expression. // string Slice(int i, int j) => "int"; Diagnostic(ErrorCode.WRN_InlineArraySliceNotUsed, "Slice").WithLocation(8, 12) ); CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( - // (8,12): warning CS9182: Slice method will not be used for element access expression. + // (8,12): warning CS9182: Inline array 'Slice' method will not be used for element access expression. // string Slice(int i, int j) => "int"; Diagnostic(ErrorCode.WRN_InlineArraySliceNotUsed, "Slice").WithLocation(8, 12) ); @@ -20934,6 +20934,34 @@ static void Main() CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics(); } + [ConditionalFact(typeof(CoreClrOnly))] + public void UserDefinedSlice_Warning_03() + { + var src = @" +[System.Runtime.CompilerServices.InlineArray(4)] +struct Buffer4 : I1 +{ + private int _element0; + + int Length => 4; + string I1.Slice(int i, int j) => ""int""; + + static void Main() + { + Buffer4 b = default; + System.Console.WriteLine(b[..][0]); + } +} + +interface I1 +{ + string Slice(int i, int j); +} +"; + var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); + CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics(); + } + [ConditionalFact(typeof(CoreClrOnly))] public void UserDefinedConversion_Warning_01() { @@ -20955,13 +20983,13 @@ static void Main() var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics( - // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // (7,37): warning CS9183: Inline array conversion operator will not be used for conversion from expression of the declaring type. // public static implicit operator System.Span(Buffer4 b) => throw null; Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.Span").WithLocation(7, 37) ); CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( - // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // (7,37): warning CS9183: Inline array conversion operator will not be used for conversion from expression of the declaring type. // public static implicit operator System.Span(Buffer4 b) => throw null; Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.Span").WithLocation(7, 37) ); @@ -20988,13 +21016,13 @@ static void Main() var comp = CreateCompilation(src, targetFramework: TargetFramework.Net80, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics( - // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // (7,37): warning CS9183: Inline array conversion operator will not be used for conversion from expression of the declaring type. // public static explicit operator System.ReadOnlySpan(in Buffer4 b) => throw null; Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.ReadOnlySpan").WithLocation(7, 37) ); CompileAndVerify(comp, expectedOutput: "0", verify: Verification.Fails).VerifyDiagnostics( - // (7,37): warning CS9183: Conversion operator will not be used for conversion from expression of the declaring type. + // (7,37): warning CS9183: Inline array conversion operator will not be used for conversion from expression of the declaring type. // public static explicit operator System.ReadOnlySpan(in Buffer4 b) => throw null; Diagnostic(ErrorCode.WRN_InlineArrayConversionOperatorNotUsed, "System.ReadOnlySpan").WithLocation(7, 37) );