Fix modifier of the generated options builder object.#53
Merged
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR ensures that the generated builder class visibility matches the accessibility of the source command object.
- Capture the
publicaccessibility flag in the command model - Add a corresponding
IsPublicproperty to the model record - Update the builder generator template to emit
publicorinternalaccordingly
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/DotNetCampus.CommandLine.Analyzer/Generators/ModelProviding/CommandModelProvider.cs | Compute isPublic flag and pass it into CommandObjectGeneratingModel |
| src/DotNetCampus.CommandLine.Analyzer/Generators/ModelProviding/CommandModelProvider.cs | Add IsPublic property to the model record |
| src/DotNetCampus.CommandLine.Analyzer/Generators/BuilderGenerator.cs | Use model.IsPublic to choose public vs. internal in class modifier |
Comments suppressed due to low confidence (2)
src/DotNetCampus.CommandLine.Analyzer/Generators/ModelProviding/CommandModelProvider.cs:137
- Add an XML doc comment for the
IsPublicproperty to explain that it controls the visibility modifier of the generated builder class.
public required bool IsPublic { get; init; }
src/DotNetCampus.CommandLine.Analyzer/Generators/BuilderGenerator.cs:78
- Add unit tests that verify builder code is generated with
publicwhen the command object is public andinternalotherwise.
{{(model.IsPublic ? "public" : "internal")}} sealed class {{model.GetBuilderTypeName()}}
Member
|
修不了 #51 的问题,我重新调查发现,这是由于没有生成 OptionsBuilder 导致的。只要 Options 没有任何标记,则 OptionsBuilder 不会生成 // Options.cs
namespace HalnerefaiwhoLanallwaynai;
public class Options
{
public required string Name { get; init; }
} |
lindexi
approved these changes
Jul 7, 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.
Fix #50