You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following mixin. My end goal is to simplify some collection types, but here I'm just beginning with this:
internal abstract class MyMixin<T> : IReadOnlyCollection<T>, ICollection
{
protected abstract int MyMixin_Count();
public int Count => MyMixin_Count();
int IReadOnlyCollection<T>.Count => MyMixin_Count();
int ICollection.Count => MyMixin_Count();
bool ICollection.IsSynchronized => false;
object ICollection.SyncRoot => null!;
void ICollection.CopyTo(Array array, int index)
{
throw new NotImplementedException();
}
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
throw new System.NotImplementedException();
}
IEnumerator IEnumerable.GetEnumerator()
{
throw new System.NotImplementedException();
}
}
As you can see there's a type parameter T. But what happens if T itself is generic?
[Mixin(typeof(MyMixin<KeyValuePair<string, string>>))]
public partial class TestObject
{
protected partial int MyMixin_Count() => 5;
}
The generator should get IReadOnlyCollection<KeyValuePair<string, string>>, but I get this other result:
public partial class TestObject : global::System.Collections.Generic.IReadOnlyCollection<global::System.Collections.Generic.KeyValuePair ` 2>, global::System.Collections.ICollection
{
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
protected partial int MyMixin_Count();
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
public int Count => MyMixin_Count();
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
int global::System.Collections.Generic.IReadOnlyCollection<global::System.Collections.Generic.KeyValuePair ` 2>.Count => MyMixin_Count();
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
int global::System.Collections.ICollection.Count => MyMixin_Count();
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
bool global::System.Collections.ICollection.IsSynchronized => false;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
object global::System.Collections.ICollection.SyncRoot => null !;
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
void global::System.Collections.ICollection.CopyTo(global::System.Array array, int index)
{
throw new global::System.NotImplementedException();
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
global::System.Collections.Generic.IEnumerator<global::System.Collections.Generic.KeyValuePair ` 2> global::System.Collections.Generic.IEnumerable<global::System.Collections.Generic.KeyValuePair ` 2>.GetEnumerator()
{
throw new global::System.NotImplementedException();
}
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Mixin Task", "1.0.52.0")]
global::System.Collections.IEnumerator global::System.Collections.IEnumerable.GetEnumerator()
{
throw new global::System.NotImplementedException();
}
}
I get global::System.Collections.Generic.KeyValuePair ` 2 instead of global::System.Collections.Generic.KeyValuePair<global::System.String, global::System.String>
The text was updated successfully, but these errors were encountered:
Sorry I wasn't able to look at this yet. I hope I'll can look at it on the following weekend (no guaranty).
But it seems like I need to build the generic types recursivly....
@R2D221 If you need it soon and have time, you may want to look into it yourself and make a pull request. I think Generics need to be handled in follwoing method:
I have the following mixin. My end goal is to simplify some collection types, but here I'm just beginning with this:
As you can see there's a type parameter T. But what happens if T itself is generic?
The generator should get IReadOnlyCollection<KeyValuePair<string, string>>, but I get this other result:
I get global::System.Collections.Generic.KeyValuePair ` 2 instead of global::System.Collections.Generic.KeyValuePair<global::System.String, global::System.String>
The text was updated successfully, but these errors were encountered: