Skip to content

Commit 73ba400

Browse files
authored
Merge pull request #4032 from AutoMapper/enum_parse
Use Enum.Parse<TEnum>
2 parents b8f8546 + 3c2d8cd commit 73ba400

File tree

491 files changed

+34307
-37307
lines changed

Some content is hidden

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

491 files changed

+34307
-37307
lines changed

.editorconfig

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
root = true
33

44
[*]
5-
end_of_line = LF
5+
end_of_line = lf
66
indent_style = space
77
indent_size = 4
88

@@ -21,7 +21,7 @@ dotnet_naming_style.constant_style.capitalization = pascal_case
2121
# Static fields are PascalCase
2222
dotnet_naming_rule.static_fields_should_be_pascal_case.severity = suggestion
2323
dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = static_fields
24-
dotnet_naming_rule.static_fields_should_be_pascal_case.style = static_field_style
24+
dotnet_naming_rule.static_fields_should_be_pascal_case.style = constant_style
2525

2626
dotnet_naming_symbols.static_fields.applicable_kinds = field
2727
dotnet_naming_symbols.static_fields.applicable_accessibilities = *
@@ -32,7 +32,7 @@ dotnet_naming_style.static_field_style.capitalization = pascal_case
3232
# Public and internal fields are PascalCase
3333
dotnet_naming_rule.public_and_internal_should_be_pascal_case.severity = suggestion
3434
dotnet_naming_rule.public_and_internal_should_be_pascal_case.symbols = public_internal_fields
35-
dotnet_naming_rule.public_and_internal_should_be_pascal_case.style = public_internal_fields_style
35+
dotnet_naming_rule.public_and_internal_should_be_pascal_case.style = constant_style
3636

3737
dotnet_naming_symbols.public_internal_fields.applicable_kinds = field
3838
dotnet_naming_symbols.public_internal_fields.applicable_accessibilities = public, internal
@@ -58,6 +58,32 @@ dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
5858
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local
5959

6060
dotnet_naming_style.camel_case_style.capitalization = camel_case
61+
dotnet_style_operator_placement_when_wrapping = beginning_of_line
62+
tab_width = 4
63+
csharp_indent_labels = one_less_than_current
64+
dotnet_style_coalesce_expression = true:suggestion
65+
dotnet_style_null_propagation = true:suggestion
66+
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
67+
dotnet_style_prefer_auto_properties = true:silent
68+
csharp_using_directive_placement = outside_namespace:silent
69+
csharp_prefer_simple_using_statement = true:suggestion
70+
csharp_prefer_braces = true:silent
71+
csharp_style_prefer_method_group_conversion = true:silent
72+
csharp_style_prefer_top_level_statements = true:silent
73+
csharp_style_expression_bodied_methods = false:silent
74+
csharp_style_expression_bodied_constructors = false:silent
75+
csharp_style_expression_bodied_operators = false:silent
76+
csharp_style_expression_bodied_properties = true:silent
77+
csharp_style_expression_bodied_indexers = true:silent
78+
csharp_style_expression_bodied_accessors = true:silent
79+
csharp_style_expression_bodied_lambdas = true:silent
80+
csharp_style_expression_bodied_local_functions = false:silent
81+
dotnet_style_object_initializer = true:suggestion
82+
csharp_style_namespace_declarations = file_scoped:suggestion
83+
dotnet_style_namespace_match_folder = true:silent
84+
dotnet_style_explicit_tuple_names = true:suggestion
85+
dotnet_style_prefer_inferred_tuple_names = true:suggestion
86+
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
6187

6288
[*.xml]
6389
indent_size = 2

Directory.Build.props

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@
66
<NoWarn>$(NoWarn);CS1701;CS1702;CS1591</NoWarn>
77
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
88
<Features>strict</Features>
9+
<ImplicitUsings>enable</ImplicitUsings>
910
</PropertyGroup>
1011

12+
<ItemGroup>
13+
<Using Include="System.Reflection"/>
14+
<Using Include="System.Diagnostics"/>
15+
<Using Include="System.ComponentModel"/>
16+
<Using Include="System.Linq.Expressions"/>
17+
<Using Include="AutoMapper.QueryableExtensions" />
18+
<Using Include="AutoMapper.Internal" />
19+
</ItemGroup>
1120
</Project>

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ var configuration = new MapperConfiguration(cfg =>
2828
cfg.CreateMap<Bar, BarDto>();
2929
});
3030
// only during development, validate your mappings; remove it before release
31+
#if DEBUG
3132
configuration.AssertConfigurationIsValid();
33+
#endif
3234
// use DI (http://docs.automapper.org/en/latest/Dependency-injection.html) or create the mapper yourself
3335
var mapper = configuration.CreateMapper();
3436
```

docs/12.0-Upgrade-Guide.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,9 @@ Another possible occurence is with `ForAllMaps` and `ForAllPropertyMaps` when it
1717

1818
You should use `ResolutionContext.Items` to access the items passed in the `Map` call.
1919

20-
Instead of `ServiceCtor` you should use dependency injection or pass the needed objects in the `Map` call.
20+
Instead of `ServiceCtor`, you should use dependency injection or pass the needed objects in the `Map` call.
21+
22+
## Naming conventions
23+
24+
We've simplified the implementation for performance reasons. If that doesn't work for you, you can write your own naming convention. Rather than address every
25+
peculiarity, we prefer to have a simple and fast implementation that covers most cases.

docs/Configuration.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,23 @@ You can set the source and destination naming conventions
9393

9494
```c#
9595
var configuration = new MapperConfiguration(cfg => {
96-
cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
97-
cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
96+
cfg.SourceMemberNamingConvention = LowerUnderscoreNamingConvention.Instance;
97+
cfg.DestinationMemberNamingConvention = PascalCaseNamingConvention.Instance;
9898
});
9999
```
100100

101101
This will map the following properties to each other:
102102
` property_name -> PropertyName `
103103

104-
You can also set this at a per profile level
104+
You can also set this per profile
105105

106106
```c#
107107
public class OrganizationProfile : Profile
108108
{
109109
public OrganizationProfile()
110110
{
111-
SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
112-
DestinationMemberNamingConvention = new PascalCaseNamingConvention();
111+
SourceMemberNamingConvention = LowerUnderscoreNamingConvention.Instance;
112+
DestinationMemberNamingConvention = PascalCaseNamingConvention.Instance;
113113
//Put your CreateMap... Etc.. here
114114
}
115115
}

docs/Construction.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ var configuration = new MapperConfiguration(cfg => cfg.DisableConstructorMapping
5050
You can configure which constructors are considered for the destination object:
5151

5252
```c#
53-
// don't map private constructors
54-
var configuration = new MapperConfiguration(cfg => cfg.ShouldUseConstructor = ci => !ci.IsPrivate);
55-
```
53+
// use only public constructors
54+
var configuration = new MapperConfiguration(cfg => cfg.ShouldUseConstructor = constructor => constructor.IsPublic);
55+
```

0 commit comments

Comments
 (0)