The semantic model

  • Last updated: July 7, 2024

One might think that there would be a 1:1 relationship between the syntax (especially the declarations) and the symbols that are produced. But this is not the case.

Semantic meaning it built from the context of one or more syntax nodes. Meaning might even come from completely different syntax trees - as is the case with partial types.

Here is a rough mapping of declaration syntax to symbol types:

DeclarationSyntaxSymbol types
BaseNamespaceDeclarationSyntaxINamespaceSymbol, INamespaceOrTypeSymbol
EventFieldDeclarationSyntaxIEventSymbol, ISymbol
FieldDeclarationSyntaxIFieldSymbol, ISymbol
BaseMethodDeclarationSyntaxIMethodSyntax, ISymbol
BasePropertyDeclarationSyntaxIPropertySymbol, ISymbol
BaseTypeDeclarationSyntaxINamedTypeSymbol, INamespaceOrTypeSymbol, ITypeSymbol, ISymbol