Arnolyzer.Tests.DiagnosticVerification.DocumentSetCreator.CreateDocumentSetFromSources C# (CSharp) Method

CreateDocumentSetFromSources() public static method

public static CreateDocumentSetFromSources ( string filePath ) : Microsoft.CodeAnalysis.Document
filePath string
return Microsoft.CodeAnalysis.Document
        public static Document CreateDocumentSetFromSources(string filePath)
        {
            var documents = CreateProject(filePath).Documents.ToArray();

            if (documents.Length != 1)
            {
                throw new SystemException($"Expected one document from the filePath, but got {documents.Length}");
            }

            return documents[0];
        }

Usage Example

Beispiel #1
0
        public static IOrderedEnumerable <Diagnostic> GetSortedDiagnostics(string filePath,
                                                                           DiagnosticAnalyzer analyzer,
                                                                           string settingsPath)
        {
            var options = new AnalyzerOptions(ImmutableArray.Create <AdditionalText>(new SettingsFile(settingsPath)));

            return(GetSortedDiagnosticsFromDocuments(analyzer,
                                                     DocumentSetCreator.CreateDocumentSetFromSources(filePath),
                                                     options));
        }