-
Notifications
You must be signed in to change notification settings - Fork 2
chore: various finish line tasks #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- '*' | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v4 | ||
with: | ||
dotnet-version: '8.0.x' | ||
|
||
- name: Get version from tag | ||
id: version | ||
shell: pwsh | ||
run: | | ||
$tag = $env:GITHUB_REF -replace 'refs/tags/','' | ||
if ($tag -notmatch '^v\d+\.\d+\.\d+$') { | ||
throw "Tag must be in format v1.2.3" | ||
} | ||
$version = $tag -replace '^v','' | ||
$assemblyVersion = "$version.0" | ||
echo "VERSION=$version" >> $env:GITHUB_OUTPUT | ||
echo "ASSEMBLY_VERSION=$assemblyVersion" >> $env:GITHUB_OUTPUT | ||
|
||
- name: Build and publish x64 | ||
run: | | ||
dotnet publish src/App/App.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64 | ||
dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-x64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/x64 | ||
|
||
- name: Build and publish arm64 | ||
run: | | ||
dotnet publish src/App/App.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64 | ||
dotnet publish src/Vpn.Service/Vpn.Service.csproj -c Release -r win-arm64 -p:Version=${{ steps.version.outputs.ASSEMBLY_VERSION }} -o publish/arm64 | ||
|
||
- name: Create ZIP archives | ||
shell: pwsh | ||
run: | | ||
Compress-Archive -Path "publish/x64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip" | ||
Compress-Archive -Path "publish/arm64/*" -DestinationPath "./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip" | ||
|
||
- name: Create Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-x64.zip | ||
./publish/CoderDesktop-${{ steps.version.outputs.VERSION }}-arm64.zip | ||
name: Release ${{ steps.version.outputs.VERSION }} | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Threading; | ||
using Microsoft.UI.Dispatching; | ||
using Microsoft.UI.Xaml; | ||
using Microsoft.Windows.AppLifecycle; | ||
using WinRT; | ||
|
||
namespace Coder.Desktop.App; | ||
|
||
#if DISABLE_XAML_GENERATED_MAIN | ||
public static class Program | ||
{ | ||
private static App? app; | ||
#if DEBUG | ||
[DllImport("kernel32.dll")] | ||
private static extern bool AllocConsole(); | ||
#endif | ||
|
||
[DllImport("user32.dll", CharSet = CharSet.Unicode)] | ||
private static extern int MessageBoxW(IntPtr hWnd, string text, string caption, int type); | ||
|
||
[STAThread] | ||
private static void Main(string[] args) | ||
{ | ||
try | ||
{ | ||
ComWrappersSupport.InitializeComWrappers(); | ||
if (!CheckSingleInstance()) return; | ||
Application.Start(p => | ||
{ | ||
var context = new DispatcherQueueSynchronizationContext(DispatcherQueue.GetForCurrentThread()); | ||
SynchronizationContext.SetSynchronizationContext(context); | ||
|
||
app = new App(); | ||
app.UnhandledException += (_, e) => | ||
{ | ||
e.Handled = true; | ||
ShowExceptionAndCrash(e.Exception); | ||
}; | ||
}); | ||
} | ||
catch (Exception e) | ||
{ | ||
ShowExceptionAndCrash(e); | ||
} | ||
} | ||
|
||
[STAThread] | ||
private static bool CheckSingleInstance() | ||
{ | ||
#if !DEBUG | ||
const string appInstanceName = "Coder.Desktop.App"; | ||
#else | ||
const string appInstanceName = "Coder.Desktop.App.Debug"; | ||
#endif | ||
|
||
var instance = AppInstance.FindOrRegisterForKey(appInstanceName); | ||
return instance.IsCurrent; | ||
} | ||
|
||
[STAThread] | ||
private static void ShowExceptionAndCrash(Exception e) | ||
{ | ||
const string title = "Coder Desktop Fatal Error"; | ||
var message = | ||
"Coder Desktop has encountered a fatal error and must exit.\n\n" + | ||
e + "\n\n" + | ||
Environment.StackTrace; | ||
MessageBoxW(IntPtr.Zero, message, title, 0); | ||
|
||
if (app != null) | ||
app.Exit(); | ||
|
||
// This will log the exception to the Windows Event Log. | ||
#if DEBUG | ||
// And, if in DEBUG mode, it will also log to the console window. | ||
AllocConsole(); | ||
#endif | ||
Environment.FailFast("Coder Desktop has encountered a fatal error and must exit.", e); | ||
} | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why this is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't understand why the entire DisposeAsync implementation is necessary or why the
GC.SuppressFinalize(this);
is?If you mean the whole implementation, we're calling it when the app closes to close the named pipe and remove the async receive tasks from the background.
If you mean the
GC.SuppressFinalize(this)
thing, it prevents the~RpcController()
finalizer method from being called. Since we're not using it and we don't need to clean up any unmanaged resources here, we just tell the GC to not bother calling it during a GC run later on.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I meant
SuppressFinalize
.I don't see an explicit
~RpcController()
method--I assume this is implicit? Is the need to suppress it required for correctness (i.e. it is not idempotent), or is suppressing it just a performance optimization?I ask because I'm concerned that this is somewhat fragile.
_speaker
is the only resource that needs to be cleaned up today, but if we add a new resource and forget to include it in this method, presumably we'd leak it by supressing the implicit finalizer.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I don't know that much about how the C# GC works, so I'm not sure. From what I can tell in most cases where you don't explicitly write a finalizer it won't try to run it, so it's probably fine without it.
The main reason this is here is because the linter said we should include it even though we don't have a finalizer:
So it seems like it's more about convention