I am on a roslyn analyzer that can handle async Task<T>
boxing to an object variable like:
int GetValue() => ...
void Print(object value) => Console.WriteLine(value);
void Main() {
Print(GetValue());
}
if you change:
-int GetValue() => ...
+Task<int> GetValue() => ...
the analyzer should throw a warning.
I am actually at the very end of the coding and just want to optimize my code on that certain position:
I have got a IsGenericTaskType
Method, were the ITypeSymbol
that is transferred to it gets analyzed for being System.Threading.Tasks.Task'1
but by string-comparison what I actually don’t like.
ChatGPTs answer:
type as INamedTypeSymbol)?.ConstructedFrom.SpecialType == SpecialType.System_Threading_Tasks_Task_T;
but I cannot access SpecialType.System_Threading_Tasks_Task_T
due to CS1061..
Is there any possible way to compare my type symbol without using strings?
kevin wolf is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
6