This project is read-only.

Please unseal Microsoft.CodeAnalysis.SyntaxAnnotation

Topics: APIs
Apr 4, 2014 at 3:02 PM
Why did you seal it?
Apr 4, 2014 at 3:34 PM
What are u trying to achieve with derived annotation?
Apr 4, 2014 at 3:47 PM
hi heejaechang,
Because I want to store complex data in SyntaxAnnotation:
class MySyntaxAnnotation : SyntaxAnnotation { 
    int a;
    string b;
    SomeClass c;
Apr 4, 2014 at 3:49 PM
One benefit of it being sealed is we can be sure that syntax tree can be serialized and deserialized any time we want without worrying about one of annotations throwing exception due to some custom serialization issue. Also it could have a better serialization perf by not allowing .net serialization.
Apr 4, 2014 at 3:52 PM
Ya, that is basically why we made it sealed so that we can prevent people from doing it. You should maintain a map yourself. (annotation 2 data map)
Apr 6, 2014 at 7:14 PM
That's interesting; why did you count with the serialization scenario? Do you have several AppDomains or processes?
Apr 6, 2014 at 10:01 PM
simple answer.

syntax node supports SerializeTo and DeserializeFrom stream. and we want it to just work and fast.
  • but currently, we don't support serializing it in one process/appDomain and deserializing from other process/appDomain. it must be within same app domain.

longer answer.

if you start from Workspace with WellKnown feature set,


WellKnown Feature Set

we will internally use syntax tree cache that makes sure we don't hold onto every syntax trees in the solution in memory.

we use various approaches to achieve this. and one of them is serializing and de-serializing the tree. and we want it to be reliable regardless whether a tree contains an annotation or not.
Marked as answer by TomasMatousek on 4/18/2014 at 9:04 PM