Exemple #1
0
        List <(int Offset, int Length, ReferenceUsage Usage)> FindReferences(string docString, MSBuildReferenceKind kind, object reference)
        {
            var textDoc = new StringTextSource(docString);

            var xmlParser = new XmlTreeParser(new XmlRootState());

            var(xdoc, _) = xmlParser.Parse(new StringReader(docString));

            var doc          = MSBuildTestHelpers.CreateEmptyDocument();
            var parseContext = new MSBuildParserContext(new NullRuntimeInformation(), null, null, null, null, new PropertyValueCollector(false), null, null, default);
            var sb           = new MSBuildSchemaBuilder(true, parseContext, null);

            sb.Run(xdoc, textDoc, doc);

            var functionTypeProvider = new RoslynFunctionTypeProvider(null);

            var results   = new List <(int Offset, int Length, ReferenceUsage Usage)> ();
            var collector = MSBuildReferenceCollector.Create(new MSBuildResolveResult {
                ReferenceKind = kind,
                Reference     = reference,
            }, functionTypeProvider, results.Add);

            collector.Run(xdoc, textDoc, doc);
            return(results);
        }
        List <(int offset, MSBuildResolveResult result)> Resolve(string doc)
        {
            var functionTypeProvider = new RoslynFunctionTypeProvider(null);

            return(MSBuildTestHelpers
                   .SelectAtMarkers(doc, "hello.csproj", (state) => MSBuildResolver.Resolve(state.parser.Clone(), state.textSource, state.doc, functionTypeProvider))
                   .ToList());
        }
Exemple #3
0
 public void LoadMSBuild() => MSBuildTestHelpers.RegisterMSBuildAssemblies();