本文整理汇总了C#中SortedSet.Join方法的典型用法代码示例。如果您正苦于以下问题:C# SortedSet.Join方法的具体用法?C# SortedSet.Join怎么用?C# SortedSet.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SortedSet
的用法示例。
在下文中一共展示了SortedSet.Join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetExpectedGeneratedCodeAnalyzerDiagnostics
private static DiagnosticDescription[] GetExpectedGeneratedCodeAnalyzerDiagnostics(Compilation compilation, Func<string, bool> isGeneratedFileName, GeneratedCodeAnalysisFlags? generatedCodeAnalysisFlagsOpt)
{
var analyzers = new DiagnosticAnalyzer[] { new GeneratedCodeAnalyzer(generatedCodeAnalysisFlagsOpt) };
var files = compilation.SyntaxTrees.Select(t => t.FilePath).ToImmutableArray();
var sortedCallbackSymbolNames = new SortedSet<string>();
var sortedCallbackTreePaths = new SortedSet<string>();
var builder = ArrayBuilder<DiagnosticDescription>.GetInstance();
for (int i = 0; i < compilation.SyntaxTrees.Count(); i++)
{
var file = files[i];
var isGeneratedFile = isGeneratedFileName(file);
// Type "GeneratedCode{0}"
var squiggledText = string.Format("GeneratedCode{0}", i);
var diagnosticArgument = squiggledText;
var line = 3;
var column = 7;
var isGeneratedCode = true;
AddExpectedLocalDiagnostics(builder, isGeneratedCode, squiggledText, line, column, generatedCodeAnalysisFlagsOpt, diagnosticArgument);
// Type "Nested{0}"
squiggledText = string.Format("Nested{0}", i);
diagnosticArgument = squiggledText;
line = 5;
column = 19;
isGeneratedCode = true;
AddExpectedLocalDiagnostics(builder, isGeneratedCode, squiggledText, line, column, generatedCodeAnalysisFlagsOpt, diagnosticArgument);
// Type "NonGeneratedCode{0}"
squiggledText = string.Format("NonGeneratedCode{0}", i);
diagnosticArgument = squiggledText;
line = 8;
column = 7;
isGeneratedCode = isGeneratedFile;
AddExpectedLocalDiagnostics(builder, isGeneratedCode, squiggledText, line, column, generatedCodeAnalysisFlagsOpt, diagnosticArgument);
// Type "NestedGeneratedCode{0}"
squiggledText = string.Format("NestedGeneratedCode{0}", i);
diagnosticArgument = squiggledText;
line = 11;
column = 19;
isGeneratedCode = true;
AddExpectedLocalDiagnostics(builder, isGeneratedCode, squiggledText, line, column, generatedCodeAnalysisFlagsOpt, diagnosticArgument);
// File diagnostic
squiggledText = "}"; // last token in file.
diagnosticArgument = file;
line = 12;
column = 1;
isGeneratedCode = isGeneratedFile;
AddExpectedLocalDiagnostics(builder, isGeneratedCode, squiggledText, line, column, generatedCodeAnalysisFlagsOpt, diagnosticArgument);
// Compilation end summary diagnostic (verify callbacks into analyzer)
// Analyzer always called for generated code, unless generated code analysis is explicitly disabled.
if (generatedCodeAnalysisFlagsOpt == null || (generatedCodeAnalysisFlagsOpt & GeneratedCodeAnalysisFlags.Analyze) != 0)
{
sortedCallbackSymbolNames.Add(string.Format("GeneratedCode{0}", i));
sortedCallbackSymbolNames.Add(string.Format("Nested{0}", i));
sortedCallbackSymbolNames.Add(string.Format("NonGeneratedCode{0}", i));
sortedCallbackSymbolNames.Add(string.Format("NestedGeneratedCode{0}", i));
sortedCallbackTreePaths.Add(file);
}
else if (!isGeneratedFile)
{
// Analyzer always called for non-generated code.
sortedCallbackSymbolNames.Add(string.Format("NonGeneratedCode{0}", i));
sortedCallbackTreePaths.Add(file);
}
}
// Compilation end summary diagnostic (verify callbacks into analyzer)
var arg1 = sortedCallbackSymbolNames.Join(",");
var arg2 = sortedCallbackTreePaths.Join(",");
AddExpectedNonLocalDiagnostic(builder, arguments: new[] { arg1, arg2 });
if (compilation.Options.GeneralDiagnosticOption == ReportDiagnostic.Error)
{
for(int i = 0; i < builder.Count; i++)
{
if (((string)builder[i].Code) != GeneratedCodeAnalyzer.Error.Id)
{
builder[i] = builder[i].WithWarningAsError(true);
}
}
}
return builder.ToArrayAndFree();
}