Skip to content

Commit

Permalink
TypeScript Parser Implementation (#54)
Browse files Browse the repository at this point in the history
* Multi-targeting with .NET 8.

* Fix test path...

* Gen AI triple slash...

* Fix the publish bits.

* Remove legacy switch

* Upgrade to .NET 8.0, and use Central Package Management.

* Fix merge issues.

* Upgrade a few versions...

* chore: remove globals.json

* fix: merge issues

* feat: start using Typescript AST

* chore: remove regex parsing for source, use new AST. For now use old method to parse objects. Use raw strings for tests

* chore: deep cleanup, apply sonar lint performance suggestions. Tests work as expected

* fix: source generator not finding reference assembly

* chore: code formatting

* feat: implmented AST into the parser and source writer

* chore: updated some test to match the output

* chore: split main into method, code readability

* fix: generic type not analyzed both for parses and builder, missing namespace to GenericOptions

* feat: remove all regexes

* fix: url double encoded

* chore: split GetNodeText into function, add types examples of to handle

* chore: create singleton for primitive mapping

---------

Co-authored-by: David Pine <[email protected]>
Co-authored-by: David Pine <[email protected]>
Co-authored-by: Koja sig. Dennis <[email protected]>
  • Loading branch information
4 people authored Jul 17, 2024
1 parent 471581c commit c4619d3
Show file tree
Hide file tree
Showing 122 changed files with 2,616 additions and 2,697 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ file_header_template = Copyright (c) David Pine. All rights reserved.\nLicensed
indent_size = 4
tab_width = 4
trim_trailing_whitespace = true
end_of_line = lf

###############################
# .NET Coding Conventions #
Expand Down
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
10 changes: 5 additions & 5 deletions .github/workflows/build-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ jobs:
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET 7.0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Restore dependencies for ${{ matrix.project }}
run: |
Expand All @@ -59,10 +59,10 @@ jobs:
steps:
- uses: actions/checkout@main

- name: Setup .NET 7.0
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Run tests
run: |
Expand All @@ -74,7 +74,7 @@ jobs:
- name: Install Playwright dependencies
run: |
pwsh ./tests/Blazor.ExampleConsumer.EndToEndTests/bin/Release/net7.0/playwright.ps1 install --with-deps
pwsh ./tests/Blazor.ExampleConsumer.EndToEndTests/bin/Release/net8.0/playwright.ps1 install --with-deps
- name: Run end-to-end tests
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x
- name: Test
run: dotnet test --filter "Category!=EndToEnd" --configuration Release

Expand All @@ -22,7 +22,7 @@ jobs:
- name: Install Playwright dependencies
run: |
pwsh ./tests/Blazor.ExampleConsumer.EndToEndTests/bin/Release/net7.0/playwright.ps1 install --with-deps
pwsh ./tests/Blazor.ExampleConsumer.EndToEndTests/bin/Release/net8.0/playwright.ps1 install --with-deps
- name: Run end-to-end tests
run: |
Expand Down Expand Up @@ -65,11 +65,11 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
dotnet-version: 8.0.x

- name: Restore dependencies for ${{ matrix.project }}
run: |
dotnet restore ./src/${{ matrix.project }}/${{ matrix.project }}.csproj --configuration Release
dotnet restore ./src/${{ matrix.project }}/${{ matrix.project }}.csproj
- name: Build ${{ matrix.project }}
run: |
Expand Down
74 changes: 37 additions & 37 deletions .github/workflows/publish-to-gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
name: publish demo
on:
push:
branches: [ main ]
name: publish demo
on:
push:
branches: [ main ]
paths:
- 'samples/**'
- 'samples/**'
workflow_dispatch:
inputs:
reason:
description: 'The reason for running the workflow'
required: true
default: 'Manual run'
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
default: 'Manual run'
jobs:
deploy-to-github-pages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: 'Print manual run reason'
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET Core SDK
uses: actions/setup-dotnet@main
with:
dotnet-version: 7.0.x
- name: Publish .NET Core Project
run: dotnet publish samples/Blazor.ExampleConsumer/Blazor.ExampleConsumer.csproj -c Release -o release --nologo

# Changes the base-tag in index.html from '/' to '/blazorators' to match GitHub Pages repository subdirectory
- name: Change base-tag in index.html from / to /blazorators
run: sed -i 's/<base href="\/" \/>/<base href="\/blazorators\/" \/>/g' release/wwwroot/index.html

# Copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html

# Add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project.
# Allow files and folders starting with an underscore
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

- name: Commit wwwroot to GitHub Pages
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
echo 'Reason: ${{ github.event.inputs.reason }}'
- name: Setup .NET
uses: actions/setup-dotnet@main
with:
dotnet-version: 8.0.x
- name: Publish .NET Core Project
run: dotnet publish samples/Blazor.ExampleConsumer/Blazor.ExampleConsumer.csproj -c Release -o release --nologo

# Changes the base-tag in index.html from '/' to '/blazorators' to match GitHub Pages repository subdirectory
- name: Change base-tag in index.html from / to /blazorators
run: sed -i 's/<base href="\/" \/>/<base href="\/blazorators\/" \/>/g' release/wwwroot/index.html

# Copy index.html to 404.html to serve the same file when a file is not found
- name: copy index.html to 404.html
run: cp release/wwwroot/index.html release/wwwroot/404.html

# Add .nojekyll file to tell GitHub pages to not treat this as a Jekyll project.
# Allow files and folders starting with an underscore
- name: Add .nojekyll file
run: touch release/wwwroot/.nojekyll

- name: Commit wwwroot to GitHub Pages
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: release/wwwroot
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
</PropertyGroup>

<PropertyGroup>
<DefaultTargetFrameworks>net7.0</DefaultTargetFrameworks>
<DefaultTargetFrameworks>net7.0;net8.0</DefaultTargetFrameworks>
<LangVersion>preview</LangVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
38 changes: 38 additions & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<Project>
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<!-- Use these versions regardless of TFM -->
<ItemGroup>
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<PackageVersion Include="MinVer" Version="5.0.0-beta.1" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
<PackageVersion Include="System.Reactive.Linq" Version="6.0.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="Microsoft.Playwright" Version="1.39.0" />
<PackageVersion Include="xunit" Version="2.6.1" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.3" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="Basic.Reference.Assemblies" Version="1.4.5" />
<PackageVersion Include="Humanizer.Core" Version="2.14.1" />
</ItemGroup>
<!-- .NET 7.0 bits -->
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="7.0.14" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="7.0.0" />
<PackageVersion Include="Microsoft.JSInterop" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.14" />
</ItemGroup>
<!-- .NET 8.0 bits -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
<PackageVersion Include="Microsoft.Extensions.Primitives" Version="8.0.0" />
<PackageVersion Include="Microsoft.JSInterop" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0" />
</ItemGroup>
</Project>
1 change: 0 additions & 1 deletion blazorators.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
.editorconfig = .editorconfig
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
global.json = global.json
LICENSE = LICENSE
logo-large.png = logo-large.png
logo.png = logo.png
Expand Down
6 changes: 0 additions & 6 deletions global.json

This file was deleted.

36 changes: 18 additions & 18 deletions samples/Blazor.ExampleConsumer/Blazor.ExampleConsumer.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Humanizer.Core" Version="2.14.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.1" PrivateAssets="all" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Humanizer.Core" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Blazor.Geolocation.WebAssembly\Blazor.Geolocation.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.LocalStorage.WebAssembly\Blazor.LocalStorage.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.Serialization\Blazor.Serialization.csproj" />
<ProjectReference Include="..\..\src\Blazor.SessionStorage.WebAssembly\Blazor.SessionStorage.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.SpeechRecognition.WebAssembly\Blazor.SpeechRecognition.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.SpeechSynthesis.WebAssembly\Blazor.SpeechSynthesis.WebAssembly.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Blazor.Geolocation.WebAssembly\Blazor.Geolocation.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.LocalStorage.WebAssembly\Blazor.LocalStorage.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.Serialization\Blazor.Serialization.csproj" />
<ProjectReference Include="..\..\src\Blazor.SessionStorage.WebAssembly\Blazor.SessionStorage.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.SpeechRecognition.WebAssembly\Blazor.SpeechRecognition.WebAssembly.csproj" />
<ProjectReference Include="..\..\src\Blazor.SpeechSynthesis.WebAssembly\Blazor.SpeechSynthesis.WebAssembly.csproj" />
</ItemGroup>

</Project>
File renamed without changes.
19 changes: 19 additions & 0 deletions samples/Blazor.ExampleConsumer/Components/Layout/MainLayout.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@using System.Runtime.InteropServices
@inherits LayoutComponentBase

<div class="page">
<div class="sidebar">
<NavMenu />
</div>

<main>
<div class="top-row px-4 text-muted">
Powered by @RuntimeInformation.FrameworkDescription
</div>

<article class="content px-4 col-xl-8">
@Body
</article>

</main>
</div>
Loading

0 comments on commit c4619d3

Please sign in to comment.