Syntax highlighting is very helpful for programmers to read code, although VisualStudio itself supports C # syntax highlighting, but only a few elements, such as keywords, class names, strings, and so on, and our code theme: variables, functions, properties, events, etc. are not highlighted, as follows:
????Varnodes =FromIdInchGetidentifiersinspans (Doc. Workspace, Doc. SemanticModel, spans)
????????????????Letnode = doc. Syntaxroot.findnode (ID. Textspan)
????????????????let symbol = doc. Semanticmodel.getsymbolinfo (getexpression (node)). Symbol
???????????????? where symbol! = null
???????????????? let type = roslynsymbolparser???????????????? where type! = null
???????????????? let Classficationtype = _classificationmap[type]
???????????????? select ID. Textspan.totagspan (Spans[0]. Snapshot, Classficationtype);
/span>
Some third-party controls, such as visual assist, have been enhanced for this shortcoming, but Visualassist is a charge control, and I found a control that, although it worked very well, was too weak to parse in the middle of the code, and once there was a syntax error , its syntax highlighting is aging, resulting in a constant flicker of the interface. This bug causes the syntax highlighting feature to be largely unavailable. Originally wanted to write their own, the results found that VisualStudio extension of the relevant documents too little, and there is no time to devote to research it, it was once shelved.
Today, on GitHub, I found a project with a syntax highlighting control, and the project itself was not roslyn-colorizer, so it was not released as a plugin. But a good example of code, based on its simple change, adding parameters, member variables, attributes, events, enumerations, functions and other elements of the syntax highlighting, the preceding code plus syntax highlighting plugin has become the following form:
????Varnodes =FromIdInchGetidentifiersinspans(Doc.Workspace,Doc.SemanticModel,Spans)
????????????????Letnode =Doc.Syntaxroot.FindNode(ID.Textspan)
????????????????LetSymbol =Doc.SemanticModel.Getsymbolinfo(GetExpression(node)).Symbol
????????????????whereSymbol! =Null
????????????????LetType =Roslynsymbolparser. Getsymboltype(symbol)
???????????????? where type! = NULL
???????????????? let classficationtype = _classificationmap[Type]
???????????????? select ID. Textspan. Totagspan(spans[0]. Snapshot, Classficationtype);
?
A C # syntax highlighting plugin