Skip to content

Commit 8cc1ecb

Browse files
authored
Next ver 068 (#84)
* updated to 0.6.7 added new rust enum version updated net api to 24-rc5 * updated comments * next version
1 parent 2ea72da commit 8cc1ecb

File tree

6 files changed

+29
-18
lines changed

6 files changed

+29
-18
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Using a terminal of your choice, create a new directory for your project and exe
5656
```sh
5757
dotnet new sln
5858
dotnet new substrate \
59-
--sdk_version 0.6.7 \
59+
--sdk_version 0.6.8 \
6060
--rest_service PROJECTNAME.RestService \
6161
--net_api PROJECTNAME.NetApiExt \
6262
--net_integration PROJECTNAME.Integration \
@@ -127,7 +127,7 @@ You can also watch our short step-by-step tutorial that guides you through the e
127127
- AstarNET
128128
```sh
129129
dotnet new substrate \
130-
--sdk_version 0.6.7 \
130+
--sdk_version 0.6.8 \
131131
--rest_service AstarNET.RestService \
132132
--net_api AstarNET.NetApiExt \
133133
--net_api AstarNET.Integration \

Substrate.ServiceLayer/Substrate.ServiceLayer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
15-
<PackageReference Include="Substrate.NET.API" Version="0.9.24-rc5" />
15+
<PackageReference Include="Substrate.NET.API" Version="0.9.24-rc6" />
1616
<PackageReference Include="System.Collections.Concurrent" Version="4.3.0" />
1717
</ItemGroup>
1818

Tools/Substrate.DotNet.Template/templates/Substrate/.template.config/template.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212
"symbols": {
1313
"sdk_version": {
1414
"datatype": "string",
15-
"defaultValue": "0.6.7",
15+
"defaultValue": "0.6.8",
1616
"description": "Uses the given Substrate .NET Toolchain version.",
1717
"replaces": "SUBSTRATE_TOOLCHAIN_VERSION",
1818
"type": "parameter"
1919
},
2020
"api_version": {
2121
"datatype": "string",
22-
"defaultValue": "0.9.24-rc5",
22+
"defaultValue": "0.9.24-rc6",
2323
"description": "Uses the given Substrate .NET API version.",
2424
"replaces": "SUBSTRATE_NETAPI_VERSION",
2525
"type": "parameter"

Tools/Substrate.DotNet/Service/Node/EnumBuilder.cs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,19 @@ public override TypeBuilderBase Create()
3131

3232
ClassName = $"Enum{enumName}";
3333
ReferenzName = $"{NamespaceName}.{ClassName}";
34-
CodeNamespace typeNamespace = new(NamespaceName);
34+
var typeNamespace = new CodeNamespace(NamespaceName);
3535
TargetUnit.Namespaces.Add(typeNamespace);
3636

3737
// Create the enum itself
38-
CodeTypeDeclaration enumType = new(enumName)
38+
var enumType = new CodeTypeDeclaration(enumName)
3939
{
4040
IsEnum = true
4141
};
4242
enumType.Comments.AddRange(GetComments(typeDef.Docs, null, enumName));
4343

44+
// Detect if this enum has associated types
45+
bool hasAssociatedTypes = false;
46+
4447
if (typeDef.Variants != null)
4548
{
4649
foreach (TypeVariant variant in typeDef.Variants)
@@ -51,26 +54,31 @@ public override TypeBuilderBase Create()
5154
};
5255
enumMember.Comments.AddRange(GetComments(variant.Docs, null, variant.Name));
5356
enumType.Members.Add(enumMember);
57+
58+
// Check if this variant has associated types
59+
if (variant.TypeFields != null && variant.TypeFields.Length > 0)
60+
{
61+
hasAssociatedTypes = true;
62+
}
5463
}
5564
}
5665
typeNamespace.Types.Add(enumType);
5766

58-
// Generate the class based on BaseEnumRust
67+
// Generate the appropriate class based on whether there are associated types
5968
var targetClass = new CodeTypeDeclaration(ClassName)
6069
{
6170
IsClass = true,
6271
TypeAttributes = TypeAttributes.Public | TypeAttributes.Sealed
6372
};
6473
targetClass.Comments.AddRange(GetComments(typeDef.Docs, typeDef));
6574

66-
if (typeDef.Variants != null)
75+
if (hasAssociatedTypes)
6776
{
68-
// Constructor to register decoders
77+
// Generate the class based on BaseEnumRust (with associated types)
6978
var codeConstructor = new CodeConstructor
7079
{
7180
Attributes = MemberAttributes.Public
7281
};
73-
7482
codeConstructor.Comments.AddRange(GetComments(new string[] { "Initializes a new instance of the class." }, null));
7583

7684
foreach (TypeVariant variant in typeDef.Variants)
@@ -96,15 +104,18 @@ public override TypeBuilderBase Create()
96104
);
97105
}
98106

107+
targetClass.BaseTypes.Add(new CodeTypeReference($"BaseEnumRust<{enumName}>"));
99108
targetClass.Members.Add(codeConstructor);
100109
}
110+
else
111+
{
112+
// Generate the class based on BaseEnum (without associated types)
113+
targetClass.BaseTypes.Add(new CodeTypeReference($"BaseEnum<{enumName}>"));
114+
}
101115

102-
targetClass.BaseTypes.Add(new CodeTypeReference($"BaseEnumRust<{enumName}>"));
103116
typeNamespace.Types.Add(targetClass);
104117

105118
return this;
106119
}
107-
108-
109120
}
110-
}
121+
}

Tools/Substrate.DotNet/Substrate.DotNet.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
<ItemGroup>
4242
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
43-
<PackageReference Include="Substrate.NET.API" Version="0.9.24-rc5" />
43+
<PackageReference Include="Substrate.NET.API" Version="0.9.24-rc6" />
4444
<PackageReference Include="System.CodeDom" Version="8.0.0" />
4545
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
4646
</ItemGroup>

Version.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
<!-- Configuration -->
55
<VersionMajor>0</VersionMajor>
66
<VersionMinor>6</VersionMinor>
7-
<VersionPatch>7</VersionPatch>
7+
<VersionPatch>8</VersionPatch>
88
<AssemblyVersion>$(VersionMajor).$(VersionMinor).$(VersionPatch)</AssemblyVersion>
99

10-
<SubstratePackageVersion>0.6.7</SubstratePackageVersion>
10+
<SubstratePackageVersion>0.6.8</SubstratePackageVersion>
1111

1212
<!-- Variables -->
1313
<SubstrateVersion>$(AssemblyVersion)</SubstrateVersion>

0 commit comments

Comments
 (0)