提交 80f24b63 编写于 作者: C Cyrus Najmabadi

Use standard pattern

上级 da769850
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics; using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Editing;
using Microsoft.CodeAnalysis.Host.Mef;
using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.Shared.Extensions;
using Roslyn.Utilities; using Roslyn.Utilities;
...@@ -24,7 +25,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseImplicitObjectCreation ...@@ -24,7 +25,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UseImplicitObjectCreation
internal class CSharpUseImplicitObjectCreationCodeFixProvider : SyntaxEditorBasedCodeFixProvider internal class CSharpUseImplicitObjectCreationCodeFixProvider : SyntaxEditorBasedCodeFixProvider
{ {
[ImportingConstructor] [ImportingConstructor]
[SuppressMessage("RoslynDiagnosticsReliability", "RS0033:Importing constructor should be [Obsolete]", Justification = "Used in test code: https://github.com/dotnet/roslyn/issues/42814")] [Obsolete(MefConstruction.ImportingConstructorMessage, error: true)]
public CSharpUseImplicitObjectCreationCodeFixProvider() public CSharpUseImplicitObjectCreationCodeFixProvider()
{ {
} }
......
...@@ -512,6 +512,28 @@ class C ...@@ -512,6 +512,28 @@ class C
FixedCode = @" FixedCode = @"
using System.Collections.Generic; using System.Collections.Generic;
class C class C
{
System.Collections.Generic.List<int> list = new();
}",
LanguageVersion = CodeAnalysis.CSharp.LanguageVersion.CSharp9,
}.RunAsync();
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseImplicitObjectCreation)]
public async Task TestAlias()
{
await new VerifyCS.Test
{
TestCode = @"
using System.Collections.Generic;
using X = System.Collections.Generic.List<int>;
class C
{
System.Collections.Generic.List<int> list = new [|X|]();
}",
FixedCode = @"
using System.Collections.Generic;
class C
{ {
System.Collections.Generic.List<int> list = new(); System.Collections.Generic.List<int> list = new();
}", }",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册