diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 5c484f7..31146bc 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -25,10 +25,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- - name: Install .NET (v8.0)
+ - name: Install .NET (v10.0)
uses: actions/setup-dotnet@v3.2.0
with:
- dotnet-version: 8.0.x
+ dotnet-version: 10.0.x
- name: Test
run: |
dotnet test --configuration Debug
@@ -66,10 +66,10 @@ jobs:
HUSKY: 0
steps:
- uses: actions/checkout@v3
- - name: Install .NET (v8.0)
+ - name: Install .NET (v10.0)
uses: actions/setup-dotnet@v3.2.0
with:
- dotnet-version: 8.x
+ dotnet-version: 10.x
- name: Build
run: |
dotnet publish src/Noted -c Release --self-contained false -r win-x64 -o ./src/Noted/bin/Portable.win-x64
diff --git a/Directory.Build.props b/Directory.Build.props
index a9d51ce..0346bb5 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -20,9 +20,11 @@
CS1573: Parameter 'parameter' has no matching param tag in the XML comment for 'parameter' (but other parameters do)
CS1591: Missing XML comment for publicly visible type or member 'Type_or_Member'
+ NU1510: PackageReference will not be pruned. We need few packages because of dependencies, e.g. JTForks.MiscUtil.
+ NU1902: vulnerable package references should be updated. We are overriding some transitive dependencies.
-->
true
- $(NoWarn),1573,1591,1712
+ $(NoWarn),1573,1591,1712,NU1510,NU1902,NU1903
true
diff --git a/Directory.Build.targets b/Directory.Build.targets
index 4cb670e..83ef8ac 100644
--- a/Directory.Build.targets
+++ b/Directory.Build.targets
@@ -1,8 +1,6 @@
-
- 1.2.0-beta.556
-
+
diff --git a/Directory.Packages.props b/Directory.Packages.props
new file mode 100644
index 0000000..d57a7ae
--- /dev/null
+++ b/Directory.Packages.props
@@ -0,0 +1,38 @@
+
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Noted/Core/Models/DocumentReference.cs b/src/Noted/Core/Models/DocumentReference.cs
index 7b505e9..0caa2f1 100644
--- a/src/Noted/Core/Models/DocumentReference.cs
+++ b/src/Noted/Core/Models/DocumentReference.cs
@@ -34,9 +34,9 @@ private SortedSet AuthorVector
return this.authorVector;
}
- this.authorVector = new SortedSet(this.Author
+ this.authorVector = [.. this.Author
.Split(' ')
- .Select(x => x.Trim(' ', ',', '.').ToLower()));
+ .Select(x => x.Trim(' ', ',', '.').ToLower())];
return this.authorVector;
}
}
diff --git a/src/Noted/Extensions/Libraries/Kindle/ClippingAnnotationProvider.cs b/src/Noted/Extensions/Libraries/Kindle/ClippingAnnotationProvider.cs
index 6ee1367..2078c80 100644
--- a/src/Noted/Extensions/Libraries/Kindle/ClippingAnnotationProvider.cs
+++ b/src/Noted/Extensions/Libraries/Kindle/ClippingAnnotationProvider.cs
@@ -34,7 +34,7 @@ public IEnumerable GetAnnotations(string sourcePath)
var annotationFile = Path.Combine(sourcePath, ClippingsFile);
using var stream = this.fileSystem.OpenPathForRead(annotationFile);
- return ClippingParser.Parse(stream).Select(c => c.ToAnnotation()).ToList();
+ return [.. ClippingParser.Parse(stream).Select(c => c.ToAnnotation())];
}
}
}
\ No newline at end of file
diff --git a/src/Noted/Extensions/Readers/Mobi/Mobi7Parser.cs b/src/Noted/Extensions/Readers/Mobi/Mobi7Parser.cs
index 369d526..c893dc4 100644
--- a/src/Noted/Extensions/Readers/Mobi/Mobi7Parser.cs
+++ b/src/Noted/Extensions/Readers/Mobi/Mobi7Parser.cs
@@ -51,7 +51,12 @@ public static async Task GetNavigationStream(Stream contentStream)
// Prepare the table of contents stream for return
contentStream.Seek(tocFilePos, SeekOrigin.Begin);
var bytes = new byte[tocContentEnd];
- await contentStream.ReadAsync(bytes);
+ int bytesRead = await contentStream.ReadAsync(bytes);
+ if (bytesRead != tocContentEnd)
+ {
+ throw new IOException("Expected to read " + tocContentEnd + " bytes but only read " + bytesRead + " bytes from TOC stream");
+ }
+
return new MemoryStream(bytes);
}
}
diff --git a/src/Noted/Infra/ConfigurationProvider.cs b/src/Noted/Infra/ConfigurationProvider.cs
index 33298a3..8eb2475 100644
--- a/src/Noted/Infra/ConfigurationProvider.cs
+++ b/src/Noted/Infra/ConfigurationProvider.cs
@@ -66,11 +66,11 @@ public Configuration Build()
: new NullLogger();
this.commandLineConfig.AnnotationProviders =
- this.annotationReaders(this.commandLineConfig).ToList();
+ [.. this.annotationReaders(this.commandLineConfig)];
this.commandLineConfig.Readers =
- this.documentReaders(this.commandLineConfig).ToList();
+ [.. this.documentReaders(this.commandLineConfig)];
this.commandLineConfig.Writers =
- this.documentWriters(this.commandLineConfig).ToList();
+ [.. this.documentWriters(this.commandLineConfig)];
return this.commandLineConfig;
}
diff --git a/src/Noted/Noted.csproj b/src/Noted/Noted.csproj
index 644ab7d..228039b 100644
--- a/src/Noted/Noted.csproj
+++ b/src/Noted/Noted.csproj
@@ -6,27 +6,27 @@
Exe
- net8.0
+ net10.0
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/test/Noted.Tests/Extensions/Libraries/KOReaderAnnotationProviderTests.cs b/test/Noted.Tests/Extensions/Libraries/KOReaderAnnotationProviderTests.cs
index ac932e0..f936d3d 100644
--- a/test/Noted.Tests/Extensions/Libraries/KOReaderAnnotationProviderTests.cs
+++ b/test/Noted.Tests/Extensions/Libraries/KOReaderAnnotationProviderTests.cs
@@ -49,7 +49,7 @@ public void KOReaderAnnotationProviderShouldReturnZeroAnnotations()
var annotations =
this.annotationProvider.GetAnnotations(AssetFactory.GetKindleLibrary()).ToList();
- Assert.AreEqual(0, annotations.Count);
+ Assert.IsEmpty(annotations);
}
}
}
\ No newline at end of file
diff --git a/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingAnnotationProviderTests.cs b/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingAnnotationProviderTests.cs
index 94b179b..bd1cb28 100644
--- a/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingAnnotationProviderTests.cs
+++ b/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingAnnotationProviderTests.cs
@@ -49,7 +49,7 @@ public void GetClippingsShouldRetrieveDocumentAnnotations()
var kindle = new ClippingAnnotationProvider(fileSystem.Object, new NullLogger());
var clippings = kindle.GetAnnotations("dummyPath").ToList();
- Assert.AreEqual(3, clippings.Count);
+ Assert.HasCount(3, clippings);
}
[TestMethod]
@@ -70,7 +70,7 @@ public void GetClippingsShouldReturnZeroAnnotationsIfPathIsNotAccessible()
var kindle = new ClippingAnnotationProvider(fileSystem.Object, new NullLogger());
var clippings = kindle.GetAnnotations("dummyPath").ToList();
- Assert.AreEqual(0, clippings.Count);
+ Assert.IsEmpty(clippings);
}
}
}
\ No newline at end of file
diff --git a/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingParserTests.cs b/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingParserTests.cs
index 2f08933..b7c6456 100644
--- a/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingParserTests.cs
+++ b/test/Noted.Tests/Extensions/Libraries/Kindle/ClippingParserTests.cs
@@ -51,7 +51,7 @@ public void ParseShouldExtractAllClippings()
var clippings = ClippingParser.Parse(this.stream).ToList();
- Assert.AreEqual(2, clippings.Count);
+ Assert.HasCount(2, clippings);
Assert.AreEqual("The Design of Everyday Things: Revised and Expanded Edition", clippings[0].Book);
Assert.AreEqual("Norman, Don", clippings[0].Author);
Assert.AreEqual(ClippingType.Highlight, clippings[0].Type);
@@ -59,7 +59,7 @@ public void ParseShouldExtractAllClippings()
Assert.AreEqual(3015, clippings[0].Location.Start);
Assert.AreEqual(3016, clippings[0].Location.End);
Assert.AreEqual(new DateTime(2019, 08, 15, 10, 14, 40), clippings[0].CreationDate);
- Assert.IsTrue(clippings[0].Content.StartsWith("Forcing functions can be"));
+ Assert.StartsWith("Forcing functions can be", clippings[0].Content);
Assert.AreEqual(ClippingType.Note, clippings[1].Type);
}
@@ -83,7 +83,7 @@ public void ParseShouldExtractClippingsWithLocationWithoutPage()
var clippings = ClippingParser.Parse(this.stream).ToList();
- Assert.AreEqual(2, clippings.Count);
+ Assert.HasCount(2, clippings);
Assert.AreEqual(-1, clippings[0].PageNumber);
Assert.AreEqual(3026, clippings[0].Location.Start);
Assert.AreEqual(3026, clippings[0].Location.End);
diff --git a/test/Noted.Tests/Extensions/Readers/Common/HtmlContextParserTests.cs b/test/Noted.Tests/Extensions/Readers/Common/HtmlContextParserTests.cs
index 227c3b0..4b69ff0 100644
--- a/test/Noted.Tests/Extensions/Readers/Common/HtmlContextParserTests.cs
+++ b/test/Noted.Tests/Extensions/Readers/Common/HtmlContextParserTests.cs
@@ -57,8 +57,8 @@ public async Task HtmlContextParserShouldAddContextToAnnotations()
SampleSections,
[(new LineLocation(1, 2), this.annotations[0])]);
- Assert.AreEqual(1, a.Count);
- Assert.IsTrue(a[0].Context.Content.StartsWith("Never"));
+ Assert.HasCount(1, a);
+ Assert.StartsWith("Never", a[0].Context.Content);
Assert.AreEqual("Ch1", a[0].Context.DocumentSection.Title);
}
@@ -70,8 +70,8 @@ public async Task HtmlContextParserShouldAddContextWhenAnnotationSpansOverElemen
SampleSections,
[(new LineLocation(1, 2), this.annotations[1])]);
- Assert.AreEqual(1, a.Count);
- Assert.IsTrue(a[0].Context.Content.StartsWith("Thus, "));
+ Assert.HasCount(1, a);
+ Assert.StartsWith("Thus, ", a[0].Context.Content);
Assert.AreEqual("Ch2", a[0].Context.DocumentSection.Title);
}
diff --git a/test/Noted.Tests/Extensions/Readers/Common/HtmlSectionParserTests.cs b/test/Noted.Tests/Extensions/Readers/Common/HtmlSectionParserTests.cs
index 8a10c61..c712c0c 100644
--- a/test/Noted.Tests/Extensions/Readers/Common/HtmlSectionParserTests.cs
+++ b/test/Noted.Tests/Extensions/Readers/Common/HtmlSectionParserTests.cs
@@ -66,13 +66,15 @@ public HtmlSectionParserTests()
this.parser = new HtmlSectionParser();
}
+ public TestContext TestContext { get; set; }
+
[TestMethod]
public async Task ParseShouldReturnTableOfContentWithDepth()
{
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(TocFragment));
- var toc = await HtmlSectionParser.Parse(stream).ToListAsync();
+ var toc = await HtmlSectionParser.Parse(stream).ToListAsync(this.TestContext.CancellationTokenSource.Token);
- Assert.AreEqual(11, toc.Count);
+ Assert.HasCount(11, toc);
Assert.AreEqual("Preface", toc[0].Title);
Assert.AreEqual(1, toc[0].Level);
Assert.AreEqual(3859, toc[0].Location);
@@ -89,7 +91,7 @@ public async Task ParseShouldReturnTableOfContentWithDepth()
public async Task ParseShouldCreateDocumentSectionRelationships()
{
await using var stream = new MemoryStream(Encoding.UTF8.GetBytes(TocFragment));
- var toc = await HtmlSectionParser.Parse(stream).ToListAsync();
+ var toc = await HtmlSectionParser.Parse(stream).ToListAsync(this.TestContext.CancellationTokenSource.Token);
Assert.IsNull(toc[3].Parent); // 1 -> null
Assert.AreEqual("Section 1.1", toc[4].Title);
diff --git a/test/Noted.Tests/Extensions/Readers/EpubReaderTests.cs b/test/Noted.Tests/Extensions/Readers/EpubReaderTests.cs
index 3400102..ac1e66c 100644
--- a/test/Noted.Tests/Extensions/Readers/EpubReaderTests.cs
+++ b/test/Noted.Tests/Extensions/Readers/EpubReaderTests.cs
@@ -53,7 +53,7 @@ public async Task EpubReaderShouldParseDocumentWithAnnotations()
var document = await new EpubReader(this.logger).Read(stream, new Noted.Core.Extensions.ReaderOptions(), [annotation]);
var annotations = document.Annotations.ToList();
- Assert.AreEqual(1, annotations.Count);
+ Assert.HasCount(1, annotations);
Assert.AreEqual("On Giving", annotations[0].Context.DocumentSection.Title);
Assert.AreNotEqual(0, annotations[0].Context.DocumentSection.Location);
Assert.AreEqual(0, annotations[0].Context.Location);
@@ -81,7 +81,7 @@ public async Task EpubReaderShouldParseEpub3DocumentWithAnnotations()
var document = await new EpubReader(this.logger).Read(stream, new Noted.Core.Extensions.ReaderOptions(), [annotation]);
var annotations = document.Annotations.ToList();
- Assert.AreEqual(1, annotations.Count);
+ Assert.HasCount(1, annotations);
Assert.AreEqual("XVII", annotations[0].Context.DocumentSection.Title);
Assert.AreNotEqual(0, annotations[0].Context.DocumentSection.Location);
Assert.AreEqual(0, annotations[0].Context.Location); // Annotation Location is not updated by EpubReader
diff --git a/test/Noted.Tests/Extensions/Readers/PdfReaderTests.cs b/test/Noted.Tests/Extensions/Readers/PdfReaderTests.cs
index c739e21..d5b3a11 100644
--- a/test/Noted.Tests/Extensions/Readers/PdfReaderTests.cs
+++ b/test/Noted.Tests/Extensions/Readers/PdfReaderTests.cs
@@ -84,7 +84,7 @@ public async Task ReadShouldParseSingleColumnLayoutDocument()
var document = await this.reader.Read(fs, new ReaderOptions(), this.emptyExternalAnnotations);
var annotations = document.Annotations.ToList();
- Assert.AreEqual(2, annotations.Count);
+ Assert.HasCount(2, annotations);
Assert.AreEqual(
"Nam id ante vitae erat consequat bibendum quis vitae sapien. Etiam ac quam ac felis gravida rutrum. ",
annotations[0].Content);
@@ -102,7 +102,7 @@ public async Task ReadShouldParseTwoColumnLayoutDocument()
var document = await this.reader.Read(fs, new ReaderOptions(), this.emptyExternalAnnotations);
var annotations = document.Annotations.ToList();
- Assert.AreEqual(5, annotations.Count);
+ Assert.HasCount(5, annotations);
// Multiple paragraphs are joined in context because there isn't much
// space between paragraph formatting
diff --git a/test/Noted.Tests/Noted.Tests.csproj b/test/Noted.Tests/Noted.Tests.csproj
index 2d29366..52d5dce 100644
--- a/test/Noted.Tests/Noted.Tests.csproj
+++ b/test/Noted.Tests/Noted.Tests.csproj
@@ -1,7 +1,7 @@
- net8.0
+ net10.0
true
true
@@ -9,23 +9,25 @@
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
runtime; build; native; contentfiles; analyzers
all