Open
Description
Current behavior
Defining a public partial class MyClass<T> : DependencyObject
results in generating something like:
public object DataContext
{
get => GetValue(DataContextProperty);
set => SetValue(DataContextProperty, value);
}
// Using a DependencyProperty as the backing store for DataContext. This enables animation, styling, binding, etc...
public static DependencyProperty DataContextProperty { get ; } =
DependencyProperty.Register(
name: nameof(DataContext),
propertyType: typeof(object),
ownerType: typeof(MyClass),
typeMetadata: new FrameworkPropertyMetadata(
defaultValue: null,
options: FrameworkPropertyMetadataOptions.Inherits,
propertyChangedCallback: (s, e) => ((MyClass)s).OnDataContextChanged(e)
)
);
And a build error stating
error CS0305: Using the generic type 'MyClass' requires 1 type arguments
Workaround
Can get the build to pass by adding an empty non-generic MyClass
definition that inherits from DependencyObject:
public partial class MyClass<T> : DependencyObject { }