Skip to content
Merged
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
2 changes: 1 addition & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<PackageVersion Include="Knapcode.MiniZip" Version="0.21.1" />
<PackageVersion Include="MetadataReferenceService.BlazorWasm" Version="0.0.1" />
<PackageVersion Include="Microsoft.AspNetCore.App.Ref" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Gateway" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="$(AspNetCoreVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="$(RoslynVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="$(RoslynVersion)" />
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

C# and Razor compiler playground.
<br/>In the browser via Blazor WebAssembly. https://lab.razor.fyi/
<br/>Desktop app on [Windows Store](https://apps.microsoft.com/detail/9PCPMM329DZT) (full .NET, best performance).
<br/>Native app (full .NET, best performance) on [Windows Store](https://apps.microsoft.com/detail/9PCPMM329DZT)
and [Android Play Store](https://play.google.com/store/apps/details?id=me.janjones.dotnetlab).

<table><tr>
<td><a href="https://github.com/jjonescz/DotNetLab"><img src="./src/App/wwwroot/favicon.png" height="40" alt=".NET Lab" /></a></td>
<td><a href="https://apps.microsoft.com/detail/9PCPMM329DZT"><img src="./docs/badges/windows.png" width="150" alt="Windows app" /></a></td>
<td><a href="https://play.google.com/store/apps/details?id=me.janjones.dotnetlab"><img src="./docs/badges/android.png" width="150" alt="Android app" /></a></td>
<td><a href="https://lab.razor.fyi/"><img src="./docs/badges/web.png" width="150" alt="Web app" /></a></td>
</tr></table>

Expand Down
Binary file added docs/badges/android.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/native-apps.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# .NET Lab Native Apps

For best performance, prefer an app native for your platform over the web app.

<table><tr>
<td><a href="https://github.com/jjonescz/DotNetLab"><img src="../src/App/wwwroot/favicon.png" height="40" alt=".NET Lab" /></a></td>
<td><a href="https://apps.microsoft.com/detail/9PCPMM329DZT"><img src="./badges/windows.png" width="150" alt="Windows app" /></a></td>
<td><a href="https://play.google.com/store/apps/details?id=me.janjones.dotnetlab"><img src="./badges/android.png" width="150" alt="Android app" /></a></td>
</tr></table>
34 changes: 15 additions & 19 deletions eng/PatchCoreLib.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,49 @@
<_PatchedCoreLibPath>$(_PatchedCoreLibDir)\$(_CoreLibAssemblyName)</_PatchedCoreLibPath>
</PropertyGroup>

<Target Name="PatchCoreLibFile"
BeforeTargets="_ResolveWasmOutputs"
Inputs="@(ReferenceCopyLocalPaths->WithMetadataValue('FileName','System.Private.CoreLib')->WithMetadataValue('Extension','.dll'));$(MSBuildThisFileDirectory)patch-corelib.cs"
Outputs="$(_PatchedCoreLibPath)">
<Target Name="_CollectCoreLibCandidate">
<ItemGroup>
<_CoreLibCandidate Remove="@(_CoreLibCandidate)" />
<_CoreLibCandidate Include="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.FileName)%(ReferenceCopyLocalPaths.Extension)' == '$(_CoreLibAssemblyName)'" />
</ItemGroup>
</Target>

<Error Condition="'@(_CoreLibCandidate)' == ''"
Text="$(_CoreLibAssemblyName) not found in ReferenceCopyLocalPaths." />
<Target Name="PatchCoreLibFile"
DependsOnTargets="_CollectCoreLibCandidate"
Condition="'@(ReferenceCopyLocalPaths->WithMetadataValue('FileName','System.Private.CoreLib')->WithMetadataValue('Extension','.dll'))' != ''"
Inputs="@(_CoreLibCandidate);$(MSBuildThisFileDirectory)patch-corelib.cs"
Outputs="$(_PatchedCoreLibPath)">

<MakeDir Directories="$(_PatchedCoreLibDir)" />

<Exec Command="&quot;$(DOTNET_HOST_PATH)&quot; run --file &quot;$(MSBuildThisFileDirectory)patch-corelib.cs&quot; &quot;@(_CoreLibCandidate)&quot; &quot;$(_PatchedCoreLibPath)&quot;" />
</Target>

<Target Name="UsePatchedCoreLib"
BeforeTargets="_ResolveWasmOutputs"
AfterTargets="ResolveReferences"
BeforeTargets="_ComputeWasmBuildCandidates;_ResolveWasmOutputs"
DependsOnTargets="PatchCoreLibFile">
<ItemGroup>
<_CoreLibCandidate Include="@(ReferenceCopyLocalPaths)"
Condition="'%(ReferenceCopyLocalPaths.FileName)%(ReferenceCopyLocalPaths.Extension)' == '$(_CoreLibAssemblyName)'" />
</ItemGroup>

<Error Condition="'@(_CoreLibCandidate)' == ''"
Text="$(_CoreLibAssemblyName) not found in ReferenceCopyLocalPaths." />

<ItemGroup>
<ItemGroup Condition="'@(_CoreLibCandidate)' != '' and Exists('$(_PatchedCoreLibPath)')">
<ReferenceCopyLocalPaths Remove="@(_CoreLibCandidate)" />
</ItemGroup>

<!-- Use `->` to ensure the original metadata are preserved (only the path is replaced). -->
<ItemGroup>
<ItemGroup Condition="'@(_CoreLibCandidate)' != '' and Exists('$(_PatchedCoreLibPath)')">
<ReferenceCopyLocalPaths Include="@(_CoreLibCandidate->'$(_PatchedCoreLibPath)')" KeepDuplicates="false" />
</ItemGroup>
</Target>

<Target Name="PublishPatchedCoreLib"
AfterTargets="_ResolveCopyLocalAssetsForPublish"
DependsOnTargets="PatchCoreLibFile">
<ItemGroup>
DependsOnTargets="_CollectCoreLibCandidate;PatchCoreLibFile">
<ItemGroup Condition="'@(_CoreLibCandidate)' != '' and Exists('$(_PatchedCoreLibPath)')">
<_ResolvedCopyLocalPublishAssets Remove="@(_CoreLibCandidate)" />
</ItemGroup>

<!-- Use `->` to ensure the original metadata are preserved (only the path is replaced). -->
<ItemGroup>
<ItemGroup Condition="'@(_CoreLibCandidate)' != '' and Exists('$(_PatchedCoreLibPath)')">
<_ResolvedCopyLocalPublishAssets Include="@(_CoreLibCandidate->'$(_PatchedCoreLibPath)')" KeepDuplicates="false" />
</ItemGroup>
</Target>
Expand Down
1 change: 0 additions & 1 deletion src/App/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using Microsoft.AspNetCore.Components.Web;
using Microsoft.Extensions.Hosting;
using Microsoft.FluentUI.AspNetCore.Components;
using Microsoft.JSInterop;

namespace DotNetLab;

Expand Down
6 changes: 4 additions & 2 deletions src/App/Lab/CommitHashView.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@implements IDisposable
@implements IAsyncDisposable
@inject ILocalStorageService LocalStorage
@inject WorkerController Worker
@inject HttpClient Client
Expand Down Expand Up @@ -122,8 +122,10 @@
}
}

void IDisposable.Dispose()
async ValueTask IAsyncDisposable.DisposeAsync()
{
// Wait for OnParametersSetAsync to complete before disposing the lock it's using.
(await loading.LockAsync()).Dispose();
loading.Dispose();
}
Comment thread
jjonescz marked this conversation as resolved.

Expand Down
4 changes: 2 additions & 2 deletions src/WebAssembly/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ file sealed class WebAssemblyAppHostEnvironment(IWebAssemblyHostEnvironment webA

public DesktopAppLink DesktopAppLink { get; } = new()
{
Url = App.DesktopAppLink,
Title = "Desktop App",
Url = "https://github.com/jjonescz/DotNetLab/blob/main/docs/native-apps.md",
Title = "Native apps available",
Description = "Faster version of .NET Lab running on full .NET.",
};
Comment thread
jjonescz marked this conversation as resolved.

Expand Down
13 changes: 11 additions & 2 deletions src/WebAssembly/WebAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
<StaticWebAssetSpaFallbackEnabled>true</StaticWebAssetSpaFallbackEnabled>
<IndexHtmlScriptPath>_framework/blazor.webassembly.js</IndexHtmlScriptPath>
<IndexHtmlHead><link href="manifest.webmanifest?v=2" rel="manifest" /></IndexHtmlHead>
<IndexHtmlScripts><script>navigator.serviceWorker.register('service-worker.js');</script></IndexHtmlScripts>
<!-- Microsoft Store SVG source: https://upload.wikimedia.org/wikipedia/commons/a/a7/Microsoft_Store.svg -->
<!-- Google Play SVG source: https://upload.wikimedia.org/wikipedia/commons/2/2f/Google_Play_2022_icon.svg -->
<IndexHtmlLoadingInfoFooter>
<div style="margin-top: 1em">
Consider using more capable and performant
Expand All @@ -17,15 +19,22 @@
<rect x="926" y="740.5" width="347.2" height="347.3" fill="#7fba00"/>
<rect x="520.9" y="1145.6" width="347.2" height="347.2" fill="#00a4ef"/>
<rect x="926" y="1145.6" width="347.2" height="347.2" fill="#ffb900"/>
</svg>Windows desktop app</a>.
</svg>Windows</a> or
<a href="https://play.google.com/store/apps/details?id=me.janjones.dotnetlab" target="_blank" rel="noopener noreferrer">
<svg viewBox="0 0 28.99 31.99" xmlns="http://www.w3.org/2000/svg" style="height: 1em; margin: 0 0.25em 0 0.25em">
<g data-name="Capa 2"><g data-name="Capa 1"><path d="M13.54 15.28.12 29.34a3.66 3.66 0 0 0 5.33 2.16l15.1-8.6Z" style="fill:#ea4335"/>
<path d="m27.11 12.89-6.53-3.74-7.35 6.45 7.38 7.28 6.48-3.7a3.54 3.54 0 0 0 1.5-4.79 3.62 3.62 0 0 0-1.5-1.5z" style="fill:#fbbc04"/>
<path d="M.12 2.66a3.57 3.57 0 0 0-.12.92v24.84a3.57 3.57 0 0 0 .12.92L14 15.64Z" style="fill:#4285f4"/>
<path d="m13.64 16 6.94-6.85L5.5.51A3.73 3.73 0 0 0 3.63 0 3.64 3.64 0 0 0 .12 2.65Z" style="fill:#34a853"/></g></g>
</svg>Android</a> app.
</div>
</IndexHtmlLoadingInfoFooter>
<WasmEmitTypeScriptDefinitions>true</WasmEmitTypeScriptDefinitions>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.Gateway" PrivateAssets="all" />
</ItemGroup>
Comment thread
jjonescz marked this conversation as resolved.

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions src/WorkerWebAssembly/WorkerWebAssembly.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
<ProjectReference Include="..\Worker\Worker.csproj" />
</ItemGroup>

<Import Project="..\..\eng\PatchCoreLib.targets" />

</Project>
Loading