From 0833472592fe27fd2dda6d5b070299fbb713c6c0 Mon Sep 17 00:00:00 2001 From: Sergey Tihon Date: Sun, 26 Nov 2023 08:20:21 +0100 Subject: [PATCH] fix: Assert.Fail & Count() --- Clippit.Tests/Word/DocumentAssemblerTests.cs | 4 +-- Clippit.Tests/Word/DocumentBuilderTests.cs | 4 +-- Clippit.Tests/Word/RevisionProcessorTests.cs | 8 ++--- Clippit.Tests/Word/WmlComparerTests.cs | 30 +++++++++---------- Clippit.Tests/Word/WmlComparerTests2.cs | 4 +-- ...mparer.Internal.Methods.ComparisonUnits.cs | 2 +- ...omparer.Private.Methods.ProduceDocument.cs | 4 +-- .../WmlComparer.Public.Methods.Consolidate.cs | 4 +-- Clippit/Excel/PegBase.cs | 2 +- Clippit/Excel/WorksheetAccessor.cs | 6 ++-- Clippit/FieldRetriever.cs | 2 +- Clippit/Html/HtmlToWmlConverterCore.cs | 10 +++---- Clippit/Html/HtmlToWmlCssApplier.cs | 22 +++++++------- Clippit/Word/ChartUpdater.cs | 2 +- Clippit/Word/DocumentAssembler.cs | 4 +-- Clippit/Word/ListItemRetriever.cs | 4 +-- Clippit/Word/RevisionProcessor.cs | 6 ++-- Clippit/Word/WmlToXml.cs | 14 ++++----- 18 files changed, 66 insertions(+), 66 deletions(-) diff --git a/Clippit.Tests/Word/DocumentAssemblerTests.cs b/Clippit.Tests/Word/DocumentAssemblerTests.cs index c4151114..95c64640 100644 --- a/Clippit.Tests/Word/DocumentAssemblerTests.cs +++ b/Clippit.Tests/Word/DocumentAssemblerTests.cs @@ -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)); diff --git a/Clippit.Tests/Word/DocumentBuilderTests.cs b/Clippit.Tests/Word/DocumentBuilderTests.cs index eaee89c0..095b2792 100644 --- a/Clippit.Tests/Word/DocumentBuilderTests.cs +++ b/Clippit.Tests/Word/DocumentBuilderTests.cs @@ -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; @@ -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; diff --git a/Clippit.Tests/Word/RevisionProcessorTests.cs b/Clippit.Tests/Word/RevisionProcessorTests.cs index 948710ac..2491be52 100644 --- a/Clippit.Tests/Word/RevisionProcessorTests.cs +++ b/Clippit.Tests/Word/RevisionProcessorTests.cs @@ -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"); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -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"); } } diff --git a/Clippit.Tests/Word/WmlComparerTests.cs b/Clippit.Tests/Word/WmlComparerTests.cs index 31a2e643..b255ba5d 100644 --- a/Clippit.Tests/Word/WmlComparerTests.cs +++ b/Clippit.Tests/Word/WmlComparerTests.cs @@ -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(); @@ -254,7 +254,7 @@ public void WC001_Consolidate(string testId, string originalName, string revised } if (validationErrors != "") - Assert.True(false, validationErrors); + Assert.Fail(validationErrors); } [Theory] @@ -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(); @@ -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] @@ -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(); @@ -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); @@ -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 @@ -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(); @@ -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(); @@ -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 = " "; @@ -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) diff --git a/Clippit.Tests/Word/WmlComparerTests2.cs b/Clippit.Tests/Word/WmlComparerTests2.cs index 6551084a..97347bc0 100644 --- a/Clippit.Tests/Word/WmlComparerTests2.cs +++ b/Clippit.Tests/Word/WmlComparerTests2.cs @@ -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)); @@ -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); } } } diff --git a/Clippit/Comparer/WmlComparer.Internal.Methods.ComparisonUnits.cs b/Clippit/Comparer/WmlComparer.Internal.Methods.ComparisonUnits.cs index ddef40a9..77a1fbe2 100644 --- a/Clippit/Comparer/WmlComparer.Internal.Methods.ComparisonUnits.cs +++ b/Clippit/Comparer/WmlComparer.Internal.Methods.ComparisonUnits.cs @@ -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(); diff --git a/Clippit/Comparer/WmlComparer.Private.Methods.ProduceDocument.cs b/Clippit/Comparer/WmlComparer.Private.Methods.ProduceDocument.cs index f308e117..2cf41524 100644 --- a/Clippit/Comparer/WmlComparer.Private.Methods.ProduceDocument.cs +++ b/Clippit/Comparer/WmlComparer.Private.Methods.ProduceDocument.cs @@ -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."); @@ -2130,7 +2130,7 @@ private static List 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 { diff --git a/Clippit/Comparer/WmlComparer.Public.Methods.Consolidate.cs b/Clippit/Comparer/WmlComparer.Public.Methods.Consolidate.cs index 1fc51056..7ee93442 100644 --- a/Clippit/Comparer/WmlComparer.Public.Methods.Consolidate.cs +++ b/Clippit/Comparer/WmlComparer.Public.Methods.Consolidate.cs @@ -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); @@ -293,7 +293,7 @@ public static WmlDocument Consolidate( }) .OrderByDescending(g => g.Count()) .ToList(); - var uniqueRevisionCount = uniqueRevisions.Count(); + var uniqueRevisionCount = uniqueRevisions.Count; ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/Clippit/Excel/PegBase.cs b/Clippit/Excel/PegBase.cs index 33fc9ba2..ada23a97 100644 --- a/Clippit/Excel/PegBase.cs +++ b/Clippit/Excel/PegBase.cs @@ -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) diff --git a/Clippit/Excel/WorksheetAccessor.cs b/Clippit/Excel/WorksheetAccessor.cs index 2c289924..0c4e3b73 100644 --- a/Clippit/Excel/WorksheetAccessor.cs +++ b/Clippit/Excel/WorksheetAccessor.cs @@ -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))))); diff --git a/Clippit/FieldRetriever.cs b/Clippit/FieldRetriever.cs index 118b768a..3f504f1f 100644 --- a/Clippit/FieldRetriever.cs +++ b/Clippit/FieldRetriever.cs @@ -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) diff --git a/Clippit/Html/HtmlToWmlConverterCore.cs b/Clippit/Html/HtmlToWmlConverterCore.cs index d8f8af8f..7d145428 100644 --- a/Clippit/Html/HtmlToWmlConverterCore.cs +++ b/Clippit/Html/HtmlToWmlConverterCore.cs @@ -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; @@ -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) @@ -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) { @@ -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; @@ -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; diff --git a/Clippit/Html/HtmlToWmlCssApplier.cs b/Clippit/Html/HtmlToWmlCssApplier.cs index 8bdc9fc2..3e41acf8 100644 --- a/Clippit/Html/HtmlToWmlCssApplier.cs +++ b/Clippit/Html/HtmlToWmlCssApplier.cs @@ -1589,7 +1589,7 @@ private static bool DoesSelectorMatch( CssSelector selector, XElement element) { - var currentSimpleSelector = selector.SimpleSelectors.Count() - 1; + var currentSimpleSelector = selector.SimpleSelectors.Count - 1; var currentElement = element; while (true) { @@ -2027,7 +2027,7 @@ private static void ExpandShorthandPropertiesForElement(XElement element, HtmlTo CssExpression borderColor; CssExpression borderWidth; CssExpression borderStyle; - if (p.Expression.Terms.Count() == 1 && p.Expression.Terms.First().Value == "inherit") + if (p.Expression.Terms.Count == 1 && p.Expression.Terms.First().Value == "inherit") { borderColor = new CssExpression { Terms = new List { new() { Value = "inherit", Type = CssTermType.String } } }; borderWidth = new CssExpression { Terms = new List { new() { Value = "inherit", Type = CssTermType.String } } }; @@ -2232,7 +2232,7 @@ private static void ExpandShorthandPropertiesForElement(XElement element, HtmlTo } } - backgroundPosition = backgroundPositionList.Count() switch + backgroundPosition = backgroundPositionList.Count switch { 1 => new CssExpression { @@ -2312,7 +2312,7 @@ private static void ExpandShorthandPropertiesForElement(XElement element, HtmlTo CssExpression fontSize; CssExpression lineHeight; CssExpression fontFamily; - if (p.Expression.Terms.Count() == 1 && p.Expression.Terms.First().Value == "inherit") + if (p.Expression.Terms.Count == 1 && p.Expression.Terms.First().Value == "inherit") { fontStyle = new CssExpression { Terms = new List { new() { Value = "inherit", Type = CssTermType.String } } }; fontVarient = new CssExpression { Terms = new List { new() { Value = "inherit", Type = CssTermType.String } } }; @@ -2735,8 +2735,8 @@ public static string DumpCss(CssDocument css) Pr(sb, indent, "CSS Tree Dump"); Pr(sb, indent, "============="); - Pr(sb, indent, "Directives count: {0}", css.Directives.Count()); - Pr(sb, indent, "RuleSet count: {0}", css.RuleSets.Count()); + Pr(sb, indent, "Directives count: {0}", css.Directives.Count); + Pr(sb, indent, "RuleSet count: {0}", css.RuleSets.Count); foreach (var rs in css.RuleSets) DumpRuleSet(sb, indent, rs); @@ -2795,7 +2795,7 @@ private static void DumpSimpleSelector(StringBuilder sb, int indent, CssSimpleSe private static void DumpSelectors(StringBuilder sb, int indent, CssSelector s) { indent++; - Pr(sb, indent, "SimpleSelectors count: {0}", s.SimpleSelectors.Count()); + Pr(sb, indent, "SimpleSelectors count: {0}", s.SimpleSelectors.Count); foreach (var ss in s.SimpleSelectors) DumpSimpleSelector(sb, indent, ss); indent--; @@ -2822,7 +2822,7 @@ private static void DumpExpression(StringBuilder sb, int indent, CssExpression e { Pr(sb, indent, "Expression >{0}<", e.ToString()); indent++; - Pr(sb, indent, "Terms count: {0}", e.Terms.Count()); + Pr(sb, indent, "Terms count: {0}", e.Terms.Count); foreach (var t in e.Terms) DumpTerm(sb, indent, t); indent--; @@ -2845,10 +2845,10 @@ private static void DumpRuleSet(StringBuilder sb, int indent, CssRuleSet rs) indent++; Pr(sb, indent, "RuleSet"); indent++; - Pr(sb, indent, "Selectors count: {0}", rs.Selectors.Count()); + Pr(sb, indent, "Selectors count: {0}", rs.Selectors.Count); foreach (var s in rs.Selectors) DumpSelectors(sb, indent, s); - Pr(sb, indent, "Declarations count: {0}", rs.Declarations.Count()); + Pr(sb, indent, "Declarations count: {0}", rs.Declarations.Count); foreach (var d in rs.Declarations) DumpDeclarations(sb, indent, d); indent--; @@ -2959,7 +2959,7 @@ int System.IComparable.CompareTo(Property other) public static string GetWmlColorFromExpression(CssExpression color) { // todo have to handle all forms of colors here - if (color.Terms.Count() == 1) + if (color.Terms.Count == 1) { var term = color.Terms.First(); if (term.Type == CssTermType.Function && term.Function.Name.ToUpper() == "RGB" && term.Function.Expression.Terms.Count == 3) diff --git a/Clippit/Word/ChartUpdater.cs b/Clippit/Word/ChartUpdater.cs index b1729805..821f7640 100644 --- a/Clippit/Word/ChartUpdater.cs +++ b/Clippit/Word/ChartUpdater.cs @@ -482,7 +482,7 @@ private static void UpdateEmbeddedWorkbook(ChartPart chartPart, ChartData chartD xaRef.Value = $"A1:{RowColToString(chartData.CategoryNames.Length - 1, chartData.SeriesNames.Length)}"; var xeNewTableColumns = new XElement(S.tableColumns, - new XAttribute("count", chartData.SeriesNames.Count() + 1), + new XAttribute("count", chartData.SeriesNames.Length + 1), new[] { new XElement(S.tableColumn, new XAttribute("id", 1), diff --git a/Clippit/Word/DocumentAssembler.cs b/Clippit/Word/DocumentAssembler.cs index 91328720..a9f04e6c 100644 --- a/Clippit/Word/DocumentAssembler.cs +++ b/Clippit/Word/DocumentAssembler.cs @@ -122,7 +122,7 @@ private static object ForceBlockLevelAsAppropriate(XNode node, TemplateError te) if (element.Name == W.p) { var childMeta = element.Elements().Where(n => s_metaToForceToBlock.Contains(n.Name)).ToList(); - if (childMeta.Count() == 1) + if (childMeta.Count == 1) { var child = childMeta.First(); var otherTextInParagraph = element.Elements(W.r).Elements(W.t).Select(t => (string)t).StringConcatenate().Trim(); @@ -141,7 +141,7 @@ private static object ForceBlockLevelAsAppropriate(XNode node, TemplateError te) child.Elements())); return meta; } - var count = childMeta.Count(); + var count = childMeta.Count; if (count % 2 == 0) { if (childMeta.Count(c => c.Name == PA.Repeat) != childMeta.Count(c => c.Name == PA.EndRepeat)) diff --git a/Clippit/Word/ListItemRetriever.cs b/Clippit/Word/ListItemRetriever.cs index 8bb2225e..d3f6311e 100644 --- a/Clippit/Word/ListItemRetriever.cs +++ b/Clippit/Word/ListItemRetriever.cs @@ -996,10 +996,10 @@ private static void InitializeListItemRetrieverForStory(XDocument numXDoc, XDocu } if (previous == null || - level >= previous.Count() || + level >= previous.Count || (level == ilvl && startOverride != null && !startOverrideAlreadyUsed.Contains(numId))) { - if (previous == null || level >= previous.Count()) + if (previous == null || level >= previous.Count) { var start = listItemInfo.Start(level); // only look at startOverride if the level that we're examining is same as the paragraph's level. diff --git a/Clippit/Word/RevisionProcessor.cs b/Clippit/Word/RevisionProcessor.cs index 5cab4cec..1804669f 100644 --- a/Clippit/Word/RevisionProcessor.cs +++ b/Clippit/Word/RevisionProcessor.cs @@ -1569,7 +1569,7 @@ private static XElement AcceptMoveFromRanges(XElement document) var moveFromElementsToDelete = startElementTagsInMoveFromRange .Intersect(endElementTagsInMoveFromRange) .ToArray(); - if (moveFromElementsToDelete.Count() > 0) + if (moveFromElementsToDelete.Length > 0) return (XElement)AcceptMoveFromRangesTransform( document, moveFromElementsToDelete); return document; @@ -1618,7 +1618,7 @@ private static object AcceptParagraphEndTagsInMoveFromTransform(XNode node) // If there is only one group, and it's key is MoveFromCollectionType.Other // then there is nothing to do. - if (groupedBodyChildren.Count() == 1 && + if (groupedBodyChildren.Count == 1 && groupedBodyChildren.First().Key == MoveFromCollectionType.Other) { var newElement = new XElement(element.Name, @@ -2517,7 +2517,7 @@ private static XElement AcceptDeletedAndMovedFromContentControls(XElement docume } throw new PowerToolsInvalidDataException("Should not have reached this point."); } - if (potentialMoveFromElements.Count() > 0 && + if (potentialMoveFromElements.Count > 0 && tag.Element.Name != W.moveFromRangeStart && tag.Element.Name != W.moveFromRangeEnd && tag.Element.Name != W.customXmlMoveFromRangeStart && diff --git a/Clippit/Word/WmlToXml.cs b/Clippit/Word/WmlToXml.cs index c78de34e..a80e6f28 100644 --- a/Clippit/Word/WmlToXml.cs +++ b/Clippit/Word/WmlToXml.cs @@ -453,7 +453,7 @@ private static XElement HierarchyPerSettings(XElement contentTypeXml, WmlToXmlSe } if (found) { - item.Add(new XAttribute(PtOpenXml.IndentLevel, stack.Count())); + item.Add(new XAttribute(PtOpenXml.IndentLevel, stack.Count)); stack.Push(item); currentlyLookingAt = FindCurrentlyLookingAt(hierarchyDefinition, item); continue; @@ -462,11 +462,11 @@ private static XElement HierarchyPerSettings(XElement contentTypeXml, WmlToXmlSe { while (true) { - if (stack.Count() == 1) + if (stack.Count == 1) { // have encountered an unexpected hierarchy element. have gone up the stack, and no element up the stack allows for this as a child element. // Therefore, put it at level one, and let the Narrdoc transform generate invalid narrdoc. - item.Add(new XAttribute(PtOpenXml.IndentLevel, stack.Count())); + item.Add(new XAttribute(PtOpenXml.IndentLevel, stack.Count)); break; } stack.Pop(); @@ -497,12 +497,12 @@ private static XElement HierarchyPerSettings(XElement contentTypeXml, WmlToXmlSe } if (found2) { - item.Add(new XAttribute(PtOpenXml.IndentLevel, stack.Count())); + item.Add(new XAttribute(PtOpenXml.IndentLevel, stack.Count)); stack.Push(item); currentlyLookingAt = FindCurrentlyLookingAt(hierarchyDefinition, item); break; } - if (stack.Count() == 0) + if (stack.Count == 0) throw new OpenXmlPowerToolsException("Internal error = reached top of hierarchy - prob not an internal error - some other error"); } continue; @@ -748,9 +748,9 @@ private static void AnnotateRunsThatUseFieldsForNumbering(XDocument mainXDoc) .TakeWhile(ch => ch is '.' or ' ') .ToList(); - sepCharsString = nextRunText.Substring(0, sepChars.Count()); + sepCharsString = nextRunText.Substring(0, sepChars.Count); - nextRunText = nextRunText.Substring(sepChars.Count()); + nextRunText = nextRunText.Substring(sepChars.Count); nextRunTextElement.Value = nextRunText; lastFldCharRunText.Value = lastFldCharRunText.Value + sepCharsString;