Skip to content

Rewrite covariance/contravariance definitions to be user-focused#52120

Open
Copilot wants to merge 5 commits intomainfrom
copilot/improve-covariance-contravariance-explanation
Open

Rewrite covariance/contravariance definitions to be user-focused#52120
Copilot wants to merge 5 commits intomainfrom
copilot/improve-covariance-contravariance-explanation

Conversation

Copy link
Contributor

Copilot AI commented Mar 9, 2026

  • Rewrite the covariance, contravariance, and invariance definitions to be more concrete and user-focused
  • Use the "where X type is permitted, you can do Y" framing as suggested in the issue
  • Address review: use "generic type argument" instead of "generic type parameters" for substitution context
  • Address review: reorder definitions to start with invariant (baseline: no substitution), then covariant, then contravariant
  • Update frontmatter with current date and ai-usage: ai-assisted
  • Review and validate changes
Original prompt

This section details on the original issue you should resolve

<issue_title>can be clearer</issue_title>
<issue_description>The article says

Covariance
Enables you to use a more derived type than originally specified.
Contravariance
Enables you to use a more generic (less derived) type than originally specified.

Rather than talking about covariance and contravariance in general terms, I think would be more effective to start by using the terms covariant and contravariant concretely. Something like,

Where a covariant type is permitted, you can use a more derived type.
Where a contravariant type is permitted, you can use a more generic type.
Where an invariant type is required, you cannot use either a more derived or a more generic type.

The general terms are more appropriate to theoretical and implementation discussions, not so much for how to use language and API features. So I think they should be used very sparingly on this page.

I bet this page would be a lot better after some user testing. Lots of people have trouble with these terms.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

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

@adegeo Thank you for opening this issue. I'll add it to the backlog. If you would like to contribute, you can submit a fix by editing the original article. Click on the **Content Source** link at the bottom of your original comment. To learn how to edit, see the [Editing files in a repository](https://help.github.com/articles/editing-files-in-your-repository) article from GitHub.

Thanks again!</comment_new>


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.


Internal previews

📄 File 🔗 Preview link
docs/standard/generics/covariance-and-contravariance.md Covariance and contravariance in generics

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
Copilot AI changed the title [WIP] Clarify covariance and contravariance definitions in article Rewrite covariance/contravariance definitions to be user-focused Mar 9, 2026
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.

Hi @copilot

A couple things to change before this is ready.

Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com>
@BillWagner BillWagner self-requested a review March 10, 2026 15:19
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 marked this pull request as ready for review March 10, 2026 15:19
@BillWagner BillWagner requested review from a team and adegeo as code owners March 10, 2026 15:19
Copilot AI review requested due to automatic review settings March 10, 2026 15:19
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the introductory definitions in the generics variance article to be more concrete and user-focused, aligning the framing with “where X is permitted, you can do Y,” and updating metadata to reflect AI-assisted edits.

Changes:

  • Rewrites the opening explanation of covariance, contravariance, and invariance with clearer, example-driven definitions.
  • Reorders the definitions to start with invariance, then covariance, then contravariance.
  • Updates frontmatter (ms.date) and adds ai-usage: ai-assisted.

BillWagner and others added 2 commits March 10, 2026 14:15
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

can be clearer

3 participants