Conversation
…level statements regression test Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com>
Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Fixes generator execution failures when the target project is an executable (e.g., uses top-level statements), by ensuring the generator’s “execution compilation” preserves the original project’s output kind instead of forcing a DLL.
Changes:
- Stop overriding the execution compilation to
OutputKind.DynamicallyLinkedLibrary, allowing top-level statements to compile. - Add a regression test that exercises generator-method execution against a
ConsoleApplicationcompilation with top-level statements. - Extend the test helper compilation factory to accept an
OutputKind.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| EasySourceGenerators.Generators/GeneratesMethodExecutionRuntime.cs | Preserves the original compilation’s output kind when building the execution compilation so executable projects (top-level statements) don’t fail to compile. |
| EasySourceGenerators.GeneratorTests/GeneratesMethodExecutionRuntimeTests.cs | Adds regression coverage for the top-level statements scenario and updates the test compilation helper to support non-DLL output kinds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| using System; | ||
|
|
||
| Console.WriteLine("warmup"); |
There was a problem hiding this comment.
This new regression test’s top-level statement uses Console.WriteLine, but GetMetadataReferences() doesn’t explicitly reference System.Console (it relies on whatever assemblies happen to already be loaded in the AppDomain). That can make the test environment-dependent/flaky if System.Console isn’t loaded. Consider using a top-level statement that doesn’t require extra references (e.g., int _ = 0;), or explicitly add a System.Console metadata reference for determinism.
| using System; | |
| Console.WriteLine("warmup"); | |
| int _ = 0; |
EasySourceGenerators.GeneratorTests/GeneratesMethodExecutionRuntimeTests.cs
Show resolved
Hide resolved
…tests Co-authored-by: dex3r <3155725+dex3r@users.noreply.github.com>
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.