File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
CodeFixes/UseImplicitOrExplicitType
Tests/UseImplicitOrExplicitType Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 17
17
using Microsoft . CodeAnalysis . LanguageService ;
18
18
using Microsoft . CodeAnalysis . PooledObjects ;
19
19
using Microsoft . CodeAnalysis . Shared . Extensions ;
20
+ using Microsoft . CodeAnalysis . Simplification ;
20
21
using Roslyn . Utilities ;
21
22
22
23
namespace Microsoft . CodeAnalysis . CSharp . TypeStyle ;
@@ -224,13 +225,14 @@ private static ExpressionSyntax GenerateTupleDeclaration(
224
225
. WithTrailingTrivia ( parensDesignation . GetTrailingTrivia ( ) ) ;
225
226
}
226
227
227
- private static SyntaxNode GenerateTypeDeclaration ( TypeSyntax typeSyntax , ITypeSymbol newTypeSymbol )
228
+ private static TypeSyntax GenerateTypeDeclaration ( TypeSyntax typeSyntax , ITypeSymbol newTypeSymbol )
228
229
{
229
230
// We're going to be passed through the simplifier. Tell it to not just convert this back to var (as
230
231
// that would defeat the purpose of this refactoring entirely).
231
232
var newTypeSyntax = newTypeSymbol
232
- . GenerateTypeSyntax ( allowVar : false )
233
- . WithTriviaFrom ( typeSyntax ) ;
233
+ . GenerateTypeSyntax ( allowVar : false )
234
+ . WithAdditionalAnnotations ( Simplifier . AddImportsAnnotation )
235
+ . WithTriviaFrom ( typeSyntax ) ;
234
236
235
237
return newTypeSyntax ;
236
238
}
Original file line number Diff line number Diff line change @@ -2653,7 +2653,9 @@ void M()
2653
2653
}
2654
2654
""" , new TestParameters ( options : ExplicitTypeEverywhere ( ) ) ) ;
2655
2655
2656
- [ Fact , WorkItem ( "https://github.com/dotnet/roslyn/issues/23907" ) ]
2656
+ [ Fact ]
2657
+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/23907" ) ]
2658
+ [ WorkItem ( "https://github.com/dotnet/roslyn/issues/24034" ) ]
2657
2659
public async Task WithNormalFuncSynthesizedLambdaType ( )
2658
2660
{
2659
2661
var before = """
@@ -2666,11 +2668,13 @@ void Method()
2666
2668
}
2667
2669
""" ;
2668
2670
var after = """
2671
+ using System;
2672
+
2669
2673
class Program
2670
2674
{
2671
2675
void Method()
2672
2676
{
2673
- System. Func<int, string> x = (int i) => i.ToString();
2677
+ Func<int, string> x = (int i) => i.ToString();
2674
2678
}
2675
2679
}
2676
2680
""" ;
You can’t perform that action at this time.
0 commit comments