Skip to content

Commit

Permalink
Merge pull request #4032 from AutoMapper/enum_parse
Browse files Browse the repository at this point in the history
Use Enum.Parse<TEnum>
  • Loading branch information
jbogard committed Sep 30, 2022
2 parents b8f8546 + 3c2d8cd commit 73ba400
Show file tree
Hide file tree
Showing 491 changed files with 34,307 additions and 37,307 deletions.
32 changes: 29 additions & 3 deletions .editorconfig
Expand Up @@ -2,7 +2,7 @@
root = true

[*]
end_of_line = LF
end_of_line = lf
indent_style = space
indent_size = 4

Expand All @@ -21,7 +21,7 @@ dotnet_naming_style.constant_style.capitalization = pascal_case
# Static fields are PascalCase
dotnet_naming_rule.static_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.static_fields_should_be_pascal_case.symbols = static_fields
dotnet_naming_rule.static_fields_should_be_pascal_case.style = static_field_style
dotnet_naming_rule.static_fields_should_be_pascal_case.style = constant_style

dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.applicable_accessibilities = *
Expand All @@ -32,7 +32,7 @@ dotnet_naming_style.static_field_style.capitalization = pascal_case
# Public and internal fields are PascalCase
dotnet_naming_rule.public_and_internal_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.public_and_internal_should_be_pascal_case.symbols = public_internal_fields
dotnet_naming_rule.public_and_internal_should_be_pascal_case.style = public_internal_fields_style
dotnet_naming_rule.public_and_internal_should_be_pascal_case.style = constant_style

dotnet_naming_symbols.public_internal_fields.applicable_kinds = field
dotnet_naming_symbols.public_internal_fields.applicable_accessibilities = public, internal
Expand All @@ -58,6 +58,32 @@ dotnet_naming_rule.locals_should_be_camel_case.style = camel_case_style
dotnet_naming_symbols.locals_and_parameters.applicable_kinds = parameter, local

dotnet_naming_style.camel_case_style.capitalization = camel_case
dotnet_style_operator_placement_when_wrapping = beginning_of_line
tab_width = 4
csharp_indent_labels = one_less_than_current
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_auto_properties = true:silent
csharp_using_directive_placement = outside_namespace:silent
csharp_prefer_simple_using_statement = true:suggestion
csharp_prefer_braces = true:silent
csharp_style_prefer_method_group_conversion = true:silent
csharp_style_prefer_top_level_statements = true:silent
csharp_style_expression_bodied_methods = false:silent
csharp_style_expression_bodied_constructors = false:silent
csharp_style_expression_bodied_operators = false:silent
csharp_style_expression_bodied_properties = true:silent
csharp_style_expression_bodied_indexers = true:silent
csharp_style_expression_bodied_accessors = true:silent
csharp_style_expression_bodied_lambdas = true:silent
csharp_style_expression_bodied_local_functions = false:silent
dotnet_style_object_initializer = true:suggestion
csharp_style_namespace_declarations = file_scoped:suggestion
dotnet_style_namespace_match_folder = true:silent
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion

[*.xml]
indent_size = 2
Expand Down
9 changes: 9 additions & 0 deletions Directory.Build.props
Expand Up @@ -6,6 +6,15 @@
<NoWarn>$(NoWarn);CS1701;CS1702;CS1591</NoWarn>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Features>strict</Features>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Using Include="System.Reflection"/>
<Using Include="System.Diagnostics"/>
<Using Include="System.ComponentModel"/>
<Using Include="System.Linq.Expressions"/>
<Using Include="AutoMapper.QueryableExtensions" />
<Using Include="AutoMapper.Internal" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -28,7 +28,9 @@ var configuration = new MapperConfiguration(cfg =>
cfg.CreateMap<Bar, BarDto>();
});
// only during development, validate your mappings; remove it before release
#if DEBUG
configuration.AssertConfigurationIsValid();
#endif
// use DI (http://docs.automapper.org/en/latest/Dependency-injection.html) or create the mapper yourself
var mapper = configuration.CreateMapper();
```
Expand Down
7 changes: 6 additions & 1 deletion docs/12.0-Upgrade-Guide.md
Expand Up @@ -17,4 +17,9 @@ Another possible occurence is with `ForAllMaps` and `ForAllPropertyMaps` when it

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

Instead of `ServiceCtor` you should use dependency injection or pass the needed objects in the `Map` call.
Instead of `ServiceCtor`, you should use dependency injection or pass the needed objects in the `Map` call.

## Naming conventions

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
peculiarity, we prefer to have a simple and fast implementation that covers most cases.
10 changes: 5 additions & 5 deletions docs/Configuration.md
Expand Up @@ -93,23 +93,23 @@ You can set the source and destination naming conventions

```c#
var configuration = new MapperConfiguration(cfg => {
cfg.SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
cfg.DestinationMemberNamingConvention = new PascalCaseNamingConvention();
cfg.SourceMemberNamingConvention = LowerUnderscoreNamingConvention.Instance;
cfg.DestinationMemberNamingConvention = PascalCaseNamingConvention.Instance;
});
```

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

You can also set this at a per profile level
You can also set this per profile

```c#
public class OrganizationProfile : Profile
{
public OrganizationProfile()
{
SourceMemberNamingConvention = new LowerUnderscoreNamingConvention();
DestinationMemberNamingConvention = new PascalCaseNamingConvention();
SourceMemberNamingConvention = LowerUnderscoreNamingConvention.Instance;
DestinationMemberNamingConvention = PascalCaseNamingConvention.Instance;
//Put your CreateMap... Etc.. here
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/Construction.md
Expand Up @@ -50,6 +50,6 @@ var configuration = new MapperConfiguration(cfg => cfg.DisableConstructorMapping
You can configure which constructors are considered for the destination object:

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

0 comments on commit 73ba400

Please sign in to comment.