Skip to content

Commit ef521ed

Browse files
authored
.Net 8.0 Upgrade (#383)
* .Net 8.0 upgrade * Updated HtmlAgilityPack, updated list of blocked translations
1 parent d9221dc commit ef521ed

114 files changed

Lines changed: 3730 additions & 1740 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.editorconfig

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ csharp_style_allow_blank_lines_between_consecutive_braces_experimental = true:si
216216
csharp_style_prefer_pattern_matching = true:suggestion
217217
csharp_style_prefer_not_pattern = true:suggestion
218218
csharp_style_prefer_extended_property_pattern = true:suggestion
219+
csharp_style_prefer_primary_constructors = true:suggestion
220+
csharp_style_prefer_readonly_struct_member = true:suggestion
221+
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = true:silent
222+
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = true:silent
219223

220224
[*.{cs,vb}]
221225
dotnet_style_operator_placement_when_wrapping = beginning_of_line
@@ -251,4 +255,5 @@ dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
251255
dotnet_style_qualification_for_field = true:suggestion
252256
dotnet_style_qualification_for_property = true:suggestion
253257
dotnet_style_qualification_for_method = true:suggestion
254-
dotnet_style_qualification_for_event = true:suggestion
258+
dotnet_style_qualification_for_event = true:suggestion
259+
dotnet_style_prefer_collection_expression = true:suggestion

.github/workflows/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ jobs:
5757
- name: Set up dotnet
5858
uses: actions/setup-dotnet@v4.0.0
5959
with:
60-
dotnet-version: '7.0.x'
60+
dotnet-version: '8.0.x'
6161
dotnet-quality: 'preview'
6262

6363

GoToBible.Engine/ExtensionMethods.cs

Lines changed: 79 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// -----------------------------------------------------------------------
22
// <copyright file="ExtensionMethods.cs" company="Conglomo">
3-
// Copyright 2020-2023 Conglomo Limited. Please see LICENSE.md for license details.
3+
// Copyright 2020-2024 Conglomo Limited. Please see LICENSE.md for license details.
44
// </copyright>
55
// -----------------------------------------------------------------------
66

@@ -62,7 +62,11 @@ public static CompareOptions AsCompareOptions(this RenderingParameters parameter
6262
/// <param name="value">The substring to count.</param>
6363
/// <param name="stringComparison">The string comparison type.</param>
6464
/// <returns>The number of occurrences of the substring within the string.</returns>
65-
public static int CountOccurrences(this string text, string value, StringComparison stringComparison)
65+
public static int CountOccurrences(
66+
this string text,
67+
string value,
68+
StringComparison stringComparison
69+
)
6670
{
6771
// Clean up the text and value
6872
text = $" {text.Trim()} ";
@@ -94,7 +98,8 @@ public static string EncodeCsvField(this string field, char separator = ',')
9498
StringBuilder sb = new StringBuilder(field);
9599

96100
// Fields with leading/trailing whitespace must be embedded in double quotes
97-
bool embedInQuotes = sb.Length > 0 && (sb[0] == ' ' || sb[0] == '\t' || sb[^1] == ' ' || sb[^1] == '\t');
101+
bool embedInQuotes =
102+
sb.Length > 0 && (sb[0] == ' ' || sb[0] == '\t' || sb[^1] == ' ' || sb[^1] == '\t');
98103

99104
// If we have not yet found a reason to embed in quotes
100105
if (!embedInQuotes)
@@ -122,7 +127,12 @@ public static string EncodeCsvField(this string field, char separator = ',')
122127
/// <param name="approximatePosition">The approximate position of this occurrence. This should be an underestimate at worst.</param>
123128
/// <param name="stringComparison">The string comparison type.</param>
124129
/// <returns>The occurrence number of the substring within the string.</returns>
125-
public static int GetOccurrence(this string text, string value, int approximatePosition, StringComparison stringComparison)
130+
public static int GetOccurrence(
131+
this string text,
132+
string value,
133+
int approximatePosition,
134+
StringComparison stringComparison
135+
)
126136
{
127137
// Clean up the text and value
128138
text = $" {text.Trim()} ";
@@ -157,7 +167,8 @@ public static int GetOccurrence(this string text, string value, int approximateP
157167
/// - brackets, see https://goto.bible/Acts.19_41/SBLGNT (SBL Greek New Testament)
158168
/// NOTE: The input must be directly from a translation.
159169
/// </returns>
160-
public static string GetVerseNumber(this string line) => line.Contains(' ') ? line[..line.IndexOf(' ')].Trim() : string.Empty;
170+
public static string GetVerseNumber(this string line) =>
171+
line.Contains(' ') ? line[..line.IndexOf(' ')].Trim() : string.Empty;
161172

162173
/// <summary>
163174
/// Determines whether this is a valid verse number.
@@ -183,7 +194,11 @@ public static bool IsValidVerseNumber(this string verseNumber)
183194
public static bool MatchesHighlightedVerses(this string verseNumber, string[] highlightedVerses)
184195
{
185196
// Ensure that the verse number is valid, and there are highlighted verses
186-
if (string.IsNullOrWhiteSpace(verseNumber) || !highlightedVerses.Any() || !verseNumber.IsValidVerseNumber())
197+
if (
198+
string.IsNullOrWhiteSpace(verseNumber)
199+
|| highlightedVerses is []
200+
|| !verseNumber.IsValidVerseNumber()
201+
)
187202
{
188203
return false;
189204
}
@@ -196,7 +211,7 @@ public static bool MatchesHighlightedVerses(this string verseNumber, string[] hi
196211
{
197212
string[] verseNumbers = verseNumber.Split('-', StringSplitOptions.RemoveEmptyEntries);
198213
return verseNumbers.First().MatchesHighlightedVerses(highlightedVerses)
199-
|| verseNumbers.Last().MatchesHighlightedVerses(highlightedVerses);
214+
|| verseNumbers.Last().MatchesHighlightedVerses(highlightedVerses);
200215
}
201216

202217
// We need to pad the numbers to account for letters
@@ -233,7 +248,9 @@ public static bool MatchesHighlightedVerses(this string verseNumber, string[] hi
233248
else if (highlightedVerses[i] == "-" && i > 0 && i < highlightedVerses.Length - 1)
234249
{
235250
// Check inside this range
236-
bool matches = string.CompareOrdinal(verseNumber, highlightedVerses[i - 1]) > 0 && string.CompareOrdinal(verseNumber, highlightedVerses[i + 1]) < 0;
251+
bool matches =
252+
string.CompareOrdinal(verseNumber, highlightedVerses[i - 1]) > 0
253+
&& string.CompareOrdinal(verseNumber, highlightedVerses[i + 1]) < 0;
237254
if (matches)
238255
{
239256
return matches;
@@ -261,19 +278,23 @@ public static bool MatchesHighlightedVerses(this string verseNumber, string[] hi
261278
/// <remarks>
262279
/// Full-width square brackets are replaced with regular square brackets.
263280
/// </remarks>
264-
public static string RenderItalics(this string line, string italicsTag = "em")
265-
=> line.Replace("[[", "<pre>").Replace("]]", "</pre>")
266-
.Replace("[", $"<{italicsTag}>").Replace("]", $"</{italicsTag}>")
267-
.Replace("<pre>", "[[").Replace("</pre>", "]]")
268-
.Replace("[", "[").Replace("]", "]");
281+
public static string RenderItalics(this string line, string italicsTag = "em") =>
282+
line.Replace("[[", "<pre>")
283+
.Replace("]]", "</pre>")
284+
.Replace("[", $"<{italicsTag}>")
285+
.Replace("]", $"</{italicsTag}>")
286+
.Replace("<pre>", "[[")
287+
.Replace("</pre>", "]]")
288+
.Replace("[", "[")
289+
.Replace("]", "]");
269290

270291
/// <summary>
271292
/// Strips the HTML tags from the string.
272293
/// </summary>
273294
/// <param name="input">The input string.</param>
274295
/// <returns>The input string without HTML tags.</returns>
275-
public static string StripHtml(this string input)
276-
=> HtmlTagRegex().Replace(input, string.Empty);
296+
public static string StripHtml(this string input) =>
297+
HtmlTagRegex().Replace(input, string.Empty);
277298

278299
/// <summary>
279300
/// Renders the supplied words in normal type.
@@ -285,9 +306,11 @@ public static string StripHtml(this string input)
285306
/// <remarks>
286307
/// Full-width square brackets are replaced with regular square brackets.
287308
/// </remarks>
288-
public static string StripItalics(this string line)
289-
=> line.Replace("[", string.Empty).Replace("]", string.Empty)
290-
.Replace("[", "[").Replace("]", "]");
309+
public static string StripItalics(this string line) =>
310+
line.Replace("[", string.Empty)
311+
.Replace("]", string.Empty)
312+
.Replace("[", "[")
313+
.Replace("]", "]");
291314

292315
/// <summary>
293316
/// Gets a unique name for the translation.
@@ -297,24 +320,50 @@ public static string StripItalics(this string line)
297320
/// <returns>
298321
/// The unique name.
299322
/// </returns>
300-
public static string UniqueName(this Translation translation, IEnumerable<Translation> translations)
323+
public static string UniqueName(
324+
this Translation translation,
325+
IEnumerable<Translation> translations
326+
)
301327
{
302-
IEnumerable<Translation> enumerable = translations as Translation[] ?? translations.ToArray();
303-
if (enumerable.Count(t => string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase)) <= 1)
328+
IEnumerable<Translation> enumerable =
329+
translations as Translation[] ?? translations.ToArray();
330+
if (
331+
enumerable.Count(t =>
332+
string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase)
333+
) <= 1
334+
)
304335
{
305336
return translation.Name;
306337
}
307-
else if (enumerable.Count(t => string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase) && t.Year == translation.Year && t.Year > 0) == 1)
338+
else if (
339+
enumerable.Count(t =>
340+
string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase)
341+
&& t.Year == translation.Year
342+
&& t.Year > 0
343+
) == 1
344+
)
308345
{
309346
return $"{translation.Name} ({translation.Year})";
310347
}
311-
else if (enumerable.Count(t => string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase) && t.Language == translation.Language) == 1)
348+
else if (
349+
enumerable.Count(t =>
350+
string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase)
351+
&& t.Language == translation.Language
352+
) == 1
353+
)
312354
{
313355
// English translation names (i.e. King James Version) have priority
314-
return translation.Language == "English" ? translation.Name : $"{translation.Language} {translation.Name}";
356+
return translation.Language == "English"
357+
? translation.Name
358+
: $"{translation.Language} {translation.Name}";
315359
}
316-
else if (enumerable.Count(t => string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase)
317-
&& t.Dialect == translation.Dialect && !string.IsNullOrWhiteSpace(t.Dialect)) == 1)
360+
else if (
361+
enumerable.Count(t =>
362+
string.Equals(t.Name, translation.Name, StringComparison.OrdinalIgnoreCase)
363+
&& t.Dialect == translation.Dialect
364+
&& !string.IsNullOrWhiteSpace(t.Dialect)
365+
) == 1
366+
)
318367
{
319368
return $"{translation.Name} ({translation.Dialect})";
320369
}
@@ -338,6 +387,9 @@ public static string UniqueName(this Translation translation, IEnumerable<Transl
338387
/// <remarks>
339388
/// This includes support for verses with letters, hypenated verses, and verses enclosed in brackets.
340389
/// </remarks>
341-
[GeneratedRegex(@"([\[]((([0-9]+[a-z]?)-([0-9]+[a-z]?))|([0-9]+[a-z]?))[\]])|((([0-9]+[a-z]?)-([0-9]+[a-z]?))|([0-9]+[a-z]?))", RegexOptions.Compiled)]
390+
[GeneratedRegex(
391+
@"([\[]((([0-9]+[a-z]?)-([0-9]+[a-z]?))|([0-9]+[a-z]?))[\]])|((([0-9]+[a-z]?)-([0-9]+[a-z]?))|([0-9]+[a-z]?))",
392+
RegexOptions.Compiled
393+
)]
342394
private static partial Regex VerseNumberRegex();
343395
}

GoToBible.Engine/GoToBible.Engine.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net7.0</TargetFramework>
4+
<TargetFramework>net8.0</TargetFramework>
55
<SignAssembly>true</SignAssembly>
66
<AssemblyOriginatorKeyFile>GoToBible.Engine.snk</AssemblyOriginatorKeyFile>
77
<Nullable>enable</Nullable>

GoToBible.Engine/GotoBibleApiRenderer.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// -----------------------------------------------------------------------
22
// <copyright file="GotoBibleApiRenderer.cs" company="Conglomo">
3-
// Copyright 2020-2023 Conglomo Limited. Please see LICENSE.md for license details.
3+
// Copyright 2020-2024 Conglomo Limited. Please see LICENSE.md for license details.
44
// </copyright>
55
// -----------------------------------------------------------------------
66

@@ -60,12 +60,22 @@ public void Dispose()
6060
}
6161

6262
/// <inheritdoc/>
63-
public async Task<RenderedPassage> RenderAsync(RenderingParameters parameters, bool renderCompleteHtmlPage, CancellationToken cancellationToken = default)
63+
public async Task<RenderedPassage> RenderAsync(
64+
RenderingParameters parameters,
65+
bool renderCompleteHtmlPage,
66+
CancellationToken cancellationToken = default
67+
)
6468
{
6569
string url = $"RenderPassage?renderCompleteHtmlPage={renderCompleteHtmlPage}";
66-
HttpResponseMessage response = await this.httpClient.PostAsJsonAsync(url, parameters, cancellationToken);
70+
HttpResponseMessage response = await this.httpClient.PostAsJsonAsync(
71+
url,
72+
parameters,
73+
cancellationToken
74+
);
6775
return response.IsSuccessStatusCode
68-
? await response.Content.ReadFromJsonAsync<RenderedPassage>(cancellationToken: cancellationToken) ?? new RenderedPassage()
76+
? await response.Content.ReadFromJsonAsync<RenderedPassage>(
77+
cancellationToken: cancellationToken
78+
) ?? new RenderedPassage()
6979
: new RenderedPassage();
7080
}
7181

GoToBible.Engine/RenderedVerse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// -----------------------------------------------------------------------
22
// <copyright file="RenderedVerse.cs" company="Conglomo">
3-
// Copyright 2020-2023 Conglomo Limited. Please see LICENSE.md for license details.
3+
// Copyright 2020-2024 Conglomo Limited. Please see LICENSE.md for license details.
44
// </copyright>
55
// -----------------------------------------------------------------------
66

0 commit comments

Comments
 (0)