-
Notifications
You must be signed in to change notification settings - Fork 6k
Clarify what constitutes a type conflict in CS0436 compiler warning documentation #48863
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
There was a problem hiding this 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.
|
||
- They have the same namespace | ||
- They have the same type name | ||
- They are both accessible in the current compilation context |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- They are both accessible in the current compilation context | |
- They're both accessible in the current compilation context |
- They have the same type name | ||
- They are both accessible in the current compilation context | ||
|
||
The conflict is determined solely by the type's fully qualified name, not by its implementation details. Two types with the same name but different implementations (such as different methods, properties, or field values) still conflict. The compiler cannot use both types simultaneously because they have the same identity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The conflict is determined solely by the type's fully qualified name, not by its implementation details. Two types with the same name but different implementations (such as different methods, properties, or field values) still conflict. The compiler cannot use both types simultaneously because they have the same identity. | |
The conflict is determined solely by the type's fully qualified name, not by its implementation details. Two types with the same name but different implementations (such as different methods, properties, or field values) still conflict. The compiler can't use both types simultaneously because they have the same identity. |
## Example 1 | ||
## Example | ||
|
||
The following examples demonstrate CS0436. In this scenario, a type `A` is defined in an external library and also locally in the source file. Even though the two types have different implementations (they print different strings), they conflict because they share the same fully qualified name. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following examples demonstrate CS0436. In this scenario, a type `A` is defined in an external library and also locally in the source file. Even though the two types have different implementations (they print different strings), they conflict because they share the same fully qualified name. | |
The following example demonstrates CS0436. In this scenario, a type `A` is defined in an external library and also locally in the source file. Even though the two types have different implementations (they print different strings), they conflict because they share the same fully qualified name. |
Summary
Fixes #[issue_number] by enhancing the CS0436 compiler warning documentation to explicitly explain what constitutes a "conflict" between types.
Problem
The original issue reporter, working on the Ecma C# spec, encountered CS0436 and found the documentation unclear about what actually causes the conflict. The existing documentation showed two type declarations that differed only by a string literal in their implementations, but didn't explain whether:
This ambiguity left developers uncertain about the fundamental cause of the warning.
Changes
Added "What constitutes a conflict" section
Explicitly defines that a conflict occurs when two types have identical fully qualified names (namespace + type name), regardless of implementation differences. The section clarifies:
Enhanced the introduction
Changed from the vague "conflicts with an imported type" to explicitly state "has the same fully qualified name (namespace and type name) as a type imported from a referenced assembly."
Improved example explanation
A
types have the fully qualified nameA
(in the global namespace)A
types have different implementations. The difference in the string literal... doesn't prevent the conflict. What matters is that both types have the same fully qualified nameA
."Added "How to resolve this warning" section
Provides four concrete resolution strategies:
Impact
The enhanced documentation now clearly answers the question: the conflict is based on identical fully qualified type names, not on implementation differences. This removes ambiguity and helps developers understand that syntactic or semantic differences in the type definitions don't prevent conflicts when the types share the same fully qualified name.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Internal previews