Skip to content

Commit 9754fea

Browse files
authored
Add AutoMapper 6.2.2 (#364)
* Update assembly infor * update license and version * Add automapper 6.2.2
1 parent 95df4e8 commit 9754fea

File tree

170 files changed

+14528
-10
lines changed

Some content is hidden

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

170 files changed

+14528
-10
lines changed

.azure-pipelines/Azure-PowerShell-Common-Publish.yml

+33-10
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,29 @@ steps:
1919
{
2020
throw "The value of Version $env:VERSION must be format of X.X.X"
2121
}
22-
2322
displayName: 'Check Version'
2423

2524
- task: UseDotNet@2
26-
displayName: 'Use dotnet sdk 2.1.302'
25+
displayName: 'Install .NET SDK'
2726
inputs:
28-
version: 2.1.302
27+
packageType: 'sdk'
28+
version: '3.x'
2929

3030
- powershell: '$(Agent.ToolsDirectory)/dotnet/dotnet msbuild build.proj /t:Build /p:Configuration=Release /p:FileVersion=$env:VERSION /NoLogo'
31-
displayName: build
31+
displayName: build common libs
32+
33+
- powershell: '$(Agent.ToolsDirectory)/dotnet/dotnet build tools/AutoMapper/AutoMapper.csproj -c Release'
34+
displayName: build AutoMapper
3235

3336
- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
3437
displayName: 'dll Signing'
3538
inputs:
3639
ConnectedServiceName: 'ESRP Signing Service'
37-
FolderPath: artifacts
40+
FolderPath: .
3841
Pattern: |
39-
Release\netstandard2.0\Microsoft.Azure.PowerShell*.dll
40-
!Release\netstandard2.0\Microsoft.Azure.PowerShell*.Test.dll
42+
artifacts\Release\netstandard2.0\Microsoft.Azure.PowerShell*.dll
43+
tools\AutoMapper\bin\Release\netstandard2.0\Microsoft.Azure.PowerShell*.dll
44+
!artifacts\Release\netstandard2.0\Microsoft.Azure.PowerShell*.Test.dll
4145
UseMinimatch: true
4246
signConfigType: inlineSignParams
4347
inlineOperation: |
@@ -78,8 +82,12 @@ steps:
7882
}
7983
]
8084
81-
- powershell: |
82-
$(Agent.ToolsDirectory)/dotnet/dotnet msbuild build.proj /t:Pack /p:Configuration=Release /p:PackageVersion=$env:VERSION /NoLogo
85+
- task: PowerShell@2
86+
inputs:
87+
targetType: 'inline'
88+
script: |
89+
$(Agent.ToolsDirectory)/dotnet/dotnet msbuild build.proj /t:Pack /p:Configuration=Release /p:PackageVersion=$env:VERSION /NoLogo
90+
$(Agent.ToolsDirectory)/dotnet/dotnet pack tools/AutoMapper/AutoMapper.csproj -c Release --no-build
8391
displayName: pack
8492

8593
- task: NuGetAuthenticate@0
@@ -91,7 +99,7 @@ steps:
9199
condition: and(succeeded(), ne(variables['publish'], 'false'))
92100
inputs:
93101
command: push
94-
packagesToPush: 'artifacts/Package/Release/Microsoft.Azure.PowerShell.*.nupkg;!artifacts/Package/Release/Microsoft.Azure.PowerShell.*.symbols.nupkg' # .nupkg and .snupkg
102+
packagesToPush: 'artifacts/Package/Release/Microsoft.Azure.PowerShell.*.nupkg;!artifacts/Package/Release/Microsoft.Azure.PowerShell.*.symbols.nupkg;' # .nupkg and .snupkg
95103
publishVstsFeed: public/azure-powershell
96104
includeSymbols: false
97105

@@ -106,3 +114,18 @@ steps:
106114
PathtoPublish: artifacts/Package/Release/
107115
ArtifactName: artifacts
108116
condition: succeededOrFailed()
117+
118+
- task: PublishBuildArtifacts@1
119+
displayName: 'Publish Artifact'
120+
inputs:
121+
PathtoPublish: tools/AutoMapper/bin/Release
122+
ArtifactName: AutoMapper
123+
condition: succeededOrFailed()
124+
125+
- task: PublishBuildArtifacts@1
126+
displayName: 'Publish All Artifact For Debug'
127+
inputs:
128+
PathtoPublish: .
129+
ArtifactName: all
130+
condition: and(succeededOrFailed(), eq(variables['System.debug'], 'true'))
131+
+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using System;
2+
using System.Collections.Generic;
3+
4+
namespace AutoMapper
5+
{
6+
using Validator = Action<ValidationContext>;
7+
8+
public class AdvancedConfiguration
9+
{
10+
private readonly List<Validator> _validators = new List<Validator>();
11+
private readonly IList<Action<IConfigurationProvider>> _beforeSealActions = new List<Action<IConfigurationProvider>>();
12+
public IEnumerable<Action<IConfigurationProvider>> BeforeSealActions => _beforeSealActions;
13+
14+
/// <summary>
15+
/// Add Action called against the IConfigurationProvider before it gets sealed
16+
/// </summary>
17+
public void BeforeSeal(Action<IConfigurationProvider> action) => _beforeSealActions.Add(action);
18+
19+
/// <summary>
20+
/// Add an action to be called when validating the configuration.
21+
/// </summary>
22+
/// <param name="validator">the validation callback</param>
23+
public void Validator(Validator validator) => _validators.Add(validator);
24+
25+
public bool AllowAdditiveTypeMapCreation { get; set; }
26+
27+
/// <summary>
28+
/// How many levels deep should AutoMapper try to inline the execution plan for child classes.
29+
/// See <a href="http://automapper.readthedocs.io/en/latest/Understanding-your-mapping.html">the wiki</a> for details.
30+
/// </summary>
31+
public int MaxExecutionPlanDepth { get; set; } = 1;
32+
33+
internal Validator[] GetValidators() => _validators.ToArray();
34+
}
35+
}

tools/AutoMapper/AssemblyInfo.cs

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Reflection;
3+
using System.Resources;
4+
using System.Runtime.InteropServices;
5+
using System.Security;
6+
7+
[assembly: CLSCompliant(true)]
8+
[assembly: AllowPartiallyTrustedCallers]
9+
[assembly: ComVisible(false)]
10+
[assembly: NeutralResourcesLanguage("en")]
11+
[assembly: Guid("b38fd93e-7dc6-43d3-9081-b2f907994b74")]
12+
[assembly: AssemblyVersion("1.0.0")]
13+
[assembly: AssemblyFileVersion("6.2.2")]

tools/AutoMapper/AutoMapper.csproj

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Summary>A convention-based object-object mapper.</Summary>
5+
<Description>A convention-based object-object mapper.</Description>
6+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
7+
<AssemblyName>Microsoft.Azure.PowerShell.AutoMapper</AssemblyName>
8+
<AssemblyOriginatorKeyFile>..\..\src\MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
9+
<SignAssembly>true</SignAssembly>
10+
<Version>6.2.2</Version>
11+
<DelaySign>true</DelaySign>
12+
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
13+
<PackageId>Microsoft.Azure.PowerShell.AutoMapper</PackageId>
14+
<PackageProjectUrl>https://automapper.org</PackageProjectUrl>
15+
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
16+
<RepositoryType>git</RepositoryType>
17+
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper</RepositoryUrl>
18+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
19+
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
20+
<NoWarn>$(NoWarn);1591</NoWarn>
21+
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
22+
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
26+
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
27+
</ItemGroup>
28+
29+
<ItemGroup>
30+
<None Include="licenses\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt"/>
31+
</ItemGroup>
32+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
using System;
2+
using System.Linq;
3+
using System.Text;
4+
5+
namespace AutoMapper
6+
{
7+
public class AutoMapperConfigurationException : Exception
8+
{
9+
public TypeMapConfigErrors[] Errors { get; }
10+
public TypePair? Types { get; }
11+
public PropertyMap PropertyMap { get; set; }
12+
13+
public class TypeMapConfigErrors
14+
{
15+
public TypeMap TypeMap { get; }
16+
public string[] UnmappedPropertyNames { get; }
17+
public bool CanConstruct { get; }
18+
19+
public TypeMapConfigErrors(TypeMap typeMap, string[] unmappedPropertyNames, bool canConstruct)
20+
{
21+
TypeMap = typeMap;
22+
UnmappedPropertyNames = unmappedPropertyNames;
23+
CanConstruct = canConstruct;
24+
}
25+
}
26+
27+
public AutoMapperConfigurationException(string message)
28+
: base(message)
29+
{
30+
}
31+
32+
protected AutoMapperConfigurationException(string message, Exception inner)
33+
: base(message, inner)
34+
{
35+
}
36+
37+
public AutoMapperConfigurationException(TypeMapConfigErrors[] errors) => Errors = errors;
38+
39+
public AutoMapperConfigurationException(TypePair types) => Types = types;
40+
41+
public override string Message
42+
{
43+
get
44+
{
45+
if (Types != null)
46+
{
47+
var message =
48+
string.Format(
49+
"The following property on {0} cannot be mapped: \n\t{2} \nAdd a custom mapping expression, ignore, add a custom resolver, or modify the destination type {1}.",
50+
Types?.DestinationType.FullName, Types?.DestinationType.FullName,
51+
PropertyMap?.DestinationProperty.Name);
52+
53+
message += "\nContext:";
54+
55+
Exception exToUse = this;
56+
while (exToUse != null)
57+
{
58+
if (exToUse is AutoMapperConfigurationException configExc)
59+
{
60+
message += configExc.PropertyMap == null
61+
? $"\n\tMapping from type {configExc.Types?.SourceType.FullName} to {configExc.Types?.DestinationType.FullName}"
62+
: $"\n\tMapping to property {configExc.PropertyMap.DestinationProperty.Name} from {configExc.Types?.SourceType.FullName} to {configExc.Types?.DestinationType.FullName}";
63+
}
64+
65+
exToUse = exToUse.InnerException;
66+
}
67+
68+
return message + "\n" + base.Message;
69+
}
70+
if (Errors != null)
71+
{
72+
var message =
73+
new StringBuilder(
74+
"\nUnmapped members were found. Review the types and members below.\nAdd a custom mapping expression, ignore, add a custom resolver, or modify the source/destination type\nFor no matching constructor, add a no-arg ctor, add optional arguments, or map all of the constructor parameters\n");
75+
76+
foreach (var error in Errors)
77+
{
78+
var len = error.TypeMap.SourceType.FullName.Length +
79+
error.TypeMap.DestinationType.FullName.Length + 5;
80+
81+
message.AppendLine(new string('=', len));
82+
message.AppendLine(error.TypeMap.SourceType.Name + " -> " + error.TypeMap.DestinationType.Name +
83+
" (" +
84+
error.TypeMap.ConfiguredMemberList + " member list)");
85+
message.AppendLine(error.TypeMap.SourceType.FullName + " -> " +
86+
error.TypeMap.DestinationType.FullName + " (" +
87+
error.TypeMap.ConfiguredMemberList + " member list)");
88+
message.AppendLine();
89+
90+
if (error.UnmappedPropertyNames.Any())
91+
{
92+
message.AppendLine("Unmapped properties:");
93+
foreach (var name in error.UnmappedPropertyNames)
94+
{
95+
message.AppendLine(name);
96+
}
97+
}
98+
if (!error.CanConstruct)
99+
{
100+
message.AppendLine("No available constructor.");
101+
}
102+
}
103+
return message.ToString();
104+
}
105+
return base.Message;
106+
}
107+
}
108+
109+
public override string StackTrace
110+
{
111+
get
112+
{
113+
if (Errors != null)
114+
return string.Join(Environment.NewLine,
115+
base.StackTrace
116+
.Split(new[] {Environment.NewLine}, StringSplitOptions.None)
117+
.Where(str => !str.TrimStart().StartsWith("at AutoMapper."))
118+
.ToArray());
119+
120+
return base.StackTrace;
121+
}
122+
}
123+
}
124+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
using System;
2+
#if !DEBUG
3+
using System.Linq;
4+
#endif
5+
6+
namespace AutoMapper
7+
{
8+
public class AutoMapperMappingException : Exception
9+
{
10+
private readonly string _message;
11+
12+
//
13+
// For guidelines regarding the creation of new exception types, see
14+
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
15+
// and
16+
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
17+
//
18+
19+
public AutoMapperMappingException()
20+
{
21+
}
22+
23+
public AutoMapperMappingException(string message)
24+
: base(message) => _message = message;
25+
26+
public AutoMapperMappingException(string message, Exception innerException)
27+
: base(message, innerException) => _message = message;
28+
29+
public AutoMapperMappingException(string message, Exception innerException, TypePair types)
30+
: this(message, innerException) => Types = types;
31+
32+
public AutoMapperMappingException(string message, Exception innerException, TypePair types, TypeMap typeMap)
33+
: this(message, innerException, types) => TypeMap = typeMap;
34+
35+
public AutoMapperMappingException(string message, Exception innerException, TypePair types, TypeMap typeMap, PropertyMap propertyMap)
36+
: this(message, innerException, types, typeMap) => PropertyMap = propertyMap;
37+
38+
public TypePair? Types { get; set; }
39+
public TypeMap TypeMap { get; set; }
40+
public PropertyMap PropertyMap { get; set; }
41+
42+
public override string Message
43+
{
44+
get
45+
{
46+
var message = _message;
47+
var newLine = Environment.NewLine;
48+
if (Types?.SourceType != null && Types?.DestinationType != null)
49+
{
50+
message = message + newLine + newLine + "Mapping types:";
51+
message += newLine +
52+
$"{Types?.SourceType.Name} -> {Types?.DestinationType.Name}";
53+
message += newLine +
54+
$"{Types?.SourceType.FullName} -> {Types?.DestinationType.FullName}";
55+
}
56+
if (TypeMap != null)
57+
{
58+
message = message + newLine + newLine + "Type Map configuration:";
59+
message += newLine +
60+
$"{TypeMap.SourceType.Name} -> {TypeMap.DestinationType.Name}";
61+
message += newLine +
62+
$"{TypeMap.SourceType.FullName} -> {TypeMap.DestinationType.FullName}";
63+
}
64+
if (PropertyMap != null)
65+
{
66+
message = message + newLine + newLine + "Property:";
67+
message += newLine +
68+
$"{PropertyMap.DestinationProperty.Name}";
69+
}
70+
71+
return message;
72+
}
73+
}
74+
75+
#if !DEBUG
76+
public override string StackTrace
77+
{
78+
get
79+
{
80+
return string.Join(Environment.NewLine,
81+
base.StackTrace
82+
.Split(new[] {Environment.NewLine}, StringSplitOptions.None)
83+
.Where(str => !str.TrimStart().StartsWith("at AutoMapper.")));
84+
}
85+
}
86+
#endif
87+
}
88+
}

0 commit comments

Comments
 (0)