Skip to content

Fix generated code namespace confliction#54

Merged
lindexi merged 1 commit intomainfrom
t/lvyi/namespace
Jul 7, 2025
Merged

Fix generated code namespace confliction#54
lindexi merged 1 commit intomainfrom
t/lvyi/namespace

Conversation

@walterlv
Copy link
Member

@walterlv walterlv commented Jul 7, 2025

Fix #52

@walterlv walterlv force-pushed the t/lvyi/namespace branch from 2d39bc6 to df47208 Compare July 7, 2025 03:13
@CLAassistant
Copy link

CLAassistant commented Jul 7, 2025

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR resolves namespace conflicts by standardizing the interceptor namespace from DotNetCampus.CommandLine.Compiler to DotNetCampus.Cli.Compiler across the build props, code generator, and docs.

  • Updated MSBuild properties to point at the new CLI compiler namespace.
  • Hardcoded the interceptor generator’s namespace to DotNetCampus.Cli.Compiler.
  • Aligned README examples (both Chinese and English) with the renamed namespace.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
src/DotNetCampus.CommandLine/Package/build/Package.props Changed <InterceptorsNamespaces> and <InterceptorsPreviewNamespaces> to use the new Cli.Compiler namespace.
src/DotNetCampus.CommandLine.Analyzer/Generators/InterceptorGenerator.cs Replaced dynamic {{GeneratorInfo.RootNamespace}}.Compiler with static DotNetCampus.Cli.Compiler.
docs/zh-hans/README.md Updated example namespace to DotNetCampus.Cli.Compiler.
docs/en/README.md Updated example namespace to DotNetCampus.Cli.Compiler.

#nullable enable

namespace {{GeneratorInfo.RootNamespace}}.Compiler
namespace DotNetCampus.Cli.Compiler
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding the namespace here removes flexibility for projects that customize the root namespace. Consider constructing it using GeneratorInfo.RootNamespace (e.g., ${GeneratorInfo.RootNamespace}.Compiler) to keep it in sync with the project’s actual root namespace.

Suggested change
namespace DotNetCampus.Cli.Compiler
namespace {{GeneratorInfo.RootNamespace}}.Compiler

Copilot uses AI. Check for mistakes.
<PropertyGroup>
<DotNetCampusCommandLineUseInterceptor Condition="'$(DotNetCampusCommandLineUseInterceptor)' == ''">true</DotNetCampusCommandLineUseInterceptor>
<InterceptorsNamespaces>$(InterceptorsNamespaces);DotNetCampus.CommandLine.Compiler</InterceptorsNamespaces>
<InterceptorsNamespaces>$(InterceptorsNamespaces);DotNetCampus.Cli.Compiler</InterceptorsNamespaces>
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The DotNetCampus.Cli.Compiler string is duplicated in both InterceptorsNamespaces and InterceptorsPreviewNamespaces. Consider defining a single MSBuild property for the CLI compiler namespace to avoid repetition and simplify future updates.

Suggested change
<InterceptorsNamespaces>$(InterceptorsNamespaces);DotNetCampus.Cli.Compiler</InterceptorsNamespaces>
<DotNetCampusCliCompilerNamespace>DotNetCampus.Cli.Compiler</DotNetCampusCliCompilerNamespace>
<InterceptorsNamespaces>$(InterceptorsNamespaces);$(DotNetCampusCliCompilerNamespace)</InterceptorsNamespaces>

Copilot uses AI. Check for mistakes.
@lindexi lindexi merged commit 8fca4f7 into main Jul 7, 2025
3 checks passed
@lindexi lindexi deleted the t/lvyi/namespace branch July 7, 2025 03:29
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.

DotNetCampus.CommandLine 和 DotNetCampus.Cli.CommandLine 冲突

3 participants