Skip to content

feat: Annotate as AOT compatible and update WinNativeSerial.Version - #165

Open
OleRoss wants to merge 2 commits into
jcurl:masterfrom
OleRoss:feat/mark-as-aot-compatible
Open

OleRoss wants to merge 2 commits into
jcurl:masterfrom
OleRoss:feat/mark-as-aot-compatible

Conversation

@OleRoss

@OleRoss OleRoss commented Jul 26, 2026

Copy link
Copy Markdown

First of all, thank you for maintaining this great alternative SerialPort library. We publish our apps with AOT, and while this works for now, I wanted to add some analyzers that help discover misuse.

The only thing that seems to be incompatible right now is the WinNativeSerial.Version property, which returns no version when you compile for a single executable (because then there is no assembly file to find the version for). To fix this, I am using the AssemblyFileVersionAttribute which returns the same Version information (see the tests included here).

The tests are more a demonstration that the change works; I am happy to remove them from the PR.

- Mark as IsAotCompatible true
- Use AssemblyFileVersionAttribute instead of FileVersionInfo
@OleRoss OleRoss changed the title feat: Return Windows Version compatible with single-file-apps feat: Annotate as AOT compatible and update WinNativeSerial.Version Jul 26, 2026
@jcurl

jcurl commented Jul 26, 2026

Copy link
Copy Markdown
Owner

What needs to be done to show that it works with AOT? As I don't use any AOT features, would you like to add a small app that would fail if this PR weren't applied? Then I'm pretty sure that if I make changes in the future, I won't break this PR.

@OleRoss

OleRoss commented Jul 26, 2026

Copy link
Copy Markdown
Author

Wow, quick reply :D

Best case, all the unit tests could be published to an AOT executable, which could then be run like a normal program. This is how xunit.v3 does it, for example.

I haven't worked with NUnit much, but it seems like AOT support is missing. I also tried to get it to work locally, but it looks like the issues start with the use of reflection during test discovery and continue with the dynamic code generation for parameterized tests, ...

I don't think that switching to xUnit makes a lot of sense for this project, so I added the AOT smoke test. In the future it should be enough to

  1. Publish the smoke test project and run it
  2. Rely on analyzers to warn about misuse - they catch almost everything in your code (but not necessarily in your dependencies)
  3. When NUnit adds support for AOT execution of their test projects, the smoke test project could be removed, and the tests could be run directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants