Roslin - why the whole type of packaging? For example Document & # 8594; DocumentState & # 8594; DocumentInfo & # 8594; DocumentAttributes

Roslyn, it seems, stores basic information on its main types - solutions, projects, documents, etc. - spreads over different classes, which often contain or reveal the same properties. I do not quite understand why, conceptually.

Take, for example, a document. It provides a bunch of properties (Id, Filepath, Name, etc., Inherited via TextDocument) that simply return the corresponding properties from the (Text) DocumentState instance. This, in turn, provides the same properties that it simply returns from the base instance of DocumentInfo. And DocumentInfo, in turn, simply returns properties from its underlying DocumentAttributes. So basically you have

Document.Name β†’ TextDocumentState.Name β†’ DocumentInfo.Name β†’ DocumentAttributes.Name

Most of the other objects are built in approximately the same way, i.e. Project -> ProjectState -> ProjectInfo -> ProjectAttributes, etc.

But why is all this wrapping? What is the conceptual idea / benefit of this?

I would understand breaking it down into one easily serializable type (for example, DocumentAttributes), and then one type in the form of a box, which will also contain information about the runtime / non-serializable information, such as a link to the workspace, etc. But that would leave me with two types (say, DocumentAttributes and Document) - why do we need additional types like -State and -Info?

thank

+4
source share

Source: https://habr.com/ru/post/1687287/


All Articles