Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Oct 1, 2025

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:

  • The different string literals were the conflict, or
  • The identical type names were the conflict

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:

  • The three criteria that must match: same namespace, same type name, and both accessible
  • That implementation details (methods, properties, field values) are irrelevant to the conflict
  • That the compiler cannot use both types simultaneously because they have the same identity

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

  • Added contextual explanations before and between code samples
  • Explicitly notes that the two A types have the fully qualified name A (in the global namespace)
  • Added a prominent note after the output emphasizing: "the conflict exists even though the two 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 name A."

Added "How to resolve this warning" section

Provides four concrete resolution strategies:

  1. Rename one of the conflicting types
  2. Use a different namespace for one of the types
  3. Remove the reference to the assembly containing the conflicting type if not needed
  4. Use an extern alias to disambiguate (with link to CS0433 for examples)

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

This section details on the original issue you should resolve

<issue_title>CS0436: Request for details on what actually constitutes a "conflict"</issue_title>
<issue_description>### Type of issue

Missing information

Description

I'm working on the Ecma C# spec and just got this error on a test program. However, I don't find a useful explanation here.

Looking at your two type declarations for A they appear to vary only by the spelling of one source token, the string literal. If that is the conflict, please say so, and if there are any other kinds of conflicts possible in other scenarios, I'd like to know about them as well. Perhaps the types need to be syntactically and semantically equivalent/identical!

[Enter feedback here]

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/misc/cs0436?f1url=%3FappId%3Droslyn%26k%3Dk(CS0436)

Content source URL

https://github.com/dotnet/docs/blob/main/docs/csharp/misc/cs0436.md

Document Version Independent Id

b320743f-f0ef-2174-df91-f0ddbb612e88

Platform Id

d0bdb84e-52a8-9c98-dfe6-76f4af3d5ea3

Article author

@BillWagner

Metadata

  • ID: 6493b5de-9d48-3a99-e213-06fdb121e067
  • PlatformId: d0bdb84e-52a8-9c98-dfe6-76f4af3d5ea3
  • Service: dotnet-csharp
  • Sub-service: errors-warnings

Related Issues</issue_description>

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

Fixes #47460

✨ 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

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

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@dotnet-policy-service dotnet-policy-service bot added dotnet-csharp/svc csharp-errors-warnings/subsvc okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. labels Oct 1, 2025
@Copilot Copilot AI changed the title [WIP] CS0436: Request for details on what actually constitutes a "conflict" Clarify what constitutes a type conflict in CS0436 compiler warning documentation Oct 1, 2025
@Copilot Copilot AI requested a review from BillWagner October 1, 2025 15:33
Copilot finished work on behalf of BillWagner October 1, 2025 15:33
@BillWagner BillWagner marked this pull request as ready for review October 2, 2025 12:45
@BillWagner BillWagner requested a review from a team as a code owner October 2, 2025 12:45
@BillWagner BillWagner marked this pull request as draft October 2, 2025 12:45
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 October 2, 2025 12:50
@BillWagner BillWagner requested review from IEvangelist and a team October 2, 2025 12:51

- They have the same namespace
- They have the same type name
- They are both accessible in the current compilation context
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- 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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

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.

CS0436: Request for details on what actually constitutes a "conflict"
3 participants