Skip to content

Add context clarification comments to interface method code snippets #47683

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface ICustomer

/*
// <SnippetLoyaltyDiscountVersionOne>
// This method belongs in the ICustomer interface (ICustomer.cs).
// Version 1:
public decimal ComputeLoyaltyDiscount()
{
Expand All @@ -26,6 +27,7 @@ public decimal ComputeLoyaltyDiscount()

/*
// <SnippetLoyaltyDiscountVersionTwo>
// These methods belong in the ICustomer interface (ICustomer.cs).
// Version 2:
public static void SetLoyaltyThresholds(
TimeSpan ago,
Expand Down Expand Up @@ -65,6 +67,7 @@ public static void SetLoyaltyThresholds(TimeSpan ago, int minimumOrders, decimal
private static decimal discountPercent = 0.10m;

// <SnippetFinalVersion>
// These methods belong in the ICustomer interface (ICustomer.cs).
public decimal ComputeLoyaltyDiscount() => DefaultLoyaltyDiscount(this);
protected static decimal DefaultLoyaltyDiscount(ICustomer c)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void AddOrder(IOrder order)
}

// <SnippetOverrideAndExtend>
// This method belongs in the SampleCustomer class (SampleCustomer.cs) that implements ICustomer.
public decimal ComputeLoyaltyDiscount()
{
if (PreviousOrders.Any() == false)
Expand Down