Extension types cannot invoke static generic members. #81421
Unanswered
nathan130200
asked this question in
Q&A
Replies: 1 comment
-
|
N/a |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm facing an issue while declaring some extension members.
Consider the function
SHA1.HashDataandMD5.HashDataboth of baseHashAlgorithmi cannot dedclare an abstract hashing method that have this signature:CS0704: An inner type cannot be specified through a type parameter. Try using the desired type explicitly.
Its because all implementations of HashAlgorithm are not using have abstract interface feature?
But if i declare separated methods for both SHA1 and MD5 with same name
HashDatacompiler show an error that same method with same name is already defined:So the type i'm extending is not relevant to consider that extension memeber is for specific type?
So i must create a separated file to create for each extension methods for each existing hash algorithm (in this example)?
An work-around about this, i can map all existing subclasses of hash alg into a
Dictionary<Type, Func<byte[], byte[]>>and invoke by callingtypeof(T)I think we need some kind of really abstract interface, that we should tell to compiler which methods we expect the type to implement, because the abstract interface members we actually need type implementing it.
Beta Was this translation helpful? Give feedback.
All reactions