本文整理汇总了C#中Microsoft.CodeAnalysis.ParseOptions类的典型用法代码示例。如果您正苦于以下问题:C# ParseOptions类的具体用法?C# ParseOptions怎么用?C# ParseOptions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseOptions类属于Microsoft.CodeAnalysis命名空间,在下文中一共展示了ParseOptions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestMissing
protected virtual void TestMissing(
string initial,
ParseOptions parseOptions,
Func<dynamic, dynamic> nodeLocator = null)
{
TestMissing(initial, parseOptions, null, nodeLocator);
}
示例2: TestAnnotations
private void TestAnnotations(
string expectedText,
IList<TextSpan> expectedSpans,
SyntaxNode fixedRoot,
string annotationKind,
bool compareTokens,
ParseOptions parseOptions = null)
{
expectedSpans = expectedSpans ?? new List<TextSpan>();
var annotatedTokens = fixedRoot.GetAnnotatedNodesAndTokens(annotationKind).Select(n => (SyntaxToken)n).ToList();
Assert.Equal(expectedSpans.Count, annotatedTokens.Count);
if (expectedSpans.Count > 0)
{
var expectedTokens = TokenUtilities.GetTokens(TokenUtilities.GetSyntaxRoot(expectedText, GetLanguage(), parseOptions));
var actualTokens = TokenUtilities.GetTokens(fixedRoot);
for (var i = 0; i < Math.Min(expectedTokens.Count, actualTokens.Count); i++)
{
var expectedToken = expectedTokens[i];
var actualToken = actualTokens[i];
var actualIsConflict = annotatedTokens.Contains(actualToken);
var expectedIsConflict = expectedSpans.Contains(expectedToken.Span);
Assert.Equal(expectedIsConflict, actualIsConflict);
}
}
}
示例3: VerifyAnalyzer
public static void VerifyAnalyzer(string path, DiagnosticAnalyzer diagnosticAnalyzer, ParseOptions options = null,
params MetadataReference[] additionalReferences)
{
var file = new FileInfo(path);
var parseOptions = GetParseOptionsAlternatives(options, file);
using (var workspace = new AdhocWorkspace())
{
var document = GetDocument(file, GeneratedAssemblyName, workspace, additionalReferences);
var project = document.Project;
foreach (var parseOption in parseOptions)
{
if (parseOption != null)
{
project = project.WithParseOptions(parseOption);
}
var compilation = project.GetCompilationAsync().Result;
var diagnostics = GetDiagnostics(compilation, diagnosticAnalyzer);
var expected = ExpectedIssues(compilation.SyntaxTrees.First()).ToList();
foreach (var diagnostic in diagnostics)
{
var line = diagnostic.GetLineNumberToReport();
expected.Should().Contain(line);
expected.Remove(line);
}
expected.Should().BeEquivalentTo(Enumerable.Empty<int>());
}
}
}
示例4: Create
public static DocumentState Create(
DocumentInfo info,
ParseOptions options,
HostLanguageServices language,
SolutionServices services)
{
var textSource = info.TextLoader != null
? CreateRecoverableText(info.TextLoader, info.Id, services)
: CreateStrongText(TextAndVersion.Create(SourceText.From(string.Empty, Encoding.UTF8), VersionStamp.Default, info.FilePath));
var treeSource = CreateLazyFullyParsedTree(
textSource,
GetSyntaxTreeFilePath(info),
options,
languageServices: language);
// remove any initial loader so we don't keep source alive
info = info.WithTextLoader(null);
return new DocumentState(
languageServices: language,
solutionServices: services,
info: info,
options: options,
textSource: textSource,
treeSource: treeSource);
}
示例5: Test
private void Test(string markup, bool isMissing, bool isLine, ParseOptions options = null)
{
int? position;
TextSpan? expectedSpan;
string source;
MarkupTestFile.GetPositionAndSpan(markup, out source, out position, out expectedSpan);
var tree = SyntaxFactory.ParseSyntaxTree(source, options);
TextSpan breakpointSpan;
bool hasBreakpoint = BreakpointSpans.TryGetBreakpointSpan(tree, position.Value, CancellationToken.None, out breakpointSpan);
if (isLine)
{
Assert.True(hasBreakpoint);
Assert.True(breakpointSpan.Length == 0);
}
else if (isMissing)
{
Assert.False(hasBreakpoint);
}
else
{
Assert.True(hasBreakpoint);
Assert.Equal(expectedSpan.Value, breakpointSpan);
}
}
示例6: GetCodeGenerationOptions
private static CodeGenerationOptions GetCodeGenerationOptions(
EnvDTE.vsCMAccess access, ParseOptions parseOptions)
{
var generateDefaultAccessibility = (access & EnvDTE.vsCMAccess.vsCMAccessDefault) == 0;
return new CodeGenerationOptions(
generateDefaultAccessibility: generateDefaultAccessibility,
parseOptions: parseOptions);
}
示例7: CommonGetObjectData
protected static void CommonGetObjectData(ParseOptions options, SerializationInfo info, StreamingContext context)
{
//public readonly SourceCodeKind Kind;
info.AddValue("Kind", options.Kind, typeof(SourceCodeKind));
//public readonly DocumentationMode DocumentationMode;
info.AddValue("DocumentationMode", options.DocumentationMode, typeof(DocumentationMode));
}
示例8: SetOptionsCore
private void SetOptionsCore(CompilationOptions newCompilationOptions, ParseOptions newParseOptions)
{
lock (_gate)
{
_currentCompilationOptions = newCompilationOptions;
_currentParseOptions = newParseOptions;
}
}
示例9: TestHostSolution
public TestHostSolution(
HostLanguageServices languageServiceProvider,
CompilationOptions compilationOptions,
ParseOptions parseOptions,
params MetadataReference[] references)
: this(new TestHostProject(languageServiceProvider, compilationOptions, parseOptions, references))
{
}
示例10: TestMissing
protected void TestMissing(
string initialMarkup,
ParseOptions parseOptions,
IDictionary<OptionKey, object> options = null,
string fixAllActionEquivalenceKey = null)
{
TestMissing(initialMarkup, parseOptions, compilationOptions: null, options:options, fixAllActionEquivalenceKey: fixAllActionEquivalenceKey);
}
示例11: CreateWorkspaceFromFilesAsync
/// <param name="files">Can pass in multiple file contents with individual source kind: files will be named test1.vb, test2.vbx, etc.</param>
public static Task<TestWorkspace> CreateWorkspaceFromFilesAsync(
string[] files,
ParseOptions[] parseOptions = null,
CompilationOptions compilationOptions = null,
ExportProvider exportProvider = null)
{
return TestWorkspaceFactory.CreateWorkspaceFromFilesAsync(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider);
}
示例12: CreateWorkspaceFromFiles
/// <param name="files">Can pass in multiple file contents: files will be named test1.vb, test2.vb, etc. and additional metadata references</param>
public static TestWorkspace CreateWorkspaceFromFiles(
string[] files,
ParseOptions parseOptions = null,
CompilationOptions compilationOptions = null,
ExportProvider exportProvider = null,
string[] metadataReferences = null)
{
return TestWorkspaceFactory.CreateWorkspaceFromFiles(LanguageNames.VisualBasic, compilationOptions, parseOptions, files, exportProvider, metadataReferences);
}
示例13: CreateWorkspaceFromFileAsync
public static Task<TestWorkspace> CreateWorkspaceFromFileAsync(
string file,
ParseOptions parseOptions = null,
CompilationOptions compilationOptions = null,
ExportProvider exportProvider = null,
string[] metadataReferences = null)
{
return CreateWorkspaceFromFilesAsync(new[] { file }, parseOptions, compilationOptions, exportProvider, metadataReferences);
}
示例14: TestMissingAsync
protected Task TestMissingAsync(
string initialMarkup,
ParseOptions parseOptions,
IDictionary<OptionKey, object> options = null,
string fixAllActionEquivalenceKey = null,
object fixProviderData = null)
{
return TestMissingAsync(initialMarkup, parseOptions, compilationOptions: null, options: options, fixAllActionEquivalenceKey: fixAllActionEquivalenceKey, fixProviderData: fixProviderData);
}
示例15: Test
protected void Test(
string initial,
string expected,
ParseOptions parseOptions,
int index = 0,
bool compareTokens = true,
Func<dynamic, dynamic> nodeLocator = null,
IDictionary<OptionKey, object> options = null)
{
Test(initial, expected, parseOptions, null, index, compareTokens, nodeLocator, options);
}