7
7
8
8
namespace Substrate . DotNet . Service . Node . Base
9
9
{
10
-
11
10
public abstract class BuilderBase
12
11
{
13
12
public static readonly List < string > Files = new ( ) ;
14
13
15
14
public uint Id { get ; }
16
-
17
- NodeTypeResolver Resolver { get ; }
15
+
16
+ private NodeTypeResolver Resolver { get ; }
18
17
19
18
public bool Success { get ; set ; }
20
19
@@ -153,7 +152,7 @@ private string GetPath(string basePath)
153
152
154
153
space . Add ( ( FileName is null ? ClassName : FileName ) + ".cs" ) ;
155
154
156
- // Remove the first two parts of the namespace to avoid the files being created in the Substrate/NetApi sub folder.
155
+ // Remove the first two parts of the namespace to avoid the files being created in the Substrate/NetApi sub folder.
157
156
space = space . TakeLast ( space . Count - 2 ) . ToList ( ) ;
158
157
159
158
// Add base path at the beginning of the paths list
@@ -176,8 +175,25 @@ protected void AddTargetClassCustomAttributes(CodeTypeDeclaration targetClass, N
176
175
targetClass . CustomAttributes . Add ( new CodeAttributeDeclaration ( new CodeTypeReference ( "SubstrateNodeType" ) , new CodeAttributeArgument (
177
176
new CodeSnippetExpression ( $ "TypeDefEnum.{ typeDef . TypeDef } ")
178
177
) ) ) ;
179
-
180
178
}
181
179
180
+ public static string HandleReservedKeyword ( string name )
181
+ {
182
+ // List of C# reserved keywords
183
+ var reservedKeywords = new HashSet < string >
184
+ {
185
+ "abstract" , "as" , "base" , "bool" , "break" , "byte" , "case" , "catch" , "char" , "checked" , "class" ,
186
+ "const" , "continue" , "decimal" , "default" , "delegate" , "do" , "double" , "else" , "enum" , "event" ,
187
+ "explicit" , "extern" , "false" , "finally" , "fixed" , "float" , "for" , "foreach" , "goto" , "if" ,
188
+ "implicit" , "in" , "int" , "interface" , "internal" , "is" , "lock" , "long" , "namespace" , "new" , "null" ,
189
+ "object" , "operator" , "out" , "override" , "params" , "private" , "protected" , "public" , "readonly" ,
190
+ "ref" , "return" , "sbyte" , "sealed" , "short" , "sizeof" , "stackalloc" , "static" , "string" , "struct" ,
191
+ "switch" , "this" , "throw" , "true" , "try" , "typeof" , "uint" , "ulong" , "unchecked" , "unsafe" , "ushort" ,
192
+ "using" , "virtual" , "void" , "volatile" , "while"
193
+ } ;
194
+
195
+ // If the name is a reserved keyword, prepend with @
196
+ return reservedKeywords . Contains ( name ) ? $ "@{ name } " : name ;
197
+ }
182
198
}
183
199
}
0 commit comments