From cfe4aade271e43606cd19fe3efe38cc7f42bc61b Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Wed, 11 Sep 2019 14:38:42 -0700 Subject: [PATCH 1/9] Fix #3244 and all the arrays of objects issues --- ...mazon.JSII.Runtime.IntegrationTests.csproj | 2 +- .../Converters/FrameworkToJsiiConverter.cs | 45 ++++++++++++++----- .../lib/targets/dotnet/filegenerator.ts | 3 +- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj index e36a80021e..086b0c8af9 100644 --- a/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj +++ b/packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj @@ -1,7 +1,7 @@  - netcoreapp2.0 + netcoreapp2.1 false diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs index 2f02b6ec52..e53243c2a8 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs @@ -157,7 +157,7 @@ protected override bool TryConvertJson(object value, out object result) return true; } - if (value.GetType().IsAssignableFrom(typeof(JObject))) + if (value.GetType().IsAssignableFrom(typeof(JObject)) || value.GetType().IsAssignableFrom(typeof(JArray))) { result = value; return true; @@ -263,16 +263,39 @@ protected override bool TryConvertMap(IReferenceMap referenceMap, TypeReference foreach (string key in keys) { object element = indexer.GetValue(value, new object[] {key}); - - TypeReference childElementType = InferType(referenceMap, element); - - // We should not pass the parent element type as we are in a map - // A map could be a map etc - // If we pass the parent referenceMap then it will try to convert it as Any - // So by inferring the child element type we are always converting the correct type. - // See https://github.com/aws/aws-cdk/issues/2496 - if (!TryConvert(childElementType, referenceMap, element, out object convertedElement)) + bool converted; + object convertedElement; + if (element is IDictionary || element is object[]) + { + var objectType = InferType(referenceMap, element); + switch (objectType.Collection?.Kind) + { + case CollectionKind.Map: + // We should not pass the parent element type as we are + // in a map containing another map. + // If we pass the parent referenceMap then it will try to convert it as Any + // So we can directly convert to another map here, and forgo the type hierarchy + // induced by elementType + // See https://github.com/aws/aws-cdk/issues/2496 + converted = TryConvertMap(referenceMap, elementType, element, out convertedElement); + break; + case CollectionKind.Array: + // The [object] could be another array. (ie Tags) + // https://github.com/aws/aws-cdk/issues/3244 + converted = TryConvertArray(referenceMap, elementType, element, out convertedElement); + break; + default: + converted = TryConvert(elementType, referenceMap, element, out convertedElement); + break; + } + } + else + { + converted = TryConvert(elementType, referenceMap, element, out convertedElement); + } + + if (!converted) { result = null; return false; @@ -328,7 +351,7 @@ TypeReference InferType(IReferenceMap referenceMap, Type type) return new TypeReference(primitive: PrimitiveType.Date); } - if (type.IsAssignableFrom(typeof(JObject))) + if (type.IsAssignableFrom(typeof(JObject)) || type.IsAssignableFrom(typeof(JArray))) { return new TypeReference(primitive: PrimitiveType.Json); } diff --git a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts index 0b9a291e2c..e279dee8f2 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts @@ -50,7 +50,7 @@ export class FileGenerator { const rootNode = xmlbuilder.create('Project', {encoding: 'UTF-8', headless: true}); rootNode.att("Sdk", "Microsoft.NET.Sdk"); const propertyGroup = rootNode.ele("PropertyGroup"); - propertyGroup.ele("TargetFramework", "netstandard2.0"); + propertyGroup.ele("TargetFrameworks", "netcoreapp2.1"); propertyGroup.ele("GeneratePackageOnBuild", "true"); propertyGroup.ele("IncludeSymbols", "true"); propertyGroup.ele("IncludeSource", "true"); @@ -58,6 +58,7 @@ export class FileGenerator { propertyGroup.ele("PackageId", packageId); propertyGroup.ele("Description", this.getDescription()); propertyGroup.ele("ProjectUrl", assembly.homepage); + propertyGroup.ele("PackageIconUrl", `https://sdk-for-net.amazonwebservices.com/images/AWSLogo128x128.png`); propertyGroup.ele("LicenseUrl", `https://spdx.org/licenses/${assembly.license}.html`); propertyGroup.ele("Authors", assembly.author.name); propertyGroup.ele("Language", "en-US"); From 8174463488fc79b5892f205d5adfefa93a8de4c0 Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Wed, 11 Sep 2019 15:46:53 -0700 Subject: [PATCH 2/9] Refactored into its own method --- .../Converters/FrameworkToJsiiConverter.cs | 71 ++++++++++--------- 1 file changed, 38 insertions(+), 33 deletions(-) diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs index e53243c2a8..7873aa7284 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs @@ -223,7 +223,7 @@ protected override bool TryConvertArray(IReferenceMap referenceMap, TypeReferenc JArray resultArray = new JArray(); foreach (object element in array) { - if (!TryConvert(elementType, referenceMap, element, out object convertedElement)) + if (!TryConvertCollectionElement(element, referenceMap, elementType, out object convertedElement)) { result = null; return false; @@ -263,39 +263,8 @@ protected override bool TryConvertMap(IReferenceMap referenceMap, TypeReference foreach (string key in keys) { object element = indexer.GetValue(value, new object[] {key}); - - bool converted; - object convertedElement; - if (element is IDictionary || element is object[]) - { - var objectType = InferType(referenceMap, element); - switch (objectType.Collection?.Kind) - { - case CollectionKind.Map: - // We should not pass the parent element type as we are - // in a map containing another map. - // If we pass the parent referenceMap then it will try to convert it as Any - // So we can directly convert to another map here, and forgo the type hierarchy - // induced by elementType - // See https://github.com/aws/aws-cdk/issues/2496 - converted = TryConvertMap(referenceMap, elementType, element, out convertedElement); - break; - case CollectionKind.Array: - // The [object] could be another array. (ie Tags) - // https://github.com/aws/aws-cdk/issues/3244 - converted = TryConvertArray(referenceMap, elementType, element, out convertedElement); - break; - default: - converted = TryConvert(elementType, referenceMap, element, out convertedElement); - break; - } - } - else - { - converted = TryConvert(elementType, referenceMap, element, out convertedElement); - } - if (!converted) + if (!TryConvertCollectionElement(element, referenceMap, elementType, out object convertedElement)) { result = null; return false; @@ -308,6 +277,42 @@ protected override bool TryConvertMap(IReferenceMap referenceMap, TypeReference return true; } + private bool TryConvertCollectionElement(object element, IReferenceMap referenceMap, TypeReference elementType, + out object convertedElement) + { + bool converted; + if (element is IDictionary || element is object[]) + { + var objectType = InferType(referenceMap, element); + switch (objectType.Collection?.Kind) + { + case CollectionKind.Map: + // We should not pass the parent element type as we are + // in a map containing another map. + // If we pass the parent referenceMap then it will try to convert it as Any + // So we can directly convert to another map here, and forgo the type hierarchy + // induced by elementType + // See https://github.com/aws/aws-cdk/issues/2496 + converted = TryConvertMap(referenceMap, elementType, element, out convertedElement); + break; + case CollectionKind.Array: + // The [object] could be another array. (ie Tags) + // https://github.com/aws/aws-cdk/issues/3244 + converted = TryConvertArray(referenceMap, elementType, element, out convertedElement); + break; + default: + converted = TryConvert(elementType, referenceMap, element, out convertedElement); + break; + } + } + else + { + converted = TryConvert(elementType, referenceMap, element, out convertedElement); + } + + return converted; + } + protected override TypeReference InferType(IReferenceMap referenceMap, object value) { value = value ?? throw new ArgumentNullException(nameof(value)); From 5b0410a7b467ebad3e6c1e2629545f2e83c7d816 Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Thu, 12 Sep 2019 14:13:27 -0700 Subject: [PATCH 3/9] Adding a test to cover the ConvertCollectionElement --- .../FrameworkToJsiiConverterTests.cs | 53 +++++++++++++++++++ .../Converters/FrameworkToJsiiConverter.cs | 19 +++++-- .../lib/targets/dotnet/filegenerator.ts | 3 +- ...s.CalculatorPackageId.BasePackageId.csproj | 2 +- ...ts.CalculatorPackageId.LibPackageId.csproj | 2 +- ...azon.JSII.Tests.CalculatorPackageId.csproj | 2 +- 6 files changed, 73 insertions(+), 8 deletions(-) diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs index dfa74c5fa5..d849fb65a6 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs @@ -450,6 +450,59 @@ public void RecursivelyConvertsArrayElements() } ); } + + [Fact(DisplayName = _Prefix + nameof(RecursivelyConvertsMapElementsWithAny))] + public void RecursivelyConvertsMapElementsWithAny() + { + var instance = new OptionalValue(new TypeReference + ( + collection: new CollectionTypeReference(CollectionKind.Map, + new TypeReference + ( + collection: new CollectionTypeReference(CollectionKind.Array, + new TypeReference(primitive: PrimitiveType.Any) + ) + ) + ) + )); + + var frameworkArray = new Dictionary() + { + {"key", new [] { "true" }}, + {"key2", new [] { false }}, + }; + + // This will test the call to FrameworkToJsiiConverter.TryConvertCollectionElement() + // In the case of a of a Map of Array of Any + bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object actual); + + Assert.True(success); + Assert.IsType(actual); + Assert.Collection + ( + ((IEnumerable>)actual).OrderBy(kvp => kvp.Key), + kvp => + { + Assert.Equal("key", kvp.Key); + Assert.IsType(kvp.Value); + Assert.Collection + ( + (JArray)kvp.Value, + subValue => Assert.Equal("true", subValue) + ); + }, + kvp => + { + Assert.Equal("key2", kvp.Key, ignoreLineEndingDifferences: true); + Assert.IsType(kvp.Value); + Assert.Collection + ( + (JArray)kvp.Value, + subValue => Assert.Equal(false, subValue) + ); + } + ); + } [Fact(DisplayName = _Prefix + nameof(ConvertsNullMap))] public void ConvertsNullMap() diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs index 7873aa7284..64c9882810 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs @@ -277,6 +277,14 @@ protected override bool TryConvertMap(IReferenceMap referenceMap, TypeReference return true; } + /// + /// Converts a collection element + /// + /// The element to convert in the collection + /// The known references map + /// The TypeReference of the element, as seen by Jsii + /// out: the converted element + /// True if the conversion was successful, false otherwise private bool TryConvertCollectionElement(object element, IReferenceMap referenceMap, TypeReference elementType, out object convertedElement) { @@ -284,21 +292,26 @@ private bool TryConvertCollectionElement(object element, IReferenceMap reference if (element is IDictionary || element is object[]) { var objectType = InferType(referenceMap, element); + var nestedType = elementType.Primitive == PrimitiveType.Any ? elementType : objectType.Collection.ElementType; switch (objectType.Collection?.Kind) { case CollectionKind.Map: // We should not pass the parent element type as we are // in a map containing another map. - // If we pass the parent referenceMap then it will try to convert it as Any + // If we pass the parent elementType then it will try to convert it as Any // So we can directly convert to another map here, and forgo the type hierarchy // induced by elementType // See https://github.com/aws/aws-cdk/issues/2496 - converted = TryConvertMap(referenceMap, elementType, element, out convertedElement); + converted = + TryConvertMap(referenceMap, nestedType, element, + out convertedElement); break; case CollectionKind.Array: // The [object] could be another array. (ie Tags) // https://github.com/aws/aws-cdk/issues/3244 - converted = TryConvertArray(referenceMap, elementType, element, out convertedElement); + converted = + TryConvertArray(referenceMap, nestedType, element, + out convertedElement); break; default: converted = TryConvert(elementType, referenceMap, element, out convertedElement); diff --git a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts index e279dee8f2..6da261fd42 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts @@ -58,7 +58,6 @@ export class FileGenerator { propertyGroup.ele("PackageId", packageId); propertyGroup.ele("Description", this.getDescription()); propertyGroup.ele("ProjectUrl", assembly.homepage); - propertyGroup.ele("PackageIconUrl", `https://sdk-for-net.amazonwebservices.com/images/AWSLogo128x128.png`); propertyGroup.ele("LicenseUrl", `https://spdx.org/licenses/${assembly.license}.html`); propertyGroup.ele("Authors", assembly.author.name); propertyGroup.ele("Language", "en-US"); @@ -78,7 +77,7 @@ export class FileGenerator { } if (dotnetInfo!.iconUrl != null) { - propertyGroup.ele("IconUrl", dotnetInfo!.iconUrl); + propertyGroup.ele("PackageIconUrl", dotnetInfo!.iconUrl); } const itemGroup1 = rootNode.ele("ItemGroup"); diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj index 89ecd00f8c..44d187931d 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + netcoreapp2.1 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj index 08dcc3d370..5bd118fc58 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + netcoreapp2.1 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj index 937ade62f5..cc671985f6 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj @@ -1,6 +1,6 @@ - netstandard2.0 + netcoreapp2.1 true true true From 6c2256152218bf5e4149972c7619d9558d9fd754 Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Thu, 12 Sep 2019 16:02:42 -0700 Subject: [PATCH 4/9] Adding a test for maps of maps of any --- .../FrameworkToJsiiConverterTests.cs | 63 ++++++++++++++++++- 1 file changed, 61 insertions(+), 2 deletions(-) diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs index d849fb65a6..eab0a03419 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs @@ -451,8 +451,67 @@ public void RecursivelyConvertsArrayElements() ); } - [Fact(DisplayName = _Prefix + nameof(RecursivelyConvertsMapElementsWithAny))] - public void RecursivelyConvertsMapElementsWithAny() + [Fact(DisplayName = _Prefix + nameof(RecursivelyConvertsMapElementsWithMapOfAny))] + public void RecursivelyConvertsMapElementsWithMapOfAny() + { + var instance = new OptionalValue(new TypeReference( + collection: new CollectionTypeReference(CollectionKind.Map, + new TypeReference( + collection: new CollectionTypeReference(CollectionKind.Map, + new TypeReference(primitive: PrimitiveType.Any) + ) + ) + ) + )); + + var frameworkMap = new Dictionary> + { + { "myKey1", new Dictionary { { "mySubKey1", "myValue1" } } }, + { "myKey2", new Dictionary { { "mySubKey2", "myValue2" } } }, + }; + + // This will test the call to FrameworkToJsiiConverter.TryConvertCollectionElement() + // In the case of a of a Map of Map of Any + bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object actual); + + Assert.True(success); + Assert.IsType(actual); + Assert.Collection + ( + ((IEnumerable>)actual).OrderBy(kvp => kvp.Key), + kvp => + { + Assert.Equal("myKey1", kvp.Key); + Assert.IsType(kvp.Value); + Assert.Collection + ( + ((IEnumerable>)kvp.Value), + subKvp => + { + Assert.Equal("mySubKey1", subKvp.Key, ignoreLineEndingDifferences: true); + Assert.Equal("myValue1", subKvp.Value); + } + ); + }, + kvp => + { + Assert.Equal("myKey2", kvp.Key, ignoreLineEndingDifferences: true); + Assert.IsType(kvp.Value); + Assert.Collection + ( + ((IEnumerable>)kvp.Value), + subKvp => + { + Assert.Equal("mySubKey2", subKvp.Key, ignoreLineEndingDifferences: true); + Assert.Equal("myValue2", subKvp.Value); + } + ); + } + ); + } + + [Fact(DisplayName = _Prefix + nameof(RecursivelyConvertsMapElementsWithArrayOfAny))] + public void RecursivelyConvertsMapElementsWithArrayOfAny() { var instance = new OptionalValue(new TypeReference ( From d613e84dd1a1541c09df3fea48ac29ae64d744cb Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Thu, 12 Sep 2019 16:36:01 -0700 Subject: [PATCH 5/9] Cosmetic: removing a typo on TargetFramework --- packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts | 2 +- .../Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj | 2 +- .../Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj | 2 +- .../Amazon.JSII.Tests.CalculatorPackageId.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts index 6da261fd42..d9aa460a8d 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts @@ -50,7 +50,7 @@ export class FileGenerator { const rootNode = xmlbuilder.create('Project', {encoding: 'UTF-8', headless: true}); rootNode.att("Sdk", "Microsoft.NET.Sdk"); const propertyGroup = rootNode.ele("PropertyGroup"); - propertyGroup.ele("TargetFrameworks", "netcoreapp2.1"); + propertyGroup.ele("TargetFramework", "netcoreapp2.1"); propertyGroup.ele("GeneratePackageOnBuild", "true"); propertyGroup.ele("IncludeSymbols", "true"); propertyGroup.ele("IncludeSource", "true"); diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj index 44d187931d..b57a70089b 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.1 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj index 5bd118fc58..59a298fba7 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.1 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj index cc671985f6..f2920f822a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.1 true true true From 7023aacbf5245d5ea73058641c4e8c1ba966e257 Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Thu, 12 Sep 2019 19:00:59 -0700 Subject: [PATCH 6/9] Fixing a typo on TargetFrameworks because of a manual regen --- .../Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj | 2 +- .../Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj | 2 +- .../Amazon.JSII.Tests.CalculatorPackageId.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj index b57a70089b..a2c3adeb0a 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.1 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj index 59a298fba7..06f6a86b40 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.1 true true true diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj index f2920f822a..498674a95d 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj @@ -1,6 +1,6 @@ - netcoreapp2.1 + netcoreapp2.1 true true true From 728a00ae500d1b1e68a045b62593054dfffe4662 Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Tue, 17 Sep 2019 11:34:11 -0700 Subject: [PATCH 7/9] Even better with the changes included ... --- packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts | 1 + .../Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj | 1 + .../Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj | 1 + .../Amazon.JSII.Tests.CalculatorPackageId.csproj | 1 + 4 files changed, 4 insertions(+) diff --git a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts index d9aa460a8d..9fe7e19ca7 100644 --- a/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts +++ b/packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts @@ -52,6 +52,7 @@ export class FileGenerator { const propertyGroup = rootNode.ele("PropertyGroup"); propertyGroup.ele("TargetFramework", "netcoreapp2.1"); propertyGroup.ele("GeneratePackageOnBuild", "true"); + propertyGroup.ele("GenerateDocumentationFile", "true"); propertyGroup.ele("IncludeSymbols", "true"); propertyGroup.ele("IncludeSource", "true"); propertyGroup.ele("PackageVersion", this.getDecoratedVersion(assembly)); diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj index a2c3adeb0a..085473c5d5 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-base/dotnet/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId/Amazon.JSII.Tests.CalculatorPackageId.BasePackageId.csproj @@ -2,6 +2,7 @@ netcoreapp2.1 true + true true true 0.16.0 diff --git a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj index 06f6a86b40..1e38a797c0 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc-lib/dotnet/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId/Amazon.JSII.Tests.CalculatorPackageId.LibPackageId.csproj @@ -2,6 +2,7 @@ netcoreapp2.1 true + true true true 0.16.0-devpreview diff --git a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj index 498674a95d..5ae1404dfc 100644 --- a/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj +++ b/packages/jsii-pacmak/test/expected.jsii-calc/dotnet/Amazon.JSII.Tests.CalculatorPackageId/Amazon.JSII.Tests.CalculatorPackageId.csproj @@ -2,6 +2,7 @@ netcoreapp2.1 true + true true true 0.16.0 From 82aed64fad7d8378ad49cc63dc79939097201bd6 Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Tue, 17 Sep 2019 11:50:53 -0700 Subject: [PATCH 8/9] Simple refactoring --- .../Services/Converters/FrameworkToJsiiConverter.cs | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs index 64c9882810..9284cff6f5 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs @@ -288,7 +288,6 @@ protected override bool TryConvertMap(IReferenceMap referenceMap, TypeReference private bool TryConvertCollectionElement(object element, IReferenceMap referenceMap, TypeReference elementType, out object convertedElement) { - bool converted; if (element is IDictionary || element is object[]) { var objectType = InferType(referenceMap, element); @@ -302,28 +301,24 @@ private bool TryConvertCollectionElement(object element, IReferenceMap reference // So we can directly convert to another map here, and forgo the type hierarchy // induced by elementType // See https://github.com/aws/aws-cdk/issues/2496 - converted = - TryConvertMap(referenceMap, nestedType, element, + return TryConvertMap(referenceMap, nestedType, element, out convertedElement); break; case CollectionKind.Array: // The [object] could be another array. (ie Tags) // https://github.com/aws/aws-cdk/issues/3244 - converted = - TryConvertArray(referenceMap, nestedType, element, + return TryConvertArray(referenceMap, nestedType, element, out convertedElement); break; default: - converted = TryConvert(elementType, referenceMap, element, out convertedElement); + return TryConvert(elementType, referenceMap, element, out convertedElement); break; } } else { - converted = TryConvert(elementType, referenceMap, element, out convertedElement); + return TryConvert(elementType, referenceMap, element, out convertedElement); } - - return converted; } protected override TypeReference InferType(IReferenceMap referenceMap, object value) From 54010b9ab3348b6dfb6017485a1df186261bd3df Mon Sep 17 00:00:00 2001 From: Hamza Assyad Date: Tue, 17 Sep 2019 11:53:15 -0700 Subject: [PATCH 9/9] No need to break - refactoring --- .../Services/Converters/FrameworkToJsiiConverter.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs index 9284cff6f5..5912f3f75c 100644 --- a/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs +++ b/packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/Services/Converters/FrameworkToJsiiConverter.cs @@ -303,16 +303,13 @@ private bool TryConvertCollectionElement(object element, IReferenceMap reference // See https://github.com/aws/aws-cdk/issues/2496 return TryConvertMap(referenceMap, nestedType, element, out convertedElement); - break; case CollectionKind.Array: // The [object] could be another array. (ie Tags) // https://github.com/aws/aws-cdk/issues/3244 return TryConvertArray(referenceMap, nestedType, element, out convertedElement); - break; default: return TryConvert(elementType, referenceMap, element, out convertedElement); - break; } } else