From d7e3e42cc89353d6e9e04c3b164b2e17dc3d520f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:24:58 +0000 Subject: [PATCH 1/3] Initial plan From 05301146ab2f3154fa8e722a5c9fba9395f4397b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:30:38 +0000 Subject: [PATCH 2/3] Fix incorrect statement about generic interface inheritance The previous statement incorrectly claimed that generic interfaces can only inherit from non-generic interfaces if they are covariant. This is false - any generic interface can inherit from a non-generic interface regardless of variance. The corrected text now: 1. States correctly that generic interfaces CAN inherit from non-generic interfaces (no conditions) 2. Explains that when this happens, the type parameter replaces 'object' in overridden members 3. Uses IEnumerable as an example where T replaces object in output positions 4. Clarifies that because T is used only in output positions, the interface CAN be marked as covariant 5. Notes that if T were used in input positions, it couldn't be covariant This addresses the issue raised in #43518 and incorporates Bill Wagner's clarification. Co-authored-by: BillWagner <493969+BillWagner@users.noreply.github.com> --- docs/csharp/programming-guide/generics/generic-interfaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/programming-guide/generics/generic-interfaces.md b/docs/csharp/programming-guide/generics/generic-interfaces.md index 107d1f431d582..809efe7f81a74 100644 --- a/docs/csharp/programming-guide/generics/generic-interfaces.md +++ b/docs/csharp/programming-guide/generics/generic-interfaces.md @@ -26,7 +26,7 @@ The rules of inheritance that apply to classes also apply to interfaces: :::code language="csharp" source="./snippets/GenericInterfaces.cs" id="Months"::: -Generic interfaces can inherit from non-generic interfaces if the generic interface is covariant, which means it only uses its type parameter as a return value. In the .NET class library, inherits from because only uses `T` in the return value of and in the property getter. +Generic interfaces can inherit from non-generic interfaces. In the .NET class library, inherits from . When a generic interface inherits from a non-generic interface, the type parameter replaces `object` in the overridden members. For example, uses `T` in place of `object` in the return value of and in the property getter. Because `T` is used only in output positions in these members, can be marked as covariant. If `T` were used in an input position in an overridden member, the interface couldn't be covariant, and the compiler would generate an error. Concrete classes can implement closed constructed interfaces, as follows: From 9663fc869b197f682f6fda072548ebb802e43293 Mon Sep 17 00:00:00 2001 From: Bill Wagner Date: Thu, 2 Oct 2025 08:48:57 -0400 Subject: [PATCH 3/3] Update docs/csharp/programming-guide/generics/generic-interfaces.md --- docs/csharp/programming-guide/generics/generic-interfaces.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/csharp/programming-guide/generics/generic-interfaces.md b/docs/csharp/programming-guide/generics/generic-interfaces.md index 809efe7f81a74..abc6b79dab2c4 100644 --- a/docs/csharp/programming-guide/generics/generic-interfaces.md +++ b/docs/csharp/programming-guide/generics/generic-interfaces.md @@ -26,7 +26,7 @@ The rules of inheritance that apply to classes also apply to interfaces: :::code language="csharp" source="./snippets/GenericInterfaces.cs" id="Months"::: -Generic interfaces can inherit from non-generic interfaces. In the .NET class library, inherits from . When a generic interface inherits from a non-generic interface, the type parameter replaces `object` in the overridden members. For example, uses `T` in place of `object` in the return value of and in the property getter. Because `T` is used only in output positions in these members, can be marked as covariant. If `T` were used in an input position in an overridden member, the interface couldn't be covariant, and the compiler would generate an error. +Generic interfaces can inherit from non-generic interfaces. In the .NET class library, inherits from . When a generic interface inherits from a non-generic interface, the type parameter typically replaces `object` in the overridden members. For example, uses `T` in place of `object` in the return value of and in the property getter. Because `T` is used only in output positions in these members, can be marked as covariant. If `T` were used in an input position in an overridden member, the interface couldn't be covariant, and the compiler would generate an error. Concrete classes can implement closed constructed interfaces, as follows: