Skip to content

Commit e39a16a

Browse files
authored
feat: Updated to .NET8 (#70)
* chore: Update formatting in code files Used CSharpier. * feat(upgrade): Upgraded to .NET8 * feat(formatting): Updated CSharpText Formatter to use CSharpier feat(server): Updated Server Generation to format after Generation Cleanup. * chore: Readme Updates * build: Update NodeJS version to 20 in GitHub workflow * chore: Update .gitignore and project dependencies * chore: Updated Sample WASM project * fix: Fixed Missing support for private and protected Accessibility types in NodeJS Parser chore: Update NoWarn property in project files +semver: minor
1 parent 382eb16 commit e39a16a

File tree

1,114 files changed

+134981
-87643
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,114 files changed

+134981
-87643
lines changed

.editorconfig

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ charset = utf-8
1818
# Organize usings
1919
dotnet_sort_system_directives_first = true
2020
# 'using' directive preferences
21-
csharp_using_directive_placement = inside_namespace:warning
21+
csharp_style_namespace_declarations = file_scoped:warning
22+
2223
# this. preferences
2324
dotnet_style_qualification_for_field = false:silent
2425
dotnet_style_qualification_for_property = false:silent

.github/workflows/dotnet-core.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ jobs:
1313
runs-on: ubuntu-latest
1414
steps:
1515
- uses: actions/checkout@v2
16-
- name: Setup .NET6
16+
- name: Setup .NET8
1717
uses: actions/setup-dotnet@v1
1818
with:
19-
dotnet-version: '6.0.x'
19+
dotnet-version: '8.0.x'
2020
- name: Setup NodeJS
2121
uses: actions/setup-node@v2
2222
with:
23-
node-version: '12'
23+
node-version: '20'
2424
- name: Install dependencies
2525
run: dotnet restore
2626
- name: Build

.github/workflows/dotnet-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ jobs:
2525
additionalArguments: '/updateAssemblyInfo'
2626
- run: |
2727
echo "NuGetVersionV2: ${{ steps.gitversion.outputs.NuGetVersionV2 }}"
28-
- name: Setup .NET6
28+
- name: Setup .NET8
2929
uses: actions/setup-dotnet@v1
3030
with:
31-
dotnet-version: '6.0.x'
31+
dotnet-version: '8.0.x'
3232
- name: Build with dotnet
3333
run: dotnet build --configuration Release
3434
- name: Pack with dotnet

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,5 +251,8 @@ appsettings.*.json
251251
data/*.json
252252
App_Data/*
253253

254+
lcov.info
254255
coverage*.json
255256
coverage*.xml
257+
258+
published

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[![Build Status](https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fcanhorn%2FEventHorizon.Blazor.TypeScript.Interop.Generator%2Fbadge%3Fref%3Dmain&style=for-the-badge)](https://actions-badge.atrox.dev/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator/goto?ref=main)
2-
[![codecov](https://img.shields.io/codecov/c/github/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge)](https://codecov.io/gh/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator)
2+
[![codecov](https://img.shields.io/codecov/c/github/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge)](https://codecov.io/gh/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator)
33
[![EventHorizon.Blazor.TypeScript.Interop.Generator](https://img.shields.io/nuget/v/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge&label=Nuget)](https://www.nuget.org/packages/EventHorizon.Blazor.TypeScript.Interop.Generator)
44

55
[![GitHub](https://img.shields.io/github/license/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator?style=for-the-badge)](https://github.com/canhorn/EventHorizon.Blazor.TypeScript.Interop.Generator/blob/main/LICENSE)
@@ -13,12 +13,12 @@
1313

1414
# About EventHorizon Blazor TypeScript Interop Generator
1515

16-
This project generates a C# Blazor Interop proxy using a TypeScript definition file.
16+
This project generates a C# Blazor Interop proxy using a TypeScript definition file.
1717

1818
## Details
1919

20-
The generated project can be used with Blazor Wasm/Server to interface with JavaScript from C#, this gives most JavaScript libraries an easy to use interface from C#.
21-
It uses the JSRuntime to interop directly with the underlying JavaScript from C#, this is done with a custom interop abstraction.
20+
The generated project can be used with Blazor Wasm/Server to interface with JavaScript from C#, this gives most JavaScript libraries an easy to use interface from C#.
21+
It uses the JSRuntime to interop directly with the underlying JavaScript from C#, this is done with a custom interop abstraction.
2222

2323
The Wasm interop project can be found in the [canhorn/EventHorizon.Blazor.Interop](https://github.com/canhorn/EventHorizon.Blazor.Interop) repository, it gives the generated code access to a common set of access patterns it then uses to interface with the JavaScript. The [canhorn/EventHorizon.Blazor.Server.Interop](https://github.com/canhorn/EventHorizon.Blazor.Server.Interop) repository contains the Blazor Server, async first, JavaScript access patterns.
2424

@@ -27,13 +27,14 @@ The Wasm interop project can be found in the [canhorn/EventHorizon.Blazor.Intero
2727
* [.NET Core](https://dotnet.microsoft.com/)
2828
* [TypeScript](https://www.typescriptlang.org/)
2929
* [NodeJS](https://nodejs.org/)
30+
* Required Version >= 20
3031

3132
## TypeScript Parser
3233

33-
The generation relies heavily on the TypeScript Abstract Syntax Tree and so the code includes ways to parse the source files into a AST representation for easier generation.
34+
The generation relies heavily on the TypeScript Abstract Syntax Tree and so the code includes ways to parse the source files into a AST representation for easier generation.
3435

3536
The code has two supported parser types, .NET and NodeJS, to do realtime parsing of code. Using a .NET library it's able to do very quick parsing, but since it has not been maintained it can not handle complex or modern TypeScript syntax.
36-
But with the NodeJS TypeScript parser it can handle modern more complex TypeScript syntax, but with the trade off of in speed.
37+
But with the NodeJS TypeScript parser it can handle modern more complex TypeScript syntax, but with the trade off of in speed.
3738

3839
> Having NodeJS installed is required to use the NodeJS TypeScript parser. (This is required when using the parser with the Tool)
3940

Sample/EventHorizon.BabylonJS.Interop.Generator.ConsoleApp/EventHorizon.BabylonJS.Interop.Generator.ConsoleApp.csproj

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

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>net8.0</TargetFramework>
66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

Lines changed: 111 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,149 +1,123 @@
1-
namespace EventHorizon.Blazor.TypeScript.Interop.Generator.ConsoleApp
1+
namespace EventHorizon.Blazor.TypeScript.Interop.Generator.ConsoleApp;
2+
3+
using System.Collections.Generic;
4+
using System.Diagnostics;
5+
using System.IO;
6+
using EventHorizon.Blazor.TypeScript.Interop.Generator.Formatter;
7+
using EventHorizon.Blazor.TypeScript.Interop.Generator.Logging;
8+
using ServerGenerator = Blazor.Interop.Generator.GenerateInteropSource;
9+
using ServerProjectWriter = Blazor.Interop.Generator.Writers.Project.ServerProjectWriter;
10+
using WasmGenerator = GenerateSource;
11+
using WasmProjectWriter = Writers.Project.ProjectWriter;
12+
13+
public class Program
214
{
3-
using System.Collections.Generic;
4-
using System.Diagnostics;
5-
using System.IO;
6-
using EventHorizon.Blazor.TypeScript.Interop.Generator.Formatter;
7-
using EventHorizon.Blazor.TypeScript.Interop.Generator.Logging;
15+
static void Main(string[] args)
16+
{
17+
// pre-05/26/2024 - 75084ms/71877ms to generate.
18+
// 05/26/2024 - 26662ms/27904ms/27486ms to generate.
19+
Run(AstParser.Model.ASTParserType.NodeJS, true, "EventHorizon.Blazor.BabylonJS.NodeJS");
820

9-
using ServerGenerator = Blazor.Interop.Generator.GenerateInteropSource;
10-
using ServerProjectWriter = Blazor.Interop.Generator.Writers.Project.ServerProjectWriter;
11-
using WasmGenerator = GenerateSource;
12-
using WasmProjectWriter = Writers.Project.ProjectWriter;
21+
// pre-05/26/2024 - 22027ms/19835ms/18236ms to generate.
22+
// 05/26/2024 - 10116ms/9721ms/9762ms to generate.
23+
Run(AstParser.Model.ASTParserType.Sdcb, true, "EventHorizon.Blazor.BabylonJS.WASM");
24+
25+
// 05/26/2024 - 10545ms/10603ms/10318ms to generate.
26+
Run(AstParser.Model.ASTParserType.Sdcb, false, "EventHorizon.Blazor.BabylonJS.Server");
27+
}
1328

14-
public class Program
29+
static void Run(AstParser.Model.ASTParserType type, bool useWasm, string projectAssembly)
1530
{
16-
static void Main(string[] args)
31+
var stopwatch = Stopwatch.StartNew();
32+
//var projectAssembly = "EventHorizon.Blazor.BabylonJS.WASM";
33+
var projectGenerationLocation = Path.Combine("..", "_generated");
34+
35+
var sourceDirectory = Path.Combine(".", "SourceFiles");
36+
var textFormatter = new CSharpTextFormatter();
37+
var sourceFiles = new List<string>
1738
{
18-
//Run(AstParser.Model.ASTParserType.NodeJS, true); // 75084ms/71877ms to generate.
19-
Run(
20-
AstParser.Model.ASTParserType.Sdcb,
21-
true,
22-
"EventHorizon.Blazor.BabylonJS.WASM"
23-
); // 22027ms/19835ms/18236ms to generate.
24-
//Run(
25-
// AstParser.Model.ASTParserType.Sdcb,
26-
// false,
27-
// "EventHorizon.Blazor.BabylonJS.Server"
28-
//);
29-
}
30-
static void Run(
31-
AstParser.Model.ASTParserType type,
32-
bool useWasm,
33-
string projectAssembly
34-
)
39+
//"testing.d.ts",
40+
"babylon.d.ts",
41+
"babylon.gui.d.ts",
42+
};
43+
var generationList = new List<string>
3544
{
36-
var stopwatch = Stopwatch.StartNew();
37-
//var projectAssembly = "EventHorizon.Blazor.BabylonJS.WASM";
38-
var projectGenerationLocation = Path.Combine(
39-
"..",
40-
"_generated"
41-
);
45+
//"Everything",
46+
"Scene",
47+
"VertexBuffer",
48+
"ICameraInput",
49+
"AbstractActionManager",
50+
"ICustomAnimationFrameRequester",
51+
"IAction",
52+
"Vector3",
53+
"EventState",
54+
"Observable",
55+
"Container",
56+
"Control",
57+
"Button",
58+
"UniversalCamera",
59+
"ArcRotateCamera",
60+
"PointLight",
61+
"Grid",
62+
"StackPanel",
63+
"MeshBuilder",
64+
"StandardMaterial",
65+
"Texture",
66+
"HemisphericLight",
67+
"PointerInfo",
68+
"PointerInfoBase",
69+
"SceneLoader",
70+
"ParticleHelper",
71+
"Sound",
72+
"Tools",
73+
};
4274

43-
var sourceDirectory = Path.Combine(
44-
".",
45-
"SourceFiles"
46-
);
47-
var textFormatter = new NoFormattingTextFormatter();
48-
var sourceFiles = new List<string>
49-
{
50-
//"testing.d.ts",
51-
"babylon.d.ts",
52-
"babylon.gui.d.ts",
53-
};
54-
var generationList = new List<string>
55-
{
56-
//"Everything",
57-
"Scene",
58-
"VertexBuffer",
59-
"ICameraInput",
60-
"AbstractActionManager",
61-
"ICustomAnimationFrameRequester",
62-
"IAction",
63-
"Vector3",
64-
"EventState",
65-
"Observable",
66-
"Container",
67-
"Control",
68-
"Button",
69-
"UniversalCamera",
70-
"ArcRotateCamera",
71-
"PointLight",
72-
"Grid",
73-
"StackPanel",
74-
"MeshBuilder",
75-
"StandardMaterial",
76-
"Texture",
77-
"HemisphericLight",
78-
"PointerInfo",
79-
"PointerInfoBase",
80-
"SceneLoader",
81-
"ParticleHelper",
82-
"Sound",
83-
"Tools",
84-
};
75+
// Remove any already Generated Source.
76+
if (Directory.Exists(Path.Combine(projectGenerationLocation, projectAssembly)))
77+
{
78+
Directory.Delete(Path.Combine(projectGenerationLocation, projectAssembly), true);
79+
}
80+
GlobalLogger.Info("Removed Generation Directory");
8581

86-
// Remove any already Generated Source.
87-
if (Directory.Exists(Path.Combine(
82+
if (useWasm)
83+
{
84+
GlobalLogger.Info("Running Wasm Generator");
85+
var writer = new WasmProjectWriter(projectGenerationLocation, projectAssembly);
86+
new WasmGenerator().Run(
87+
projectAssembly,
88+
sourceDirectory,
89+
sourceFiles,
90+
generationList,
91+
writer,
92+
textFormatter,
93+
new Dictionary<string, string> { { "BABYLON.PointerInfoBase | type", "int" } },
94+
type
95+
);
96+
}
97+
else
98+
{
99+
GlobalLogger.Info("Running Server Generator");
100+
// For the Server Generator, we don't want to format the text. So we use the NoFormattingTextFormatter.
101+
// We want to let the Server Project Writer handle the formatting.
102+
var noFormattingTextFormatter = new NoFormattingTextFormatter();
103+
var writer = new ServerProjectWriter(
88104
projectGenerationLocation,
89-
projectAssembly
90-
)))
91-
{
92-
Directory.Delete(
93-
Path.Combine(
94-
projectGenerationLocation,
95-
projectAssembly
96-
),
97-
true
98-
);
99-
}
100-
GlobalLogger.Info("Removed Generation Directory");
101-
102-
if (useWasm)
103-
{
104-
GlobalLogger.Info("Running Wasm Generator");
105-
var writer = new WasmProjectWriter(
106-
projectGenerationLocation,
107-
projectAssembly
108-
);
109-
new WasmGenerator().Run(
110-
projectAssembly,
111-
sourceDirectory,
112-
sourceFiles,
113-
generationList,
114-
writer,
115-
textFormatter,
116-
new Dictionary<string, string>
117-
{
118-
{ "BABYLON.PointerInfoBase | type", "int" }
119-
},
120-
type
121-
);
122-
}
123-
else
124-
{
125-
GlobalLogger.Info("Running Server Generator");
126-
var writer = new ServerProjectWriter(
127-
projectGenerationLocation,
128-
projectAssembly
129-
);
130-
new ServerGenerator().Run(
131-
projectAssembly,
132-
sourceDirectory,
133-
sourceFiles,
134-
generationList,
135-
writer,
136-
textFormatter,
137-
new Dictionary<string, string>
138-
{
139-
{ "BABYLON.PointerInfoBase | type", "int" }
140-
},
141-
type
142-
);
143-
}
144-
stopwatch.Stop();
145-
GlobalLogger.Info("Removed Generation Directory");
146-
GlobalLogger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to generate.");
105+
projectAssembly,
106+
textFormatter
107+
);
108+
new ServerGenerator().Run(
109+
projectAssembly,
110+
sourceDirectory,
111+
sourceFiles,
112+
generationList,
113+
writer,
114+
noFormattingTextFormatter,
115+
new Dictionary<string, string> { { "BABYLON.PointerInfoBase | type", "int" } },
116+
type
117+
);
147118
}
119+
stopwatch.Stop();
120+
GlobalLogger.Info("Removed Generation Directory");
121+
GlobalLogger.Info($"Took {stopwatch.ElapsedMilliseconds}ms to generate.");
148122
}
149123
}

Sample/EventHorizon.Blazor.BabylonJS/App.razor

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
<Router AppAssembly="@typeof(Program).Assembly">
1+
<Router AppAssembly="@typeof(App).Assembly">
22
<Found Context="routeData">
33
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />
4+
<FocusOnNavigate RouteData="@routeData" Selector="h1" />
45
</Found>
56
<NotFound>
7+
<PageTitle>Not found</PageTitle>
68
<LayoutView Layout="@typeof(MainLayout)">
7-
<p>Sorry, there's nothing at this address.</p>
9+
<p role="alert">Sorry, there's nothing at this address.</p>
810
</LayoutView>
911
</NotFound>
1012
</Router>

0 commit comments

Comments
 (0)