Use C# 13 overload resolution attribute to improve friendly overloads#1336
Merged
Use C# 13 overload resolution attribute to improve friendly overloads#1336
Conversation
There was a problem hiding this comment.
Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 comment.
Files not reviewed (3)
- src/Microsoft.Windows.CsWin32/SimpleSyntaxFactory.cs: Evaluated as low risk
- src/Microsoft.Windows.CsWin32/Generator.cs: Evaluated as low risk
- src/Microsoft.Windows.CsWin32/Generator.FriendlyOverloads.cs: Evaluated as low risk
Comments suppressed due to low confidence (4)
src/Microsoft.Windows.CsWin32/Generator.Templates.cs:42
- [nitpick] The method name TryFetchTemplate is ambiguous as there is already a method with the same name but different parameters. Consider renaming it to TryFetchTemplateCompilationUnit for clarity.
private static bool TryFetchTemplate(string name, Generator? generator, [NotNullWhen(true)] out CompilationUnitSyntax? compilationUnit)
src/Microsoft.Windows.CsWin32/Generator.Templates.cs:44
- The FetchTemplateText method should handle null values correctly. Ensure that null values are appropriately managed to avoid potential null reference exceptions.
string? template = FetchTemplateText(name);
src/Microsoft.Windows.CsWin32/Generator.Templates.cs:51
- The new method TryFetchTemplate should be covered by tests to ensure it works as expected. Add test cases to verify its functionality.
compilationUnit = SyntaxFactory.ParseCompilationUnit(template, options: generator?.parseOptions) ?? throw new GenerationFailedException($"Unable to parse compilation unit from a template: {name}");
test/Microsoft.Windows.CsWin32.Tests/GeneratorTestBase.cs:227
- Verify that the StringSyntax attribute is correctly supported and used in the context of the project.
protected CSharpCompilation AddCode([StringSyntax("c#-test")] string code, string? fileName = null, CSharpCompilation? compilation = null)
e41f64c to
519a407
Compare
519a407 to
50032d4
Compare
This was referenced Aug 4, 2025
This was referenced Sep 2, 2025
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.
As brought up in #1049 (comment)
C# supports using a polyfill attribute, so this works on any target framework. But it does require C# 13 to reference the attribute on an API or an error results, so CsWin32 only emits or uses the attribute when C# 13 is in operation.