Skip to content

Commit

Permalink
Merge pull request #2 from Azure/master
Browse files Browse the repository at this point in the history
Merge changes from base repository
  • Loading branch information
NiklasGustafsson committed Mar 1, 2016
2 parents 3c0682e + 77613e4 commit 705495a
Show file tree
Hide file tree
Showing 551 changed files with 14,164 additions and 4,256 deletions.
4 changes: 2 additions & 2 deletions AutoRest/AutoRest.Core/ClientModel/CompositeType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public CompositeType()
/// <summary>
/// Gets or sets the list of CompositeType properties.
/// </summary>
public IList<Property> Properties { get; private set; }
public List<Property> Properties { get; private set; }

/// <summary>
/// Gets the union of Parent and current type properties
Expand Down Expand Up @@ -75,7 +75,7 @@ public IEnumerable<Property> ComposedProperties
/// <summary>
/// Gets the union of Parent and current type properties
/// </summary>
public IDictionary<string, object> ComposedExtensions
public Dictionary<string, object> ComposedExtensions
{
get
{
Expand Down
2 changes: 1 addition & 1 deletion AutoRest/AutoRest.Core/ClientModel/EnumType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public EnumType()
/// <summary>
/// Gets or sets the enum values.
/// </summary>
public IList<EnumValue> Values { get; private set; }
public List<EnumValue> Values { get; private set; }

/// <summary>
/// Gets or sets the model type name on the wire.
Expand Down
5 changes: 3 additions & 2 deletions AutoRest/AutoRest.Core/ClientModel/Method.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public Parameter Body
/// <summary>
/// Gets the list of input Parameter transformations
/// </summary>
public IList<ParameterTransformation> InputParameterTransformation { get; private set; }
public List<ParameterTransformation> InputParameterTransformation { get; private set; }

/// <summary>
/// Gets or sets request headers.
Expand Down Expand Up @@ -168,7 +168,8 @@ public override string ToString()
/// <returns></returns>
public object Clone()
{
Method newMethod = (Method)this.MemberwiseClone();
Method newMethod = new Method();
newMethod.LoadFrom(this);
newMethod.Extensions = new Dictionary<string, object>();
newMethod.Parameters = new List<Parameter>();
newMethod.RequestHeaders = new Dictionary<string, string>();
Expand Down
4 changes: 3 additions & 1 deletion AutoRest/AutoRest.Core/ClientModel/Parameter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Rest.Generator.Utilities;

namespace Microsoft.Rest.Generator.ClientModel
{
Expand Down Expand Up @@ -99,7 +100,8 @@ public override string ToString()
/// <returns>A deep clone of current object.</returns>
public object Clone()
{
Parameter param = (Parameter)this.MemberwiseClone();
Parameter param = new Parameter();
param.LoadFrom(this);
return param;
}
}
Expand Down
7 changes: 2 additions & 5 deletions AutoRest/AutoRest.Core/ClientModel/ParameterMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace Microsoft.Rest.Generator.ClientModel
{
using System;
using System.Globalization;

using Utilities;
/// <summary>
/// Defines a parameter mapping.
/// </summary>
Expand Down Expand Up @@ -53,11 +53,8 @@ public override string ToString()
/// <returns>A deep clone of current object.</returns>
public object Clone()
{
//ParameterMapping paramMapping = (ParameterMapping)this.MemberwiseClone();
//return paramMapping;

ParameterMapping mapping = new ParameterMapping();
mapping.InputParameter = this.InputParameter;
mapping.InputParameter = (Parameter)this.InputParameter.Clone();
mapping.InputParameterProperty = this.InputParameterProperty;
mapping.OutputParameterProperty = this.OutputParameterProperty;
return mapping;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public ParameterTransformation()
/// <summary>
/// Gets the list of Parameter Mappings
/// </summary>
public IList<ParameterMapping> ParameterMappings { get; private set; }
public List<ParameterMapping> ParameterMappings { get; private set; }

/// <summary>
/// Returns a string representation of the ParameterMapping object.
Expand Down
6 changes: 5 additions & 1 deletion AutoRest/AutoRest.Core/ClientModel/Property.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Rest.Generator.Utilities;

namespace Microsoft.Rest.Generator.ClientModel
{
Expand Down Expand Up @@ -93,7 +94,10 @@ public override string ToString()
/// <returns>A deep clone of current object.</returns>
public object Clone()
{
var property = (Property) this.MemberwiseClone();
Property property = new Property();
property.LoadFrom(this);
property.Constraints = new Dictionary<Constraint, string>(this.Constraints);
property.Extensions = new Dictionary<string, object>(this.Extensions);
return property;
}
}
Expand Down
12 changes: 6 additions & 6 deletions AutoRest/AutoRest.Core/ClientModel/ServiceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,32 @@ public ServiceClient()
/// <summary>
/// Gets or sets the client parameters.
/// </summary>
public IList<Property> Properties { get; private set; }
public List<Property> Properties { get; private set; }

/// <summary>
/// Gets the model types.
/// </summary>
public ISet<CompositeType> ModelTypes { get; private set; }
public HashSet<CompositeType> ModelTypes { get; private set; }

/// <summary>
/// Gets the enum types.
/// </summary>
public ISet<EnumType> EnumTypes { get; private set; }
public HashSet<EnumType> EnumTypes { get; private set; }

/// <summary>
/// Gets the list of error type for customize exceptions.
/// </summary>
public ISet<CompositeType> ErrorTypes { get; private set; }
public HashSet<CompositeType> ErrorTypes { get; private set; }

/// <summary>
/// Gets the list of header types.
/// </summary>
public ISet<CompositeType> HeaderTypes { get; private set; }
public HashSet<CompositeType> HeaderTypes { get; private set; }

/// <summary>
/// Gets the methods.
/// </summary>
public IList<Method> Methods { get; private set; }
public List<Method> Methods { get; private set; }

/// <summary>
/// Gets the method groups.
Expand Down
8 changes: 2 additions & 6 deletions AutoRest/AutoRest.Core/CodeNamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,16 +198,12 @@ public virtual void NormalizeMethod(Method method)
{
if (parameterMapping.InputParameterProperty != null)
{
parameterMapping.InputParameterProperty = string.Join(".",
parameterMapping.InputParameterProperty.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
.Select(p => GetPropertyName(p)));
parameterMapping.InputParameterProperty = GetPropertyName(parameterMapping.InputParameterProperty);
}

if (parameterMapping.OutputParameterProperty != null)
{
parameterMapping.OutputParameterProperty = string.Join(".",
parameterMapping.OutputParameterProperty.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries)
.Select(p => GetPropertyName(p)));
parameterMapping.OutputParameterProperty = GetPropertyName(parameterMapping.OutputParameterProperty);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions AutoRest/AutoRest.Core/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly", MessageId = "Rfc", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.KnownPrimaryType.#DateTimeRfc1123")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.PrimaryType.#Type")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA2204:Literals should be spelled correctly", MessageId = "FileSystem", Scope = "member", Target = "Microsoft.Rest.Generator.Extensibility.ExtensionsLoader.#GetConfigurationFileContent(Microsoft.Rest.Generator.Settings)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.CompositeType.#Properties")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.EnumType.#Values")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.Method.#InputParameterTransformation")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.ServiceClient.#Methods")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.ServiceClient.#Properties")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.ParameterTransformation.#ParameterMappings")]

10 changes: 10 additions & 0 deletions AutoRest/AutoRest.Core/Utilities/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -168,6 +169,15 @@ public static TU LoadFrom<TU, TV>(this TU destination, TV source)
sourceProperty.PropertyType == destinationProperty.PropertyType &&
sourceProperty.SetMethod != null)
{
if (destinationProperty.PropertyType.IsGenericType && sourceProperty.GetValue(source, null) is IEnumerable)
{
var ctor = destinationProperty.PropertyType.GetConstructor(new[] { destinationProperty.PropertyType });
if (ctor != null)
{
destinationProperty.SetValue(destination, ctor.Invoke(new[] { sourceProperty.GetValue(source, null) }), null);
continue;
}
}
destinationProperty.SetValue(destination, sourceProperty.GetValue(source, null), null);
}
}
Expand Down
Loading

0 comments on commit 705495a

Please sign in to comment.