Skip to content

Commit

Permalink
.NET 8
Browse files Browse the repository at this point in the history
  • Loading branch information
maxkatz6 committed Jan 8, 2024
1 parent 713d892 commit ede90ea
Show file tree
Hide file tree
Showing 19 changed files with 73 additions and 157 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/azure-swa.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ jobs:
run: dotnet tool install --global DotNetCompress --version 2.0.0 --no-cache

- name: Publish .NET Project
run: dotnet publish src/XamlPlayground.Wasm/XamlPlayground.Wasm.csproj -c Release -o release --nologo
run: dotnet publish src/XamlPlayground.Browser/XamlPlayground.Browser.csproj -c Release -o release --nologo

- name: Brotli Compress Output (dll)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.dll'
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.dll'

- name: Brotli Compress Output (js)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.js'
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.js'

- name: Brotli Compress Output (symbols)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.symbols'
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.symbols'

- name: Brotli Compress Output (blat)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.blat'
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.blat'

- name: Brotli Compress Output (bin)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.bin'
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.bin'

- name: Brotli Compress Output (wasm)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.wasm'
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.wasm'

- name: Build And Deploy
id: builddeploy
Expand All @@ -53,7 +53,7 @@ jobs:
action: "upload"
###### Repository/Build Configurations - These values can be configured to match your app requirements. ######
# For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig
app_location: "src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/" # App source code path
app_location: "src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/" # App source code path
api_location: "" # Api source code path - optional
output_location: "" # Modify this to where your SSG places the built HTML - could be `dist`, `build`... check your config
skip_app_build: true
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,38 +22,38 @@ jobs:
run: dotnet tool install --global DotNetCompress --version 2.0.0 --no-cache

- name: Publish .NET Project
run: dotnet publish src/XamlPlayground.Wasm/XamlPlayground.Wasm.csproj -c Release -o release --nologo
run: dotnet publish src/XamlPlayground.Browser/XamlPlayground.Browser.csproj -c Release -o release --nologo

- name: Brotli Compress Output (dll)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/managed -p '*.dll' --format br --threads 4
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/managed -p '*.dll' --format br --threads 4

- name: Brotli Compress Output (js)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.js' --format br --threads 4
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.js' --format br --threads 4

- name: Brotli Compress Output (wasm)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.wasm' --format br --threads 4
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.wasm' --format br --threads 4

- name: GZip Compress Output (dll)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/managed -p '*.dll' --format gz --threads 4
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/managed -p '*.dll' --format gz --threads 4

- name: GZip Compress Output (js)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.js' --format gz --threads 4
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.js' --format gz --threads 4

- name: GZip Compress Output (wasm)
run: DotNetCompress -d src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/ -p '*.wasm' --format gz --threads 4
run: DotNetCompress -d src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/ -p '*.wasm' --format gz --threads 4

- name: Change base-tag in index.html from / to XamlPlayground
run: sed -i 's/<base href="\/" \/>/<base href="\/XamlPlayground\/" \/>/g' src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/index.html
run: sed -i 's/<base href="\/" \/>/<base href="\/XamlPlayground\/" \/>/g' src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/index.html

- name: copy index.html to 404.html
run: cp src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/index.html src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/404.html
run: cp src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/index.html src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/404.html

- name: Add .nojekyll file
run: touch src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle/.nojekyll
run: touch src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle/.nojekyll

- name: Commit wwwroot to GitHub Pages
uses: JamesIves/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: gh-pages
FOLDER: src/XamlPlayground.Wasm/bin/Release/net7.0/browser-wasm/AppBundle
FOLDER: src/XamlPlayground.Browser/bin/Release/net8.0-browser/browser-wasm/AppBundle
3 changes: 2 additions & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
<Deterministic>true</Deterministic>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<IsAotCompatible>true</IsAotCompatible>
</PropertyGroup>
<PropertyGroup>
<AvaloniaVersion>11.0.6</AvaloniaVersion>
<AvaloniaBehaviorsVersion>11.0.5</AvaloniaBehaviorsVersion>
<AvaloniaBehaviorsVersion>11.0.6</AvaloniaBehaviorsVersion>
<AvaloniaEditVersion>11.0.5</AvaloniaEditVersion>
<AvaloniaEditTextMateGrammarsVersion>0.10.12</AvaloniaEditTextMateGrammarsVersion>
<OctokitVersion>9.0.0</OctokitVersion>
Expand Down
12 changes: 4 additions & 8 deletions XamlPlayground.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlPlayground", "src\XamlP
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlPlayground.NetCore", "src\XamlPlayground.NetCore\XamlPlayground.NetCore.csproj", "{5B0621D6-B7D4-49EF-8C24-FD81823D56AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlPlayground.Web", "src\XamlPlayground.Web\XamlPlayground.Web.csproj", "{5E83BE38-4F45-4966-8821-761B91C532C0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9CF0A712-DEA1-42BC-AB3A-ED8E6DAE523C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{2629EA9C-FEFD-4604-BD92-C23DBB54316A}"
Expand All @@ -14,9 +12,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{2629EA9C
Directory.Build.props = Directory.Build.props
global.json = global.json
nuget.config = nuget.config
.github\workflows\azure-swa.yml = .github\workflows\azure-swa.yml
.github\workflows\build.yml = .github\workflows\build.yml
.github\workflows\pages.yml = .github\workflows\pages.yml
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlPlayground.Wasm", "src\XamlPlayground.Wasm\XamlPlayground.Wasm.csproj", "{00E8340C-7F10-446C-A1B4-48C68D8F1612}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlPlayground.Browser", "src\XamlPlayground.Browser\XamlPlayground.Browser.csproj", "{00E8340C-7F10-446C-A1B4-48C68D8F1612}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{D38F82B0-74ED-4F7E-A060-62FCF6330CE7}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -38,10 +39,6 @@ Global
{5B0621D6-B7D4-49EF-8C24-FD81823D56AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5B0621D6-B7D4-49EF-8C24-FD81823D56AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5B0621D6-B7D4-49EF-8C24-FD81823D56AF}.Release|Any CPU.Build.0 = Release|Any CPU
{5E83BE38-4F45-4966-8821-761B91C532C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5E83BE38-4F45-4966-8821-761B91C532C0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5E83BE38-4F45-4966-8821-761B91C532C0}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5E83BE38-4F45-4966-8821-761B91C532C0}.Release|Any CPU.Build.0 = Release|Any CPU
{00E8340C-7F10-446C-A1B4-48C68D8F1612}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00E8340C-7F10-446C-A1B4-48C68D8F1612}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00E8340C-7F10-446C-A1B4-48C68D8F1612}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -50,7 +47,6 @@ Global
GlobalSection(NestedProjects) = preSolution
{4E84133A-4280-41FC-A4E1-34463403CA8A} = {9CF0A712-DEA1-42BC-AB3A-ED8E6DAE523C}
{5B0621D6-B7D4-49EF-8C24-FD81823D56AF} = {9CF0A712-DEA1-42BC-AB3A-ED8E6DAE523C}
{5E83BE38-4F45-4966-8821-761B91C532C0} = {9CF0A712-DEA1-42BC-AB3A-ED8E6DAE523C}
{00E8340C-7F10-446C-A1B4-48C68D8F1612} = {9CF0A712-DEA1-42BC-AB3A-ED8E6DAE523C}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "7.0.100",
"version": "8.0.100",
"rollForward": "latestMinor",
"allowPrerelease": true
}
Expand Down
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ const dotnetRuntime = await dotnet

const config = dotnetRuntime.getConfig();

await dotnetRuntime.runMainAndExit(config.mainAssemblyName, [window.location.search, globalThis.document.baseURI]);
await dotnetRuntime.runMain(config.mainAssemblyName, [window.location.search, globalThis.document.baseURI]);
File renamed without changes.
31 changes: 31 additions & 0 deletions src/XamlPlayground.Browser/XamlPlayground.Browser.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0-browser</TargetFramework>
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
<WasmMainJSPath>AppBundle\main.js</WasmMainJSPath>
<OutputType>Exe</OutputType>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

<PropertyGroup>
<InvariantGlobalization>true</InvariantGlobalization>
<WasmEnableExceptionHandling>false</WasmEnableExceptionHandling>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
</PropertyGroup>

<ItemGroup>
<WasmExtraFilesToDeploy Include="AppBundle\*" />
</ItemGroup>


<ItemGroup>
<PackageReference Include="Avalonia.Browser" Version="$(AvaloniaVersion)" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\XamlPlayground\XamlPlayground.csproj" />
</ItemGroup>

</Project>
3 changes: 1 addition & 2 deletions src/XamlPlayground.NetCore/XamlPlayground.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>XamlPlayground.NetCore</RootNamespace>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
43 changes: 0 additions & 43 deletions src/XamlPlayground.Wasm/Roots.xml

This file was deleted.

52 changes: 0 additions & 52 deletions src/XamlPlayground.Wasm/XamlPlayground.Wasm.csproj

This file was deleted.

40 changes: 13 additions & 27 deletions src/XamlPlayground/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
using CommunityToolkit.Mvvm.Input;
using Avalonia.Platform.Storage;
using System.Collections.Generic;
using System.Reactive.Linq;
using ReactiveMarbles.PropertyChanged;
using System.ComponentModel;
using XamlPlayground.Services;
using System.Reactive.Subjects;
using Avalonia.Threading;
using Avalonia.ReactiveUI;

namespace XamlPlayground.ViewModels;

Expand All @@ -34,11 +31,10 @@ public partial class MainViewModel : ViewModelBase
private (Assembly? Assembly, AssemblyLoadContext? Context)? _previous;
private IStorageFile? _openXamlFile;
private IStorageFile? _openCodeFile;
private readonly Subject<(string? xaml, string? code)> _runSubject;
private IDisposable? _timer;

public MainViewModel(string? initialGist)
{
_runSubject = new Subject<(string? xaml, string? code)>();
_editorFontSize = 12;
_samples = GetSamples(".xml");
_enableAutoRun = true;
Expand All @@ -50,20 +46,6 @@ public MainViewModel(string? initialGist)
RunCommand = new RelayCommand(() => Run(_currentSample?.Xaml.Text, _currentSample?.Code.Text));
GistCommand = new AsyncRelayCommand<string?>(Gist);

this.WhenChanged(x => x.CurrentSample)
.DistinctUntilChanged()
.Subscribe(CurrentSampleChanged);

_runSubject.AsObservable()
.Throttle(TimeSpan.FromMilliseconds(400))
.ObserveOn(AvaloniaScheduler.Instance)
.Subscribe(OnRun);

async void OnRun((string? xaml, string? code) x)
{
await RunInternal(x.xaml, x.code);
}

if (!string.IsNullOrEmpty(initialGist))
{
Gist(initialGist);

Check warning on line 51 in src/XamlPlayground/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / deploy-to-github-pages

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

Check warning on line 51 in src/XamlPlayground/ViewModels/MainViewModel.cs

View workflow job for this annotation

GitHub Actions / Build ubuntu-latest

Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.
Expand All @@ -86,9 +68,12 @@ async void OnRun((string? xaml, string? code) x)

public ICommand SaveCodeFileCommand { get; }

private void CurrentSampleChanged(SampleViewModel? sampleViewModel)
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
if (sampleViewModel is { })
base.OnPropertyChanged(e);

if (e.PropertyName == nameof(CurrentSample)
&& CurrentSample is { } sampleViewModel)
{
Open(sampleViewModel);
}
Expand Down Expand Up @@ -214,7 +199,8 @@ private void AutoRun(SampleViewModel sampleViewModel)

private void Run(string? xaml, string? code)
{
_runSubject.OnNext((xaml, code));
_timer?.Dispose();
_timer = DispatcherTimer.RunOnce(() => _ = RunInternal(xaml, code), TimeSpan.FromMicroseconds(1000));
}

private async Task RunInternal(string? xaml, string? code)
Expand Down Expand Up @@ -273,10 +259,10 @@ private async Task RunInternal(string? xaml, string? code)
{
var rootInstance = Activator.CreateInstance(type);

using var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(xaml);
writer.Flush();
await using var stream = new MemoryStream();
await using var writer = new StreamWriter(stream);
await writer.WriteAsync(xaml);
await writer.FlushAsync();
stream.Position = 0;

var control = AvaloniaRuntimeXamlLoader.Load(stream, scriptAssembly, rootInstance);
Expand Down
Loading

0 comments on commit ede90ea

Please sign in to comment.