Roslyn Parsing now Formatting Code
I almost took another break on Roslyn’s SyntaxTree, to
tackle dialogue. But I spent Thursday resolving it to completion. 😊
For the initial test, I wanted parsing, as it is *somewhat* easy to
apply formatting based on the syntax kind (of which there are around 500 see: https://github.com/dotnet/roslyn/blob/master/src/Compilers/CSharp/Portable/Syntax/SyntaxKind.cs
). I set it up to pick a color at random for each new kind it comes
across in code. (rather than resolve them all right now)
What is not so visible, is the fact that I now have access
to the types called out in the code. I can tell what classes and namespaces are
in use. After researching several paths, including looking up black lists of
C#, such as CAS, I ultimately will be going with a white list.
If a type or
method is not in the white list, the code will not be executed, and the unsafe
code will be highlighted as under risk. I will also generate a black list
myself. Basically code will go into one of 3 categories; Safe,
Unevaluated, Unsafe.
If all types are considered safe, it will compile.
If any type is unevaluated or unsafe, it will prevent the compiling of the
code, and highlight the member(s) in question. If the class/member is marked
unsafe, then it will give the reason through a tool tip or another system, as
to why you cannot use it. I.e. the specific security concerns. Finally,
if it is unevaluated, then it will explain that we simply haven’t considered
the safety risks for using the given code. It will also give the option to flag
the code for evaluation in a later release.
I don’t have the lists built up for this at all, but I will
be starting that soon. Before the first playable demos are released to the
public. I do plan on hitting the dialog system next, from UI and
editor as well. I’m specifically looking at using Unity Graphview for managing the
dialogue. But that will be a later post.
Comments
Post a Comment