Skip to content

Commit 62beee9

Browse files
committed
Upgraded to dotnet 10
1 parent 6578681 commit 62beee9

15 files changed

Lines changed: 318 additions & 283 deletions

src/DateTimeUtcTicks.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
namespace Orbyss.Components.Json.Models
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public readonly struct DateTimeUtcTicks(long utcTicks)
24
{
3-
public readonly struct DateTimeUtcTicks(long utcTicks)
4-
{
5-
public readonly DateTimeOffset DateTime = new(utcTicks, TimeSpan.Zero);
6-
public readonly long UtcTicks = utcTicks;
7-
}
5+
public readonly DateTimeOffset DateTime = new(utcTicks, TimeSpan.Zero);
6+
public readonly long UtcTicks = utcTicks;
87
}

src/DateUtcTicks.cs

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,27 @@
1-
namespace Orbyss.Components.Json.Models
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public readonly struct DateUtcTicks
24
{
3-
public readonly struct DateUtcTicks
4-
{
5-
public readonly long UtcTicks;
6-
public readonly DateOnly DateOnly;
5+
public readonly long UtcTicks;
6+
public readonly DateOnly DateOnly;
77

8-
private readonly DateTime start;
9-
private readonly DateTime end;
8+
private readonly DateTime start;
9+
private readonly DateTime end;
1010

11-
public (DateTime start, DateTime end) GetDayRange()
12-
{
13-
return (
14-
start,
15-
end
16-
);
17-
}
11+
public (DateTime start, DateTime end) GetDayRange()
12+
{
13+
return (
14+
start,
15+
end
16+
);
17+
}
1818

19-
public DateUtcTicks(long utcTicks)
20-
{
21-
UtcTicks = utcTicks;
22-
var dateTime = new DateTimeOffset(utcTicks, TimeSpan.Zero);
23-
DateOnly = new DateOnly(dateTime.Year, dateTime.Month, dateTime.Day);
24-
start = DateOnly.ToDateTime(TimeOnly.MinValue);
25-
end = DateOnly.ToDateTime(TimeOnly.MaxValue);
26-
}
19+
public DateUtcTicks(long utcTicks)
20+
{
21+
UtcTicks = utcTicks;
22+
var dateTime = new DateTimeOffset(utcTicks, TimeSpan.Zero);
23+
DateOnly = new DateOnly(dateTime.Year, dateTime.Month, dateTime.Day);
24+
start = DateOnly.ToDateTime(TimeOnly.MinValue);
25+
end = DateOnly.ToDateTime(TimeOnly.MaxValue);
2726
}
2827
}
Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
namespace Orbyss.Components.Json.Models
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public static class DefaultJsonFormValidationMessages
24
{
3-
public static class DefaultJsonFormValidationMessages
4-
{
5-
public static string Default { get; set; } = "Input is invalid";
6-
public static string Minimum { get; set; } = "Input is greater than minimum required value";
7-
public static string Maximum { get; set; } = "Input is less than maximum allowed value";
8-
public static string MaxItems { get; set; } = "List has more than the maximum allowed items";
9-
public static string MinItems { get; set; } = "List has less than the minimum required items";
10-
public static string MaxLength { get; set; } = "Input has more than maximum allowed characters";
11-
public static string MinLength { get; set; } = "Input has less than the minimum required characters";
12-
public static string Contains { get; set; } = "Input does not contain all required values";
13-
public static string Required { get; set; } = "Field is required";
14-
public static string Pattern { get; set; } = "Input does not match regex pattern";
15-
public static string Const { get; set; } = "Input is not equal to the constant value";
16-
}
5+
public static string Default { get; set; } = "Input is invalid";
6+
public static string Minimum { get; set; } = "Input is greater than minimum required value";
7+
public static string Maximum { get; set; } = "Input is less than maximum allowed value";
8+
public static string MaxItems { get; set; } = "List has more than the maximum allowed items";
9+
public static string MinItems { get; set; } = "List has less than the minimum required items";
10+
public static string MaxLength { get; set; } = "Input has more than maximum allowed characters";
11+
public static string MinLength { get; set; } = "Input has less than the minimum required characters";
12+
public static string Contains { get; set; } = "Input does not contain all required values";
13+
public static string Required { get; set; } = "Field is required";
14+
public static string Pattern { get; set; } = "Input does not match regex pattern";
15+
public static string Const { get; set; } = "Input is not equal to the constant value";
1716
}

src/Orbyss.Components.Json.Models.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>net8.0</TargetFramework>
4+
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
55
<ImplicitUsings>enable</ImplicitUsings>
66
<Nullable>enable</Nullable>
77
<PackageId>Orbyss.Components.Json.Models</PackageId>

src/TranslatedEnumItem.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
namespace Orbyss.Components.Json.Models
2-
{
3-
public readonly record struct TranslatedEnumItem(string Label, string Value);
4-
}
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public readonly record struct TranslatedEnumItem(string Label, string Value);

src/TranslationErrorSection.cs

Lines changed: 83 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,92 @@
1-
namespace Orbyss.Components.Json.Models
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public sealed record TranslationErrorSection(
4+
string? Custom,
5+
string? Const,
6+
string? Required,
7+
string? Minimum,
8+
string? Maximum,
9+
string? MinimumLength,
10+
string? MaximumLength,
11+
string? MinimumItems,
12+
string? MaximumItems,
13+
string? Contains,
14+
string? Pattern)
215
{
3-
public sealed record TranslationErrorSection(
4-
string? Custom,
5-
string? Const,
6-
string? Required,
7-
string? Minimum,
8-
string? Maximum,
9-
string? MinimumLength,
10-
string? MaximumLength,
11-
string? MinimumItems,
12-
string? MaximumItems,
13-
string? Contains,
14-
string? Pattern)
15-
{
16-
public string GetConst() => GetValueOrDefault(Const, DefaultJsonFormValidationMessages.Const);
17-
public string GetMinimum() => GetValueOrDefault(Minimum, DefaultJsonFormValidationMessages.Minimum);
18-
public string GetMaximum() => GetValueOrDefault(Maximum, DefaultJsonFormValidationMessages.Maximum);
19-
public string GetMinimumLength() => GetValueOrDefault(MinimumLength, DefaultJsonFormValidationMessages.MinLength);
20-
public string GetMaximumLength() => GetValueOrDefault(MaximumItems, DefaultJsonFormValidationMessages.MaxLength);
21-
public string GetMinimumItems() => GetValueOrDefault(MinimumItems, DefaultJsonFormValidationMessages.MinItems);
22-
public string GetMaximumItems() => GetValueOrDefault(MaximumItems, DefaultJsonFormValidationMessages.MaxItems);
23-
24-
public string GetContains() => GetValueOrDefault(Contains, DefaultJsonFormValidationMessages.Contains);
25-
public string GetRequired() => GetValueOrDefault(Required, DefaultJsonFormValidationMessages.Required);
26-
public string GetPattern() => GetValueOrDefault(Pattern, DefaultJsonFormValidationMessages.Pattern);
27-
public string GetDefault() => GetValueOrDefault(Custom, DefaultJsonFormValidationMessages.Default);
28-
29-
string GetValueOrDefault(string? value, string defaultValue)
30-
{
31-
if (!string.IsNullOrWhiteSpace(value))
32-
{
33-
return value;
34-
}
16+
public string GetConst()
17+
{
18+
return GetValueOrDefault(Const, DefaultJsonFormValidationMessages.Const);
19+
}
20+
21+
public string GetMinimum()
22+
{
23+
return GetValueOrDefault(Minimum, DefaultJsonFormValidationMessages.Minimum);
24+
}
25+
26+
public string GetMaximum()
27+
{
28+
return GetValueOrDefault(Maximum, DefaultJsonFormValidationMessages.Maximum);
29+
}
3530

36-
if (!string.IsNullOrWhiteSpace(Custom))
37-
{
38-
return Custom;
39-
}
31+
public string GetMinimumLength()
32+
{
33+
return GetValueOrDefault(MinimumLength, DefaultJsonFormValidationMessages.MinLength);
34+
}
35+
36+
public string GetMaximumLength()
37+
{
38+
return GetValueOrDefault(MaximumItems, DefaultJsonFormValidationMessages.MaxLength);
39+
}
4040

41-
return defaultValue;
41+
public string GetMinimumItems()
42+
{
43+
return GetValueOrDefault(MinimumItems, DefaultJsonFormValidationMessages.MinItems);
44+
}
45+
46+
public string GetMaximumItems()
47+
{
48+
return GetValueOrDefault(MaximumItems, DefaultJsonFormValidationMessages.MaxItems);
49+
}
50+
51+
public string GetContains()
52+
{
53+
return GetValueOrDefault(Contains, DefaultJsonFormValidationMessages.Contains);
54+
}
55+
56+
public string GetRequired()
57+
{
58+
return GetValueOrDefault(Required, DefaultJsonFormValidationMessages.Required);
59+
}
60+
61+
public string GetPattern()
62+
{
63+
return GetValueOrDefault(Pattern, DefaultJsonFormValidationMessages.Pattern);
64+
}
65+
66+
public string GetDefault()
67+
{
68+
return GetValueOrDefault(Custom, DefaultJsonFormValidationMessages.Default);
69+
}
70+
71+
private string GetValueOrDefault(string? value, string defaultValue)
72+
{
73+
if (!string.IsNullOrWhiteSpace(value))
74+
{
75+
return value;
4276
}
4377

44-
public static TranslationErrorSection DefaultSection()
78+
if (!string.IsNullOrWhiteSpace(Custom))
4579
{
46-
return new(
47-
null, null, null, null, null, null, null, null, null, null, null
48-
);
80+
return Custom;
4981
}
82+
83+
return defaultValue;
84+
}
85+
86+
public static TranslationErrorSection DefaultSection()
87+
{
88+
return new(
89+
null, null, null, null, null, null, null, null, null, null, null
90+
);
5091
}
5192
}

src/TranslationObject.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
namespace Orbyss.Components.Json.Models
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public sealed class TranslationObject(string language, IDictionary<string, TranslationSection> sections)
24
{
3-
public sealed class TranslationObject(string language, IDictionary<string, TranslationSection> sections)
4-
{
5-
public string Language { get; } = language;
5+
public string Language { get; } = language;
66

7-
public IDictionary<string, TranslationSection> Sections { get; } = sections;
8-
}
7+
public IDictionary<string, TranslationSection> Sections { get; } = sections;
98
}
Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
namespace Orbyss.Components.Json.Models
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public sealed class TranslationResourcesDictionary : Dictionary<string, TranslationSchemaResource>
24
{
3-
public sealed class TranslationResourcesDictionary : Dictionary<string, TranslationSchemaResource>
4-
{
5-
public TranslationResourcesDictionary() : base(StringComparer.OrdinalIgnoreCase)
6-
{
7-
}
5+
public TranslationResourcesDictionary() : base(StringComparer.OrdinalIgnoreCase)
6+
{
7+
}
88

9-
public TranslationResourcesDictionary(IDictionary<string, TranslationSchemaResource> dictionary)
10-
: base(dictionary, StringComparer.OrdinalIgnoreCase)
11-
{
12-
}
9+
public TranslationResourcesDictionary(IDictionary<string, TranslationSchemaResource> dictionary)
10+
: base(dictionary, StringComparer.OrdinalIgnoreCase)
11+
{
12+
}
1313

14-
public TranslationResourcesDictionary(IEnumerable<KeyValuePair<string, TranslationSchemaResource>> collection)
15-
: base(collection, StringComparer.OrdinalIgnoreCase)
16-
{
17-
}
14+
public TranslationResourcesDictionary(IEnumerable<KeyValuePair<string, TranslationSchemaResource>> collection)
15+
: base(collection, StringComparer.OrdinalIgnoreCase)
16+
{
1817
}
1918
}

src/TranslationSchema.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
namespace Orbyss.Components.Json.Models
2-
{
3-
public sealed record TranslationSchema(TranslationResourcesDictionary Resources);
4-
}
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public sealed record TranslationSchema(TranslationResourcesDictionary Resources);

src/TranslationSchemaResource.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
namespace Orbyss.Components.Json.Models
2-
{
3-
public sealed record TranslationSchemaResource(object Translation);
4-
}
1+
namespace Orbyss.Components.Json.Models;
2+
3+
public sealed record TranslationSchemaResource(object Translation);

0 commit comments

Comments
 (0)