Mappa 10.1.0
dotnet add package Mappa --version 10.1.0
NuGet\Install-Package Mappa -Version 10.1.0
<PackageReference Include="Mappa" Version="10.1.0" />
<PackageVersion Include="Mappa" Version="10.1.0" />
<PackageReference Include="Mappa" />
paket add Mappa --version 10.1.0
#r "nuget: Mappa, 10.1.0"
#:package Mappa@10.1.0
#addin nuget:?package=Mappa&version=10.1.0
#tool nuget:?package=Mappa&version=10.1.0
Mappa
This package contains all the attributes that can be used to drive the behaviour of the Mappa source generator. This is the list of attributes provided:
Mappa: Identifies partial classes that are meant to be source generated by the Mappa source generator;MappaIgnore: Identifies methods that should not be used for mapping;MappaDependency: Identifies a property or field inside a mapper class that can be used when identifying suitable mappings between two types; fields and properties tagged on accessible base classes of the mapper are also considered; methods on the dependency type and its base classes are considered when the field or property type is that type or a derived type;MappaStaticDependency: Defines a static class whose methods can be used as dependencies while performing mappings;MappaSettings: Allows specifying mapping behaviour (for example, culture when parsing or formatting date/time,Guid, and numeric types, and format when converting numeric types tostring);MappaUseProperty: When mapping structured types (class,struct, and records) allows specifying which source property to use for a target property or constructor parameter;MappaIgnoreTargetProperty: When mapping structured types via an empty constructor, excludes a target property from property-initializer mapping; has no effect when mapping uses a constructor with parameters;MappaAssignFromContext: When mapping structured types, allows specifying which value from aMappaContextto use for a target property or constructor parameter;MappaAssignToContext: When mapping structured types via the constructor-map strategy, stores the value of a target property or field inMappaContextafter the target object has been fully constructed;MappaInvokeMethodAttribute: When mapping structured types via the constructor-map strategy, forces a target property or constructor parameter to be mapped by invoking a named method; supports an optionalSourcePropertyNamenamed parameter to select the source property passed to the invoked method;MappaAssignFromConstant: When mapping structured types, allows specifying a constant value for a target property or constructor parameter;MappaTypeMapping: When mapping structured types or interfaces, allows defining the target type depending on the source type;MappaTypeMappingDefault: Describes the default behaviour for polymorphic methods defined viaMappaTypeMapping.
This package also provides the MappaContext class that can be used to pass contextual values to mappers via the MappaAssignFromContext attribute, store mapped values via the MappaAssignToContext attribute, or supply context to methods invoked via the MappaInvokeMethodAttribute attribute.
Via MappaSettings the following settings can be tweaked:
DateTimeFormat: the format to use when mappingstrings to and fromSystem.DateTime;DateTimeOffsetFormat: the format to use when mappingstrings to and fromSystem.DateTimeOffset;DateOnlyFormat: the format to use when mappingstrings to and fromSystem.DateOnly;TimeOnlyFormat: the format to use when mappingstrings to and fromSystem.TimeOnly;DateTimeStyle: the DateTimeStyles to use when parsingstrings toSystem.DateTime(unset values inherit; does not affectToString);DateTimeOffsetStyle: the DateTimeStyles to use when parsingstrings toSystem.DateTimeOffset(unset values inherit; does not affectToString);DateOnlyStyle: the DateTimeStyles to use when parsingstrings toSystem.DateOnly(unset values inherit; does not affectToString);TimeOnlyStyle: the DateTimeStyles to use when parsingstrings toSystem.TimeOnly(unset values inherit; does not affectToString);GlobalDateTimeStyle: the default DateTimeStyles for parsing date/time types when the type-specific style is unset (type-specific styles override when both are set; does not affectToString);TimeSpanFormat: the format to use when mappingstrings to and fromSystem.TimeSpan;GuidFormat: the format to use when mappingstrings to and fromSystem.Guid;ByteFormat,SByteFormat,ShortFormat,UShortFormat,IntFormat,UIntFormat,LongFormat,ULongFormat,DecimalFormat,FloatFormat,DoubleFormat: the format to use when converting the corresponding numeric type tostring(numeric formats apply toToStringonly);ByteStyle,SByteStyle,ShortStyle,UShortStyle,IntStyle,UIntStyle,LongStyle,ULongStyle,DecimalStyle,FloatStyle,DoubleStyle: the NumberStyles to use when parsingstrings to the corresponding numeric type (unset values inherit; does not affectToString);GlobalNumberStyle: the default NumberStyles for parsing numeric types when the type-specific style is unset (type-specific styles override when both are set; does not affectToString);CultureInfoSetting: defines which culture to use when mapping any of the above types and numeric types (current culture, invariant culture, or user-defined culture);CultureName: defines the culture to use when user-defined culture is selected byCultureInfoSetting;ProtobufOptional: enables or disables the ability of the Mappa source generator to handleoptionalfields in protobuf models;PragmaWarning: allows surrounding the generated methods with a#pragma warning disableblock;FastCollections: usesSpan<T>to make mappings involving arrays andSystem.Collections.Generic.List<T>faster;ContainerCapacityConstructors: supports mapping custom containers using (if available) a constructor accepting an integer value representing the initial capacity of the container;EnumerableConcreteType: selects whether mappings to sequence-like collection interfaces (for exampleIEnumerable<T>) useList<T>(default) orT[]as the concrete buffer;PolymorphicMapMethodWithMatchingDefaultAttribute: when enabled,MappaTypeMappingDefaultcan be used to locate an appropriate polymorphic method when looking for the mapping between two types;CaseInsensitivePropertyMap: when enabled, source property names are matched case-insensitively when pairing a target property or constructor parameter with a source property by name;IgnoreUnderscoreForPropertyMap: when enabled, underscore characters are stripped from names before comparing a target property or constructor parameter with a source property by name;CaseInsensitiveEnumMap: when enabled, enum member names or[Description]values are matched case-insensitively when mapping between enums or fromstringto an enum;EnumStringMapSetting: selects whether enum and string mappings match members by name (default) or by[Description]attribute value;EnumToEnumMapSetting: selects whether enum-to-enum mappings match members by name (default), by underlying numeric value, or by[Description]attribute value;IdentityMapDeepCopy: selects whether identity mappings return the original reference, clone viaMemberwiseClone, or recursively copy nested fields (seeMappa.MappaCloning.MemberwiseClone).
Via MappaTypeMappingDefault the following settings can be tweaked:
Undefined: this setting should never be used;Throw: if the source type is not defined by any of theMappaTypeMappingattributes, throwsArgumentOutOfRangeExceptionor the exception defined in theMappaTypeMappingDefaultattribute;Default: returnsdefault;Null: returnsnull;MapSourceType: maps the source type to the target type of the method or the type specified in theMappaTypeMappingDefaultattribute;InvokeMethod: invokes a method in the mapper with the name specified inMappaTypeMappingDefaultto perform the mapping;MappaTypeMappingDefaultcan also specify the type on which the method is defined—in that case the method must bestatic. The method can optionally accept aMappaContextparameter.
Relevant packages:
- Mappa source generator: source generator that automatically generates mappings between classes and value types;
- Mappa Protobuf: methods to map
Google.Protobuf.WellKnownTypesobjects from the Google.Protobuf package into common objects; - Mappa Protobuf dependency: utility methods to register the Protobuf mapper;
- Mappa Bson: methods to map
MongoDB.Bsonobjects from the MongoDB.Bson package into common objects; - Mappa Bson dependency: utility methods to register the Bson mapper.
You can find samples here. Visit the Mappa documentation to learn more.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.