Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 29, 2025

The CS0759 compiler error documentation was unclear about what a "defining declaration" means, leaving users confused when encountering this error. The existing documentation simply stated "No defining declaration found..." without explaining the concept or providing working examples.

Changes Made

Enhanced Documentation: Added comprehensive explanation for CS0759 that:

  • References the existing definition of "defining declaration" from the Partial members section
  • Explains the two required parts: defining declaration (signature without body) and implementing declaration (signature with body)
  • Clearly states when CS0759 occurs: having an implementation without a corresponding definition

Code Examples: Created practical examples showing:

Incorrect code that generates CS0759:

public partial class ExampleClass
{
    // ERROR: This is an implementing declaration without a corresponding defining declaration
    partial void MyMethod() // CS0759
    {
        Console.WriteLine("Implementation without definition");
    }
}

Correct fix - separate partial declarations:

public partial class CorrectExampleClass
{
    // Defining declaration (signature without body)
    partial void MyMethod();
}

public partial class CorrectExampleClass  
{
    // Implementing declaration (signature with body)
    partial void MyMethod()
    {
        Console.WriteLine("This works correctly");
    }
}

Alternative fix - both in same partial class:

public partial class AlternativeExampleClass
{
    partial void MyMethod();        // Defining declaration
    
    partial void MyMethod()         // Implementing declaration
    {
        Console.WriteLine("This also works correctly");
    }
}

The enhanced documentation now clearly explains what a "defining declaration" is, why the CS0759 error occurs, and provides practical examples of both the error scenario and its resolution.

Fixes #27997.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/compiler-messages/partial-declarations.md docs/csharp/language-reference/compiler-messages/partial-declarations

@Copilot Copilot AI changed the title [WIP] Define "defining declaration" Define "defining declaration" and enhance CS0759 compiler error documentation Jul 29, 2025
Copilot finished work on behalf of BillWagner July 29, 2025 21:21
@Copilot Copilot AI requested a review from BillWagner July 29, 2025 21:21
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.

One small change and this is ready.

Copilot finished work on behalf of BillWagner July 30, 2025 18:17
@Copilot Copilot AI requested a review from BillWagner July 30, 2025 18:17
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 LGTM. It's ready for final review.

@BillWagner BillWagner marked this pull request as ready for review July 30, 2025 18:23
@BillWagner BillWagner requested a review from a team as a code owner July 30, 2025 18:23
@BillWagner BillWagner requested a review from tdykstra July 30, 2025 18:24
@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Aug 5, 2025
Copilot finished work on behalf of gewarren August 5, 2025 20:00
@Copilot Copilot AI requested a review from gewarren August 5, 2025 20:00
@BillWagner BillWagner enabled auto-merge (squash) August 6, 2025 14:01
@BillWagner BillWagner merged commit 74706a4 into main Aug 6, 2025
11 checks passed
@BillWagner BillWagner deleted the copilot/fix-27997 branch August 6, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

csharp-diagnostics/subsvc dotnet-csharp/svc lang-reference/subsvc 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.

Define "defining declaration"

3 participants