Skip to content

Commit 1e80a68

Browse files
authored
Merge branch 'main' into dependabot/nuget/System.Text.Json-7.0.3
2 parents fc43eb7 + 471539f commit 1e80a68

File tree

9 files changed

+80
-8
lines changed

9 files changed

+80
-8
lines changed

CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributing to Ardalis.GuardClauses
2+
3+
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
4+
5+
- Reporting a bug
6+
- Discussing the current state of the code
7+
- Submitting a fix
8+
- Proposing new features
9+
10+
## We Develop with GitHub
11+
12+
Obviously...
13+
14+
## We Use Pull Requests
15+
16+
Mostly. But pretty much exclusively for non-maintainers. You'll need to fork the repo in order to submit a pull request. Here are the basic steps:
17+
18+
1. Fork the repo and create your branch from `main`.
19+
2. If you've added code that should be tested, add tests.
20+
3. If you've changed APIs, update the documentation.
21+
4. Ensure the test suite passes.
22+
5. Make sure your code lints.
23+
6. Issue that pull request!
24+
25+
- [Pull Request Check List](https://ardalis.com/github-pull-request-checklist/)
26+
- [Resync your fork with this upstream repo](https://ardalis.com/syncing-a-fork-of-a-github-repository-with-upstream/)
27+
28+
## Ask before adding a pull request
29+
30+
You can just add a pull request out of the blue if you want, but it's much better etitquette (and more likely to be accepted) if you open a new issue or comment in an existing issue stating you'd like to make a pull request.
31+
32+
## Getting Started
33+
34+
Look for [issues marked with 'help wanted'](https://github.com/ardalis/guardclauses/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) to find good places to start contributing.
35+
36+
## Any contributions you make will be under the MIT Software License
37+
38+
In short, when you submit code changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers this project.
39+
40+
## Report bugs using Github's [issues](https://github.com/ardalis/guardclauses/issues)
41+
42+
We use GitHub issues to track public bugs. Report a bug by [opening a new issue](https://github.com/ardalis/GuardClauses/issues/new/choose); it's that easy!
43+
44+
## Sponsor us
45+
46+
If you don't have the time or expertise to contribute code, you can still support us by [sponsoring](https://github.com/sponsors/ardalis).

Directory.Build.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<Features>strict</Features>
1616
</PropertyGroup>
1717
<PropertyGroup>
18+
<SolutionDir Condition="'$(SolutionDir)'==''">$(MSBuildThisFileDirectory)</SolutionDir>
1819
<RepoRelativeProjectDir>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</RepoRelativeProjectDir>
1920

2021
<!-- Define useful flags based on project name conventions -->

Directory.Packages.props

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@
44
</PropertyGroup>
55
<ItemGroup>
66
<PackageVersion Include="AutoFixture" Version="4.17.0" />
7-
<PackageVersion Include="BenchmarkDotNet" Version="0.13.4" />
7+
<PackageVersion Include="BenchmarkDotNet" Version="0.13.10" />
88
<PackageVersion Include="Constant" Version="2.0.4" />
99
<PackageVersion Include="coverlet.collector" Version="3.2.0" />
1010
<PackageVersion Include="coverlet.msbuild" Version="3.2.0" />
11-
<PackageVersion Include="Dapper" Version="2.0.123" />
11+
<PackageVersion Include="Dapper" Version="2.1.15" />
1212
<PackageVersion Include="Enums.NET" Version="4.0.1" />
1313
<PackageVersion Include="FluentAssertions" Version="6.11.0" />
1414
<PackageVersion Include="MessagePack" Version="2.4.59" />
1515
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
1616
<PackageVersion Include="Microsoft.Data.Sqlite" Version="7.0.2" />
17-
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
18-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2" />
19-
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
20-
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.4.1" />
17+
<PackageVersion Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
18+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13" />
19+
<PackageVersion Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.13" />
20+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
2121
<PackageVersion Include="Microsoft.SourceLink.GitHub" Version="1.1.1" />
2222
<PackageVersion Include="Moq" Version="4.18.4" />
2323
<PackageVersion Include="Newtonsoft.Json" Version="13.0.2" />

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Install-Package Ardalis.SmartEnum -Version 2.1.0
9898

9999
## Usage
100100

101-
Define your smart enum by inheriting from `SmartEnum<TEnum>` where `TEnum` is the type you're declaring. For [example](/src/SmartEnum.UnitTests/TestEnum.cs):
101+
Define your smart enum by inheriting from `SmartEnum<TEnum>` where `TEnum` is the type you're declaring. For [example](/test/SmartEnum.UnitTests/TestEnum.cs):
102102

103103
```csharp
104104
using Ardalis.SmartEnum;

src/SmartEnum.EFCore/SmartEnumConverterExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
77
using System;
88
using System.Collections.Generic;
9+
using System.ComponentModel.DataAnnotations.Schema;
910
using System.Linq;
11+
using System.Reflection;
1012
using System.Text;
1113

1214
namespace SmartEnum.EFCore
@@ -23,6 +25,7 @@ public static void ConfigureSmartEnum(this ModelConfigurationBuilder configurati
2325
var propertyTypes = modelBuilder.Model.GetEntityTypes()
2426
.SelectMany(e => e.ClrType.GetProperties())
2527
.Where(p => TypeUtil.IsDerived(p.PropertyType, typeof(SmartEnum<,>)))
28+
.Where(p => p.GetCustomAttribute<NotMappedAttribute>() == null)
2629
.Select(p => p.PropertyType)
2730
.Distinct();
2831

@@ -52,7 +55,8 @@ public static void ConfigureSmartEnum(this ModelBuilder modelBuilder)
5255
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
5356
{
5457
var properties = entityType.ClrType.GetProperties()
55-
.Where(p => TypeUtil.IsDerived(p.PropertyType, typeof(SmartEnum<,>)));
58+
.Where(p => TypeUtil.IsDerived(p.PropertyType, typeof(SmartEnum<,>)))
59+
.Where(p => p.GetCustomAttribute<NotMappedAttribute>() == null);
5660

5761
foreach (var property in properties)
5862
{

test/SmartEnum.EFCore.IntegrationTests/Entities/SomeEntity.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.EntityFrameworkCore;
22
using Microsoft.EntityFrameworkCore.Metadata.Builders;
33
using System.Collections.Generic;
4+
using System.ComponentModel.DataAnnotations.Schema;
45

56
namespace SmartEnum.EFCore.IntegrationTests.Entities
67
{
@@ -24,6 +25,9 @@ public class SomeEntity
2425

2526
public List<SomeOwnedEntity> OwnedEntities { get; set; }
2627

28+
[NotMapped]
29+
public TestEnum NotMappedTest { get; set; }
30+
2731
public class Configuration : IEntityTypeConfiguration<SomeEntity>
2832
{
2933
public void Configure(EntityTypeBuilder<SomeEntity> builder)

test/SmartEnum.EFCore.IntegrationTests/Entities/SomeOuterOwnedEntity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.EntityFrameworkCore;
22

3+
using System.ComponentModel.DataAnnotations.Schema;
4+
35
namespace SmartEnum.EFCore.IntegrationTests.Entities
46
{
57
[Owned]
@@ -18,5 +20,8 @@ public class SomeOuterOwnedEntity
1820
public TestBaseEnumWithDerivedValues Test4 { get; set; }
1921

2022
public SomeOwnedEntity InnerOwnedEntity { get; set; }
23+
24+
[NotMapped]
25+
public TestEnum NotMappedTest { get; set; }
2126
}
2227
}

test/SmartEnum.EFCore.IntegrationTests/Entities/SomeOwnedEntity.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.EntityFrameworkCore;
22

3+
using System.ComponentModel.DataAnnotations.Schema;
4+
35
namespace SmartEnum.EFCore.IntegrationTests.Entities
46
{
57
[Owned]
@@ -16,5 +18,8 @@ public class SomeOwnedEntity
1618
public TestStringEnum Test3 { get; set; }
1719

1820
public TestBaseEnumWithDerivedValues Test4 { get; set; }
21+
22+
[NotMapped]
23+
public TestEnum NotMappedTest { get; set; }
1924
}
2025
}

test/SmartEnum.EFCore.IntegrationTests/SmartEnumEFCoreDbTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ private static SomeEntity CreateEntity()
8585
Test2 = TestDerivedEnum.One,
8686
Test3 = TestStringEnum.One,
8787
Test4 = DerivedTestEnumWithValues1.A,
88+
NotMappedTest = TestEnum.One,
8889
OwnedEntity = new SomeOwnedEntity
8990
{
9091
Value = 2,
@@ -143,27 +144,31 @@ private static void VerifyEntity(SomeEntity entity)
143144
entity.Test2.Should().Be(TestDerivedEnum.One);
144145
entity.Test3.Should().Be(TestStringEnum.One);
145146
entity.Test4.Should().Be(DerivedTestEnumWithValues1.A);
147+
entity.NotMappedTest.Should().BeNull();
146148

147149
entity.OwnedEntity.Value.Should().Be(2);
148150
entity.OwnedEntity.Weekday.Should().Be(Weekday.Friday);
149151
entity.OwnedEntity.Test1.Should().Be(TestEnum.Two);
150152
entity.OwnedEntity.Test2.Should().Be(TestDerivedEnum.One);
151153
entity.OwnedEntity.Test3.Should().Be(TestStringEnum.Two);
152154
entity.OwnedEntity.Test4.Should().Be(DerivedTestEnumWithValues1.B);
155+
entity.OwnedEntity.NotMappedTest.Should().BeNull();
153156

154157
entity.OuterOwnedEntity.Value.Should().Be(3);
155158
entity.OuterOwnedEntity.Weekday.Should().Be(Weekday.Friday);
156159
entity.OuterOwnedEntity.Test1.Should().Be(TestEnum.Two);
157160
entity.OuterOwnedEntity.Test2.Should().Be(TestDerivedEnum.One);
158161
entity.OuterOwnedEntity.Test3.Should().Be(TestStringEnum.Two);
159162
entity.OuterOwnedEntity.Test4.Should().Be(DerivedTestEnumWithValues1.B);
163+
entity.OuterOwnedEntity.NotMappedTest.Should().BeNull();
160164

161165
entity.OuterOwnedEntity.InnerOwnedEntity.Value.Should().Be(4);
162166
entity.OuterOwnedEntity.InnerOwnedEntity.Weekday.Should().Be(Weekday.Friday);
163167
entity.OuterOwnedEntity.InnerOwnedEntity.Test1.Should().Be(TestEnum.Two);
164168
entity.OuterOwnedEntity.InnerOwnedEntity.Test2.Should().Be(TestDerivedEnum.One);
165169
entity.OuterOwnedEntity.InnerOwnedEntity.Test3.Should().Be(TestStringEnum.Two);
166170
entity.OuterOwnedEntity.InnerOwnedEntity.Test4.Should().Be(DerivedTestEnumWithValues1.B);
171+
entity.OuterOwnedEntity.InnerOwnedEntity.NotMappedTest.Should().BeNull();
167172

168173
entity.OwnedEntities.Should().SatisfyRespectively(
169174
o =>
@@ -174,6 +179,7 @@ private static void VerifyEntity(SomeEntity entity)
174179
o.Test2.Should().Be(TestDerivedEnum.One);
175180
o.Test3.Should().Be(TestStringEnum.Three);
176181
o.Test4.Should().Be(DerivedTestEnumWithValues1.A);
182+
o.NotMappedTest.Should().BeNull();
177183
},
178184
o =>
179185
{
@@ -183,6 +189,7 @@ private static void VerifyEntity(SomeEntity entity)
183189
o.Test2.Should().Be(TestDerivedEnum.One);
184190
o.Test3.Should().Be(TestStringEnum.One);
185191
o.Test4.Should().Be(DerivedTestEnumWithValues1.B);
192+
o.NotMappedTest.Should().BeNull();
186193
});
187194
}
188195
}

0 commit comments

Comments
 (0)