Skip to content
Merged

Vite #1210

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 95 additions & 20 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,33 @@ on:
branches: [ master, main ]
pull_request:
branches: [ master, main ]
workflow_dispatch:
inputs:
publishNuget:
description: "Publish NuGet package and dotnet tool"
required: false
type: boolean
default: false
deployWebFunc:
description: "Deploy web/func artifacts"
required: false
type: boolean
default: false
createRelease:
description: "Create GitHub release"
required: false
type: boolean
default: false
nugetApiKey:
description: "NuGet API key (required if Publish NuGet is checked)"
required: false
type: string

env:
BuildVersion: '10.0.0'

jobs:
build:
build:
runs-on: windows-2022
env:
BuildPlatform: Any CPU
Expand Down Expand Up @@ -51,6 +72,10 @@ jobs:
env:
Tests1: Tests/bin/${{ env.BuildTarget }}/ICSharpCode.CodeConverter.Tests.dll

- name: Run vitest
working-directory: Web
run: npm test -- --run

- name: Upload NuGet package
uses: actions/upload-artifact@v4
with:
Expand All @@ -70,31 +95,81 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
path: Web/bin/${{ env.BuildTarget }}/publish/
path: web/dist/
- name: Upload Function
uses: actions/upload-artifact@v4
with:
name: ICSharpCode.CodeConverter.Func.${{ env.BuildVersion }}.zip
path: Func/bin/${{ env.BuildTarget }}/publish/

deploy:
if: ${{ github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' }}
concurrency: ci-${{ github.ref }}
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4
deploy:
if: ${{ github.event_name == 'workflow_dispatch' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main') }}
concurrency: ci-${{ github.ref }}
needs: [build] # The second job must depend on the first one to complete before running and uses ubuntu-latest instead of windows.
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout 🛎️
uses: actions/checkout@v4

- name: Download Artifacts 🔻 # The built project is downloaded into the 'site' folder.
uses: actions/download-artifact@v4
with:
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
path: site
- name: Download web artifact 🔻 # The built project is downloaded into the 'site' folder.
if: ${{ inputs.deployWebFunc }}
uses: actions/download-artifact@v4
with:
name: ICSharpCode.CodeConverter.Web.${{ env.BuildVersion }}.zip
path: site

- name: Download release artifacts
if: ${{ inputs.createRelease || inputs.publishNuget }}
uses: actions/download-artifact@v4
with:
pattern: ICSharpCode.CodeConverter.*
path: release-artifacts
merge-multiple: true

- name: Extract latest changelog section
id: changelog
shell: pwsh
if: ${{ inputs.createRelease }}
run: |
./Get-LatestChangelog.ps1 -Path CHANGELOG.md | Tee-Object -FilePath release-notes.md
"notes<<EOF" >> $env:GITHUB_OUTPUT
Get-Content release-notes.md >> $env:GITHUB_OUTPUT
"EOF" >> $env:GITHUB_OUTPUT

- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: 'autoupdated/gh-pages'
folder: 'site/wwwroot'
- name: Deploy 🚀
if: ${{ inputs.deployWebFunc }}
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: 'autoupdated/gh-pages'
folder: 'site/wwwroot'

- name: Publish NuGet packages
if: ${{ inputs.publishNuget }}
shell: pwsh
env:
NUGET_API_KEY: ${{ inputs.nugetApiKey }}
run: |
if (-not $env:NUGET_API_KEY) { throw "nugetApiKey input is required when Publish NuGet is checked." }
Write-Output "::add-mask::$env:NUGET_API_KEY"
$source = "https://api.nuget.org/v3/index.json"
$packages = @(
"release-artifacts/ICSharpCode.CodeConverter.*.nupkg",
"release-artifacts/ICSharpCode.CodeConverter.CodeConv.*.nupkg"
)
foreach ($pattern in $packages) {
Get-ChildItem -Path $pattern -File | ForEach-Object {
dotnet nuget push $_.FullName -k $env:NUGET_API_KEY -s $source --skip-duplicate
}
}

- name: Create GitHub release
if: ${{ inputs.createRelease }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.BuildVersion }}.${{ github.run_number }}
name: v${{ env.BuildVersion }}.${{ github.run_number }}
body: ${{ steps.changelog.outputs.notes }}
files: release-artifacts/**

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -287,3 +287,4 @@ __pycache__/
*.odx.cs
*.xsd.cs
/.nuget
/web/.vite/
8 changes: 4 additions & 4 deletions CodeConverter.slnLaunch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[
{
"Name": "Func \u002B Web",
"Name": "Func + Web",
"Projects": [
{
"Name": "Web\\Web.csproj",
"Path": "Func\\Func.csproj",
"Action": "Start"
},
{
"Name": "Func\\Func.csproj",
"Action": "Start"
"Path": "Web\\web.esproj",
"Action": "StartWithoutDebugging"
}
]
}
Expand Down
5 changes: 4 additions & 1 deletion CodeConverter.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@
<Project Path="Func/Func.csproj" />
<Project Path="Tests/Tests.csproj" />
<Project Path="Vsix/Vsix.csproj" Id="99498ef8-c9e0-433b-8d7b-ea8e9e66f0c7" />
<Project Path="Web/Web.csproj" />
<Project Path="Web/web.esproj">
<Build />
<Deploy />
</Project>
</Solution>
2 changes: 1 addition & 1 deletion DotNetBuildable.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"CodeConv\\CodeConv.csproj",
"Func\\Func.csproj",
"Tests\\Tests.csproj",
"Web\\Web.csproj"
"Web\\web.esproj"
]
}
}
2 changes: 1 addition & 1 deletion DotNetPublishable.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"path": "CodeConverter.slnx",
"projects": [
"Func\\Func.csproj",
"Web\\Web.csproj"
"Web\\web.esproj"
]
}
}
10 changes: 10 additions & 0 deletions Func/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
{
services.AddApplicationInsightsTelemetryWorkerService();
services.ConfigureFunctionsApplicationInsights();

services.AddCors(options =>
{
options.AddPolicy("AllowWeb", builder =>
{
builder.WithOrigins("http://localhost:5173")
.AllowAnyMethod()
.AllowAnyHeader();
});
});
})
.Build();

Expand Down
11 changes: 11 additions & 0 deletions Func/host.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,16 @@
},
"enableLiveMetricsFilters": true
}
},
"extensions": {
"http": {
"routePrefix": "api"
}
},
"cors": {
"allowedOrigins": [
"http://localhost:5173"
],
"supportCredentials": false
}
}
3 changes: 3 additions & 0 deletions Func/local.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
},
"Host": {
"CORS": "*"
}
}
39 changes: 39 additions & 0 deletions Get-LatestChangelog.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Param(
[string]$Path = 'CHANGELOG.md'
)

if (-not [System.IO.Path]::IsPathRooted($Path)) {
$Path = Join-Path $PSScriptRoot $Path
}

if (-not (Test-Path -Path $Path)) {
throw "Changelog not found at '$Path'."
}

$lines = Get-Content -Path $Path
$inSection = $false
$collected = New-Object System.Collections.Generic.List[string]

foreach ($line in $lines) {
if ($line -match '^## \[') {
if (-not $inSection) {
if ($line -match '^## \[Unreleased\]') {
continue
}
$inSection = $true
}
elseif ($inSection) {
break
}
}

if ($inSection) {
$collected.Add($line) | Out-Null
}
}

if (-not $inSection -or $collected.Count -eq 0) {
throw "No released changelog section found in '$Path'."
}

$collected | Write-Output
44 changes: 44 additions & 0 deletions Tests/CSharp/MemberTests/MemberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,50 @@ public async static Task ThenExit<T>(this Task<T> task, Func<T, Task> f)
}");
}

[Fact]
public async Task TestAsyncFunctionExitReturnsDefaultAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Imports System.Threading.Tasks

Class AsyncExit
Public Async Function AsyncFuncExit() As Task(Of Integer)
Await Task.Delay(1)
Exit Function
End Function
End Class", @"using System.Threading.Tasks;

internal partial class AsyncExit
{
public async Task<int> AsyncFuncExit()
{
await Task.Delay(1);
return default;
}
}");
}

[Fact]
public async Task TestAsyncTaskFunctionNoImplicitReturnAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Imports System.Threading.Tasks

Class AsyncNoReturn
Public Async Function DoAsync() As Task
Await Task.Delay(1)
End Function
End Class", @"using System.Threading.Tasks;

internal partial class AsyncNoReturn
{
public async Task DoAsync()
{
await Task.Delay(1);
}
}");
}

[Fact]
public async Task TestExternDllImportAsync()
{
Expand Down
56 changes: 56 additions & 0 deletions Tests/CSharp/MemberTests/PropertyMemberTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,62 @@ public int Test3
BC30124: Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set'.");
}

[Fact]
public async Task TestWriteOnlyPropertyExitAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Class TestClass
Private m_value As Integer

Public WriteOnly Property Value As Integer
Set(ByVal value As Integer)
If value = 0 Then Exit Property
m_value = value
End Set
End Property
End Class", @"
internal partial class TestClass
{
private int m_value;

public int Value
{
set
{
if (value == 0)
return;
m_value = value;
}
}
}");
}

[Fact]
public async Task TestExitPropertyInTaskReturningGetterAsync()
{
await TestConversionVisualBasicToCSharpAsync(
@"Imports System.Threading.Tasks

Class TestClass
Public ReadOnly Property Value As Task(Of Integer)
Get
Exit Property
End Get
End Property
End Class", @"using System.Threading.Tasks;

internal partial class TestClass
{
public Task<int> Value
{
get
{
return default;
}
}
}");
}

[Fact]
public async Task TestParameterizedPropertyAsync()
{
Expand Down
Loading
Loading