|
1 |
| -using Amazon.JSII.JsonModel.Spec; |
| 1 | +using System.Collections.Generic; |
| 2 | +using System.Linq; |
| 3 | +using Amazon.JSII.JsonModel.Spec; |
2 | 4 | using Microsoft.CodeAnalysis;
|
3 | 5 | using Microsoft.CodeAnalysis.CSharp;
|
4 | 6 | using Microsoft.CodeAnalysis.CSharp.Syntax;
|
5 |
| -using System.Collections.Generic; |
6 |
| -using System.Linq; |
7 | 7 | using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
|
8 | 8 |
|
9 | 9 | namespace Amazon.JSII.Generator.Class
|
@@ -97,37 +97,41 @@ IEnumerable<MemberDeclarationSyntax> CreateConstructors()
|
97 | 97 | {
|
98 | 98 | SyntaxToken typeName = Symbols.GetNameSyntaxToken(Type);
|
99 | 99 |
|
100 |
| - yield return SF.ConstructorDeclaration |
101 |
| - ( |
102 |
| - SF.List<AttributeListSyntax>(), |
103 |
| - SF.TokenList(SF.Token( |
104 |
| - Type.IsAbstract || Type.Initializer.IsProtected ? |
105 |
| - SyntaxKind.ProtectedKeyword : |
106 |
| - SyntaxKind.PublicKeyword |
107 |
| - )), |
108 |
| - typeName, |
109 |
| - Type.Initializer.GetParameterListSyntax(Namespaces, Symbols), |
110 |
| - SF.ConstructorInitializer |
| 100 | + if (Type.Initializer != null) |
| 101 | + { |
| 102 | + yield return SF.ConstructorDeclaration |
111 | 103 | (
|
112 |
| - SyntaxKind.BaseConstructorInitializer, |
113 |
| - SF.ArgumentList( |
114 |
| - SF.SeparatedList(new[] { |
115 |
| - SF.Argument( |
116 |
| - SF.ObjectCreationExpression( |
117 |
| - SF.Token(SyntaxKind.NewKeyword), |
118 |
| - SF.ParseTypeName("DeputyProps"), |
119 |
| - SF.ArgumentList(SF.SeparatedList( |
120 |
| - new[] { GetBaseArgument() } |
121 |
| - )), |
122 |
| - null |
| 104 | + SF.List<AttributeListSyntax>(), |
| 105 | + SF.TokenList(SF.Token( |
| 106 | + Type.IsAbstract || Type.Initializer.IsProtected |
| 107 | + ? SyntaxKind.ProtectedKeyword |
| 108 | + : SyntaxKind.PublicKeyword |
| 109 | + )), |
| 110 | + typeName, |
| 111 | + Type.Initializer.GetParameterListSyntax(Namespaces, Symbols), |
| 112 | + SF.ConstructorInitializer |
| 113 | + ( |
| 114 | + SyntaxKind.BaseConstructorInitializer, |
| 115 | + SF.ArgumentList( |
| 116 | + SF.SeparatedList(new[] |
| 117 | + { |
| 118 | + SF.Argument( |
| 119 | + SF.ObjectCreationExpression( |
| 120 | + SF.Token(SyntaxKind.NewKeyword), |
| 121 | + SF.ParseTypeName("DeputyProps"), |
| 122 | + SF.ArgumentList(SF.SeparatedList( |
| 123 | + new[] {GetBaseArgument()} |
| 124 | + )), |
| 125 | + null |
| 126 | + ) |
123 | 127 | )
|
124 |
| - ) |
125 |
| - }) |
126 |
| - ) |
127 |
| - ), |
128 |
| - SF.Block(), |
129 |
| - null |
130 |
| - ); |
| 128 | + }) |
| 129 | + ) |
| 130 | + ), |
| 131 | + SF.Block(), |
| 132 | + null |
| 133 | + ); |
| 134 | + } |
131 | 135 |
|
132 | 136 | yield return SF.ConstructorDeclaration
|
133 | 137 | (
|
|
0 commit comments