Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 18, 2025

The new KeywordOptionConfigurator API provides a fluent syntax for specifying access modifiers. The README showed the legacy .WithKeyword("public") approach in several examples.

Changes

  • Updated all code examples to use fluent keyword API wherever applicable:

    • ns.Public.Class() instead of ns.Class() + cls.WithKeyword("public")
    • cls.Public.AutoProperty() instead of p.WithKeyword("public")
    • cls.Public.Method() instead of method.WithKeyword("public")
  • Updated sections:

    • Basic Usage - Uses ns.Public.Class() and cls.Public.AutoProperty()
    • Generate a Class with Methods - Uses ns.Public.Class() and cls.Public.Method()
    • Using Constructors - Uses classOption.WithKeyword("public") for TypeOption and classOption.Public.AutoProperty() for properties
    • Control Structures - For Loop - Rewritten to use classOption.Public.Method() within a class context
    • Control Structures - Switch Statement - Rewritten to use classOption.Public.Method() within a class context
  • Added "Using Keyword Configurator" section demonstrating:

    • Direct usage: new NamespaceOption().WithName("X").Public.Class(...)
    • Via Code.Create(): Code.Create().Class(cls => cls.Public.AutoProperty(...))
    • Required import: using Fengb3.EasyCodeBuilder.Csharp.OptionConfigurations;
  • Updated Extension Methods documentation to include Public, Private, Internal, Static properties and KeywordConfigurator for advanced chaining

Example

Before:

ns.Class(cls => {
    cls.Name = "Person";
    cls.AutoProperty(p => {
        p.WithKeyword("public")
         .WithType("string")
         .WithName("Name");
    });
});

After:

ns.Public.Class(cls => {
    cls.WithName("Person");
    cls.Public.AutoProperty(p => p
        .WithType("string")
        .WithName("Name")
    );
});

Testing

Comprehensive verification tests added for all 7 README examples to ensure they compile and produce expected output. All tests pass successfully.

Note: Some examples still use .WithKeyword() where KeywordConfigurator support doesn't exist yet (e.g., Constructor doesn't have a Public.Constructor() extension method).

Original prompt

This section details on the original issue you should resolve

<issue_title>UPDATE README</issue_title>
<issue_description>添加了新的api, 需要更新readme</issue_description>

<agent_instructions>添加了新的 api, 可参考 CsharpCodeOptionConfiguratorTests.cs 修改readme 相关章节的代码示例</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 18, 2025 08:38
Co-authored-by: fengb3 <45181245+fengb3@users.noreply.github.com>
Co-authored-by: fengb3 <45181245+fengb3@users.noreply.github.com>
Co-authored-by: fengb3 <45181245+fengb3@users.noreply.github.com>
Copilot AI changed the title [WIP] Update README to include new API examples Update README with KeywordOptionConfigurator API examples Dec 18, 2025
Copilot AI requested a review from fengb3 December 18, 2025 08:45
@fengb3
Copy link
Owner

fengb3 commented Dec 18, 2025

@copilot 我希望所有可以用到 新 api 的地方都使用 KeywordOptionConfigurator 作为示例

… applicable

Co-authored-by: fengb3 <45181245+fengb3@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 18, 2025

@copilot 我希望所有可以用到 新 api 的地方都使用 KeywordOptionConfigurator 作为示例

Done! I've updated all README examples to use the KeywordOptionConfigurator API wherever applicable:

Using Constructors - Now uses classOption.WithKeyword("public") for the class and classOption.Public.AutoProperty() for properties
Control Structures - For Loop - Updated to use classOption.Public.Method()
Control Structures - Switch Statement - Updated to use classOption.Public.Method()

All 7 README examples now verified with passing tests. Commit: 3604733

Co-authored-by: fengb3 <45181245+fengb3@users.noreply.github.com>
Copilot AI changed the title Update README with KeywordOptionConfigurator API examples Update all README examples to use KeywordOptionConfigurator API Dec 18, 2025
@fengb3 fengb3 marked this pull request as ready for review December 18, 2025 08:58
@fengb3 fengb3 merged commit 3dca14e into main Dec 18, 2025
@fengb3 fengb3 deleted the copilot/update-readme-for-new-api branch December 18, 2025 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UPDATE README

2 participants