This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AdhocWorkspace workspace = new AdhocWorkspace(); | |
Project project = workspace.AddProject("Test", LanguageNames.CSharp); | |
string annotationKind = "SampleKind"; | |
var syntaxAnnotation = new SyntaxAnnotation(annotationKind); | |
var classDeclaration = SyntaxFactory.ClassDeclaration("MyClass") | |
.WithAdditionalAnnotations(syntaxAnnotation); | |
var compilationUnit = SyntaxFactory.CompilationUnit().AddMembers(classDeclaration); | |
Document document = project.AddDocument("Test.cs", compilationUnit); | |
SemanticModel semanticModel = await document.GetSemanticModelAsync(); | |
var newAnnotation = new SyntaxAnnotation("test"); | |
//Just search for the Kind instead | |
var root = await document.GetSyntaxRootAsync(); | |
var changedClass = root.GetAnnotatedNodes(annotationKind).Single(); | |
var symbol = semanticModel.GetDeclaredSymbol(changedClass); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment