Skip to content

Clarify that abstract classes can contain implemented methods alongside abstract members #47667

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 30, 2025

The current documentation for the abstract keyword suggests that abstract classes only have "missing or incomplete implementation," which could mislead readers into thinking that ALL members in an abstract class must be abstract. This PR addresses that confusion by clearly explaining and demonstrating that abstract classes can contain both abstract and fully implemented members.

Changes Made

Enhanced documentation clarity:

  • Added explanatory text that abstract classes can contain both abstract members (requiring implementation) and fully implemented members (providing common functionality)
  • Updated the features list to explicitly mention implemented members
  • Improved the introductory paragraph to be more precise about what "incomplete implementation" means

New comprehensive example:

  • Created Example 1 with a Vehicle abstract class that demonstrates mixed member types:
    • Implemented members: GetInfo() method, StartEngine() method, constructor with functionality
    • Abstract members: Move() method and MaxSpeed property requiring derived class implementation
  • Shows two derived classes (Car and Boat) implementing the abstract members differently
  • Includes detailed explanation of the design pattern and its benefits

Example organization:

  • Renumbered existing examples to maintain proper sequence
  • Placed the new mixed-member example first to address the core concept immediately

The enhanced documentation now makes it crystal clear that abstract classes serve as both providers of shared functionality and enforcers of required implementations, addressing the user's concern about the concept not being "obvious enough."

Fixes #28065.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/csharp/language-reference/keywords/abstract.md docs/csharp/language-reference/keywords/abstract

@Copilot Copilot AI changed the title [WIP] Abstract classes with implemented methods Clarify that abstract classes can contain implemented methods alongside abstract members Jul 30, 2025
@Copilot Copilot AI requested a review from BillWagner July 30, 2025 18:57
Copilot finished work on behalf of BillWagner July 30, 2025 18:57
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.

Good start, but I have some feedback.

@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 Copilot AI requested a review from BillWagner July 31, 2025 15:12
Copilot finished work on behalf of BillWagner July 31, 2025 15:12
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 now ready for final review.

@BillWagner BillWagner requested a review from tdykstra July 31, 2025 15:15
@BillWagner BillWagner marked this pull request as ready for review July 31, 2025 15:15
@BillWagner BillWagner requested a review from a team as a code owner July 31, 2025 15:15
@Copilot Copilot AI requested a review from BillWagner July 31, 2025 15:18
Copilot finished work on behalf of BillWagner July 31, 2025 15:18
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.

You need to fix some build errors now.

Copy link
Contributor Author

Copilot AI commented Jul 31, 2025

You need to fix some build errors now.

Fixed the build errors by adjusting the target framework to .NET 8.0 (due to environment limitations) and ensuring proper Main method entry point. The code now builds and runs successfully. Commit: 2fd7a2a

@Copilot Copilot AI requested a review from BillWagner July 31, 2025 15:34
Copilot finished work on behalf of BillWagner July 31, 2025 15:34
@Copilot Copilot AI requested a review from BillWagner July 31, 2025 15:42
Copilot finished work on behalf of BillWagner July 31, 2025 15:42
@BillWagner
Copy link
Member

The final failure is because of a new extension feature that will be in next .NET 10 preview.

Copilot finished work on behalf of BillWagner July 31, 2025 15:54
@BillWagner BillWagner requested a review from a team August 4, 2025 18:26
@BillWagner BillWagner requested review from a team and adegeo August 4, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

Abstract classes with implemented methods
2 participants