Skip to content

Commit ba345bd

Browse files
committed
Merge branch 'features/v-next'
2 parents fcca67a + c1e5364 commit ba345bd

File tree

412 files changed

+2674
-7917
lines changed

Some content is hidden

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

412 files changed

+2674
-7917
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<Copyright>(c) $([System.DateTime]::Now.Year), Pawel Gerr. All rights reserved.</Copyright>
5-
<VersionPrefix>8.9.2</VersionPrefix>
5+
<VersionPrefix>9.0.0</VersionPrefix>
66
<Authors>Pawel Gerr</Authors>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageProjectUrl>https://github.com/PawelGerr/Thinktecture.Runtime.Extensions</PackageProjectUrl>

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
![NuGet Downloads](https://img.shields.io/nuget/dt/Thinktecture.Runtime.Extensions)
44

55
[![Thinktecture.Runtime.Extensions](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.svg?maxAge=60&label=Thinktecture.Runtime.Extensions)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions/)
6-
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore6](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore6.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore6)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore6/)
76
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore7](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore7.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore7)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore7/)
87
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore8](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore8.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore8)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore8/)
98
[![Thinktecture.Runtime.Extensions.EntityFrameworkCore9](https://img.shields.io/nuget/v/Thinktecture.Runtime.Extensions.EntityFrameworkCore9.svg?maxAge=60&label=Thinktecture.Runtime.Extensions.EntityFrameworkCore9)](https://www.nuget.org/packages/Thinktecture.Runtime.Extensions.EntityFrameworkCore9/)
@@ -35,6 +34,7 @@ See [wiki](https://github.com/PawelGerr/Thinktecture.Runtime.Extensions/wiki) fo
3534

3635
# Migrations
3736

37+
* [Migration from v8 to v9](https://github.com/PawelGerr/Thinktecture.Runtime.Extensions/wiki/Migration-from-v8-to-v9)
3838
* [Migration from v7 to v8](https://github.com/PawelGerr/Thinktecture.Runtime.Extensions/wiki/Migration-from-v7-to-v8)
3939
* [Migration from v6 to v7](https://github.com/PawelGerr/Thinktecture.Runtime.Extensions/wiki/Migration-from-v6-to-v7)
4040

Thinktecture.Runtime.Extensions.sln

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extens
4242
EndProject
4343
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityFrameworkCore.Samples", "samples\EntityFrameworkCore.Samples\EntityFrameworkCore.Samples.csproj", "{8663F6FA-AC39-4D1D-A0A0-226E574A5202}"
4444
EndProject
45-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extensions.EntityFrameworkCore6", "src\Thinktecture.Runtime.Extensions.EntityFrameworkCore6\Thinktecture.Runtime.Extensions.EntityFrameworkCore6.csproj", "{C34C0B86-DC38-42D6-8D64-A0B2E69B396C}"
46-
EndProject
4745
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extensions.Newtonsoft.Json", "src\Thinktecture.Runtime.Extensions.Newtonsoft.Json\Thinktecture.Runtime.Extensions.Newtonsoft.Json.csproj", "{914196F5-6208-4710-9A75-201E17457D2B}"
4846
EndProject
4947
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests", "test\Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests\Thinktecture.Runtime.Extensions.Newtonsoft.Json.Tests.csproj", "{47890FAA-7CDF-491C-A1B8-9B141EABECF1}"
@@ -70,8 +68,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extens
7068
EndProject
7169
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extensions.Tests.Shared", "test\Thinktecture.Runtime.Extensions.Tests.Shared\Thinktecture.Runtime.Extensions.Tests.Shared.csproj", "{E654E2B6-9396-4B8D-917D-EAD8FAA0DBF2}"
7270
EndProject
73-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Thinktecture.Runtime.Extensions.EntityFrameworkCore6.Tests", "test\Thinktecture.Runtime.Extensions.EntityFrameworkCore6.Tests\Thinktecture.Runtime.Extensions.EntityFrameworkCore6.Tests.csproj", "{AB7280F9-6653-4CF0-9E26-45A3B606B5E9}"
74-
EndProject
7571
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack.Samples", "samples\MessagePack.Samples\MessagePack.Samples.csproj", "{B1E357B7-7F91-4558-85BA-F6784C33FF97}"
7672
EndProject
7773
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Benchmarking", "samples\Benchmarking\Benchmarking.csproj", "{267EAD74-3F4D-41B8-BCF6-9D0F6F99A16F}"
@@ -114,10 +110,6 @@ Global
114110
{8663F6FA-AC39-4D1D-A0A0-226E574A5202}.Debug|Any CPU.Build.0 = Debug|Any CPU
115111
{8663F6FA-AC39-4D1D-A0A0-226E574A5202}.Release|Any CPU.ActiveCfg = Release|Any CPU
116112
{8663F6FA-AC39-4D1D-A0A0-226E574A5202}.Release|Any CPU.Build.0 = Release|Any CPU
117-
{C34C0B86-DC38-42D6-8D64-A0B2E69B396C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
118-
{C34C0B86-DC38-42D6-8D64-A0B2E69B396C}.Debug|Any CPU.Build.0 = Debug|Any CPU
119-
{C34C0B86-DC38-42D6-8D64-A0B2E69B396C}.Release|Any CPU.ActiveCfg = Release|Any CPU
120-
{C34C0B86-DC38-42D6-8D64-A0B2E69B396C}.Release|Any CPU.Build.0 = Release|Any CPU
121113
{914196F5-6208-4710-9A75-201E17457D2B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
122114
{914196F5-6208-4710-9A75-201E17457D2B}.Debug|Any CPU.Build.0 = Debug|Any CPU
123115
{914196F5-6208-4710-9A75-201E17457D2B}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -170,10 +162,6 @@ Global
170162
{E654E2B6-9396-4B8D-917D-EAD8FAA0DBF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
171163
{E654E2B6-9396-4B8D-917D-EAD8FAA0DBF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
172164
{E654E2B6-9396-4B8D-917D-EAD8FAA0DBF2}.Release|Any CPU.Build.0 = Release|Any CPU
173-
{AB7280F9-6653-4CF0-9E26-45A3B606B5E9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
174-
{AB7280F9-6653-4CF0-9E26-45A3B606B5E9}.Debug|Any CPU.Build.0 = Debug|Any CPU
175-
{AB7280F9-6653-4CF0-9E26-45A3B606B5E9}.Release|Any CPU.ActiveCfg = Release|Any CPU
176-
{AB7280F9-6653-4CF0-9E26-45A3B606B5E9}.Release|Any CPU.Build.0 = Release|Any CPU
177165
{B1E357B7-7F91-4558-85BA-F6784C33FF97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
178166
{B1E357B7-7F91-4558-85BA-F6784C33FF97}.Debug|Any CPU.Build.0 = Debug|Any CPU
179167
{B1E357B7-7F91-4558-85BA-F6784C33FF97}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -223,7 +211,6 @@ Global
223211
{AB1E9CFF-E0AB-4450-9B2B-1E20DDF8988D} = {E6F200ED-86D2-4D5C-9D5F-34592908B107}
224212
{2D1BADCE-1B2C-4828-9995-F80B2C0F9AF9} = {AE711F89-41F2-4519-B20D-BA1FAB0EB364}
225213
{8663F6FA-AC39-4D1D-A0A0-226E574A5202} = {E6F200ED-86D2-4D5C-9D5F-34592908B107}
226-
{C34C0B86-DC38-42D6-8D64-A0B2E69B396C} = {8F117684-7943-4DCE-8861-F2B854924837}
227214
{914196F5-6208-4710-9A75-201E17457D2B} = {8F117684-7943-4DCE-8861-F2B854924837}
228215
{47890FAA-7CDF-491C-A1B8-9B141EABECF1} = {AE711F89-41F2-4519-B20D-BA1FAB0EB364}
229216
{9F04BA7C-2D9C-4ED9-A405-BEDAB7E8954B} = {E6F200ED-86D2-4D5C-9D5F-34592908B107}
@@ -237,7 +224,6 @@ Global
237224
{CA1D0C43-10C9-46E2-A893-4E93FB4A1511} = {8F117684-7943-4DCE-8861-F2B854924837}
238225
{EF07F98E-9914-4419-A1B4-AB264F496121} = {AE711F89-41F2-4519-B20D-BA1FAB0EB364}
239226
{E654E2B6-9396-4B8D-917D-EAD8FAA0DBF2} = {AE711F89-41F2-4519-B20D-BA1FAB0EB364}
240-
{AB7280F9-6653-4CF0-9E26-45A3B606B5E9} = {AE711F89-41F2-4519-B20D-BA1FAB0EB364}
241227
{B1E357B7-7F91-4558-85BA-F6784C33FF97} = {E6F200ED-86D2-4D5C-9D5F-34592908B107}
242228
{267EAD74-3F4D-41B8-BCF6-9D0F6F99A16F} = {E6F200ED-86D2-4D5C-9D5F-34592908B107}
243229
{9A80C790-3BE2-4FA7-ACC1-574577E759EF} = {8F117684-7943-4DCE-8861-F2B854924837}

docs

Submodule docs updated from c53dcb2 to 12cb5e3

samples/AspNetCore.Samples/AspNetCore.Samples_demo.json

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"content": {
2727
"application/json": {
2828
"schema": {
29-
"$ref": "#/components/schemas/ProductCategoryBoolean<>f__AnonymousType0"
29+
"$ref": "#/components/schemas/ProductCategory"
3030
}
3131
}
3232
}
@@ -55,7 +55,7 @@
5555
"content": {
5656
"application/json": {
5757
"schema": {
58-
"$ref": "#/components/schemas/ProductGroupBoolean<>f__AnonymousType0"
58+
"$ref": "#/components/schemas/ProductGroup"
5959
}
6060
}
6161
}
@@ -575,18 +575,6 @@
575575
"Dairy"
576576
]
577577
},
578-
"ProductCategoryBoolean<>f__AnonymousType0": {
579-
"type": "object",
580-
"properties": {
581-
"value": {
582-
"$ref": "#/components/schemas/ProductCategory"
583-
},
584-
"isValid": {
585-
"type": "boolean"
586-
}
587-
},
588-
"additionalProperties": false
589-
},
590578
"ProductGroup": {
591579
"enum": [
592580
1,
@@ -599,18 +587,6 @@
599587
"Orange"
600588
]
601589
},
602-
"ProductGroupBoolean<>f__AnonymousType0": {
603-
"type": "object",
604-
"properties": {
605-
"value": {
606-
"$ref": "#/components/schemas/ProductGroup"
607-
},
608-
"isValid": {
609-
"type": "boolean"
610-
}
611-
},
612-
"additionalProperties": false
613-
},
614590
"ProductName": {
615591
"type": "string"
616592
},

samples/AspNetCore.Samples/Controllers/DemoController.cs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public DemoController(ILogger<DemoController> logger)
2222
[HttpGet("category/{category}")]
2323
public IActionResult RoundTrip(ProductCategory category)
2424
{
25-
return RoundTripValidatableEnum(category);
25+
return RoundTripInternal(category);
2626
}
2727

2828
[HttpGet("group/{group}")]
2929
public IActionResult RoundTrip(ProductGroup group)
3030
{
31-
return RoundTripValidatableEnum(group);
31+
return RoundTripInternal(group);
3232
}
3333

3434
[HttpGet("productType/{productType}")]
@@ -143,17 +143,6 @@ public IActionResult RoundTrip(TextOrNumberSerializable textOrNumber)
143143
return Json(textOrNumber);
144144
}
145145

146-
private IActionResult RoundTripValidatableEnum<T>(T value)
147-
where T : IValidatableEnum
148-
{
149-
if (!ModelState.IsValid)
150-
return BadRequest(ModelState);
151-
152-
_logger.LogInformation("Round trip test with {Type}: {Value}", value.GetType().Name, value);
153-
154-
return Json(new { Value = value, value.IsValid });
155-
}
156-
157146
private IActionResult RoundTripInternal<T>(T value)
158147
where T : notnull
159148
{

samples/AspNetCore.Samples/Program.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,8 @@ private static Task StartMinimalWebApiAsync(ILoggerFactory loggerFactory)
173173

174174
var routeGroup = app.MapGroup("/api");
175175

176-
routeGroup.MapGet("category/{category}", (ProductCategory category) => new { Value = category, category.IsValid });
177-
routeGroup.MapGet("group/{group}", (ProductGroup group) => new { Value = group, group.IsValid });
176+
routeGroup.MapGet("category/{category}", (ProductCategory category) => category);
177+
routeGroup.MapGet("group/{group}", (ProductGroup group) => group);
178178
routeGroup.MapGet("productType/{productType}", (ProductType productType) => productType);
179179
routeGroup.MapGet("productType", (ProductType productType) => productType);
180180
routeGroup.MapGet("productTypeWithFilter", (BoundValueObject<ProductType, ProductTypeValidationError> productType) => ValueTask.FromResult(productType.Value))

samples/AspNetCore.Samples/Validation/BoundValueObject.cs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,9 @@ public static bool TryParse(string s, IFormatProvider? formatProvider, out Bound
3333
{
3434
var validationError = T.Validate(key, formatProvider, out var item);
3535

36-
if (validationError is null || item is IValidatableEnum)
37-
{
38-
value = new BoundValueObject<T, TKey, TValidationError>(item);
39-
}
40-
else
41-
{
42-
value = new BoundValueObject<T, TKey, TValidationError>(validationError.ToString() ?? "Invalid format");
43-
}
36+
value = validationError is null
37+
? new BoundValueObject<T, TKey, TValidationError>(item)
38+
: new BoundValueObject<T, TKey, TValidationError>(validationError.ToString() ?? "Invalid format");
4439
}
4540

4641
return true;
@@ -70,14 +65,9 @@ public static bool TryParse(string s, IFormatProvider? formatProvider, out Bound
7065
{
7166
var validationError = T.Validate(s, formatProvider, out var item);
7267

73-
if (validationError is null || item is IValidatableEnum)
74-
{
75-
value = new BoundValueObject<T, TValidationError>(item);
76-
}
77-
else
78-
{
79-
value = new BoundValueObject<T, TValidationError>(validationError.ToString() ?? "Invalid format");
80-
}
68+
value = validationError is null
69+
? new BoundValueObject<T, TValidationError>(item)
70+
: new BoundValueObject<T, TValidationError>(validationError.ToString() ?? "Invalid format");
8171

8272
return true;
8373
}

samples/Basic.Samples/SmartEnums/ProductCategory.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Thinktecture.SmartEnums;
22

3-
[SmartEnum<string>(IsValidatable = true,
4-
KeyMemberName = "Name")]
3+
[SmartEnum<string>(KeyMemberName = "Name")]
54
public partial class ProductCategory
65
{
76
public static readonly ProductCategory Fruits = new("Fruits");

samples/Basic.Samples/SmartEnums/ProductGroup.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Thinktecture.SmartEnums;
22

3-
[SmartEnum<int>(IsValidatable = true,
4-
ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads,
3+
[SmartEnum<int>(ComparisonOperators = OperatorsGeneration.DefaultWithKeyTypeOverloads,
54
SkipToString = true)]
65
public partial class ProductGroup
76
{
@@ -13,20 +12,11 @@ public partial class ProductGroup
1312

1413
public int Do(string foo)
1514
{
16-
EnsureValid(); // "Do()" is not allowed for invalid items
17-
1815
// do something
1916

2017
return 42;
2118
}
2219

23-
private static ProductGroup CreateInvalidItem(int key)
24-
{
25-
// the values can be anything besides the key,
26-
// the key must not be null
27-
return new(key, false, "Unknown product group", ProductCategory.Get("Unknown"));
28-
}
29-
3020
public override string ToString()
3121
{
3222
return DisplayName;

samples/Basic.Samples/SmartEnums/ProductGroupStruct.cs

Lines changed: 0 additions & 11 deletions
This file was deleted.

samples/Basic.Samples/SmartEnums/SmartEnumDemos.cs

Lines changed: 5 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ public static void Demo(ILogger logger)
1313
{
1414
DemoForSmartEnum(logger);
1515
DemoForSmartEnumWithCustomComparer(logger);
16-
DemoForValidatableEnum(logger);
1716

1817
DemoForDailySalesCsvImporterType(logger);
1918
DemoForMonthlySalesCsvImporterType(logger);
@@ -97,7 +96,10 @@ private static void DemoForSmartEnum(ILogger logger)
9796
isBigger = ProductGroup.Apple > 42;
9897
logger.Information("{Apple} > {42} = {IsBigger}", ProductGroup.Apple, 42, isBigger);
9998

100-
logger.Information("==== Demo for abstract static members ====");
99+
logger.Information(@"
100+
101+
==== Demo for abstract static members ====
102+
");
101103

102104
Get<ProductType, string, ProductTypeValidationError>(logger, "Groceries");
103105
}
@@ -173,11 +175,6 @@ private static void SwitchWithAction(ILogger logger)
173175
groceries: static l => l.Information("Switch with Action: Groceries"),
174176
housewares: static l => l.Information("Switch with Action: Housewares"));
175177

176-
// Switch of a "validatable" enum
177-
ProductGroupStruct.Get(42).Switch(invalid: invalidItem => Console.WriteLine($"Invalid item: {invalidItem}"),
178-
apple: () => Console.WriteLine("apple"),
179-
orange: () => Console.WriteLine("orange"));
180-
181178
// SwitchPartially with Action
182179
productType.SwitchPartially(@default: item => logger.Information("SwitchPartially with Action: default ('{Item}')", item),
183180
groceries: () => logger.Information("SwitchPartially with Action: Groceries"));
@@ -188,11 +185,6 @@ private static void SwitchWithAction(ILogger logger)
188185
ProductType.Housewares.SwitchPartially(@default: item => logger.Information("SwitchPartially with Action: default ('{Item}')", item),
189186
groceries: () => logger.Information("SwitchPartially with Action: Groceries"));
190187

191-
// Switch of a "validatable" enum
192-
ProductGroupStruct.Get(42).SwitchPartially(invalid: invalidItem => Console.WriteLine($"SwitchPartially with Action: Invalid item ({invalidItem})"),
193-
apple: () => Console.WriteLine("SwitchPartially with Action: apple"),
194-
orange: () => Console.WriteLine("SwitchPartially with Action: orange"));
195-
196188
// SwitchPartially with Action<TState>
197189
productType.SwitchPartially(logger,
198190
@default: static (l, item) => l.Information("SwitchPartially with Action<TState>: default ('{Item}')", item),
@@ -242,35 +234,6 @@ private static void DemoForSmartEnumWithCustomComparer(ILogger logger)
242234
lowerCased > upperCased);
243235
}
244236

245-
private static void DemoForValidatableEnum(ILogger logger)
246-
{
247-
logger.Information("""
248-
249-
250-
==== Demo for SmartEnum<T>(IsValidatable = true) ====
251-
252-
""");
253-
254-
var categories = ProductCategory.Items;
255-
logger.Information("Categories: {Categories}", categories);
256-
257-
var category = ProductCategory.Get("Fruits");
258-
logger.Information("Category: {Category}", category);
259-
260-
// Throws "InvalidOperationException" if not valid
261-
category.EnsureValid();
262-
263-
if (ProductCategory.TryGet("fruits", out var fruits))
264-
logger.Information("Category {Category} with TryGet found", fruits);
265-
266-
string keyOfTheCategory = category;
267-
logger.Information("Implicit conversion of Category -> string: {Key}", keyOfTheCategory);
268-
269-
var unknownCategory = ProductCategory.Get("Grains");
270-
logger.Information("unknownCategory.Key: {CategoryKey}", unknownCategory.Name);
271-
logger.Information("unknownCategory.isValid: {IsValid}", unknownCategory.IsValid);
272-
}
273-
274237
private static void DemoForDailySalesCsvImporterType(ILogger logger)
275238
{
276239
logger.Information("""
@@ -350,7 +313,7 @@ private static void PrintAllItems<T, TKey, TValidationError>(ILogger logger)
350313

351314
foreach (var item in T.Items)
352315
{
353-
logger.Information("Item: {Item}", item);
316+
logger.Information(" Item: {Item}", item);
354317
}
355318
}
356319

0 commit comments

Comments
 (0)