Repository navigation
Add TreatWarningsAsErrors -> True for release builds, cleanup - #14
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Enables stricter compilation by treating warnings as errors in Release builds, and updates InteropGen’s model/codegen to satisfy nullable/initialization analysis so generated code and projects don’t produce large warning counts.
Changes:
- Added root
Directory.Build.propsto setTreatWarningsAsErrors=truefor Release configuration. - Added an
external/Directory.Build.propsshim to prevent the root props from impacting external projects. - Updated InteropGen model/codegen to reduce nullable/initialization warnings and to correctly handle nullable handle returns for non-
Newfunctions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/InteropGen/NativeModel.cs | Marks key model properties as required to avoid uninitialized non-nullable property warnings. |
| src/InteropGen/Generator.cs | Improves nullable annotations and fixes nullable handle-return codegen for non-New handle functions. |
| external/Directory.Build.props | Prevents root build props from flowing into external projects. |
| Directory.Build.props | Enables TreatWarningsAsErrors in Release builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+311
to
+316
| // New-suffixed factories return a SafeHandle from P/Invoke (compare to null); | ||
| // other handle-returning functions return a raw IntPtr (compare to IntPtr.Zero). | ||
| if (f.Name.EndsWith("New")) | ||
| gen.Line("if(ret == null) return null;"); | ||
| else | ||
| gen.Line("if(ret == global::System.IntPtr.Zero) return null;"); |
Contributor
Author
There was a problem hiding this comment.
Running it locally, that code would break the generation because that logic doesn't hold for the code being passed in.
323df43
Updated here to make it clear for the future.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
InteropGen would generate code that would result in hundreds of warnings in the test project. To prevent this, I enabled TreatWarningsAsErrors and fixed the resulting errors in generation and in the other projects. For the codebase, it's enabled for Release builds, so it should trigger tests if we regress it there, but it won't break local debug builds.