I am using Roslyn to create a C# scripting control with IntelliSense.
I am generally very happy with the results I am getting, however, the recommended symbols don't include keywords such as for
and if
et cetera and also don't contain type aliases such as int
, when it includes Int32
.
More specifically, I am using Microsoft.CodeAnalysis.Recommendations
, that is:
Recommender.GetRecommendedSymbolsAtPositionAsync(mySemanticModel, scriptPosition, myAdhocWorkspace);
My SemanticModel
object is obtained from a C# compilation which always has a reference to mscorlib.dll
at the very least.
At all positions in my script, the recommended completions are always correct. However, I would argue that they are incomplete if they are missing keywords such as if
, else
and for
etc.
I can see that it would be easy for me to include common type aliases in my IntelliSense manually. That is, if Int32
is a possible completion, then I could manually add int
.
However, it is less obvious when an if
statement or a for
statement or even is
/as
would be appropriate in the given scope.
Is there a way to include these keywords when getting the recommended symbols this way?
Is there also a way to automatically include type aliases?