/// <summary> /// Convert XamlDiagnostics to VSDiagnostics /// </summary> private static VSDiagnostic[]? ConvertToVSDiagnostics(ImmutableArray <XamlDiagnostic>?xamlDiagnostics, Document document, SourceText text) { if (xamlDiagnostics == null) { return(null); } var project = document.Project; return(xamlDiagnostics.Value.Select(d => new VSDiagnostic() { Code = d.Code, Message = d.Message ?? string.Empty, ExpandedMessage = d.ExtendedMessage, Severity = ConvertDiagnosticSeverity(d.Severity), Range = ProtocolConversions.TextSpanToRange(new TextSpan(d.Offset, d.Length), text), Tags = ConvertTags(d), Source = d.Tool, CodeDescription = ProtocolConversions.HelpLinkToCodeDescription(d.GetHelpLinkUri()), Projects = new[] { new VSDiagnosticProjectInformation { ProjectIdentifier = project.Id.Id.ToString(), ProjectName = project.Name, }, }, }).ToArray()); }