From 2317f234a3303773382b5f5cb5932d3f70d6e640 Mon Sep 17 00:00:00 2001 From: AlekseyTs Date: Tue, 9 Jul 2024 08:49:50 -0700 Subject: [PATCH] Use more precise wording for errors specifying requirements for types that can be used in a `using` statement. Closes #73559. --- ...akeStatementAsynchronousCodeFixProvider.cs | 2 +- .../MakeMethodSynchronousTests.cs | 4 +- .../CSharp/Portable/CSharpResources.resx | 8 +- .../Portable/xlf/CSharpResources.cs.xlf | 16 ++-- .../Portable/xlf/CSharpResources.de.xlf | 16 ++-- .../Portable/xlf/CSharpResources.es.xlf | 16 ++-- .../Portable/xlf/CSharpResources.fr.xlf | 16 ++-- .../Portable/xlf/CSharpResources.it.xlf | 16 ++-- .../Portable/xlf/CSharpResources.ja.xlf | 16 ++-- .../Portable/xlf/CSharpResources.ko.xlf | 16 ++-- .../Portable/xlf/CSharpResources.pl.xlf | 16 ++-- .../Portable/xlf/CSharpResources.pt-BR.xlf | 16 ++-- .../Portable/xlf/CSharpResources.ru.xlf | 16 ++-- .../Portable/xlf/CSharpResources.tr.xlf | 16 ++-- .../Portable/xlf/CSharpResources.zh-Hans.xlf | 16 ++-- .../Portable/xlf/CSharpResources.zh-Hant.xlf | 16 ++-- .../Emit/CodeGen/CodeGenAwaitUsingTests.cs | 22 ++--- .../CodeGen/CodeGenUsingDeclarationTests.cs | 26 +++--- .../CodeGen/CodeGenUsingStatementTests.cs | 32 +++---- .../Test/Emit2/Semantics/OutVarTests.cs | 10 +-- .../Test/Emit3/RefStructInterfacesTests.cs | 7 +- .../IOperationTests_IUsingStatement.cs | 26 +++--- .../IOperationTests_IVariableDeclaration.cs | 6 +- .../Semantic/Semantics/DelegateTypeTests.cs | 6 +- .../Semantic/Semantics/RefEscapingTests.cs | 2 +- .../Semantic/Semantics/SemanticErrorTests.cs | 4 +- .../Semantics/StackAllocInitializerTests.cs | 6 +- .../StackAllocSpanExpressionsTests.cs | 2 +- .../Semantic/Semantics/UsingStatementTests.cs | 86 +++++++++---------- .../Symbols/AnonymousTypesSemanticsTests.cs | 4 +- .../Test/Symbol/Symbols/ConversionTests.cs | 2 +- .../Syntax/Parsing/ParserErrorMessageTests.cs | 2 +- ...ceUsingStatementCodeRefactoringProvider.cs | 2 +- 33 files changed, 233 insertions(+), 234 deletions(-) diff --git a/src/Analyzers/CSharp/CodeFixes/MakeStatementAsynchronous/CSharpMakeStatementAsynchronousCodeFixProvider.cs b/src/Analyzers/CSharp/CodeFixes/MakeStatementAsynchronous/CSharpMakeStatementAsynchronousCodeFixProvider.cs index c490d8e1d7355..618b92e97a284 100644 --- a/src/Analyzers/CSharp/CodeFixes/MakeStatementAsynchronous/CSharpMakeStatementAsynchronousCodeFixProvider.cs +++ b/src/Analyzers/CSharp/CodeFixes/MakeStatementAsynchronous/CSharpMakeStatementAsynchronousCodeFixProvider.cs @@ -32,7 +32,7 @@ public CSharpMakeStatementAsynchronousCodeFixProvider() } // error CS8414: foreach statement cannot operate on variables of type 'IAsyncEnumerable' because 'IAsyncEnumerable' does not contain a public instance definition for 'GetEnumerator'. Did you mean 'await foreach'? - // error CS8418: 'IAsyncDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + // error CS8418: 'IAsyncDisposable': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? public sealed override ImmutableArray FixableDiagnosticIds => ["CS8414", "CS8418"]; public override async Task RegisterCodeFixesAsync(CodeFixContext context) diff --git a/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs b/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs index a1ec1bf721a4f..899e883712fe8 100644 --- a/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs +++ b/src/Analyzers/CSharp/Tests/MakeMethodSynchronous/MakeMethodSynchronousTests.cs @@ -883,7 +883,7 @@ async System.Threading.Tasks.Task MAsync() TestCode = source, ExpectedDiagnostics = { - // /0/Test0.cs(5,22): error CS8410: 'object': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // /0/Test0.cs(5,22): error CS8410: 'object': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. DiagnosticResult.CompilerError("CS8410").WithLocation(0).WithArguments("object"), }, FixedCode = source, @@ -905,7 +905,7 @@ class C } } """, - // /0/Test0.cs(5,16): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // /0/Test0.cs(5,16): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. DiagnosticResult.CompilerError("CS1674").WithLocation(0).WithArguments("object"), """ class C diff --git a/src/Compilers/CSharp/Portable/CSharpResources.resx b/src/Compilers/CSharp/Portable/CSharpResources.resx index 4bbab9340238f..731a68e78ddf2 100644 --- a/src/Compilers/CSharp/Portable/CSharpResources.resx +++ b/src/Compilers/CSharp/Portable/CSharpResources.resx @@ -3119,16 +3119,16 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep Anonymous methods, lambda expressions, query expressions, and local functions inside structs cannot access instance members of 'this'. Consider copying 'this' to a local variable outside the anonymous method, lambda expression, query expression, or local function and using the local instead. - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + '{0}': type used in a using statement must implement 'System.IDisposable'. - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? Parameter {0} must be declared with the '{1}' keyword diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf index 3a2ec07ee38ac..c3f6812976663 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - {0}: typ použitý v asynchronním příkazu using musí být implicitně převoditelný na System.IAsyncDisposable nebo musí implementovat odpovídající metodu DisposeAsync. Měli jste v úmyslu použít using nebo await using? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + {0}: typ použitý v asynchronním příkazu using musí být implicitně převoditelný na System.IAsyncDisposable nebo musí implementovat odpovídající metodu DisposeAsync. Měli jste v úmyslu použít using nebo await using? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - {0}: Typ použitý v příkazu using musí být implicitně převoditelný na System.IDisposable. Neměli jste v úmyslu použít await using místo using? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + {0}: Typ použitý v příkazu using musí být implicitně převoditelný na System.IDisposable. Neměli jste v úmyslu použít await using místo using? @@ -9557,8 +9557,8 @@ Blok catch() po bloku catch (System.Exception e) může zachytit výjimky, kter - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - {0}: Typ použitý v příkazu using musí být implicitně převeditelný na System.IDisposable. + '{0}': type used in a using statement must implement 'System.IDisposable'. + {0}: Typ použitý v příkazu using musí být implicitně převeditelný na System.IDisposable. @@ -13085,8 +13085,8 @@ Pokud chcete odstranit toto varování, můžete místo toho použít /reference - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - {0}: typ použitý v asynchronním příkazu using musí být implicitně převoditelný na System.IAsyncDisposable nebo musí implementovat odpovídající metodu DisposeAsync. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + {0}: typ použitý v asynchronním příkazu using musí být implicitně převoditelný na System.IAsyncDisposable nebo musí implementovat odpovídající metodu DisposeAsync. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf index 0ee3b63361731..5695666f8e949 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - "{0}": Der in einer asynchronen using-Anweisung verwendete Typ muss implizit in "System.IAsyncDisposable" konvertiert werden können oder eine geeignete DisposeAsync-Methode implementieren. Meinten Sie "using" anstelle von "await using"? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + "{0}": Der in einer asynchronen using-Anweisung verwendete Typ muss implizit in "System.IAsyncDisposable" konvertiert werden können oder eine geeignete DisposeAsync-Methode implementieren. Meinten Sie "using" anstelle von "await using"? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - "{0}": Der in einer using-Anweisung verwendete Typ muss implizit in "System.IDisposable" konvertierbar sein. Meinten Sie "await using" anstelle von "using"? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + "{0}": Der in einer using-Anweisung verwendete Typ muss implizit in "System.IDisposable" konvertierbar sein. Meinten Sie "await using" anstelle von "using"? @@ -9557,8 +9557,8 @@ Ein catch()-Block nach einem catch (System.Exception e)-Block kann nicht-CLS-Aus - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - "{0}": Der in einer using-Anweisung verwendete Typ muss implizit in "System.IDisposable" konvertierbar sein. + '{0}': type used in a using statement must implement 'System.IDisposable'. + "{0}": Der in einer using-Anweisung verwendete Typ muss implizit in "System.IDisposable" konvertierbar sein. @@ -13085,8 +13085,8 @@ Um die Warnung zu beheben, können Sie stattdessen /reference verwenden (Einbett - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - "{0}": Der in einer asynchronen using-Anweisung verwendete Typ muss implizit in "System.IAsyncDisposable" konvertiert werden können oder eine geeignete DisposeAsync-Methode implementieren. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + "{0}": Der in einer asynchronen using-Anweisung verwendete Typ muss implizit in "System.IAsyncDisposable" konvertiert werden können oder eine geeignete DisposeAsync-Methode implementieren. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf index 093e50b6953b1..dae68afabfa21 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - "{0}": el tipo usado en una instrucción using asincrónica debe poder convertirse de forma implícita en "System.IAsyncDisposable" o implementar un método "DisposeAsync" adecuado. ¿Quiso decir "using" en lugar de "await using"? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + "{0}": el tipo usado en una instrucción using asincrónica debe poder convertirse de forma implícita en "System.IAsyncDisposable" o implementar un método "DisposeAsync" adecuado. ¿Quiso decir "using" en lugar de "await using"? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - "{0}": el tipo usado en una instrucción using debe poder convertirse implícitamente en "System.IDisposable". ¿Quiso decir "await using" en lugar de "using"? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + "{0}": el tipo usado en una instrucción using debe poder convertirse implícitamente en "System.IDisposable". ¿Quiso decir "await using" en lugar de "using"? @@ -9557,8 +9557,8 @@ Un bloque catch() después de un bloque catch (System.Exception e) puede abarcar - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - "{0}": el tipo usado en una instrucción using debe poder convertirse implícitamente en "System.IDisposable". + '{0}': type used in a using statement must implement 'System.IDisposable'. + "{0}": el tipo usado en una instrucción using debe poder convertirse implícitamente en "System.IDisposable". @@ -13085,8 +13085,8 @@ Para eliminar la advertencia puede usar /reference (establezca la propiedad Embe - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - "{0}": el tipo usado en una instrucción using asincrónica debe poder convertirse de forma implícita en "System.IAsyncDisposable" o implementar un método "DisposeAsync" adecuado. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + "{0}": el tipo usado en una instrucción using asincrónica debe poder convertirse de forma implícita en "System.IAsyncDisposable" o implementar un método "DisposeAsync" adecuado. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf index 02dd4a9926a49..52b9509a74721 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}' : le type utilisé dans une instruction using asynchrone doit être implicitement convertible en 'System.IAsyncDisposable' ou doit implémenter une méthode 'DisposeAsync' appropriée. Est-ce qu'il ne s'agit pas plutôt de 'using' au lieu de 'await using' ? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}' : le type utilisé dans une instruction using asynchrone doit être implicitement convertible en 'System.IAsyncDisposable' ou doit implémenter une méthode 'DisposeAsync' appropriée. Est-ce qu'il ne s'agit pas plutôt de 'using' au lieu de 'await using' ? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}' : le type utilisé dans une instruction using doit être implicitement convertible en 'System.IDisposable'. Est-ce qu'il ne s'agit pas plutôt de 'await using' au lieu de 'using' ? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}' : le type utilisé dans une instruction using doit être implicitement convertible en 'System.IDisposable'. Est-ce qu'il ne s'agit pas plutôt de 'await using' au lieu de 'using' ? @@ -9557,8 +9557,8 @@ Un bloc catch() après un bloc catch (System.Exception e) peut intercepter des e - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}' : le type utilisé dans une instruction using doit être implicitement convertible en 'System.IDisposable'. + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}' : le type utilisé dans une instruction using doit être implicitement convertible en 'System.IDisposable'. @@ -13085,8 +13085,8 @@ Pour supprimer l'avertissement, vous pouvez utiliser la commande /reference (dé - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}' : le type utilisé dans une instruction using asynchrone doit être implicitement convertible en 'System.IAsyncDisposable' ou doit implémenter une méthode 'DisposeAsync' appropriée. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}' : le type utilisé dans une instruction using asynchrone doit être implicitement convertible en 'System.IAsyncDisposable' ou doit implémenter une méthode 'DisposeAsync' appropriée. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf index cf4f068e659ba..4cce5c7c8c415 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.it.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}': il tipo usato in un'istruzione using asincrona deve essere convertibile in modo implicito in 'System.IAsyncDisposable' o implementare un metodo 'DisposeAsync' adatto. Si intendeva 'using' invece di 'await using'? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': il tipo usato in un'istruzione using asincrona deve essere convertibile in modo implicito in 'System.IAsyncDisposable' o implementare un metodo 'DisposeAsync' adatto. Si intendeva 'using' invece di 'await using'? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': il tipo usato in un'istruzione using deve essere convertibile in modo implicito in 'System.IDisposable'. Si intendeva 'await using' invece di 'using'? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': il tipo usato in un'istruzione using deve essere convertibile in modo implicito in 'System.IDisposable'. Si intendeva 'await using' invece di 'using'? @@ -9557,8 +9557,8 @@ Un blocco catch() dopo un blocco catch (System.Exception e) può rilevare eccezi - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}': il tipo usato in un'istruzione using deve essere convertibile in modo implicito in 'System.IDisposable'. + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}': il tipo usato in un'istruzione using deve essere convertibile in modo implicito in 'System.IDisposable'. @@ -13085,8 +13085,8 @@ Per rimuovere l'avviso, è invece possibile usare /reference (impostare la propr - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': il tipo usato in un'istruzione using asincrona deve essere convertibile in modo implicito in 'System.IAsyncDisposable' o implementare un metodo 'DisposeAsync' adatto. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': il tipo usato in un'istruzione using asincrona deve essere convertibile in modo implicito in 'System.IAsyncDisposable' o implementare un metodo 'DisposeAsync' adatto. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf index 44abc7890aa60..12dc2fa520d19 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ja.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}': 非同期 using ステートメントで使用される型は、暗黙的に 'System.IAsyncDisposable' に変換可能であるか、適切な 'DisposeAsync' メソッドを実装する必要があります。'await using' ではなく 'using' ですか? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': 非同期 using ステートメントで使用される型は、暗黙的に 'System.IAsyncDisposable' に変換可能であるか、適切な 'DisposeAsync' メソッドを実装する必要があります。'await using' ではなく 'using' ですか? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': using ステートメントで使用される型は、暗黙的に 'System.IDisposable' への変換が可能でなければなりません。'using' ではなく 'await using' ですか? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': using ステートメントで使用される型は、暗黙的に 'System.IDisposable' への変換が可能でなければなりません。'using' ではなく 'await using' ですか? @@ -9557,8 +9557,8 @@ AssemblyInfo.cs ファイルで RuntimeCompatibilityAttribute が false に設 - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}': using ステートメントで使用される型は、暗黙的に 'System.IDisposable' への変換が可能でなければなりません。 + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}': using ステートメントで使用される型は、暗黙的に 'System.IDisposable' への変換が可能でなければなりません。 @@ -13085,8 +13085,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': 非同期 using ステートメントで使用される型は、暗黙的に 'System.IAsyncDisposable' に変換可能であるか、適切な 'DisposeAsync' メソッドを実装する必要があります。 + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': 非同期 using ステートメントで使用される型は、暗黙的に 'System.IAsyncDisposable' に変換可能であるか、適切な 'DisposeAsync' メソッドを実装する必要があります。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf index 0fd39c2664310..10df20403fdee 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ko.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}': 비동기 using 문에 사용된 형식은 암시적으로 'System.IAsyncDisposable'로 변환할 수 있거나 적합한 'DisposeAsync' 메서드를 구현해야 합니다. 'await using' 대신 'using'을 사용하시겠습니까? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': 비동기 using 문에 사용된 형식은 암시적으로 'System.IAsyncDisposable'로 변환할 수 있거나 적합한 'DisposeAsync' 메서드를 구현해야 합니다. 'await using' 대신 'using'을 사용하시겠습니까? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': using 문에 사용된 형식은 암시적으로 'System.IDisposable'로 변환할 수 있어야 합니다. 'using' 대신 'await using'을 사용하시겠습니까? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': using 문에 사용된 형식은 암시적으로 'System.IDisposable'로 변환할 수 있어야 합니다. 'using' 대신 'await using'을 사용하시겠습니까? @@ -9557,8 +9557,8 @@ catch (System.Exception e) 블록 뒤의 catch() 블록은 RuntimeCompatibilityA - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}': using 문에 사용된 형식은 암시적으로 'System.IDisposable'로 변환할 수 있어야 합니다. + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}': using 문에 사용된 형식은 암시적으로 'System.IDisposable'로 변환할 수 있어야 합니다. @@ -13085,8 +13085,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': 비동기 using 문에 사용된 형식은 암시적으로 'System.IAsyncDisposable'로 변환할 수 있거나 적합한 'DisposeAsync' 메서드를 구현해야 합니다. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': 비동기 using 문에 사용된 형식은 암시적으로 'System.IAsyncDisposable'로 변환할 수 있거나 적합한 'DisposeAsync' 메서드를 구현해야 합니다. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf index 6a89a80d1283d..7f6bee79ead71 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pl.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - „{0}”: Typ użyty w asynchronicznej instrukcji using musi być jawnie konwertowalny na typ „System.IAsyncDisposable” lub musi implementować odpowiednią metodę „DisposeAsync”. Czy chodziło Ci o użycie instrukcji „using”, a nie „await using”? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + „{0}”: Typ użyty w asynchronicznej instrukcji using musi być jawnie konwertowalny na typ „System.IAsyncDisposable” lub musi implementować odpowiednią metodę „DisposeAsync”. Czy chodziło Ci o użycie instrukcji „using”, a nie „await using”? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - „{0}”: typ użyty w instrukcji using musi umożliwiać niejawną konwersję na interfejs „System.IDisposable”. Czy chodziło Ci o instrukcję „await using”, a nie „using”? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + „{0}”: typ użyty w instrukcji using musi umożliwiać niejawną konwersję na interfejs „System.IDisposable”. Czy chodziło Ci o instrukcję „await using”, a nie „using”? @@ -9557,8 +9557,8 @@ Blok catch() po bloku catch (System.Exception e) może przechwytywać wyjątki n - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - „{0}”: typ użyty w instrukcji using musi umożliwiać niejawną konwersję na interfejs „System.IDisposable”. + '{0}': type used in a using statement must implement 'System.IDisposable'. + „{0}”: typ użyty w instrukcji using musi umożliwiać niejawną konwersję na interfejs „System.IDisposable”. @@ -13085,8 +13085,8 @@ Aby usunąć ostrzeżenie, możesz zamiast tego użyć opcji /reference (ustaw w - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - „{0}”: Typ użyty w asynchronicznej instrukcji using musi być jawnie konwertowalny na typ „System.IAsyncDisposable” lub musi implementować odpowiednią metodę „DisposeAsync”. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + „{0}”: Typ użyty w asynchronicznej instrukcji using musi być jawnie konwertowalny na typ „System.IAsyncDisposable” lub musi implementować odpowiednią metodę „DisposeAsync”. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf index 1abc35ae01710..1076c3e8a4db1 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.pt-BR.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}': o tipo usado em uma instrução using assíncrona deve ser implicitamente conversível em 'System.IAsyncDisposable' ou implementar um método 'DisposeAsync' adequado. Você quis dizer 'using' em vez de 'await using'? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': o tipo usado em uma instrução using assíncrona deve ser implicitamente conversível em 'System.IAsyncDisposable' ou implementar um método 'DisposeAsync' adequado. Você quis dizer 'using' em vez de 'await using'? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': o tipo usado em uma instrução using deve ser implicitamente conversível em 'System.IDisposable'. Você quis dizer 'await using' em vez de 'using'? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': o tipo usado em uma instrução using deve ser implicitamente conversível em 'System.IDisposable'. Você quis dizer 'await using' em vez de 'using'? @@ -9557,8 +9557,8 @@ Um bloco catch() depois de um bloco catch (System.Exception e) poderá capturar - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}': o tipo usado em uma instrução using deve ser implicitamente conversível em 'System.IDisposable'. + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}': o tipo usado em uma instrução using deve ser implicitamente conversível em 'System.IDisposable'. @@ -13085,8 +13085,8 @@ Para incorporar informações de tipo de interoperabilidade para os dois assembl - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': o tipo usado em uma instrução using assíncrona deve ser implicitamente conversível em 'System.IAsyncDisposable' ou implementar um método 'DisposeAsync' adequado. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': o tipo usado em uma instrução using assíncrona deve ser implicitamente conversível em 'System.IAsyncDisposable' ou implementar um método 'DisposeAsync' adequado. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf index 0f878f0bb0162..2ec61069b3871 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.ru.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - "{0}": тип, используемый в асинхронном операторе using, должен допускать неявное преобразование в тип "System.IAsyncDisposable" или реализовывать подходящий метод "DisposeAsync". Возможно, вы имели в виду "using", а не "await using"? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + "{0}": тип, используемый в асинхронном операторе using, должен допускать неявное преобразование в тип "System.IAsyncDisposable" или реализовывать подходящий метод "DisposeAsync". Возможно, вы имели в виду "using", а не "await using"? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - "{0}": тип, использованный в операторе using, должен иметь возможность неявного преобразования в System.IDisposable. Вы хотели использовать "await using" вместо "using"? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + "{0}": тип, использованный в операторе using, должен иметь возможность неявного преобразования в System.IDisposable. Вы хотели использовать "await using" вместо "using"? @@ -9558,8 +9558,8 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - "{0}": тип, использованный в операторе using, должен иметь возможность неявного преобразования в System.IDisposable. + '{0}': type used in a using statement must implement 'System.IDisposable'. + "{0}": тип, использованный в операторе using, должен иметь возможность неявного преобразования в System.IDisposable. @@ -13086,8 +13086,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - "{0}": тип, используемый в асинхронном операторе using, должен допускать неявное преобразование в тип "System.IAsyncDisposable" или реализовывать подходящий метод "DisposeAsync". + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + "{0}": тип, используемый в асинхронном операторе using, должен допускать неявное преобразование в тип "System.IAsyncDisposable" или реализовывать подходящий метод "DisposeAsync". diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf index 91cfb2163911b..689da88f08597 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.tr.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}': Asenkron bir using deyiminde kullanılan tür örtük olarak 'System.IAsyncDisposable' arabirimine dönüştürebilir olmalı veya uygun bir 'DisposeAsync' metodunu uygulamalıdır. 'await using' yerine 'using' mi kullanmak istediniz? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': Asenkron bir using deyiminde kullanılan tür örtük olarak 'System.IAsyncDisposable' arabirimine dönüştürebilir olmalı veya uygun bir 'DisposeAsync' metodunu uygulamalıdır. 'await using' yerine 'using' mi kullanmak istediniz? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': using deyiminde kullanılan tür örtük olarak 'System.IDisposable' arabirimine dönüştürülebilir olmalıdır. 'using' yerine 'await using' mi kullanmak istediniz? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': using deyiminde kullanılan tür örtük olarak 'System.IDisposable' arabirimine dönüştürülebilir olmalıdır. 'using' yerine 'await using' mi kullanmak istediniz? @@ -9557,8 +9557,8 @@ RuntimeCompatibilityAttribute AssemblyInfo.cs dosyasında false olarak ayarlanm - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}': using deyiminde kullanılan tür örtük olarak 'System.IDisposable' arabirimine dönüştürülebilir olmalıdır. + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}': using deyiminde kullanılan tür örtük olarak 'System.IDisposable' arabirimine dönüştürülebilir olmalıdır. @@ -13085,8 +13085,8 @@ Uyarıyı kaldırmak için, /reference kullanabilirsiniz (Birlikte Çalışma T - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': Asenkron bir using deyiminde kullanılan tür örtük olarak 'System.IAsyncDisposable' arabirimine dönüştürebilir olmalı veya uygun bir 'DisposeAsync' metodunu uygulamalıdır. + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': Asenkron bir using deyiminde kullanılan tür örtük olarak 'System.IAsyncDisposable' arabirimine dönüştürebilir olmalı veya uygun bir 'DisposeAsync' metodunu uygulamalıdır. diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf index fa7207eaea1d3..bd92af03f8c38 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hans.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - “{0}”: 异步 using 语句中使用的类型必须可隐式转换为 "System.IAsyncDisposable" 或实现适用的 "DisposeAsync" 方法。是否希望使用 "using" 而非 "await using"? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + “{0}”: 异步 using 语句中使用的类型必须可隐式转换为 "System.IAsyncDisposable" 或实现适用的 "DisposeAsync" 方法。是否希望使用 "using" 而非 "await using"? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - “{0}”: using 语句中使用的类型必须可隐式转换为 "System.IDisposable"。是否希望使用 "await using" 而非 "using"? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + “{0}”: using 语句中使用的类型必须可隐式转换为 "System.IDisposable"。是否希望使用 "await using" 而非 "using"? @@ -9557,8 +9557,8 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - “{0}”: using 语句中使用的类型必须可隐式转换为“System.IDisposable” + '{0}': type used in a using statement must implement 'System.IDisposable'. + “{0}”: using 语句中使用的类型必须可隐式转换为“System.IDisposable” @@ -13085,8 +13085,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - “{0}”: 异步 using 语句中使用的类型必须可隐式转换为 "System.IAsyncDisposable" 或实现适用的 "DisposeAsync" 方法。 + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + “{0}”: 异步 using 语句中使用的类型必须可隐式转换为 "System.IAsyncDisposable" 或实现适用的 "DisposeAsync" 方法。 diff --git a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf index d3dc1ba8ed18b..260ac89b0aa04 100644 --- a/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf +++ b/src/Compilers/CSharp/Portable/xlf/CSharpResources.zh-Hant.xlf @@ -1448,13 +1448,13 @@ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? - '{0}': 在非同步 using 陳述式中使用的類型,必須可隱含地轉換為 'System.IAsyncDisposable' 或實作合適的 'DisposeAsync' 方法。您指的是否為 'using',而非 'await using'? + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. Did you mean 'using' rather than 'await using'? + '{0}': 在非同步 using 陳述式中使用的類型,必須可隱含地轉換為 'System.IAsyncDisposable' 或實作合適的 'DisposeAsync' 方法。您指的是否為 'using',而非 'await using'? - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? - '{0}': using 陳述式中使用的類型必須可以隱含轉換為 'System.IDisposable'。您指的是 'await using' 而不是 'using' 嗎? + '{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + '{0}': using 陳述式中使用的類型必須可以隱含轉換為 'System.IDisposable'。您指的是 'await using' 而不是 'using' 嗎? @@ -9557,8 +9557,8 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep - '{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. - '{0}': using 陳述式中使用的類型必須可以隱含轉換為 'System.IDisposable'。 + '{0}': type used in a using statement must implement 'System.IDisposable'. + '{0}': using 陳述式中使用的類型必須可以隱含轉換為 'System.IDisposable'。 @@ -13085,8 +13085,8 @@ To remove the warning, you can use /reference instead (set the Embed Interop Typ - '{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. - '{0}': 在非同步 using 陳述式中使用的類型,必須可隱含地轉換為 'System.IAsyncDisposable' 或實作合適的 'DisposeAsync' 方法。 + '{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + '{0}': 在非同步 using 陳述式中使用的類型,必須可隱含地轉換為 'System.IAsyncDisposable' 或實作合適的 'DisposeAsync' 方法。 diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAwaitUsingTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAwaitUsingTests.cs index f1511be7c6bb4..f72056285c0e4 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAwaitUsingTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenAwaitUsingTests.cs @@ -601,10 +601,10 @@ async System.Threading.Tasks.Task M() "; var comp = CreateCompilationWithTasksExtensions(source); comp.VerifyDiagnostics( - // (6,22): error CS8410: 'C': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (6,22): error CS8410: 'C': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (new C()) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "new C()").WithArguments("C").WithLocation(6, 22), - // (9,22): error CS8410: 'C': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (9,22): error CS8410: 'C': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (var x = new C()) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "var x = new C()").WithArguments("C").WithLocation(9, 22) ); @@ -634,13 +634,13 @@ System.Threading.Tasks.Task M() // (6,9): error CS4032: The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task>'. // await using (new C()) Diagnostic(ErrorCode.ERR_BadAwaitWithoutAsyncMethod, "await").WithArguments("System.Threading.Tasks.Task").WithLocation(6, 9), - // (6,22): error CS8410: 'C': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (6,22): error CS8410: 'C': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (new C()) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "new C()").WithArguments("C").WithLocation(6, 22), // (9,9): error CS4032: The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task>'. // await using (var x = new C()) Diagnostic(ErrorCode.ERR_BadAwaitWithoutAsyncMethod, "await").WithArguments("System.Threading.Tasks.Task").WithLocation(9, 9), - // (9,22): error CS8410: 'C': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (9,22): error CS8410: 'C': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (var x = new C()) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "var x = new C()").WithArguments("C").WithLocation(9, 22), // (11,20): error CS0029: Cannot implicitly convert type 'int' to 'System.Threading.Tasks.Task' @@ -670,10 +670,10 @@ int M() var comp = CreateCompilationWithMscorlib46(source); comp.MakeTypeMissing(SpecialType.System_IDisposable); comp.VerifyEmitDiagnostics( - // (6,16): error CS1674: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'C': type used in a using statement must implement 'System.IDisposable'. // using (new C()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "new C()").WithArguments("C").WithLocation(6, 16), - // (9,16): error CS1674: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (9,16): error CS1674: 'C': type used in a using statement must implement 'System.IDisposable'. // using (var x = new C()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var x = new C()").WithArguments("C").WithLocation(9, 16) ); @@ -930,7 +930,7 @@ public System.Threading.Tasks.ValueTask DisposeAsync() "; var comp = CreateCompilationWithTasksExtensions(new[] { source, IAsyncDisposableDefinition }); comp.VerifyDiagnostics( - // (6,16): error CS8418: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'? + // (6,16): error CS8418: 'C': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'? // using (var x = new C()) Diagnostic(ErrorCode.ERR_NoConvToIDispWrongAsync, "var x = new C()").WithArguments("C").WithLocation(6, 16) ); @@ -955,7 +955,7 @@ public System.Threading.Tasks.ValueTask DisposeAsync() "; var comp = CreateCompilationWithTasksExtensions(new[] { source, IAsyncDisposableDefinition }); comp.VerifyDiagnostics( - // (6,16): error CS8418: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using'? + // (6,16): error CS8418: 'C': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using'? // using (new C()) Diagnostic(ErrorCode.ERR_NoConvToIDispWrongAsync, "new C()").WithArguments("C").WithLocation(6, 16) ); @@ -2665,7 +2665,7 @@ private System.Threading.Tasks.ValueTask DisposeAsync() "; var comp = CreateCompilationWithTasksExtensions(new[] { source, IAsyncDisposableDefinition }); comp.VerifyDiagnostics( - // 0.cs(6,22): error CS8410: 'C': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // 0.cs(6,22): error CS8410: 'C': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (var x = new C()) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "var x = new C()").WithArguments("C").WithLocation(6, 22)); } @@ -3075,7 +3075,7 @@ public void Dispose() var comp = CreateCompilation(source); comp.MakeTypeMissing(SpecialType.System_IDisposable); comp.VerifyDiagnostics( - // source(2,8): error CS1674: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // source(2,8): error CS1674: 'C': type used in a using statement must implement 'System.IDisposable'. // using (new C()) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "new C()").WithArguments("C").WithLocation(2, 8) ); @@ -3589,7 +3589,7 @@ public static ValueTask DisposeAsync(this IEnumerable objects) """; var comp = CreateCompilationWithTasksExtensions([source, IAsyncDisposableDefinition]); comp.VerifyEmitDiagnostics( - // (5,1): error CS8410: 'Class1': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (5,1): error CS8410: 'Class1': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using var x = new Class1(); Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "await using var x = new Class1();").WithArguments("Class1").WithLocation(5, 1)); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingDeclarationTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingDeclarationTests.cs index 7c29ca0f33e1a..dfefc44fa16b4 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingDeclarationTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingDeclarationTests.cs @@ -815,7 +815,7 @@ static void Main(string[] args) var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (17,13): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (17,13): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using S1 s1 = new S1(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using S1 s1 = new S1();").WithArguments("S1").WithLocation(17, 13) ); @@ -1445,7 +1445,7 @@ void M() """; var comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (5,9): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (5,9): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using const var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using const var obj = new object();").WithArguments("object").WithLocation(5, 9), // (5,15): error CS9229: Modifiers cannot be placed on using declarations @@ -1457,7 +1457,7 @@ void M() """; comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (1,1): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (1,1): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using const var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using const var obj = new object();").WithArguments("object").WithLocation(1, 1), // (1,7): error CS9229: Modifiers cannot be placed on using declarations @@ -1502,7 +1502,7 @@ public void ModifiersInUsingLocalDeclarations_Const_Async() Diagnostic(ErrorCode.WRN_InvalidMainSig, "await using const var obj = new object();").WithArguments("").WithLocation(1, 1), // error CS5001: Program does not contain a static 'Main' method suitable for an entry point Diagnostic(ErrorCode.ERR_NoEntryPoint).WithLocation(1, 1), - // (1,1): error CS8410: 'object': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (1,1): error CS8410: 'object': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using const var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "await using const var obj = new object();").WithArguments("object").WithLocation(1, 1), // (1,13): error CS9229: Modifiers cannot be placed on using declarations @@ -1667,7 +1667,7 @@ void M() """; var comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (5,9): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (5,9): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using readonly var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using readonly var obj = new object();").WithArguments("object").WithLocation(5, 9), // (5,15): error CS9229: Modifiers cannot be placed on using declarations @@ -1679,7 +1679,7 @@ void M() """; comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (1,1): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (1,1): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using readonly var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using readonly var obj = new object();").WithArguments("object").WithLocation(1, 1), // (1,7): error CS9229: Modifiers cannot be placed on using declarations @@ -1725,7 +1725,7 @@ void M() """; var comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (5,9): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (5,9): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using static var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using static var obj = new object();").WithArguments("object").WithLocation(5, 9), // (5,15): error CS9229: Modifiers cannot be placed on using declarations @@ -1737,7 +1737,7 @@ void M() """; comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (1,1): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (1,1): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using static var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using static var obj = new object();").WithArguments("object").WithLocation(1, 1), // (1,7): error CS9229: Modifiers cannot be placed on using declarations @@ -1783,7 +1783,7 @@ void M() """; var comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (5,9): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (5,9): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using volatile var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using volatile var obj = new object();").WithArguments("object").WithLocation(5, 9), // (5,15): error CS9229: Modifiers cannot be placed on using declarations @@ -1795,7 +1795,7 @@ void M() """; comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (1,1): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (1,1): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using volatile var obj = new object(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using volatile var obj = new object();").WithArguments("object").WithLocation(1, 1), // (1,7): error CS9229: Modifiers cannot be placed on using declarations @@ -1873,7 +1873,7 @@ void M() """; var comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (6,9): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,9): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using ref object y = ref x; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using ref object y = ref x;").WithArguments("object").WithLocation(6, 9), // (6,15): error CS1073: Unexpected token 'ref' @@ -1886,7 +1886,7 @@ void M() """; comp = CreateCompilation(source); comp.VerifyEmitDiagnostics( - // (2,1): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (2,1): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using ref object y = ref x; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using ref object y = ref x;").WithArguments("object").WithLocation(2, 1), // (2,7): error CS1073: Unexpected token 'ref' @@ -1902,7 +1902,7 @@ void M() // (2,8): error CS1073: Unexpected token 'ref' // using (ref object y = ref x) { } Diagnostic(ErrorCode.ERR_UnexpectedToken, "ref").WithArguments("ref").WithLocation(2, 8), - // (2,8): error CS1674: 'object': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (2,8): error CS1674: 'object': type used in a using statement must implement 'System.IDisposable'. // using (ref object y = ref x) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "ref object y = ref x").WithArguments("object").WithLocation(2, 8)); } diff --git a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs index a0775de65acd8..aff1ebe7dca23 100644 --- a/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs +++ b/src/Compilers/CSharp/Test/Emit/CodeGen/CodeGenUsingStatementTests.cs @@ -1153,7 +1153,7 @@ static void Main() }"; var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (17,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (17,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(17, 16) ); @@ -1235,7 +1235,7 @@ static void Main() }"; var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15) ); @@ -1265,7 +1265,7 @@ static void Main() }"; var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15) ); @@ -1426,10 +1426,10 @@ public static void TestUsing() } "; CreateCompilation(source).VerifyDiagnostics( - // (13,16): error CS1674: 'T': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (13,16): error CS1674: 'T': type used in a using statement must implement 'System.IDisposable'. // using (val) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "val").WithArguments("T"), - // (24,16): error CS1674: 'T': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (24,16): error CS1674: 'T': type used in a using statement must implement 'System.IDisposable'. // using (T disp = new T()) // Invalid Diagnostic(ErrorCode.ERR_NoConvToIDisp, "T disp = new T()").WithArguments("T")); } @@ -1484,7 +1484,7 @@ public void Dispose() } "; CreateCompilation(source).VerifyDiagnostics( - // (7,16): error CS1674: 'Program.MyManagedClass': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (7,16): error CS1674: 'Program.MyManagedClass': type used in a using statement must implement 'System.IDisposable'. // using (res) // Invalid Diagnostic(ErrorCode.ERR_NoConvToIDisp, "res").WithArguments("Program.MyManagedClass").WithLocation(7, 16) ); @@ -1511,7 +1511,7 @@ public void Dispose() } "; CreateCompilation(source).VerifyDiagnostics( - // (7,16): error CS1674: 'Program.MyManagedClass': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (7,16): error CS1674: 'Program.MyManagedClass': type used in a using statement must implement 'System.IDisposable'. // using (res) // Invalid Diagnostic(ErrorCode.ERR_NoConvToIDisp, "res").WithArguments("Program.MyManagedClass").WithLocation(7, 16) ); @@ -2730,13 +2730,13 @@ static void Main(string[] args) } "; CreateCompilation(source).VerifyDiagnostics( - // (6,16): error CS1674: 'lambda expression': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'lambda expression': type used in a using statement must implement 'System.IDisposable'. // using (x => x) // err Diagnostic(ErrorCode.ERR_NoConvToIDisp, "x => x").WithArguments("lambda expression"), - // (9,16): error CS1674: 'lambda expression': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (9,16): error CS1674: 'lambda expression': type used in a using statement must implement 'System.IDisposable'. // using (() => { }) // err Diagnostic(ErrorCode.ERR_NoConvToIDisp, "() => { }").WithArguments("lambda expression"), - // (12,16): error CS1674: 'lambda expression': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (12,16): error CS1674: 'lambda expression': type used in a using statement must implement 'System.IDisposable'. // using ((int @int) => { return @int; }) // err Diagnostic(ErrorCode.ERR_NoConvToIDisp, "(int @int) => { return @int; }").WithArguments("lambda expression")); } @@ -2770,19 +2770,19 @@ static void Main(string[] args) } "; CreateCompilation(source).VerifyDiagnostics( - // (6,16): error CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (var a = new { }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var a = new { }").WithArguments(""), - // (9,16): error CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (9,16): error CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (var b = new { p1 = 10 }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var b = new { p1 = 10 }").WithArguments(""), - // (12,16): error CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (12,16): error CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (var c = new { p1 = 10.0, p2 = 'a' }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var c = new { p1 = 10.0, p2 = 'a' }").WithArguments(""), - // (15,16): error CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,16): error CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (new { }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "new { }").WithArguments(""), - // (19,16): error CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (19,16): error CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (new { f1 = "12345", f2 = 'S' }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, @"new { f1 = ""12345"", f2 = 'S' }").WithArguments("") ); @@ -3113,7 +3113,7 @@ ref struct S if (modifier == "ref") { CreateCompilation(source).VerifyDiagnostics( - // (2,8): error CS1674: 'S': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (2,8): error CS1674: 'S': type used in a using statement must implement 'System.IDisposable'. // using (var s = new S()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var s = new S()").WithArguments("S").WithLocation(2, 8), // (8,25): error CS1741: A ref or out parameter cannot have a default value diff --git a/src/Compilers/CSharp/Test/Emit2/Semantics/OutVarTests.cs b/src/Compilers/CSharp/Test/Emit2/Semantics/OutVarTests.cs index 5d7ef10c2724e..f260c86e90410 100644 --- a/src/Compilers/CSharp/Test/Emit2/Semantics/OutVarTests.cs +++ b/src/Compilers/CSharp/Test/Emit2/Semantics/OutVarTests.cs @@ -34284,7 +34284,7 @@ static bool TakeOutParam(T y, out T x) var compilation = CreateCompilation(syntaxTree, options: TestOptions.ReleaseExe); compilation.VerifyDiagnostics( - // file.cs(12,16): error CS1674: 'int[*,*]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(12,16): error CS1674: 'int[*,*]': type used in a using statement must implement 'System.IDisposable'. // using (int[TakeOutParam(true, out var x1),x1] d = null) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "int[TakeOutParam(true, out var x1),x1] d = null").WithArguments("int[*,*]").WithLocation(12, 16), // file.cs(12,19): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) @@ -34299,7 +34299,7 @@ static bool TakeOutParam(T y, out T x) // file.cs(14,19): error CS0165: Use of unassigned local variable 'x1' // Dummy(x1); Diagnostic(ErrorCode.ERR_UseDefViolation, "x1").WithArguments("x1").WithLocation(14, 19), - // file.cs(20,16): error CS1674: 'int[*,*]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(20,16): error CS1674: 'int[*,*]': type used in a using statement must implement 'System.IDisposable'. // using (int[TakeOutParam(true, out var x2),x2] d = null) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "int[TakeOutParam(true, out var x2),x2] d = null").WithArguments("int[*,*]").WithLocation(20, 16), // file.cs(20,19): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) @@ -34314,7 +34314,7 @@ static bool TakeOutParam(T y, out T x) // file.cs(21,19): error CS0165: Use of unassigned local variable 'x2' // Dummy(x2); Diagnostic(ErrorCode.ERR_UseDefViolation, "x2").WithArguments("x2").WithLocation(21, 19), - // file.cs(29,16): error CS1674: 'int[*,*]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(29,16): error CS1674: 'int[*,*]': type used in a using statement must implement 'System.IDisposable'. // using (int[TakeOutParam(true, out var x3),x3] d = null) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "int[TakeOutParam(true, out var x3),x3] d = null").WithArguments("int[*,*]").WithLocation(29, 16), // file.cs(29,19): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) @@ -34393,7 +34393,7 @@ static bool TakeOutParam(T y, out T x) var compilation = CreateCompilation(source, options: TestOptions.ReleaseExe, parseOptions: TestOptions.Regular); compilation.VerifyDiagnostics( - // (12,9): error CS1674: 'int[*,*]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (12,9): error CS1674: 'int[*,*]': type used in a using statement must implement 'System.IDisposable'. // using int[TakeOutParam(true, out var x1), x1] d = null; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using int[TakeOutParam(true, out var x1), x1] d = null;").WithArguments("int[*,*]").WithLocation(12, 9), // (12,18): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) @@ -34408,7 +34408,7 @@ static bool TakeOutParam(T y, out T x) // (13,15): error CS0165: Use of unassigned local variable 'x1' // Dummy(x1); Diagnostic(ErrorCode.ERR_UseDefViolation, "x1").WithArguments("x1").WithLocation(13, 15), - // (21,9): error CS1674: 'int[*,*]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (21,9): error CS1674: 'int[*,*]': type used in a using statement must implement 'System.IDisposable'. // using int[TakeOutParam(true, out var x2), x2] d = null; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using int[TakeOutParam(true, out var x2), x2] d = null;").WithArguments("int[*,*]").WithLocation(21, 9), // (21,18): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) diff --git a/src/Compilers/CSharp/Test/Emit3/RefStructInterfacesTests.cs b/src/Compilers/CSharp/Test/Emit3/RefStructInterfacesTests.cs index 3bc114a56fefc..c05cb7b433053 100644 --- a/src/Compilers/CSharp/Test/Emit3/RefStructInterfacesTests.cs +++ b/src/Compilers/CSharp/Test/Emit3/RefStructInterfacesTests.cs @@ -7133,12 +7133,11 @@ static void Test(T t, IMyDisposable s) where T : IMyDisposable, allows ref st "; var comp = CreateCompilation(src, targetFramework: s_targetFrameworkSupportingByRefLikeGenerics, options: TestOptions.ReleaseExe); - // https://github.com/dotnet/roslyn/issues/73559: Should we adjust wording for the error? Ref struct implement interfaces, but not convertible to them. comp.VerifyDiagnostics( - // (23,16): error CS1674: 'T': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (23,16): error CS1674: 'T': type used in a using statement must implement 'System.IDisposable'. // using (t) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "t").WithArguments("T").WithLocation(23, 16), - // (27,16): error CS1674: 'IMyDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (27,16): error CS1674: 'IMyDisposable': type used in a using statement must implement 'System.IDisposable'. // using (s) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s").WithArguments("IMyDisposable").WithLocation(27, 16) ); @@ -13501,7 +13500,7 @@ static async Task Main() var comp = CreateCompilation(src, targetFramework: s_targetFrameworkSupportingByRefLikeGenerics, options: TestOptions.ReleaseExe); comp.VerifyDiagnostics( - // (32,22): error CS8410: 'T': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (32,22): error CS8410: 'T': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (new T()) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "new T()").WithArguments("T").WithLocation(32, 22) ); diff --git a/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IUsingStatement.cs b/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IUsingStatement.cs index 3eb38d6c2ba3f..f83a8e79a35bb 100644 --- a/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IUsingStatement.cs +++ b/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IUsingStatement.cs @@ -1047,7 +1047,7 @@ public static void M1() OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) "; var expectedDiagnostics = new DiagnosticDescription[] { - // CS1674: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // CS1674: 'C': type used in a using statement must implement 'System.IDisposable' // /**/using (var c1 = new C()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var c1 = new C()").WithArguments("C").WithLocation(9, 26) }; @@ -1096,7 +1096,7 @@ public static void M1() OutConversion: CommonConversion (Exists: True, IsIdentity: True, IsNumeric: False, IsReference: False, IsUserDefined: False) (MethodSymbol: null) "; var expectedDiagnostics = new DiagnosticDescription[] { - // CS1674: 'C': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // CS1674: 'C': type used in a using statement must implement 'System.IDisposable' // /**/using (c1) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "c1").WithArguments("C").WithLocation(10, 26) }; @@ -1939,7 +1939,7 @@ .maxstack 8 var expectedDiagnostics = new[] { - // (6,15): error CS1674: 'S': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,15): error CS1674: 'S': type used in a using statement must implement 'System.IDisposable'. // using(var s = new S()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var s = new S()").WithArguments("S").WithLocation(6, 15), // (14,11): error CS7036: There is no argument given that corresponds to the required parameter 'extras' of 'S.Dispose(params int)' @@ -2073,7 +2073,7 @@ .maxstack 8 var expectedDiagnostics = new[] { - // (6,15): error CS1674: 'S': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,15): error CS1674: 'S': type used in a using statement must implement 'System.IDisposable'. // using(var s = new S()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var s = new S()").WithArguments("S").WithLocation(6, 15), // (14,11): error CS7036: There is no argument given that corresponds to the required parameter 'extras' of 'S.Dispose(params int)' @@ -2207,7 +2207,7 @@ .maxstack 8 var expectedDiagnostics = new[] { - // (6,15): error CS1674: 'S': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,15): error CS1674: 'S': type used in a using statement must implement 'System.IDisposable'. // using(var s = new S()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var s = new S()").WithArguments("S").WithLocation(6, 15), // (14,11): error CS7036: There is no argument given that corresponds to the required parameter 'extras' of 'S.Dispose(params int)' @@ -2342,7 +2342,7 @@ .maxstack 8 var expectedDiagnostics = new[] { - // (6,15): error CS1674: 'S': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,15): error CS1674: 'S': type used in a using statement must implement 'System.IDisposable'. // using(var s = new S()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var s = new S()").WithArguments("S").WithLocation(6, 15), // (14,11): error CS7036: There is no argument given that corresponds to the required parameter 'extras' of 'S.Dispose(params object[], int)' @@ -3272,7 +3272,7 @@ class NotDisposable Statements (0) "; var expectedDiagnostics = new[] { - // file.cs(6,16): error CS1674: 'NotDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // file.cs(6,16): error CS1674: 'NotDisposable': type used in a using statement must implement 'System.IDisposable' // using (GetDisposable() ?? input) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "GetDisposable() ?? input").WithArguments("NotDisposable").WithLocation(6, 16) }; @@ -3368,7 +3368,7 @@ struct MyDisposable Statements (0) "; var expectedDiagnostics = new[] { - // file.cs(6,16): error CS1674: 'MyDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // file.cs(6,16): error CS1674: 'MyDisposable': type used in a using statement must implement 'System.IDisposable' // using (b ? GetDisposable() : input) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "b ? GetDisposable() : input").WithArguments("MyDisposable").WithLocation(6, 16) }; @@ -3472,7 +3472,7 @@ void M(MyDisposable input, bool b) Statements (0) "; var expectedDiagnostics = new[] { - // file.cs(6,16): error CS1674: 'MyDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // file.cs(6,16): error CS1674: 'MyDisposable': type used in a using statement must implement 'System.IDisposable' // using (b ? GetDisposable() : input) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "b ? GetDisposable() : input").WithArguments("MyDisposable").WithLocation(6, 16) }; @@ -3594,7 +3594,7 @@ struct MyDisposable Statements (0) "; var expectedDiagnostics = new[] { - // file.cs(6,16): error CS1674: 'MyDisposable?': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // file.cs(6,16): error CS1674: 'MyDisposable?': type used in a using statement must implement 'System.IDisposable' // using (GetDisposable() ?? input) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "GetDisposable() ?? input").WithArguments("MyDisposable?").WithLocation(6, 16) }; @@ -4390,7 +4390,7 @@ public Task DisposeAsync() "; var expectedDiagnostics = new[] { - // (9,22): error CS8410: 'S?': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // (9,22): error CS8410: 'S?': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using (s) Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "s").WithArguments("S?").WithLocation(9, 22) }; @@ -4743,7 +4743,7 @@ public async Task M() "; var expectedDiagnostics = new[] { - // file.cs(8,21): error CS8410: 'C': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. + // file.cs(8,21): error CS8410: 'C': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method. // await using(this){} Diagnostic(ErrorCode.ERR_NoConvToIAsyncDisp, "this").WithArguments("C").WithLocation(8, 21), // file.cs(11,34): error CS0231: A params parameter must be the last parameter in a parameter list @@ -7558,7 +7558,7 @@ void M(bool b) "; var expectedDiagnostics = new[] { - // file.cs(8,13): error CS1674: 'P': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(8,13): error CS1674: 'P': type used in a using statement must implement 'System.IDisposable'. // using var x = new P(); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using var x = new P();").WithArguments("P").WithLocation(8, 13) }; diff --git a/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IVariableDeclaration.cs b/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IVariableDeclaration.cs index 04abcd6d442ec..ae2a6a1cf6fb7 100644 --- a/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IVariableDeclaration.cs +++ b/src/Compilers/CSharp/Test/IOperation/IOperation/IOperationTests_IVariableDeclaration.cs @@ -2334,7 +2334,7 @@ Dimension Sizes(1): // file.cs(6,13): warning CS0219: The variable 'y' is assigned but its value is never used // int y = 10; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y").WithArguments("y").WithLocation(6, 13), - // file.cs(7,25): error CS1674: 'int[]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(7,25): error CS1674: 'int[]': type used in a using statement must implement 'System.IDisposable'. // using( /**/int[y switch { int z => 42 }] x = new int[0]/**/){} Diagnostic(ErrorCode.ERR_NoConvToIDisp, "int[y switch { int z => 42 }] x = new int[0]").WithArguments("int[]").WithLocation(7, 25), // file.cs(7,28): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) @@ -2395,7 +2395,7 @@ Dimension Sizes(1): // file.cs(6,13): warning CS0219: The variable 'y' is assigned but its value is never used // int y = 10; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y").WithArguments("y").WithLocation(6, 13), - // file.cs(7,25): error CS1674: 'int[]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(7,25): error CS1674: 'int[]': type used in a using statement must implement 'System.IDisposable'. // using( /**/int[y switch { int z => 42 }] x = new int[0]/**/); Diagnostic(ErrorCode.ERR_NoConvToIDisp, "int[y switch { int z => 42 }] x = new int[0]").WithArguments("int[]").WithLocation(7, 25), // file.cs(7,28): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) @@ -2454,7 +2454,7 @@ Dimension Sizes(1): // file.cs(6,13): warning CS0219: The variable 'y' is assigned but its value is never used // int y = 10; Diagnostic(ErrorCode.WRN_UnreferencedVarAssg, "y").WithArguments("y").WithLocation(6, 13), - // file.cs(7,8): error CS1674: 'int[]': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // file.cs(7,8): error CS1674: 'int[]': type used in a using statement must implement 'System.IDisposable'. // using /**/int[y switch { int z => 42 }] x = new int[0]/**/; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using /**/int[y switch { int z => 42 }] x = new int[0]/**/;").WithArguments("int[]").WithLocation(7, 8), // file.cs(7,27): error CS0270: Array size cannot be specified in a variable declaration (try initializing with a 'new' expression) diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs index e97f02e134edc..34463ef999cd7 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/DelegateTypeTests.cs @@ -9391,13 +9391,13 @@ static void Main() }"; var comp = CreateCompilation(source); comp.VerifyDiagnostics( - // (5,9): error CS1674: 'Action': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (5,9): error CS1674: 'Action': type used in a using statement must implement 'System.IDisposable'. // using var d1 = Main; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using var d1 = Main;").WithArguments("System.Action").WithLocation(5, 9), - // (6,9): error CS1674: 'Action': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,9): error CS1674: 'Action': type used in a using statement must implement 'System.IDisposable'. // using var d2 = () => { }; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using var d2 = () => { };").WithArguments("System.Action").WithLocation(6, 9), - // (7,9): error CS1674: 'Action': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (7,9): error CS1674: 'Action': type used in a using statement must implement 'System.IDisposable'. // using var d3 = delegate () { }; Diagnostic(ErrorCode.ERR_NoConvToIDisp, "using var d3 = delegate () { };").WithArguments("System.Action").WithLocation(7, 9)); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/RefEscapingTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/RefEscapingTests.cs index 2821c4bcabfc2..96eacfff1d304 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/RefEscapingTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/RefEscapingTests.cs @@ -91,7 +91,7 @@ ref struct S2 } }"); comp.VerifyDiagnostics( - // (6,16): error CS1674: 'C.S2': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'C.S2': type used in a using statement must implement 'System.IDisposable'. // using (var x = GetRefStruct()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var x = GetRefStruct()").WithArguments("C.S2").WithLocation(6, 16)); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs index a84424081226b..51e30c96a44c7 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/SemanticErrorTests.cs @@ -16296,9 +16296,9 @@ public static void Main() CreateCompilation(text).VerifyDiagnostics( // (7,22): warning CS0642: Possible mistaken empty statement Diagnostic(ErrorCode.WRN_PossibleMistakenNullStatement, ";"), - // (6,16): error CS1674: 'int': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'int': type used in a using statement must implement 'System.IDisposable'. Diagnostic(ErrorCode.ERR_NoConvToIDisp, "int a = 0").WithArguments("int"), - // (7,20): error CS1674: 'int': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (7,20): error CS1674: 'int': type used in a using statement must implement 'System.IDisposable'. Diagnostic(ErrorCode.ERR_NoConvToIDisp, "a").WithArguments("int")); } diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocInitializerTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocInitializerTests.cs index d528b3110b0c5..3cf3ccd72654c 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocInitializerTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocInitializerTests.cs @@ -1533,13 +1533,13 @@ unsafe public static void Main() } "; CreateCompilationWithMscorlibAndSpan(test, options: TestOptions.ReleaseDll.WithAllowUnsafe(true)).VerifyDiagnostics( - // (6,16): error CS1674: 'Span': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // (6,16): error CS1674: 'Span': type used in a using statement must implement 'System.IDisposable' // using (var v1 = stackalloc int [3] { 1, 2, 3 }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v1 = stackalloc int [3] { 1, 2, 3 }").WithArguments("System.Span").WithLocation(6, 16), - // (7,16): error CS1674: 'Span': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // (7,16): error CS1674: 'Span': type used in a using statement must implement 'System.IDisposable' // using (var v2 = stackalloc int [ ] { 1, 2, 3 }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v2 = stackalloc int [ ] { 1, 2, 3 }").WithArguments("System.Span").WithLocation(7, 16), - // (8,16): error CS1674: 'Span': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // (8,16): error CS1674: 'Span': type used in a using statement must implement 'System.IDisposable' // using (var v3 = stackalloc [ ] { 1, 2, 3 }) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v3 = stackalloc [ ] { 1, 2, 3 }").WithArguments("System.Span").WithLocation(8, 16) ); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocSpanExpressionsTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocSpanExpressionsTests.cs index 22a137fcd9673..80adc6b7a1358 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocSpanExpressionsTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/StackAllocSpanExpressionsTests.cs @@ -430,7 +430,7 @@ unsafe public static void Main() } "; CreateCompilationWithMscorlibAndSpan(test, options: TestOptions.ReleaseDll.WithAllowUnsafe(true)).VerifyDiagnostics( - // (6,16): error CS1674: 'Span': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // (6,16): error CS1674: 'Span': type used in a using statement must implement 'System.IDisposable' // using (var v = stackalloc int[1]) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v = stackalloc int[1]").WithArguments("System.Span").WithLocation(6, 16) ); diff --git a/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs b/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs index 847bb7496713e..2c1e1daf4fdf0 100644 --- a/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs +++ b/src/Compilers/CSharp/Test/Semantic/Semantics/UsingStatementTests.cs @@ -92,7 +92,7 @@ static void Main() "; CreateCompilation(source).VerifyDiagnostics( - // (6,16): error CS1674: 'method group': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'method group': type used in a using statement must implement 'System.IDisposable'. Diagnostic(ErrorCode.ERR_NoConvToIDisp, "Main").WithArguments("method group")); } @@ -136,7 +136,7 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'C1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'C1': type used in a using statement must implement 'System.IDisposable'. // using (C1 c1 = new C1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "C1 c1 = new C1()").WithArguments("C1").WithLocation(11, 16) ); @@ -165,7 +165,7 @@ static void Main() // (5,17): error CS0111: Type 'S1' already defines a member called 'Dispose' with the same parameter types // public void Dispose() { } Diagnostic(ErrorCode.ERR_MemberAlreadyExists, "Dispose").WithArguments("Dispose", "S1").WithLocation(5, 17), - // (12,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (12,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(12, 16) ); @@ -196,10 +196,10 @@ static void Main() // (5,17): error CS0111: Type 'S1' already defines a member called 'Dispose' with the same parameter types // public bool Dispose() { return false; } Diagnostic(ErrorCode.ERR_MemberAlreadyExists, "Dispose").WithArguments("Dispose", "S1").WithLocation(5, 17), - // (12,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (12,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(12, 16), - // (16,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (16,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (c1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(16, 16) ); @@ -255,10 +255,10 @@ static void Main() // (5,19): error CS0111: Type 'S1' already defines a member called 'Dispose' with the same parameter types // internal void Dispose() { } Diagnostic(ErrorCode.ERR_MemberAlreadyExists, "Dispose").WithArguments("Dispose", "S1").WithLocation(5, 19), - // (12,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (12,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(12, 16), - // (16,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (16,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (c1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(16, 16) ); @@ -320,10 +320,10 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (15,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 16), - // (19,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (19,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (s1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(19, 16) ); @@ -355,10 +355,10 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (16,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (16,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(16, 16), - // (20,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (20,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (s1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(20, 16) ); @@ -383,7 +383,7 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(11, 16) ); @@ -420,7 +420,7 @@ static void Main() // Tracked by https://github.com/dotnet/roslyn/issues/32767 CreateCompilation(source).VerifyDiagnostics( - // (20,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (20,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(20, 16) ); @@ -545,22 +545,22 @@ static void M6() // Tracked by https://github.com/dotnet/roslyn/issues/32767 CreateCompilation(source).VerifyDiagnostics( - // (37,20): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (37,20): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) // error 1 Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(37, 20), - // (50,20): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (50,20): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) // error 2 Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(50, 20), - // (63,20): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (63,20): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) // error 3 Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(63, 20), - // (77,20): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (77,20): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) // error 4 Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(77, 20), - // (92,24): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (92,24): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) // error 5 Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(92, 24), - // (105,28): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (105,28): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) // error 6 Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(105, 28) ); @@ -604,16 +604,16 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (22,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (22,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(22, 16), - // (26,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (26,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (s1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(26, 16), - // (28,16): error CS1674: 'S2': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (28,16): error CS1674: 'S2': type used in a using statement must implement 'System.IDisposable'. // using (S2 s = new S2()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S2 s = new S2()").WithArguments("S2").WithLocation(28, 16), - // (32,16): error CS1674: 'S2': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (32,16): error CS1674: 'S2': type used in a using statement must implement 'System.IDisposable'. // using (s2b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s2b").WithArguments("S2").WithLocation(32, 16) ); @@ -651,7 +651,7 @@ static void Main() // Tracked by https://github.com/dotnet/roslyn/issues/32767 CreateCompilation(source).VerifyDiagnostics( - // (21,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (21,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(21, 15) ); @@ -682,10 +682,10 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15), - // (19,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (19,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (s1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(19, 15) ); @@ -718,7 +718,7 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (19,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (19,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(19, 15) ); @@ -748,7 +748,7 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (16,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (16,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(16, 15) ); @@ -779,10 +779,10 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15), - // (19,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (19,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (s1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "s1b").WithArguments("S1").WithLocation(19, 15) ); @@ -811,7 +811,7 @@ static void Main() } }"; var compilation = CreateCompilation(source).VerifyDiagnostics( - // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15) ); @@ -841,7 +841,7 @@ static void Main() }"; var compilation = CreateCompilation(source).VerifyDiagnostics( - // (15,15): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,15): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(15, 15) ); @@ -914,10 +914,10 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 c = new S1()").WithArguments("S1").WithLocation(11, 16), - // (15,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (c1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "c1b").WithArguments("S1").WithLocation(15, 16) ); @@ -944,10 +944,10 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 c = new S1()").WithArguments("S1").WithLocation(11, 16), - // (15,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (15,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (c1b) { } Diagnostic(ErrorCode.ERR_NoConvToIDisp, "c1b").WithArguments("S1").WithLocation(15, 16) ); @@ -996,7 +996,7 @@ static void Main() } "; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c1 = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 c1 = new S1()").WithArguments("S1").WithLocation(11, 16) ); @@ -1021,7 +1021,7 @@ static void Main() } }"; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable'. // using (S1 c = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 c = new S1()").WithArguments("S1").WithLocation(11, 16) ); @@ -1047,7 +1047,7 @@ static void Main() } "; CreateCompilation(source).VerifyDiagnostics( - // (11,16): error CS1674: 'C1': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (11,16): error CS1674: 'C1': type used in a using statement must implement 'System.IDisposable'. // using (C1 c1 = new C1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "C1 c1 = new C1()").WithArguments("C1").WithLocation(11, 16) ); @@ -1190,13 +1190,13 @@ static void Main() } "; CreateCompilation(source, parseOptions: TestOptions.Regular7_3).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable' or implement a suitable 'Dispose' method. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable' or implement a suitable 'Dispose' method. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(11, 16) ); CreateCompilation(source, parseOptions: TestOptions.Regular8).VerifyDiagnostics( - // (11,16): error CS1674: 'S1': type used in a using statement must be implicitly convertible to 'System.IDisposable' or implement a suitable 'Dispose' method. + // (11,16): error CS1674: 'S1': type used in a using statement must implement 'System.IDisposable' or implement a suitable 'Dispose' method. // using (S1 s = new S1()) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "S1 s = new S1()").WithArguments("S1").WithLocation(11, 16) ); @@ -1218,7 +1218,7 @@ static void Main() "; CreateCompilation(source).VerifyDiagnostics( - // (6,16): error CS1674: 'lambda expression': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'lambda expression': type used in a using statement must implement 'System.IDisposable'. Diagnostic(ErrorCode.ERR_NoConvToIDisp, "x => x").WithArguments("lambda expression")); } @@ -1697,7 +1697,7 @@ static void M(T0 t0, T1 t1, T2 t2, T3 t3, T4 t4) } }"; CreateCompilation(source).VerifyDiagnostics( - // (16,16): error CS1674: 'T0': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (16,16): error CS1674: 'T0': type used in a using statement must implement 'System.IDisposable'. Diagnostic(ErrorCode.ERR_NoConvToIDisp, "t0").WithArguments("T0").WithLocation(16, 16)); } diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/AnonymousTypesSemanticsTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/AnonymousTypesSemanticsTests.cs index d59cb69bc23a0..c94ce3159fb76 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/AnonymousTypesSemanticsTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/AnonymousTypesSemanticsTests.cs @@ -1328,7 +1328,7 @@ public static void Test1(int x) } }"; var data = Compile(source, 1, - // (6,16): error CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (var v1 = new { } ) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v1 = new { }").WithArguments("") ); @@ -1365,7 +1365,7 @@ public static void Test1(int x) Initializer: null"; var expectedDiagnostics = new DiagnosticDescription[] { - // CS1674: '': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // CS1674: '': type used in a using statement must implement 'System.IDisposable'. // using (/**/var v1 = new { }/**/) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v1 = new { }").WithArguments("").WithLocation(6, 26) }; diff --git a/src/Compilers/CSharp/Test/Symbol/Symbols/ConversionTests.cs b/src/Compilers/CSharp/Test/Symbol/Symbols/ConversionTests.cs index a3f10e059c6fa..2172bf636d89c 100644 --- a/src/Compilers/CSharp/Test/Symbol/Symbols/ConversionTests.cs +++ b/src/Compilers/CSharp/Test/Symbol/Symbols/ConversionTests.cs @@ -1194,7 +1194,7 @@ static void Main() } }"; CreateCompilationWithILAndMscorlib40(csharp, il).VerifyDiagnostics( - // (6,16): error CS1674: 'ConvertibleToIDisposable': type used in a using statement must be implicitly convertible to 'System.IDisposable'. + // (6,16): error CS1674: 'ConvertibleToIDisposable': type used in a using statement must implement 'System.IDisposable'. Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var d = new ConvertibleToIDisposable()").WithArguments("ConvertibleToIDisposable")); } diff --git a/src/Compilers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs b/src/Compilers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs index 0296a9fd5be7b..b4a43b474e4d1 100644 --- a/src/Compilers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs +++ b/src/Compilers/CSharp/Test/Syntax/Parsing/ParserErrorMessageTests.cs @@ -4918,7 +4918,7 @@ unsafe public static void Main() } "; CreateCompilationWithMscorlibAndSpan(test, options: TestOptions.ReleaseDll.WithAllowUnsafe(true)).VerifyDiagnostics( - // (6,16): error CS1674: 'Span': type used in a using statement must be implicitly convertible to 'System.IDisposable' + // (6,16): error CS1674: 'Span': type used in a using statement must implement 'System.IDisposable' // using (var v = stackalloc int[1]) Diagnostic(ErrorCode.ERR_NoConvToIDisp, "var v = stackalloc int[1]").WithArguments("System.Span").WithLocation(6, 16)); } diff --git a/src/Features/Core/Portable/IntroduceUsingStatement/AbstractIntroduceUsingStatementCodeRefactoringProvider.cs b/src/Features/Core/Portable/IntroduceUsingStatement/AbstractIntroduceUsingStatementCodeRefactoringProvider.cs index 1ebc8bbf3df6a..0b4cae3a0ddd2 100644 --- a/src/Features/Core/Portable/IntroduceUsingStatement/AbstractIntroduceUsingStatementCodeRefactoringProvider.cs +++ b/src/Features/Core/Portable/IntroduceUsingStatement/AbstractIntroduceUsingStatementCodeRefactoringProvider.cs @@ -103,7 +103,7 @@ public override async Task ComputeRefactoringsAsync(CodeRefactoringContext conte /// private static bool IsLegalUsingStatementType(Compilation compilation, ITypeSymbol disposableType, ITypeSymbol type) { - // CS1674: type used in a using statement must be implicitly convertible to 'System.IDisposable' + // CS1674: type used in a using statement must implement 'System.IDisposable' return compilation.ClassifyCommonConversion(type, disposableType).IsImplicit; }