static MSBuildRootDocument ParseDoc(string contents, string filename = "myfile.csproj") { var runtimeInfo = new MSBuildEnvironmentRuntimeInformation(); var textSource = new StringTextSource(contents); var schemaProvider = new MSBuildSchemaProvider(); var taskBuilder = new NoopTaskMetadataBuilder(); return(MSBuildRootDocument.Parse(textSource, filename, null, schemaProvider, runtimeInfo, taskBuilder, default)); }
public void TextViewCreated(ITextView textView) { var buffer = (ITextBuffer2)textView.TextBuffer; // attach the parser to the buffer and initialize it var parser = BackgroundParser <MSBuildParseResult> .GetParser <MSBuildBackgroundParser> (buffer); IRuntimeInformation runtimeInformation = new MSBuildEnvironmentRuntimeInformation(); MSBuildSchemaProvider schemaProvider = new MSBuildSchemaProvider(); ITaskMetadataBuilder taskMetadataBuilder = TaskMetadataBuilder; parser.Initialize(runtimeInformation, schemaProvider, taskMetadataBuilder); //kick off a parse so it's ready when other things need it parser.GetOrParseAsync((ITextSnapshot2)buffer.CurrentSnapshot, CancellationToken.None); }
MSBuildBackgroundParser CreateParser(ITextBuffer buffer) { var runtimeInfo = RuntimeInformation; if (runtimeInfo == null) { try { runtimeInfo = new MSBuildEnvironmentRuntimeInformation(); } catch (Exception ex) { LoggingService.LogError("Failed to initialize runtime info for parser", ex); runtimeInfo = new NullRuntimeInformation(); } } return(new MSBuildBackgroundParser( buffer, runtimeInfo, SchemaProvider ?? new MSBuildSchemaProvider(), TaskMetadataBuilder ?? new NoopTaskMetadataBuilder() )); }