From c38771d7778c731d12a6295f5e12fece40bb6552 Mon Sep 17 00:00:00 2001 From: Dan Schulte Date: Fri, 22 Apr 2016 14:43:33 -0700 Subject: [PATCH] Fix FXCopy issues --- ...oRest.Generator.AzureResourceSchema.csproj | 2 +- .../AzureResourceSchemaCodeGenerator.cs | 18 +++++-------- .../Properties/AssemblyInfo.cs | 4 ++- .../AzureResourceSchema/Resource.cs | 14 +++++------ .../AzureResourceSchema/ResourceProperty.cs | 16 ++++++------ .../{Schema.cs => ResourceSchema.cs} | 25 ++++++++++--------- 6 files changed, 39 insertions(+), 40 deletions(-) rename AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/{Schema.cs => ResourceSchema.cs} (89%) diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj index e7549af2d27f0..985dda8db10b8 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AutoRest.Generator.AzureResourceSchema.csproj @@ -31,7 +31,7 @@ - + Properties\AssemblyVersionInfo.cs diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AzureResourceSchemaCodeGenerator.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AzureResourceSchemaCodeGenerator.cs index ed8daccd728bf..04553f6ea2c0c 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AzureResourceSchemaCodeGenerator.cs +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/AzureResourceSchemaCodeGenerator.cs @@ -63,7 +63,7 @@ public override async Task Generate(ServiceClient serviceClient) writer.Indentation = 2; writer.IndentChar = ' '; - Schema schema = Schema.Parse(serviceClient); + ResourceSchema schema = ResourceSchema.Parse(serviceClient); WriteSchema(writer, schema); } @@ -76,12 +76,12 @@ public override async Task Generate(ServiceClient serviceClient) } } - private static void WriteSchema(JsonTextWriter writer, Schema schema) + private static void WriteSchema(JsonTextWriter writer, ResourceSchema schema) { WriteObject(writer, () => { WriteProperty(writer, "id", schema.Id); - WriteProperty(writer, "$schema", schema.SchemaUri); + WriteProperty(writer, "$schema", "http://json-schema.org/draft-04/schema#"); WriteProperty(writer, "title", schema.Title); WriteProperty(writer, "description", schema.Description); WriteProperty(writer, "resourceDefinitions", () => @@ -105,7 +105,7 @@ private static void WriteResource(JsonTextWriter writer, Resource resource) { WriteProperty(writer, "enum", new string[] { - resource.Type + resource.ResourceType }); }); @@ -147,9 +147,9 @@ private static void WriteResourceProperty(JsonTextWriter writer, ResourcePropert { WriteObjectOrExpression(writer, () => { - if (resourceProperty.Type != null) + if (resourceProperty.PropertyType != null) { - WriteProperty(writer, "type", resourceProperty.Type); + WriteProperty(writer, "type", resourceProperty.PropertyType); } if (resourceProperty.AllowedValues != null) @@ -196,12 +196,6 @@ private static void WriteProperty(JsonTextWriter writer, string propertyName, st writer.WriteValue(propertyValue); } - private static void WriteProperty(JsonTextWriter writer, string propertyName, int propertyValue) - { - writer.WritePropertyName(propertyName); - writer.WriteValue(propertyValue); - } - private static void WriteProperty(JsonTextWriter writer, string propertyName, Action writeObjectContents) { writer.WritePropertyName(propertyName); diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs index cd800eca11c4b..37bc04b37366f 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Properties/AssemblyInfo.cs @@ -1,4 +1,5 @@ -using System.Reflection; +using System; +using System.Reflection; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -31,4 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] +[assembly: CLSCompliant(true)] [assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Resource.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Resource.cs index fc1a67175cbcb..1c64d2ef150b2 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Resource.cs +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Resource.cs @@ -9,15 +9,15 @@ namespace Microsoft.Rest.Generator.AzureResourceSchema public class Resource { private readonly string name; - private readonly string type; + private readonly string resourceType; private readonly string[] apiVersions; private readonly IEnumerable properties; private readonly string description; - public Resource(string name, string type, string[] apiVersions, IEnumerable properties, string description) + public Resource(string name, string resourceType, string[] apiVersions, IEnumerable properties, string description) { this.name = name; - this.type = type; + this.resourceType = resourceType; this.apiVersions = apiVersions; this.properties = properties; this.description = description; @@ -28,12 +28,12 @@ public string Name get { return name; } } - public string Type + public string ResourceType { - get { return type; } + get { return resourceType; } } - public string[] ApiVersions + public IEnumerable ApiVersions { get { return apiVersions; } } @@ -43,7 +43,7 @@ public IEnumerable Properties get { return properties; } } - public string[] RequiredPropertyNames + public IEnumerable RequiredPropertyNames { get { return Properties.Where(property => property.IsRequired).Select(property => property.Name).ToArray(); } } diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceProperty.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceProperty.cs index ecb0c10a6b52e..7212e90200bc7 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceProperty.cs +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceProperty.cs @@ -1,21 +1,23 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. +using System.Collections.Generic; + namespace Microsoft.Rest.Generator.AzureResourceSchema { public class ResourceProperty { private readonly string name; private readonly bool isRequired; - private readonly string type; - private readonly string[] allowedValues; + private readonly string propertyType; + private readonly IEnumerable allowedValues; private readonly string description; - public ResourceProperty(string name, bool isRequired = false, string type = null, string[] allowedValues = null, string description = null) + public ResourceProperty(string name, bool isRequired, string propertyType, IEnumerable allowedValues, string description) { this.name = name; this.isRequired = isRequired; - this.type = type; + this.propertyType = propertyType; this.allowedValues = allowedValues; this.description = description; } @@ -30,12 +32,12 @@ public bool IsRequired get { return isRequired; } } - public string Type + public string PropertyType { - get { return type; } + get { return propertyType; } } - public string[] AllowedValues + public IEnumerable AllowedValues { get { return allowedValues; } } diff --git a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Schema.cs b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchema.cs similarity index 89% rename from AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Schema.cs rename to AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchema.cs index be3e1d0600a7e..c10ae6bb29b6a 100644 --- a/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/Schema.cs +++ b/AutoRest/Generators/AzureResourceSchema/AzureResourceSchema/ResourceSchema.cs @@ -4,11 +4,12 @@ using Microsoft.Rest.Generator.ClientModel; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; namespace Microsoft.Rest.Generator.AzureResourceSchema { - public class Schema + public class ResourceSchema { private const string resourceMethodPrefix = "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/"; @@ -17,7 +18,7 @@ public class Schema private readonly string description; private readonly IEnumerable resources; - private Schema(string id, string title, string description, IEnumerable resources) + private ResourceSchema(string id, string title, string description, IEnumerable resources) { this.id = id; this.title = title; @@ -30,11 +31,6 @@ public string Id get { return id; } } - public string SchemaUri - { - get { return "http://json-schema.org/draft-04/schema#"; } - } - public string Title { get { return title; } @@ -50,12 +46,17 @@ public IEnumerable Resources get { return resources; } } - public static Schema Parse(ServiceClient serviceClient) + public static ResourceSchema Parse(ServiceClient serviceClient) { + if (serviceClient == null) + { + throw new ArgumentNullException("serviceClient"); + } + string resourceProvider = GetResourceProvider(serviceClient); string apiVersion = serviceClient.ApiVersion; - string id = String.Format("http://schema.management.azure.com/schemas/{0}/{1}.json#", apiVersion, resourceProvider); + string id = String.Format(CultureInfo.InvariantCulture, "http://schema.management.azure.com/schemas/{0}/{1}.json#", apiVersion, resourceProvider); string title = resourceProvider; @@ -85,7 +86,7 @@ public static Schema Parse(ServiceClient serviceClient) bool propertyIsRequired = property.IsRequired; string propertyType = null; string[] allowedValues = null; - string propertyDescription = String.Format("{0}: {1}", resourceType, property.Documentation); + string propertyDescription = String.Format(CultureInfo.InvariantCulture, "{0}: {1}", resourceType, property.Documentation); if(property.Type is EnumType) { @@ -108,12 +109,12 @@ public static Schema Parse(ServiceClient serviceClient) } } - return new Schema(id, title, description, resources); + return new ResourceSchema(id, title, description, resources); } private static IEnumerable GetResourceMethods(ServiceClient serviceClient) { - return serviceClient.Methods.Where(method => method.Url.StartsWith(resourceMethodPrefix)); + return serviceClient.Methods.Where(method => method.Url.StartsWith(resourceMethodPrefix, StringComparison.Ordinal)); } private static string GetResourceProvider(ServiceClient serviceClient)