Skip to content

Commit

Permalink
Use more precise wording for errors specifying requirements for types…
Browse files Browse the repository at this point in the history
… that can be used in a `using` statement. (#74311)

Closes #73559.
  • Loading branch information
AlekseyTs authored Jul 12, 2024
1 parent a6824ae commit e231014
Show file tree
Hide file tree
Showing 33 changed files with 233 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace Microsoft.CodeAnalysis.CSharp.CodeFixes.MakeStatementAsynchronous;
internal sealed class CSharpMakeStatementAsynchronousCodeFixProvider() : SyntaxEditorBasedCodeFixProvider
{
// error CS8414: foreach statement cannot operate on variables of type 'IAsyncEnumerable<int>' because 'IAsyncEnumerable<int>' 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<string> FixableDiagnosticIds => ["CS8414", "CS8418"];

public override async Task RegisterCodeFixesAsync(CodeFixContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/Compilers/CSharp/Portable/CSharpResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3119,16 +3119,16 @@ A catch() block after a catch (System.Exception e) block can catch non-CLS excep
<value>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.</value>
</data>
<data name="ERR_NoConvToIDisp" xml:space="preserve">
<value>'{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'.</value>
<value>'{0}': type used in a using statement must implement 'System.IDisposable'.</value>
</data>
<data name="ERR_NoConvToIDispWrongAsync" xml:space="preserve">
<value>'{0}': type used in a using statement must be implicitly convertible to 'System.IDisposable'. Did you mean 'await using' rather than 'using'?</value>
<value>'{0}': type used in a using statement must implement 'System.IDisposable'. Did you mean 'await using' rather than 'using'?</value>
</data>
<data name="ERR_NoConvToIAsyncDisp" xml:space="preserve">
<value>'{0}': type used in an asynchronous using statement must be implicitly convertible to 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method.</value>
<value>'{0}': type used in an asynchronous using statement must implement 'System.IAsyncDisposable' or implement a suitable 'DisposeAsync' method.</value>
</data>
<data name="ERR_NoConvToIAsyncDispWrongAsync" xml:space="preserve">
<value>'{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'?</value>
<value>'{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'?</value>
</data>
<data name="ERR_BadParamRef" xml:space="preserve">
<value>Parameter {0} must be declared with the '{1}' keyword</value>
Expand Down
16 changes: 8 additions & 8 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/Compilers/CSharp/Portable/xlf/CSharpResources.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit e231014

Please sign in to comment.