1
1
using System . Collections . Generic ;
2
2
using System . Collections . Immutable ;
3
3
using System . Linq ;
4
- using System . Net ;
5
4
using System . Text . RegularExpressions ;
6
5
7
6
using Microsoft . CodeAnalysis ;
@@ -14,36 +13,36 @@ partial class VisitorTemplate
14
13
15
14
public string TaskName { get ; }
16
15
17
- public ITypeSymbol ? BaseResultType { get ; }
16
+ public ITypeSymbol ? BaseResult { get ; }
18
17
19
18
public INamedTypeSymbol VisitorInterface { get ; }
20
19
21
- public INamedTypeSymbol AcceptorInterface { get ; }
20
+ public INamedTypeSymbol Acceptor { get ; }
22
21
23
- public ImmutableArray < ( INamedTypeSymbol Type , INamedTypeSymbol ? ResultType ) > AcceptorTypes { get ; }
22
+ public ImmutableArray < ( INamedTypeSymbol Type , INamedTypeSymbol ? ResultType ) > Acceptors { get ; }
24
23
25
24
public VisitorTemplate (
26
25
string rootNamespace ,
27
26
string taskName ,
28
- ITypeSymbol ? baseResultType ,
27
+ ITypeSymbol ? baseResult ,
29
28
INamedTypeSymbol visitorInterface ,
30
- INamedTypeSymbol acceptorInterface ,
29
+ INamedTypeSymbol acceptor ,
31
30
ImmutableArray < ( INamedTypeSymbol Type , INamedTypeSymbol ? ResultType ) > acceptors
32
31
)
33
32
{
34
33
this . RootNamespace = rootNamespace ;
35
34
this . TaskName = taskName ;
36
- this . BaseResultType = baseResultType ;
35
+ this . BaseResult = baseResult ;
37
36
this . VisitorInterface = visitorInterface ;
38
- this . AcceptorInterface = acceptorInterface ;
39
- this . AcceptorTypes = acceptors ;
37
+ this . Acceptor = acceptor ;
38
+ this . Acceptors = acceptors ;
40
39
}
41
40
42
41
public bool IsAsync => ! string . IsNullOrWhiteSpace ( this . TaskName ) ;
43
42
44
43
public string IfAsync ( string str ) => this . IsAsync ? str : string . Empty ;
45
44
46
- public bool IsGeneric => this . BaseResultType is ITypeParameterSymbol ;
45
+ public bool IsGeneric => this . BaseResult is ITypeParameterSymbol ;
47
46
48
47
public string GetTypeParamStr ( )
49
48
{
@@ -96,7 +95,9 @@ public string GetReturnType(ITypeSymbol? resultType)
96
95
return resultName is null ? taskName ?? "void" : taskName is null ? resultName : $ "{ taskName } <{ resultName } >";
97
96
}
98
97
99
- public static string WrapAngle ( ITypeSymbol type , ITypeSymbol ? resultType = null )
100
- => $ "< { type . ToDisplayString ( ) } " + ( resultType is null ? ">" : $ ", { resultType . ToDisplayString ( ) } >" ) ;
98
+ public static string GetNamespace ( INamedTypeSymbol type )
99
+ => type . ContainingNamespace . ToDisplayString ( ) ;
101
100
101
+ public static string GetTypeIdentifier ( INamedTypeSymbol type )
102
+ => type . ToDisplayString ( SymbolDisplayFormat . MinimallyQualifiedFormat . WithGenericsOptions ( SymbolDisplayGenericsOptions . IncludeTypeParameters | SymbolDisplayGenericsOptions . IncludeVariance ) ) ;
102
103
}
0 commit comments