c# - Roslyn Diagnostic + Visual Studio Colorisation -


does know can location "simple" example of colourisation of token based on roslyn diagnostic. yep can make them info, warning, error or hidden. let want use hidden doesn't appear in errors list/window, accessible later.

now i've got these hidden diagnostic, affect colourisation of text in ide.

this i've tried for.

private sub createvisuals(byval line itextviewline)   try     'grab reference lines in current textview      dim textviewlines = _view?.textviewlines     if textviewlines nothing exit sub      if line nothing exit sub      dim linestart integer = line.start     dim lineend integer = line.end     dim q = textviewlines.firstordefault     if q nothing exit sub     dim qq = q.snapshot.getopendocumentincurrentcontextwithchanges     if qq nothing exit sub     dim sm = qq.getsemanticmodelasync.result '..getsemanticmodelasync.result     '   dim di = sm.getsyntaxdiagnostics.toarray     if sm nothing exit sub     dim diags = sm.getdiagnostics.toarray 

i have tried getsyntaxdiagnostic

    if diags.any() = false exit sub     each d in diags       ' id if diagnostic want color.       'if d.id<>"sfd000" continue       dim charspan new snapshotspan(_view.textsnapshot,                       span.frombounds(d.location.sourcespan.start, d.location.sourcespan.end))       dim g geometry = textviewlines.getmarkergeometry(charspan)       if g isnot nothing         dim drawing new geometrydrawing(_brush, _pen, g) : drawing.freeze()         dim drawingimage new drawingimage(drawing) : drawingimage.freeze()         dim image new image()         image.source = drawingimage         'align image top of bounds of text geometry         canvas.setleft(image, g.bounds.left)         canvas.settop(image, g.bounds.top)         _layer?.addadornment(adornmentpositioningbehavior.textrelative,                              charspan, nothing, image, nothing)       end if     next   catch ex exception     debug.print(ex.tostring)   end try  end sub 

i diagnostic issue compiler, not mine. why?

the example can either c# or vb.net.

this can done idiagnosticservice (which how roslyn classifies error tags & unnecessary code).

that interface internal, you're out of luck (unless want use lot of reflection).

you can file issue on codeplex & ask them make idiagnosticservice public.

you can ask them make abstractdiagnosticstagproducer<ttag> public; you're looking for, letting plug in filter , tag creator.
more information, @ class in decompiler.


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -