Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jul 31, 2025

The code snippets in the default interface methods tutorial were showing interface method implementations without proper context, making it unclear to readers that these methods belong within interface declarations.

Problem:
When documentation readers viewed the code examples, they saw method implementations like:

public decimal ComputeLoyaltyDiscount()
{
    DateTime TwoYearsAgo = DateTime.Now.AddYears(-2);
    if ((DateJoined < TwoYearsAgo) && (PreviousOrders.Count() > 10))
    {
        return 0.10m;
    }
    return 0;
}

Without any indication that this code should be declared within the ICustomer interface.

Solution:
Added clarifying comments to all relevant code snippets that specify:

  • The interface or class where each method belongs
  • The filename for reference

Now readers see:

// This method belongs in the ICustomer interface (ICustomer.cs)
public decimal ComputeLoyaltyDiscount()
{
    DateTime TwoYearsAgo = DateTime.Now.AddYears(-2);
    if ((DateJoined < TwoYearsAgo) && (PreviousOrders.Count() > 10))
    {
        return 0.10m;
    }
    return 0;
}

Files changed:

  • ICustomer.cs: Added context comments to SnippetLoyaltyDiscountVersionOne, SnippetLoyaltyDiscountVersionTwo, and SnippetFinalVersion
  • SampleCustomer.cs: Added context comment to SnippetOverrideAndExtend

The changes are minimal and non-breaking - only clarifying comments were added without modifying any functional code.

Fixes #29643.


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

@dotnet-policy-service dotnet-policy-service bot added the okr-quality Content-quality KR: Concerns article defects (bugs), freshness, or build warnings. label Jul 31, 2025
Copilot AI changed the title [WIP] Why aren't the examples show IN AN INTERFACE? Add context clarification comments to interface method code snippets Jul 31, 2025
Copilot AI requested a review from BillWagner July 31, 2025 16:06
Copilot finished work on behalf of BillWagner July 31, 2025 16:06
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 and is ready for final review.

@BillWagner BillWagner marked this pull request as ready for review August 1, 2025 19:01
@BillWagner BillWagner requested a review from a team as a code owner August 1, 2025 19:01
@BillWagner BillWagner requested a review from tdykstra August 1, 2025 19:01
Copilot AI requested a review from gewarren August 4, 2025 17:55
Copilot finished work on behalf of gewarren August 4, 2025 17:55
Copilot finished work on behalf of gewarren August 4, 2025 17:58
@BillWagner BillWagner enabled auto-merge (squash) August 4, 2025 18:23
@BillWagner BillWagner merged commit 1cef022 into main Aug 4, 2025
11 checks passed
@BillWagner BillWagner deleted the copilot/fix-29643 branch August 4, 2025 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Why aren't the examples show IN AN INTERFACE?

3 participants