Skip to content

Commit

Permalink
Merge branch 'rmuller/fix-dotnet-anonymousobject' into rmuller/fix-ne…
Browse files Browse the repository at this point in the history
…sted-foreign-class
  • Loading branch information
RomainMuller committed Aug 11, 2020
2 parents 4a69d07 + 2dc4a23 commit 0f211ed
Show file tree
Hide file tree
Showing 17 changed files with 19,582 additions and 20,471 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,10 @@ jobs:
# Run the integration test
- name: Install Dependencies
run: |-
# Python tools used during packaging
python3 -m pip install --upgrade pipx setuptools twine wheel
# TypeScript project dependencies
yarn install --frozen-lockfile
working-directory: aws-cdk
- name: Install Tested Packages
Expand Down
2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime-test/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ obj/
node_modules/
.nyc_output/
coverage/

.nuget/
1 change: 0 additions & 1 deletion packages/@jsii/dotnet-runtime-test/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,3 @@
!*.nupkg
!package.json
!index.js

2 changes: 1 addition & 1 deletion packages/@jsii/dotnet-runtime-test/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -euo pipefail
test="./test"

# Generate NuGet packages for jsii-calc and its dependencies.
jsii-pacmak -vv -t dotnet --recurse -o ${test}/generated ../../jsii-calc
jsii-pacmak -t dotnet --recurse -o ${test}/generated ../../jsii-calc

# Generate Directory.Build.props
/usr/bin/env node ./Directory.Build.props.t.js > ${test}/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public RuntimeException(string message)
const string Prefix = nameof(IntegrationTests) + ".Compliance.";

private readonly IDisposable _serviceContainerFixture;

public ComplianceTests(ITestOutputHelper outputHelper, ServiceContainerFixture serviceContainerFixture)
{
serviceContainerFixture.SetOverride(outputHelper);
Expand Down Expand Up @@ -1475,5 +1475,19 @@ public void CollectionOfInterfaces_MapOfInterfaces()
Assert.IsAssignableFrom<IBell>(elt);
}
}

[Fact(DisplayName = Prefix + nameof(BurriedAnonymousObject))]
public void BurriedAnonymousObject()
{
var subject = new BurriedAnonymousObjectImpl();
Assert.True(subject.Check());
}

private sealed class BurriedAnonymousObjectImpl : BurriedAnonymousObject
{
public override object GiveItBack(object value) {
return value;
}
}
}
}
11 changes: 11 additions & 0 deletions packages/@jsii/dotnet-runtime-test/test/NuGet.Config
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="@jsii/dotnet-runtime" value="../../dotnet-runtime/bin/Release/NuGet" />
<add key="generated" value="./generated/dotnet" />
</packageSources>
<config>
<add key="globalPackagesFolder" value="./.nuget/packages" />
</config>
</configuration>

9 changes: 0 additions & 9 deletions packages/@jsii/dotnet-runtime-test/test/NuGet.config

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Amazon.JSII.JsonModel.Spec;
using Amazon.JSII.Runtime.Deputy;
using System;

namespace Amazon.JSII.Runtime.Services.Converters
Expand Down Expand Up @@ -89,8 +90,17 @@ protected bool IsNumeric(System.Type type)
return null;
}

if (value is AnonymousObject)
{
if (!TryConvertClass(type, referenceMap, value, out var anonResult))
{
throw new Exception("Unable to convert AnonymousObject instance!");
}
return anonResult;
}

TypeReference reference = InferType(referenceMap, value);
if (TryConvert(reference, type, referenceMap, value, out object? result))
if (TryConvert(reference, type, referenceMap, value, out var result))
{
return result;
}
Expand Down
24 changes: 24 additions & 0 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,30 @@ export class UmaskCheck {
private constructor() {}
}

/**
* See https://github.com/aws/aws-cdk/issues/7977
*/
export abstract class BurriedAnonymousObject {
public check(): boolean {
const anonymousObject = {
method() {
return true;
},
};
const result = this.giveItBack({ anonymousObject });
return anonymousObject === result.anonymousObject;
}

/**
* Implement this method and have it return it's parameter.
*
* @param value the value that should be returned.
*
* @returns `value`
*/
public abstract giveItBack(value: any): any;
}

/** Does nothing with provided arguments, useful to artifically use parameters */
function consume(..._args: readonly any[]) {
return;
Expand Down
68 changes: 67 additions & 1 deletion packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1623,6 +1623,72 @@
}
]
},
"jsii-calc.BurriedAnonymousObject": {
"abstract": true,
"assembly": "jsii-calc",
"docs": {
"stability": "experimental",
"summary": "See https://github.com/aws/aws-cdk/issues/7977."
},
"fqn": "jsii-calc.BurriedAnonymousObject",
"initializer": {
"docs": {
"stability": "experimental"
}
},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2767
},
"methods": [
{
"docs": {
"stability": "experimental"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2768
},
"name": "check",
"returns": {
"type": {
"primitive": "boolean"
}
}
},
{
"abstract": true,
"docs": {
"returns": "`value`",
"stability": "experimental",
"summary": "Implement this method and have it return it's parameter."
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 2785
},
"name": "giveItBack",
"parameters": [
{
"docs": {
"summary": "the value that should be returned."
},
"name": "value",
"type": {
"primitive": "any"
}
}
],
"returns": {
"type": {
"primitive": "any"
}
}
}
],
"name": "BurriedAnonymousObject"
},
"jsii-calc.Calculator": {
"assembly": "jsii-calc",
"base": "jsii-calc.composition.CompositeOperation",
Expand Down Expand Up @@ -13753,5 +13819,5 @@
}
},
"version": "0.0.0",
"fingerprint": "mLU0hvK9Teaq2GAeeCGFPwAZab85G7lFIH/VCKgAvp4="
"fingerprint": "NsqdwWgXi+kjrpLQtQ27eA/znULJ7TtXy03ht68N9Ms="
}
27 changes: 22 additions & 5 deletions packages/jsii-pacmak/lib/targets/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,25 @@ export default class Python extends Target {
await shell('python3', ['setup.py', 'sdist', '--dist-dir', outDir], {
cwd: sourceDir,
});
await shell('python3', ['setup.py', 'bdist_wheel', '--dist-dir', outDir], {
cwd: sourceDir,
});
await shell(
'python3',
['-m', 'pip', 'wheel', '--no-deps', '--wheel-dir', outDir, sourceDir],
{
cwd: sourceDir,
},
);
if (await isPresent('twine', sourceDir)) {
await shell('twine', ['check', path.join(outDir, '*')], {
cwd: sourceDir,
});
} else if (await isPresent('pipx', sourceDir)) {
await shell('pipx', ['run', 'twine', 'check', path.join(outDir, '*')], {
cwd: sourceDir,
env: {
...process.env,
PIPX_HOME: path.join(sourceDir, '.pipx'),
},
});
} else {
warn(
'Unable to validate distribution packages because `twine` is not present. ' +
Expand Down Expand Up @@ -1649,6 +1661,9 @@ class Package {
(this.metadata.author.email !== undefined
? `<${this.metadata.author.email}>`
: ''),
bdist_wheel: {
universal: true,
},
project_urls: {
Source: this.metadata.repository.url,
},
Expand All @@ -1659,7 +1674,9 @@ class Package {
install_requires: [
`jsii${toPythonVersionRange(`^${jsiiVersionSimple}`)}`,
'publication>=0.0.3',
].concat(dependencies),
]
.concat(dependencies)
.sort(),
classifiers: [
'Intended Audience :: Developers',
'Operating System :: OS Independent',
Expand Down Expand Up @@ -1719,7 +1736,7 @@ class Package {
// TODO: Might be easier to just use a TOML library to write this out.
code.openFile('pyproject.toml');
code.line('[build-system]');
code.line('requires = ["setuptools >= 38.6.0", "wheel >= 0.31.0"]');
code.line('requires = ["setuptools >= 49.3.1", "wheel >= 0.34.2"]');
code.line('build-backend = "setuptools.build_meta"');
code.closeFile('pyproject.toml');

Expand Down
5 changes: 3 additions & 2 deletions packages/jsii-pacmak/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"watch": "tsc --build -w",
"lint": "eslint . --ext .js,.ts --ignore-path=.gitignore",
"lint:fix": "yarn lint --fix",
"test": "jest && bash test/build-test.sh",
"test:update": "jest -u && bash test/build-test.sh",
"test": "jest && npm run test:build",
"test:build": "bash test/build-test.sh",
"test:update": "jest -u && npm run test:build",
"package": "package-js"
},
"dependencies": {
Expand Down
Loading

0 comments on commit 0f211ed

Please sign in to comment.