Skip to content

Build fails with CS0263 when a partial class derived from a generic type is defined across different nullable contexts #45960

@hamzasood

Description

@hamzasood

Related to #38560

Version Used:
version 3.8.0-dev (<developer build>)
(Built from master a few minutes ago)

Steps to Reproduce:

Compile the following code:

class Base<T> { }

#nullable enable
partial class Derived : Base<object> { }
#nullable disable
partial class Derived : Base<object> { }

Expected Behavior:

The build should probably succeed. I've ran into this issue in a WPF project with nullable enabled (although the above code shows that this isn't a WPF issue). Code generated from xaml files is marked as auto-generated and is therefore has nullable disabled, which means that you can't use xaml for classes with a generic base class (which unfortunately is quite common with ReactiveUI, e.g. ReactiveWindow<ViewModel>).

Actual Behavior:

<file>(4,15): error CS0263: Partial declarations of 'Derived' must not specify different base classes

I've also tried changing the base declaration to Base<object?> in the nullable enable block, but that still gives the same error.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

Status

Language/design

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions