Closed 84819760 closed 2 years ago
There is no way to distinguish them. Intellicode just spits out normal text which becomes a standard part of the roslyn pipeline. Once emitted there is no way to distinguish it from anything the user may have written themselves.
I found a way to distinguish. I hope there can be an official way。
@84819760 what way did you find?
@CyrusNajmabadi
Can only distinguish whether it is generated by intellicode,This code can also achieve my goal,I hope there can be an official way。
public void Execute(GeneratorExecutionContext context)
{
var isPrediction = new StackTrace().GetFrames()
.Select(stackFrame => stackFrame.GetMethod().DeclaringType.Name)
.Any(typeName => typeName is "SemanticsModelPredictionModifier");
if (isPrediction) return;
// code ......
}
Intellicode will trigger the generation of a new tree,How to distinguish SyntaxNode generated by intelliCode ?