Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: DocumentFormat.OpenXml v3 and deps update #71

Merged
merged 2 commits into from
Nov 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"isRoot": true,
"tools": {
"paket": {
"version": "7.2.1",
"version": "8.0.0",
"commands": [
"paket"
]
Expand Down
4 changes: 2 additions & 2 deletions Clippit.Tests/Word/DocumentAssemblerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ public void DATemplateMaior(string name, string data, bool err)
}

[Theory]
[InlineData("DA-xmlerror.docx", "DA-xmlerror.xml", true)]
public void DAXmlError(string name, string data, bool err)
[InlineData("DA-xmlerror.docx", "DA-xmlerror.xml")]
public void DAXmlError(string name, string data)
{

var templateDocx = new FileInfo(Path.Combine(_sourceDir.FullName, name));
Expand Down
4 changes: 2 additions & 2 deletions Clippit.Tests/Word/DocumentBuilderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ public void DB009_ImportIntoHeadersFooters(string testId, string src, string des
// Create the dir for the test
var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id: " + testId);
Assert.Fail("Duplicate test id: " + testId);
else
thisTestTempDir.Create();
var tempDirFullName = thisTestTempDir.FullName;
Expand Down Expand Up @@ -785,7 +785,7 @@ public void WithGlossaryDocuments(string testId, string baseline, string src1, s
// Create the dir for the test
var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id: " + testId);
Assert.Fail("Duplicate test id: " + testId);
else
thisTestTempDir.Create();
var tempDirFullName = thisTestTempDir.FullName;
Expand Down
8 changes: 4 additions & 4 deletions Clippit.Tests/Word/RevisionProcessorTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ public void RP001(string name)
var revisions = WmlComparer.GetRevisions(result, wmlComparerSettings);
if (revisions.Any())
{
Assert.True(false, "Regression Error: Accepted baseline document did not match processed document");
Assert.Fail("Regression Error: Accepted baseline document did not match processed document");
}
}
else
{
Assert.True(false, "No Accepted baseline document");
Assert.Fail("No Accepted baseline document");
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand All @@ -194,12 +194,12 @@ public void RP001(string name)
var revisions = WmlComparer.GetRevisions(result, wmlComparerSettings);
if (revisions.Any())
{
Assert.True(false, "Regression Error: Rejected baseline document did not match processed document");
Assert.Fail("Regression Error: Rejected baseline document did not match processed document");
}
}
else
{
Assert.True(false, "No Rejected baseline document");
Assert.Fail("No Rejected baseline document");
}
}

Expand Down
30 changes: 15 additions & 15 deletions Clippit.Tests/Word/WmlComparerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public void WC001_Consolidate(string testId, string originalName, string revised

var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id: " + testId);
Assert.Fail("Duplicate test id: " + testId);
else
thisTestTempDir.Create();

Expand Down Expand Up @@ -254,7 +254,7 @@ public void WC001_Consolidate(string testId, string originalName, string revised
}

if (validationErrors != "")
Assert.True(false, validationErrors);
Assert.Fail(validationErrors);
}

[Theory]
Expand Down Expand Up @@ -350,7 +350,7 @@ public void WC002_Consolidate_Bulk_Test(string testId, string name1, string name

var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id: " + testId);
Assert.Fail("Duplicate test id: " + testId);
else
thisTestTempDir.Create();

Expand Down Expand Up @@ -482,7 +482,7 @@ public void WC002_Consolidate_Bulk_Test(string testId, string name1, string name

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
if (validationErrors != "")
Assert.True(false, validationErrors);
Assert.Fail(validationErrors);
}

[Theory]
Expand Down Expand Up @@ -607,7 +607,7 @@ public void WC003_Compare(string testId, string name1, string name2, int revisio

var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id???");
Assert.Fail("Duplicate test id???");
else
thisTestTempDir.Create();

Expand Down Expand Up @@ -744,14 +744,14 @@ public void WC003_Compare(string testId, string name1, string name2, int revisio

if (validationErrors != "")
{
Assert.True(false, validationErrors);
Assert.Fail(validationErrors);
}

var settings2 = new WmlComparerSettings();

var revisionWml = new WmlDocument(docxWithRevisionsFi.FullName);
var revisions = WmlComparer.GetRevisions(revisionWml, settings);
Assert.Equal(revisionCount, revisions.Count());
Assert.Equal(revisionCount, revisions.Count);

var afterRejectingWml = RevisionProcessor.RejectRevisions(revisionWml);

Expand Down Expand Up @@ -789,10 +789,10 @@ public void WC003_Compare(string testId, string name1, string name2, int revisio
afterAcceptingComparedWml.SaveAs(afterAcceptingComparedFi.FullName);
}

if (sanityCheck1.Count() != 0)
Assert.True(false, "Sanity Check #1 failed");
if (sanityCheck2.Count() != 0)
Assert.True(false, "Sanity Check #2 failed");
if (sanityCheck1.Count != 0)
Assert.Fail("Sanity Check #1 failed");
if (sanityCheck2.Count != 0)
Assert.Fail("Sanity Check #2 failed");
}

#if false
Expand Down Expand Up @@ -892,7 +892,7 @@ public void WC004_Compare_To_Self(string testId, string name)

var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id???");
Assert.Fail("Duplicate test id???");
else
thisTestTempDir.Create();

Expand Down Expand Up @@ -928,7 +928,7 @@ public void WC005_Compare_CaseInsensitive(string testId, string name1, string na

var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id???");
Assert.Fail("Duplicate test id???");
else
thisTestTempDir.Create();

Expand Down Expand Up @@ -980,7 +980,7 @@ public void WC005_Compare_CaseInsensitive(string testId, string name1, string na
{
var validator = new OpenXmlValidator();
var errors = validator.Validate(wDoc).Where(e => !ExpectedErrors.Contains(e.Description));
if (errors.Count() > 0)
if (errors.Any())
{

var ind = " ";
Expand Down Expand Up @@ -1015,7 +1015,7 @@ public void WC005_Compare_CaseInsensitive(string testId, string name1, string na

var revisionWml = new WmlDocument(docxWithRevisionsFi.FullName);
var revisions = WmlComparer.GetRevisions(revisionWml, settings);
Assert.Equal(revisionCount, revisions.Count());
Assert.Equal(revisionCount, revisions.Count);
}

private static void ValidateDocument(WmlDocument wmlToValidate)
Expand Down
4 changes: 2 additions & 2 deletions Clippit.Tests/Word/WmlComparerTests2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void CZ001_CompareTrackedInPrev(string testId, string name1, string name2

var thisTestTempDir = new DirectoryInfo(Path.Combine(TempDir, testId));
if (thisTestTempDir.Exists)
Assert.True(false, "Duplicate test id???");
Assert.Fail("Duplicate test id???");
else
thisTestTempDir.Create();
var source1CopiedToDestDocx = new FileInfo(Path.Combine(thisTestTempDir.FullName, source1Docx.Name));
Expand Down Expand Up @@ -104,7 +104,7 @@ public void CZ001_CompareTrackedInPrev(string testId, string name1, string name2
}
var sbs = sb.ToString();
if (sbs != "")
Assert.True(false, sbs);
Assert.Fail(sbs);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private static void VerifyNoInvalidContent(XElement contentParent)
private static void MoveLastSectPrIntoLastParagraph(XElement contentParent)
{
var lastSectPrList = contentParent.Elements(W.sectPr).ToList();
if (lastSectPrList.Count() > 1)
if (lastSectPrList.Count > 1)
throw new OpenXmlPowerToolsException("Invalid document");

var lastSectPr = lastSectPrList.FirstOrDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ private static object MarkContentAsDeletedOrInsertedTransform(XNode node, WmlCom
.Distinct()
.ToList();

if (statusList.Count() > 1)
if (statusList.Count > 1)
{
throw new OpenXmlPowerToolsException(
"Internal error - have both deleted and inserted text elements in the same run.");
Expand Down Expand Up @@ -2130,7 +2130,7 @@ private static List<CorrelatedSequence> FindCommonAtBeginningAndEnd(
{
var split1 = SplitAtParagraphMark(remainingInLeft);
var split2 = SplitAtParagraphMark(remainingInRight);
if (split1.Count() == 1 && split2.Count() == 1)
if (split1.Count == 1 && split2.Count == 1)
{
var csUnknown2 = new CorrelatedSequence
{
Expand Down
4 changes: 2 additions & 2 deletions Clippit/Comparer/WmlComparer.Public.Methods.Consolidate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public static WmlDocument Consolidate(
originalWithUnids.SaveAs(preProcFi1.FullName);
}

var revisedDocumentInfoListCount = revisedDocumentInfoList.Count();
var revisedDocumentInfoListCount = revisedDocumentInfoList.Count;

using var consolidatedMs = new MemoryStream();
consolidatedMs.Write(consolidated.DocumentByteArray, 0, consolidated.DocumentByteArray.Length);
Expand Down Expand Up @@ -293,7 +293,7 @@ public static WmlDocument Consolidate(
})
.OrderByDescending(g => g.Count())
.ToList();
var uniqueRevisionCount = uniqueRevisions.Count();
var uniqueRevisionCount = uniqueRevisions.Count;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion Clippit/Excel/PegBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private void AddLineStarts(string s, int first, int last, ref int lineNo, out in
}
public void GetLineAndCol(string s, int pos, out int lineNo, out int colNo)
{
for (var i = _lineStarts.Count(); i > 0; --i)
for (var i = _lineStarts.Count; i > 0; --i)
{
var curLs = _lineStarts.ElementAt(i - 1);
if (curLs.Key == pos)
Expand Down
6 changes: 3 additions & 3 deletions Clippit/Excel/WorksheetAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -648,19 +648,19 @@ public static void AddPivotAxis(SpreadsheetDocument document, WorksheetPart shee
if (x == -1)
{
values.Add(val);
x = values.Count() - 1;
x = values.Count - 1;
}
val.ReplaceWith(new XElement(S.x, new XAttribute(NoNamespace.v, x)));
}
var sharedItems = cacheDef.Descendants(S.cacheField).Skip(index).First().Element(S.sharedItems);
sharedItems.Add(new XAttribute(NoNamespace.count, values.Count()), values);
sharedItems.Add(new XAttribute(NoNamespace.count, values.Count), values);
recordsPart.PutXDocument();
cacheDefPart.PutXDocument();

// Add axis definition to pivot table field
var pivotTable = pivotTablePart.GetXDocument();
var pivotField = pivotTable.Descendants(S.pivotField).Skip(index).First();
var items = new XElement(S.items, new XAttribute(NoNamespace.count, values.Count() + 1),
var items = new XElement(S.items, new XAttribute(NoNamespace.count, values.Count + 1),
values.OrderBy(z => z.Attribute(NoNamespace.v).Value).Select(z => new XElement(S.item,
new XAttribute(NoNamespace.x, Array.FindIndex(values.ToArray(),
a => a.Attribute(NoNamespace.v).Value == z.Attribute(NoNamespace.v).Value)))));
Expand Down
2 changes: 1 addition & 1 deletion Clippit/FieldRetriever.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public static void AnnotateWithFieldInfo(OpenXmlPart part)
};
}
}
if (s.FiStack == null || s.FiStack.Count() == 0)
if (s.FiStack == null || s.FiStack.Count == 0)
return s;
var wfi3 = s.FiStack.Peek();
if (wfi3.FieldElementType == FieldElementTypeEnum.Begin)
Expand Down
10 changes: 5 additions & 5 deletions Clippit/Html/HtmlToWmlConverterCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3222,7 +3222,7 @@ private static Twip GetBorderSize(XElement element, string whichBorder)
{
var widthProp = element.GetProp($"border-{whichBorder}-width");

if (widthProp != null && widthProp.Terms.Count() == 1)
if (widthProp != null && widthProp.Terms.Count == 1)
{
var term = widthProp.Terms.First();
var twips = (Twip)widthProp;
Expand Down Expand Up @@ -3288,7 +3288,7 @@ private static XElement GetTableGrid(XElement element, HtmlToWmlConverterSetting
private static Twip GetTwipWidth(CssExpression columnWidth, int printable)
{
Twip defaultTwipWidth = 1440;
if (columnWidth.Terms.Count() == 1)
if (columnWidth.Terms.Count == 1)
{
var term = columnWidth.Terms.First();
if (term.Unit == CssUnit.PT)
Expand All @@ -3308,7 +3308,7 @@ private static XElement[][] GetTableArray(XElement table)
{
var rowList = table.DescendantsTrimmed(XhtmlNoNamespace.table).Where(e => e.Name == XhtmlNoNamespace.tr).ToList();
var numberColumns = rowList.Select(r => r.Elements().Where(e => e.Name == XhtmlNoNamespace.td || e.Name == XhtmlNoNamespace.th).Count()).Max();
var tableArray = new XElement[rowList.Count()][];
var tableArray = new XElement[rowList.Count][];
var rowNumber = 0;
foreach (var row in rowList)
{
Expand Down Expand Up @@ -4018,7 +4018,7 @@ private static XAttribute GetXmlSpaceAttribute(string value)
{
if (fontSize == null)
return null;
if (fontSize.Terms.Count() == 1)
if (fontSize.Terms.Count == 1)
{
var term = fontSize.Terms.First();
double size = 0;
Expand Down Expand Up @@ -4540,7 +4540,7 @@ public static void UpdateStylesPart(
var selector = ruleSet.Selectors.Where(
sel =>
{
var found = sel.SimpleSelectors.Count() == 1 &&
var found = sel.SimpleSelectors.Count == 1 &&
sel.SimpleSelectors.First().Class == item &&
sel.SimpleSelectors.First().ElementName is "" or null;
return found;
Expand Down
Loading
Loading