File tree 2 files changed +36
-2
lines changed
packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src 2 files changed +36
-2
lines changed Original file line number Diff line number Diff line change 5
5
using Microsoft . TypeSpec . Generator . Expressions ;
6
6
using Microsoft . TypeSpec . Generator . Input ;
7
7
using Microsoft . TypeSpec . Generator . Providers ;
8
+ using Microsoft . TypeSpec . Generator . Snippets ;
8
9
using Microsoft . TypeSpec . Generator . Statements ;
9
10
10
11
namespace Microsoft . TypeSpec . Generator
@@ -202,6 +203,11 @@ internal virtual void Visit(OutputLibrary library)
202
203
return statement ;
203
204
}
204
205
206
+ protected internal virtual ValueExpression ? VisitScopedApiExpression ( ScopedApi expression , MethodProvider method )
207
+ {
208
+ return expression ;
209
+ }
210
+
205
211
protected internal virtual MethodBodyStatement ? VisitIfElseStatement ( IfElseStatement statement , MethodProvider method )
206
212
{
207
213
return statement ;
Original file line number Diff line number Diff line change 3
3
4
4
using Microsoft . TypeSpec . Generator . Expressions ;
5
5
using Microsoft . TypeSpec . Generator . Primitives ;
6
+ using Microsoft . TypeSpec . Generator . Providers ;
6
7
using Microsoft . TypeSpec . Generator . Statements ;
7
8
8
9
namespace Microsoft . TypeSpec . Generator . Snippets
9
10
{
10
11
public record ScopedApi : ValueExpression
11
12
{
12
- public ValueExpression Original { get ; }
13
- public CSharpType Type { get ; }
13
+ public ValueExpression Original { get ; private set ; }
14
+ public CSharpType Type { get ; private set ; }
14
15
15
16
public ScopedApi ( CSharpType type , ValueExpression original )
16
17
: base ( original )
@@ -28,5 +29,32 @@ internal override void Write(CodeWriter writer)
28
29
29
30
protected internal override bool IsEmptyExpression ( ) => Original . IsEmptyExpression ( ) ;
30
31
public MethodBodyStatement Terminate ( ) => _terminated ??= new ExpressionStatement ( this ) ;
32
+
33
+ internal override ValueExpression ? Accept ( LibraryVisitor visitor , MethodProvider method )
34
+ {
35
+ var updatedExpression = visitor . VisitScopedApiExpression ( this , method ) ;
36
+
37
+ if ( updatedExpression is not ScopedApi scopedApi )
38
+ {
39
+ return updatedExpression ? . Accept ( visitor , method ) ;
40
+ }
41
+
42
+ scopedApi . Original = scopedApi . Original . Accept ( visitor , method ) ! ;
43
+
44
+ return scopedApi ;
45
+ }
46
+
47
+ public void Update ( ValueExpression ? original = null , CSharpType ? type = null )
48
+ {
49
+ if ( original != null )
50
+ {
51
+ Original = original ;
52
+ }
53
+
54
+ if ( type != null )
55
+ {
56
+ Type = type ;
57
+ }
58
+ }
31
59
}
32
60
}
You can’t perform that action at this time.
0 commit comments