Roslyn: Determine if these IP character types are equivalent.

I am trying to determine with Roslyn if two method signatures are equivalent (ignoring the order of the parameters). This becomes somewhat nontrivial if the methods contain common parameters.

I would like to define AGenericMethod and AnotherGenericMethod below as having equivalent signatures:

 public void AGenericMethod<X>(X someX, int someInt) where X : IEnumerable<int> { //... } public void AnotherGenericMethod<Y>(Y someY, int someInt) where Y : IEnumerable<int> { //... } 

It seems that .Equals() will return false for ITypeParameterSymbols corresponding to X and Y.

Is there any existing functionality in Roslyn to classify ITypeParameterSymbols as "equivalent" (in the sense of having equivalent restrictions)? If not, then what is the best way to implement this (given that the constraints themselves can be type parameters)?

+6
source share

Source: https://habr.com/ru/post/987869/


All Articles