diff --git a/src/Framework/Framework/Binding/ExtractGenericArgumentDataContextChangeAttribute.cs b/src/Framework/Framework/Binding/ExtractGenericArgumentDataContextChangeAttribute.cs index 8c8f34275b..246e9d6b37 100644 --- a/src/Framework/Framework/Binding/ExtractGenericArgumentDataContextChangeAttribute.cs +++ b/src/Framework/Framework/Binding/ExtractGenericArgumentDataContextChangeAttribute.cs @@ -15,17 +15,23 @@ public class ExtractGenericArgumentDataContextChangeAttribute : DataContextChang public override int Order { get; } public ExtractGenericArgumentDataContextChangeAttribute(Type genericType, int typeArgumentIndex, int order = 0) + : this(new ResolvedTypeDescriptor(genericType), typeArgumentIndex, order) + { + } + + + public ExtractGenericArgumentDataContextChangeAttribute(ITypeDescriptor genericType, int typeArgumentIndex, int order = 0) { if (!genericType.IsGenericTypeDefinition) { throw new ArgumentException($"The {nameof(genericType)} argument must be a generic type definition!", nameof(genericType)); } - if (typeArgumentIndex < 0 || typeArgumentIndex >= genericType.GetGenericArguments().Length) + if (typeArgumentIndex < 0 || typeArgumentIndex >= genericType.GetGenericArguments()!.Length) { throw new ArgumentOutOfRangeException(nameof(typeArgumentIndex), $"The {nameof(typeArgumentIndex)} is not a valid index of a type argument!"); } - GenericType = new ResolvedTypeDescriptor(genericType); + GenericType = genericType; TypeArgumentIndex = typeArgumentIndex; Order = order; } diff --git a/src/Framework/Framework/Compilation/ControlTree/ITypeDescriptor.cs b/src/Framework/Framework/Compilation/ControlTree/ITypeDescriptor.cs index 0f416b68c1..1d3e9fa555 100644 --- a/src/Framework/Framework/Compilation/ControlTree/ITypeDescriptor.cs +++ b/src/Framework/Framework/Compilation/ControlTree/ITypeDescriptor.cs @@ -18,6 +18,7 @@ public interface ITypeDescriptor string CSharpName { get; } /// Returns type name including namespace with generic arguments in the C# style. string CSharpFullName { get; } + bool IsGenericTypeDefinition { get; } bool IsAssignableTo(ITypeDescriptor typeDescriptor); diff --git a/src/Framework/Framework/Compilation/ControlTree/Resolved/ResolvedTypeDescriptor.cs b/src/Framework/Framework/Compilation/ControlTree/Resolved/ResolvedTypeDescriptor.cs index 92db1896a2..05b84f1b0c 100644 --- a/src/Framework/Framework/Compilation/ControlTree/Resolved/ResolvedTypeDescriptor.cs +++ b/src/Framework/Framework/Compilation/ControlTree/Resolved/ResolvedTypeDescriptor.cs @@ -35,6 +35,8 @@ public ResolvedTypeDescriptor(Type type) public string CSharpName => Type.ToCode(stripNamespace: true); public string CSharpFullName => Type.ToCode(); + public bool IsGenericTypeDefinition => Type.IsGenericTypeDefinition; + public bool IsAssignableTo(ITypeDescriptor typeDescriptor) { return ToSystemType(typeDescriptor).IsAssignableFrom(Type);