Skip to content

Commit

Permalink
Add AutoMapper 6.2.2 (#364)
Browse files Browse the repository at this point in the history
* Update assembly infor

* update license and version

* Add automapper 6.2.2
  • Loading branch information
dingmeng-xue authored Nov 17, 2022
1 parent 95df4e8 commit 9754fea
Show file tree
Hide file tree
Showing 170 changed files with 14,528 additions and 10 deletions.
43 changes: 33 additions & 10 deletions .azure-pipelines/Azure-PowerShell-Common-Publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,29 @@ steps:
{
throw "The value of Version $env:VERSION must be format of X.X.X"
}
displayName: 'Check Version'

- task: UseDotNet@2
displayName: 'Use dotnet sdk 2.1.302'
displayName: 'Install .NET SDK'
inputs:
version: 2.1.302
packageType: 'sdk'
version: '3.x'

- powershell: '$(Agent.ToolsDirectory)/dotnet/dotnet msbuild build.proj /t:Build /p:Configuration=Release /p:FileVersion=$env:VERSION /NoLogo'
displayName: build
displayName: build common libs

- powershell: '$(Agent.ToolsDirectory)/dotnet/dotnet build tools/AutoMapper/AutoMapper.csproj -c Release'
displayName: build AutoMapper

- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
displayName: 'dll Signing'
inputs:
ConnectedServiceName: 'ESRP Signing Service'
FolderPath: artifacts
FolderPath: .
Pattern: |
Release\netstandard2.0\Microsoft.Azure.PowerShell*.dll
!Release\netstandard2.0\Microsoft.Azure.PowerShell*.Test.dll
artifacts\Release\netstandard2.0\Microsoft.Azure.PowerShell*.dll
tools\AutoMapper\bin\Release\netstandard2.0\Microsoft.Azure.PowerShell*.dll
!artifacts\Release\netstandard2.0\Microsoft.Azure.PowerShell*.Test.dll
UseMinimatch: true
signConfigType: inlineSignParams
inlineOperation: |
Expand Down Expand Up @@ -78,8 +82,12 @@ steps:
}
]
- powershell: |
$(Agent.ToolsDirectory)/dotnet/dotnet msbuild build.proj /t:Pack /p:Configuration=Release /p:PackageVersion=$env:VERSION /NoLogo
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$(Agent.ToolsDirectory)/dotnet/dotnet msbuild build.proj /t:Pack /p:Configuration=Release /p:PackageVersion=$env:VERSION /NoLogo
$(Agent.ToolsDirectory)/dotnet/dotnet pack tools/AutoMapper/AutoMapper.csproj -c Release --no-build
displayName: pack

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

Expand All @@ -106,3 +114,18 @@ steps:
PathtoPublish: artifacts/Package/Release/
ArtifactName: artifacts
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact'
inputs:
PathtoPublish: tools/AutoMapper/bin/Release
ArtifactName: AutoMapper
condition: succeededOrFailed()

- task: PublishBuildArtifacts@1
displayName: 'Publish All Artifact For Debug'
inputs:
PathtoPublish: .
ArtifactName: all
condition: and(succeededOrFailed(), eq(variables['System.debug'], 'true'))

35 changes: 35 additions & 0 deletions tools/AutoMapper/AdvancedConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;

namespace AutoMapper
{
using Validator = Action<ValidationContext>;

public class AdvancedConfiguration
{
private readonly List<Validator> _validators = new List<Validator>();
private readonly IList<Action<IConfigurationProvider>> _beforeSealActions = new List<Action<IConfigurationProvider>>();
public IEnumerable<Action<IConfigurationProvider>> BeforeSealActions => _beforeSealActions;

/// <summary>
/// Add Action called against the IConfigurationProvider before it gets sealed
/// </summary>
public void BeforeSeal(Action<IConfigurationProvider> action) => _beforeSealActions.Add(action);

/// <summary>
/// Add an action to be called when validating the configuration.
/// </summary>
/// <param name="validator">the validation callback</param>
public void Validator(Validator validator) => _validators.Add(validator);

public bool AllowAdditiveTypeMapCreation { get; set; }

/// <summary>
/// How many levels deep should AutoMapper try to inline the execution plan for child classes.
/// See <a href="http://automapper.readthedocs.io/en/latest/Understanding-your-mapping.html">the wiki</a> for details.
/// </summary>
public int MaxExecutionPlanDepth { get; set; } = 1;

internal Validator[] GetValidators() => _validators.ToArray();
}
}
13 changes: 13 additions & 0 deletions tools/AutoMapper/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System;
using System.Reflection;
using System.Resources;
using System.Runtime.InteropServices;
using System.Security;

[assembly: CLSCompliant(true)]
[assembly: AllowPartiallyTrustedCallers]
[assembly: ComVisible(false)]
[assembly: NeutralResourcesLanguage("en")]
[assembly: Guid("b38fd93e-7dc6-43d3-9081-b2f907994b74")]
[assembly: AssemblyVersion("1.0.0")]
[assembly: AssemblyFileVersion("6.2.2")]
32 changes: 32 additions & 0 deletions tools/AutoMapper/AutoMapper.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Summary>A convention-based object-object mapper.</Summary>
<Description>A convention-based object-object mapper.</Description>
<TargetFrameworks>netstandard2.0</TargetFrameworks>
<AssemblyName>Microsoft.Azure.PowerShell.AutoMapper</AssemblyName>
<AssemblyOriginatorKeyFile>..\..\src\MSSharedLibKey.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<Version>6.2.2</Version>
<DelaySign>true</DelaySign>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Microsoft.Azure.PowerShell.AutoMapper</PackageId>
<PackageProjectUrl>https://automapper.org</PackageProjectUrl>
<PackageLicenseFile>LICENSE.txt</PackageLicenseFile>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/AutoMapper/AutoMapper</RepositoryUrl>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
<NoWarn>$(NoWarn);1591</NoWarn>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.3.0" />
<PackageReference Include="System.Reflection.Emit" Version="4.3.0" />
</ItemGroup>

<ItemGroup>
<None Include="licenses\LICENSE.txt" Pack="true" PackagePath="LICENSE.txt"/>
</ItemGroup>
</Project>
124 changes: 124 additions & 0 deletions tools/AutoMapper/AutoMapperConfigurationException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
using System;
using System.Linq;
using System.Text;

namespace AutoMapper
{
public class AutoMapperConfigurationException : Exception
{
public TypeMapConfigErrors[] Errors { get; }
public TypePair? Types { get; }
public PropertyMap PropertyMap { get; set; }

public class TypeMapConfigErrors
{
public TypeMap TypeMap { get; }
public string[] UnmappedPropertyNames { get; }
public bool CanConstruct { get; }

public TypeMapConfigErrors(TypeMap typeMap, string[] unmappedPropertyNames, bool canConstruct)
{
TypeMap = typeMap;
UnmappedPropertyNames = unmappedPropertyNames;
CanConstruct = canConstruct;
}
}

public AutoMapperConfigurationException(string message)
: base(message)
{
}

protected AutoMapperConfigurationException(string message, Exception inner)
: base(message, inner)
{
}

public AutoMapperConfigurationException(TypeMapConfigErrors[] errors) => Errors = errors;

public AutoMapperConfigurationException(TypePair types) => Types = types;

public override string Message
{
get
{
if (Types != null)
{
var message =
string.Format(
"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}.",
Types?.DestinationType.FullName, Types?.DestinationType.FullName,
PropertyMap?.DestinationProperty.Name);

message += "\nContext:";

Exception exToUse = this;
while (exToUse != null)
{
if (exToUse is AutoMapperConfigurationException configExc)
{
message += configExc.PropertyMap == null
? $"\n\tMapping from type {configExc.Types?.SourceType.FullName} to {configExc.Types?.DestinationType.FullName}"
: $"\n\tMapping to property {configExc.PropertyMap.DestinationProperty.Name} from {configExc.Types?.SourceType.FullName} to {configExc.Types?.DestinationType.FullName}";
}

exToUse = exToUse.InnerException;
}

return message + "\n" + base.Message;
}
if (Errors != null)
{
var message =
new StringBuilder(
"\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");

foreach (var error in Errors)
{
var len = error.TypeMap.SourceType.FullName.Length +
error.TypeMap.DestinationType.FullName.Length + 5;

message.AppendLine(new string('=', len));
message.AppendLine(error.TypeMap.SourceType.Name + " -> " + error.TypeMap.DestinationType.Name +
" (" +
error.TypeMap.ConfiguredMemberList + " member list)");
message.AppendLine(error.TypeMap.SourceType.FullName + " -> " +
error.TypeMap.DestinationType.FullName + " (" +
error.TypeMap.ConfiguredMemberList + " member list)");
message.AppendLine();

if (error.UnmappedPropertyNames.Any())
{
message.AppendLine("Unmapped properties:");
foreach (var name in error.UnmappedPropertyNames)
{
message.AppendLine(name);
}
}
if (!error.CanConstruct)
{
message.AppendLine("No available constructor.");
}
}
return message.ToString();
}
return base.Message;
}
}

public override string StackTrace
{
get
{
if (Errors != null)
return string.Join(Environment.NewLine,
base.StackTrace
.Split(new[] {Environment.NewLine}, StringSplitOptions.None)
.Where(str => !str.TrimStart().StartsWith("at AutoMapper."))
.ToArray());

return base.StackTrace;
}
}
}
}
88 changes: 88 additions & 0 deletions tools/AutoMapper/AutoMapperMappingException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using System;
#if !DEBUG
using System.Linq;
#endif

namespace AutoMapper
{
public class AutoMapperMappingException : Exception
{
private readonly string _message;

//
// For guidelines regarding the creation of new exception types, see
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/cpconerrorraisinghandlingguidelines.asp
// and
// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncscol/html/csharp07192001.asp
//

public AutoMapperMappingException()
{
}

public AutoMapperMappingException(string message)
: base(message) => _message = message;

public AutoMapperMappingException(string message, Exception innerException)
: base(message, innerException) => _message = message;

public AutoMapperMappingException(string message, Exception innerException, TypePair types)
: this(message, innerException) => Types = types;

public AutoMapperMappingException(string message, Exception innerException, TypePair types, TypeMap typeMap)
: this(message, innerException, types) => TypeMap = typeMap;

public AutoMapperMappingException(string message, Exception innerException, TypePair types, TypeMap typeMap, PropertyMap propertyMap)
: this(message, innerException, types, typeMap) => PropertyMap = propertyMap;

public TypePair? Types { get; set; }
public TypeMap TypeMap { get; set; }
public PropertyMap PropertyMap { get; set; }

public override string Message
{
get
{
var message = _message;
var newLine = Environment.NewLine;
if (Types?.SourceType != null && Types?.DestinationType != null)
{
message = message + newLine + newLine + "Mapping types:";
message += newLine +
$"{Types?.SourceType.Name} -> {Types?.DestinationType.Name}";
message += newLine +
$"{Types?.SourceType.FullName} -> {Types?.DestinationType.FullName}";
}
if (TypeMap != null)
{
message = message + newLine + newLine + "Type Map configuration:";
message += newLine +
$"{TypeMap.SourceType.Name} -> {TypeMap.DestinationType.Name}";
message += newLine +
$"{TypeMap.SourceType.FullName} -> {TypeMap.DestinationType.FullName}";
}
if (PropertyMap != null)
{
message = message + newLine + newLine + "Property:";
message += newLine +
$"{PropertyMap.DestinationProperty.Name}";
}

return message;
}
}

#if !DEBUG
public override string StackTrace
{
get
{
return string.Join(Environment.NewLine,
base.StackTrace
.Split(new[] {Environment.NewLine}, StringSplitOptions.None)
.Where(str => !str.TrimStart().StartsWith("at AutoMapper.")));
}
}
#endif
}
}
Loading

0 comments on commit 9754fea

Please sign in to comment.