当前位置: 首页>>代码示例>>C#>>正文


C# ImmutableArray.OrderBy方法代码示例

本文整理汇总了C#中ImmutableArray.OrderBy方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableArray.OrderBy方法的具体用法?C# ImmutableArray.OrderBy怎么用?C# ImmutableArray.OrderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImmutableArray的用法示例。


在下文中一共展示了ImmutableArray.OrderBy方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GenerateAttributeLists

 public static SyntaxList<AttributeListSyntax> GenerateAttributeLists(
     ImmutableArray<AttributeData> attributes,
     CodeGenerationOptions options,
     SyntaxToken? target = null)
 {
     if (options.MergeAttributes)
     {
         var attributeNodes = attributes.OrderBy(a => a.AttributeClass.Name).Select((a) => GenerateAttribute(a, options)).WhereNotNull().ToList();
         return attributeNodes.Count == 0
             ? default(SyntaxList<AttributeListSyntax>)
             : SyntaxFactory.SingletonList(SyntaxFactory.AttributeList(
                 target.HasValue ? SyntaxFactory.AttributeTargetSpecifier(target.Value) : null,
                 SyntaxFactory.SeparatedList(attributeNodes)));
     }
     else
     {
         var attributeDeclarations = attributes.OrderBy(a => a.AttributeClass.Name).Select(a => GenerateAttributeDeclaration(a, target, options)).WhereNotNull().ToList();
         return attributeDeclarations.Count == 0
             ? default(SyntaxList<AttributeListSyntax>)
             : SyntaxFactory.List<AttributeListSyntax>(attributeDeclarations);
     }
 }
开发者ID:EkardNT,项目名称:Roslyn,代码行数:22,代码来源:AttributeGenerator.cs

示例2: WriteDiagnosticResults

        private static void WriteDiagnosticResults(ImmutableArray<Tuple<ProjectId, Diagnostic>> diagnostics, string fileName)
        {
            var orderedDiagnostics =
                diagnostics
                .OrderBy(i => i.Item2.Id)
                .ThenBy(i => i.Item2.Location.SourceTree?.FilePath, StringComparer.OrdinalIgnoreCase)
                .ThenBy(i => i.Item2.Location.SourceSpan.Start)
                .ThenBy(i => i.Item2.Location.SourceSpan.End);

            var uniqueLines = new HashSet<string>();
            StringBuilder completeOutput = new StringBuilder();
            StringBuilder uniqueOutput = new StringBuilder();
            foreach (var diagnostic in orderedDiagnostics)
            {
                string message = diagnostic.Item2.ToString();
                string uniqueMessage = $"{diagnostic.Item1}: {diagnostic.Item2}";
                completeOutput.AppendLine(message);
                if (uniqueLines.Add(uniqueMessage))
                {
                    uniqueOutput.AppendLine(message);
                }
            }

            string directoryName = Path.GetDirectoryName(fileName);
            string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
            string extension = Path.GetExtension(fileName);
            string uniqueFileName = Path.Combine(directoryName, $"{fileNameWithoutExtension}-Unique{extension}");

            File.WriteAllText(fileName, completeOutput.ToString(), Encoding.UTF8);
            File.WriteAllText(uniqueFileName, uniqueOutput.ToString(), Encoding.UTF8);
        }
开发者ID:umaranis,项目名称:StyleCopAnalyzers,代码行数:31,代码来源:Program.cs

示例3: WriteDiagnosticsToLog

        private static void WriteDiagnosticsToLog(string logFile, Project project, ImmutableArray<Diagnostic> diagnostics)
        {
            lock (_logLock)
            {
                try
                {
                    var header = $"Found {diagnostics.Length} diagnostic in project '{project.Name}'";

                    var stringResult =
                        string.Join(
                            Environment.NewLine,
                            diagnostics
                                .OrderBy(i => i.Id)
                                .ThenBy(i => i.Location.SourceTree?.FilePath ?? "")
                                .ThenBy(i => i.Location.SourceSpan.Start)
                                .Select(i => i.ToString()));

                    File.AppendAllText(logFile, string.Join(Environment.NewLine, header, stringResult));
                }
                catch (Exception e)
                {
                    WriteError($"Failed to write a log file:{Environment.NewLine}:{e}", enabled: true);
                }
            }
        }
开发者ID:SergeyTeplyakov,项目名称:SolutionDiagnosticRunner,代码行数:25,代码来源:Program.cs

示例4: PrintDiagnostics

        private static void PrintDiagnostics(Project project, ImmutableArray<Diagnostic> diagnostics)
        {
            lock (_consoleLock)
            {
                WriteCaption($"Found {diagnostics.Length} diagnostic in project '{project.Name}'", enabled: true);

                foreach (var rd in diagnostics
                                        .OrderBy(i => i.Id)
                                        .ThenBy(i => i.Location.SourceTree?.FilePath ?? "")
                                        .ThenBy(i => i.Location.SourceSpan.Start))
                {
                    ConsoleDiagnosticPrinters[rd.Severity](rd.ToString());
                }
            }
        }
开发者ID:SergeyTeplyakov,项目名称:SolutionDiagnosticRunner,代码行数:15,代码来源:Program.cs

示例5: LogDiagnostics

        public static void LogDiagnostics(Project project, ImmutableArray<Diagnostic> diagnostics)
        {
            var caption = CreateCaption($"Found {diagnostics.Length} diagnostic in project '{project.Name}'");

            var orderedDiagnostics = 
                diagnostics
                .OrderBy(i => i.Id)
                .ThenBy(i => i.Location.SourceTree?.FilePath ?? "")
                .ThenBy(i => i.Location.SourceSpan.Start)
                .ToList();

            lock (_consoleLock)
            {
                WriteCaption(caption);

                foreach (var rd in orderedDiagnostics)
                {
                    ConsoleDiagnosticPrinters[rd.Severity](rd.ToString());
                }
            }

            string logEntry = $"{caption}\r\n{string.Join("\r\n", orderedDiagnostics)}";
            WriteFile(logEntry);
        }
开发者ID:SergeyTeplyakov,项目名称:ErrorProne.NET,代码行数:24,代码来源:CustomLogger.cs


注:本文中的ImmutableArray.OrderBy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。