Skip to content

Improve CS0430 extern alias documentation with practical usage examples #47708

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 4, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 1, 2025

The CS0430 compiler error documentation had examples that didn't demonstrate how to actually use extern aliases, making it difficult for first-time users to understand the feature. The original examples showed extern alias declarations but no practical usage.

Changes made:

  1. Enhanced code examples: Added a static method M() to MyClass and demonstrated actual usage with MyType::MyClass.M() in the Main method to show how extern alias resolves naming conflicts.

  2. Added cross-reference: Included a "See also" section linking to the extern alias keyword documentation to help users understand the complete picture.

Before:

// CS0430_a.cs  
public class MyClass {}  

// CS0430_b.cs  
extern alias MyType;   // CS0430  
public class Test
{  
   public static void Main() {}  // No usage shown
}  

After:

// CS0430_a.cs  
public class MyClass
{
    public static void M() { /*...*/ }
}

// CS0430_b.cs  
extern alias MyType;   // CS0430  
public class Test
{  
   public static void Main() { MyType::MyClass.M(); }  // Shows actual usage
}  

These minimal changes now clearly demonstrate how extern alias works with the :: operator and provide users with a complete understanding of the feature when encountering CS0430 errors.

Fixes #33207.


💡 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.


Internal previews

📄 File 🔗 Preview link
docs/csharp/misc/cs0430.md docs/csharp/misc/cs0430

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Less-than-useful example of using extern alias Improve CS0430 extern alias documentation with practical usage examples Aug 1, 2025
Copilot finished work on behalf of BillWagner August 1, 2025 19:48
@Copilot Copilot AI requested a review from BillWagner August 1, 2025 19:48
Copy link
Member

@BillWagner BillWagner left a comment

Choose a reason for hiding this comment

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

This is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review August 4, 2025 16:31
@BillWagner BillWagner requested a review from a team as a code owner August 4, 2025 16:31
@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Aug 4, 2025
@BillWagner BillWagner merged commit af447e3 into main Aug 4, 2025
13 checks passed
@BillWagner BillWagner deleted the copilot/fix-33207 branch August 4, 2025 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
csharp-errors-warnings/subsvc dotnet-csharp/svc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Less-than-useful example of using extern alias
3 participants