8000 Merge pull request #74 from danmoseley/xml.read.write · dotnet/api-docs-sync@bcbb8d3 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bcbb8d3

Browse files
authored
Merge pull request #74 from danmoseley/xml.read.write
2 parents 9e8ec93 + 369d3c1 commit bcbb8d3

File tree

2 files changed

+26
-9
lines changed

2 files changed

+26
-9
lines changed

Libraries/Docs/DocsCommentsContainer.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void Save()
8686
}
8787
catch (Exception e)
8888
{
89-
Log.Error(e.Message);
89+
Log.Error("Failed to write to {0}. {1}", type.FilePath, e.Message);
9090
Log.Line();
9191
Log.Error(e.StackTrace ?? string.Empty);
9292
if (e.InnerException != null)
@@ -174,12 +174,18 @@ private IEnumerable<FileInfo> EnumerateFiles()
174174

175175
private void LoadFile(FileInfo fileInfo)
176176
{
177-
if (!fileInfo.Exists)
177+
try
178178
{
179-
throw new Exception($"Docs xml file does not exist: {fileInfo.FullName}");
179+
// docs repo uses code page 1252
180+
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
181+
StreamReader sr = new(fileInfo.FullName, Encoding.GetEncoding(1252));
182+
xDoc = XDocument.Load(sr);
183+
}
184+
catch(Exception ex)
185+
{
186+
Log.Error($"Failed to load '{fileInfo.FullName}'. {ex}");
187+
return;
180188
}
181-
182-
xDoc = XDocument.Load(fileInfo.FullName);
183189

184190
if (IsXmlMalformed(xDoc, fileInfo.FullName))
185191
{

Libraries/IntelliSenseXml/IntelliSenseXmlCommentsContainer.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Diagnostics.CodeAnalysis;
55
using System.IO;
66
using System.Linq;
7+
using System.Xml;
78
using System.Xml.Linq;
89

910
/*
@@ -85,12 +86,15 @@ private IEnumerable<FileInfo> EnumerateFiles()
8586

8687
private void LoadFile(FileInfo fileInfo, bool printSuccess)
8788
{
88-
if (!fileInfo.Exists)
89+
try
8990
{
90-
throw new Exception($"The IntelliSense xml file does not exist: {fileInfo.FullName}");
91+
xDoc = XDocument.Load(fileInfo.FullName);
92+
}
93+
catch (Exception ex)
94+
{
95+
Log.Error($"Failed to load '{fileInfo.FullName}'. {ex}");
96+
return;
9197
}
92-
93-
xDoc = XDocument.Load(fileInfo.FullName);
9498

9599
if (TryGetAssemblyName(xDoc, fileInfo.FullName, out string? assembly))
96100
{
@@ -135,12 +139,19 @@ private bool TryGetAssemblyName(XDocument? xDoc, string fileName, [NotNullWhen(r
135139
Log.Error($"The XDocument was null: {fileName}");
136140
return true;
137141
}
142+
138143
if (xDoc.Root == null)
139144
{
140145
Log.Error($"The IntelliSense xml file does not contain a root element: {fileName}");
141146
return true;
142147
}
143148

149+
if (xDoc.Root.Name == "linker" || xDoc.Root.Name == "FileList")
150+
{
151+
// This is a linker suppression file or a framework list
152+
return true;
153+
}
154+
144155
if (xDoc.Root.Name != "doc")
145156
{
146157
Log.Error($"The IntelliSense xml file does not contain a doc element: {fileName}");

0 commit comments

Comments
 (0)
0