Skip to content

Commit 14c7ba7

Browse files
🚚 Rename to Lite3
1 parent 9e3c616 commit 14c7ba7

32 files changed

+458
-459
lines changed
File renamed without changes.
Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
using System.Text;
2+
using Lite3.Generators.Text;
23
using Microsoft.CodeAnalysis;
34
using Microsoft.CodeAnalysis.Text;
4-
using TronDotNet.Generators.Text;
5-
using static TronDotNet.Generators.TronApiGenerator.AttributeProperty;
5+
using static Lite3.Generators.Lite3ApiGenerator.AttributeProperty;
66

7-
namespace TronDotNet.Generators;
7+
namespace Lite3.Generators;
88

99
[Generator]
10-
public class TronApiGenerator : IIncrementalGenerator
10+
public class Lite3ApiGenerator : IIncrementalGenerator
1111
{
1212
public static class AttributeProperty
1313
{
@@ -18,14 +18,14 @@ public const string
1818
}
1919

2020
private const string
21-
CoreTypeName = "Lite3",
22-
TronTypeName = "Tron",
23-
TronContextTypeName = "TronContext",
24-
TronContextExtensionsTypeName = $"{TronContextTypeName}Extensions",
21+
CoreTypeName = "Lite3Core",
22+
PublicTypeName = "Lite3",
23+
ContextTypeName = "Lite3Context",
24+
ContextExtensionsTypeName = $"{ContextTypeName}Extensions",
2525
CoreMethodPrefix = $"{CoreTypeName}.",
26-
CoreNamespace = $"{nameof(TronDotNet)}",
26+
CoreNamespace = $"{nameof(Lite3)}",
2727
AttributeNamespace = $"{CoreNamespace}.{nameof(Generators)}",
28-
AttributeName = "TronApiAttribute",
28+
AttributeName = "Lite3ApiAttribute",
2929
AttributeTypeMetadataName = $"{AttributeNamespace}.{AttributeName}",
3030
AttributeSource =
3131
$$"""
@@ -65,25 +65,25 @@ public void Initialize(IncrementalGeneratorInitializationContext initialization)
6565

6666
var attributeType = compilation.GetTypeByMetadataName(AttributeTypeMetadataName);
6767

68-
var tronPrimarySource = new StringBuilder();
69-
var tronContextSource = new StringBuilder();
68+
var primarySource = new StringBuilder();
69+
var contextSource = new StringBuilder();
7070

71-
tronPrimarySource
71+
primarySource
7272
.Append("namespace ").Append(CoreNamespace).AppendLine(";")
7373
.AppendLine()
7474
.AppendLine("using System.Runtime.CompilerServices;")
75-
.Append("using static ").Append(CoreNamespace).Append(".").Append(CoreTypeName).AppendLine(";")
75+
.Append("using static ").Append(CoreTypeName).AppendLine(";")
7676
.AppendLine()
77-
.Append("public static partial class ").AppendLine(TronTypeName)
77+
.Append("public static partial class ").AppendLine(PublicTypeName)
7878
.AppendLine("{");
7979

80-
tronContextSource
80+
contextSource
8181
.Append("namespace ").Append(CoreNamespace).AppendLine(";")
8282
.AppendLine()
8383
.AppendLine("using System.Runtime.CompilerServices;")
84-
.Append("using static ").Append(CoreNamespace).Append(".").Append(CoreTypeName).AppendLine(";")
84+
.Append("using static ").Append(CoreTypeName).AppendLine(";")
8585
.AppendLine()
86-
.Append("public static class ").AppendLine(TronContextExtensionsTypeName)
86+
.Append("public static class ").AppendLine(ContextExtensionsTypeName)
8787
.AppendLine("{");
8888

8989
foreach (var (method, methodIndex) in methodSymbols.Select(Index))
@@ -117,24 +117,24 @@ public void Initialize(IncrementalGeneratorInitializationContext initialization)
117117

118118
var writeNewLine = methodIndex > 0;
119119
// ReSharper disable RedundantAssignment
120-
writeNewLine |= TryWriteMethod(tronContextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: true, isContextApi: true);
121-
writeNewLine |= TryWriteMethod(tronContextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: false, isContextApi: true);
122-
writeNewLine |= TryWriteMethod(tronContextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: true, isContextApi: true);
123-
writeNewLine |= TryWriteMethod(tronContextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: false, isContextApi: true);
120+
writeNewLine |= TryWriteMethod(contextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: true, isContextApi: true);
121+
writeNewLine |= TryWriteMethod(contextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: false, isContextApi: true);
122+
writeNewLine |= TryWriteMethod(contextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: true, isContextApi: true);
123+
writeNewLine |= TryWriteMethod(contextSource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: false, isContextApi: true);
124124

125125
writeNewLine = methodIndex > 0;
126-
writeNewLine |= TryWriteMethod(tronPrimarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: true, isContextApi: false);
127-
writeNewLine |= TryWriteMethod(tronPrimarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: false, isContextApi: false);
128-
writeNewLine |= TryWriteMethod(tronPrimarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: true, isContextApi: false);
129-
writeNewLine |= TryWriteMethod(tronPrimarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: false, isContextApi: false);
126+
writeNewLine |= TryWriteMethod(primarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: true, isContextApi: false);
127+
writeNewLine |= TryWriteMethod(primarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: true, createKeyData: false, isContextApi: false);
128+
writeNewLine |= TryWriteMethod(primarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: true, isContextApi: false);
129+
writeNewLine |= TryWriteMethod(primarySource, method, attrData, xmlComment, writeNewLine, useTryPattern: false, createKeyData: false, isContextApi: false);
130130
// ReSharper restore RedundantAssignment
131131
}
132132

133-
tronPrimarySource.AppendLine("}");
134-
tronContextSource.AppendLine("}");
133+
primarySource.AppendLine("}");
134+
contextSource.AppendLine("}");
135135

136-
context.AddSource($"Tron.g.cs", tronPrimarySource.ToString());
137-
context.AddSource($"TronContextExtensions.g.cs", tronContextSource.ToString());
136+
context.AddSource($"Lite3.g.cs", primarySource.ToString());
137+
context.AddSource($"Lite3ContextExtensions.g.cs", contextSource.ToString());
138138
}
139139
);
140140
}
@@ -194,9 +194,11 @@ private static bool TryWriteMethod(StringBuilder source,
194194

195195
var originalReturnTypeName = method.ReturnsVoid ? "void" : GetTypeName(method.ReturnType);
196196

197-
var returnTypeName =
197+
const string refContext = $"ref {ContextTypeName}";
198+
199+
var returnTypeMoniker =
198200
useTryPattern ? "bool" :
199-
isContextApi && isChainableMethod ? "ref TronContext" :
201+
isContextApi && isChainableMethod ? refContext :
200202
returnArgParam != null ? GetTypeName(returnArgParam.Type) :
201203
tryPattern ? "void" :
202204
originalReturnTypeName;
@@ -254,7 +256,7 @@ private static bool TryWriteMethod(StringBuilder source,
254256

255257
if (text.StartsWith("<returns>"))
256258
{
257-
if (returnTypeName == "void")
259+
if (returnTypeMoniker == "void")
258260
continue;
259261

260262
if (useTryPattern)
@@ -300,7 +302,7 @@ private static bool TryWriteMethod(StringBuilder source,
300302
.Append(indent).AppendLine(InlineAttribute)
301303
.Append(indent)
302304
.Append("public static ")
303-
.Append(returnTypeName)
305+
.Append(returnTypeMoniker)
304306
.Append(" ")
305307
.Append(useTryPattern ? "Try" : null)
306308
.Append(method.Name)
@@ -311,7 +313,7 @@ private static bool TryWriteMethod(StringBuilder source,
311313
{
312314
if (isContextApi && index == 0)
313315
{
314-
source.Append("this ref TronContext context");
316+
source.Append("this ").Append(refContext).Append(" context");
315317
indexOffset++;
316318
}
317319

@@ -410,7 +412,7 @@ private static bool TryWriteMethod(StringBuilder source,
410412
source.Append(indent).AppendLine("return ref context;");
411413
else if (returnArgParam != null)
412414
source.Append(indent).Append("return ").Append(returnArgParam.Name).AppendLine(";");
413-
else if (returnTypeName != "void")
415+
else if (returnTypeMoniker != "void")
414416
source.Append(indent).AppendLine("return result;");
415417
}
416418

TronDotNet.Generators/Properties/launchSettings.json renamed to Lite3.Generators/Properties/launchSettings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"profiles": {
44
"Generators": {
55
"commandName": "DebugRoslynComponent",
6-
"targetProject": "../TronDotNet/TronDotNet.csproj"
6+
"targetProject": "../Lite3/Lite3.csproj"
77
}
88
}
9-
}
9+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TronDotNet.Generators.Text;
1+
namespace Lite3.Generators.Text;
22

33
internal class Indent
44
{

TronDotNet.Generators/Text/TextExtensions.cs renamed to Lite3.Generators/Text/TextExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TronDotNet.Generators.Text;
1+
namespace Lite3.Generators.Text;
22

33
public static class TextExtensions
44
{

TronDotNet.SystemTextJson/JsonConstants.cs renamed to Lite3.SystemTextJson/JsonConstants.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace TronDotNet.SystemTextJson;
1+
namespace Lite3.SystemTextJson;
22

33
internal static class JsonConstants
44
{

TronDotNet.SystemTextJson/TronDotNet.SystemTextJson.csproj renamed to Lite3.SystemTextJson/Lite3.SystemTextJson.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77

8-
<PackageId>Tron.Lite3.SystemTextJson</PackageId>
8+
<PackageId>Lite3.Net.SystemTextJson</PackageId>
99
<Authors>Anders Storhaug</Authors>
10-
<Description>JSON Encoding for Tron-DotNet, C# port of TRON (Lite³).</Description>
10+
<Description>JSON Encoding for Lite³</Description>
1111
<PackageLicenseExpression>MIT</PackageLicenseExpression>
12-
<RepositoryUrl>https://github.com/andersstorhaug/Tron-DotNet</RepositoryUrl>
12+
<RepositoryUrl>https://github.com/andersstorhaug/Lite3-DotNet</RepositoryUrl>
1313
<RepositoryType>git</RepositoryType>
1414
<PackageReadmeFile>README.md</PackageReadmeFile>
1515
</PropertyGroup>
@@ -19,7 +19,7 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<ProjectReference Include="..\TronDotNet\TronDotNet.csproj" />
22+
<ProjectReference Include="..\Lite3\Lite3.csproj" />
2323
</ItemGroup>
2424

2525
</Project>

0 commit comments

Comments
 (0)