Emit fully qualified type constraints for generic interfaces#75
Merged
ChristianSauer merged 3 commits intocodecentric:masterfrom Apr 7, 2025
Conversation
9df6448 to
88a18c3
Compare
- Use RoslynExtensions to generate type constraints, as we do for method type constraints - Move generic interface definition tests into a new file - Add test for generation of an interface with base class type constraints - Remove custom `GetFullTypeString` method from RoslynExtensions - the same result is produced by using `ToDisplayString`.
88a18c3 to
006cbdb
Compare
57dc473 to
6b03b55
Compare
simonmckenzie
commented
Apr 6, 2025
| var constraints = ""; | ||
|
|
||
| var isFirstConstraint = true; | ||
| var constraints = new List<string>(); |
Contributor
Author
There was a problem hiding this comment.
I refactored this to emit the new() constraint last.
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/new-constraint
When you use the new() constraint with other constraints, it must be specified last
Collaborator
|
Thanks, that looks very good! |
ChaseFlorell
added a commit
to ChaseFlorell/net_automatic_interface
that referenced
this pull request
Apr 23, 2025
…tion is properly referenced on the autogenerated interfaces
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.
This addresses #74, where generic interface type constraints were not being fully qualified, which could result in failure to resolve references within generated interfaces.
GetFullTypeStringmethod from RoslynExtensions - the same result is produced by usingToDisplayString.-Add test for
new()constraint, update logic to ensure thatnew()is always last