Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(kernel): annotate implemented interfaces on "ObjRef"s #825

Merged
merged 26 commits into from
Oct 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
00fa430
feat: annotate implemented interfaces on "ObjRef"s
RomainMuller Sep 26, 2019
9eacf3c
WIP
RomainMuller Sep 30, 2019
62bbf5c
WIP progress
RomainMuller Oct 4, 2019
aad06b8
finished fixing java
RomainMuller Oct 7, 2019
64b205b
fixup regression test expectations
RomainMuller Oct 8, 2019
1e11b33
fix python runtime
RomainMuller Oct 8, 2019
5f93693
fixup licensing info in NuGet packages
RomainMuller Oct 10, 2019
a71a418
improve NuGet package metadata
RomainMuller Oct 10, 2019
c601bc5
fix dotnet runtime
RomainMuller Oct 14, 2019
b07d21e
fixup unit tests
RomainMuller Oct 14, 2019
7499a01
Merge remote-tracking branch 'origin/master' into rmuller/fix-object-bug
RomainMuller Oct 15, 2019
ab176e5
Merge remote-tracking branch 'origin/master' into rmuller/fix-object-bug
RomainMuller Oct 16, 2019
3661615
Merge branch 'master' into rmuller/fix-object-bug
RomainMuller Oct 17, 2019
05c9e6b
Merge remote-tracking branch 'origin/master' into rmuller/fix-object-bug
RomainMuller Oct 17, 2019
49e5297
Merge remote-tracking branch 'origin/rmuller/fix-object-bug' into rmu…
RomainMuller Oct 17, 2019
27b5f8d
minor style fixes
RomainMuller Oct 18, 2019
db831aa
Merge branch 'master' into rmuller/fix-object-bug
RomainMuller Oct 22, 2019
271121e
some minor tuning
RomainMuller Oct 23, 2019
f015570
Merge remote-tracking branch 'origin/master' into rmuller/fix-object-bug
RomainMuller Oct 24, 2019
d2c11f0
fixup expecations
RomainMuller Oct 24, 2019
5cea023
Merge remote-tracking branch 'origin/master' into rmuller/fix-object-bug
RomainMuller Oct 29, 2019
a3ffd12
stop using deprecated API
RomainMuller Oct 29, 2019
45af794
add some test coverage
RomainMuller Oct 29, 2019
a7f445f
Merge branch 'master' into rmuller/fix-object-bug
RomainMuller Oct 29, 2019
bf8800f
fix test I forgot to update as I changed the code
RomainMuller Oct 29, 2019
997afb2
Merge remote-tracking branch 'origin/master' into rmuller/fix-object-bug
RomainMuller Oct 29, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"bump": "bash scripts/bump.sh",
"fetch-dotnet-snk": "bash scripts/fetch-dotnet-snk.sh",
"package": "bash scripts/package.sh",
"test": "lerna run test --stream"
"test": "lerna run test --stream",
"test:update": "UPDATE_DIFF=1 lerna run test --stream"
},
"devDependencies": {
"@types/node": "^10.17.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/jsii-calc-base-of-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "jsii",
"test": "diff-test test/assembly.jsii .jsii"
"test": "diff-test test/assembly.jsii .jsii",
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
},
"devDependencies": {
"jsii": "^0.19.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/jsii-calc-base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "jsii",
"test": "diff-test test/assembly.jsii .jsii"
"test": "diff-test test/assembly.jsii .jsii",
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
},
"dependencies": {
"@scope/jsii-calc-base-of-base": "^0.19.0"
Expand Down
3 changes: 2 additions & 1 deletion packages/jsii-calc-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
"types": "lib/index.d.ts",
"scripts": {
"build": "jsii",
"test": "diff-test test/assembly.jsii .jsii"
"test": "diff-test test/assembly.jsii .jsii",
"test:update": "npm run build && UPDATE_DIFF=1 npm run test"
},
"dependencies": {
"@scope/jsii-calc-base": "^0.19.0"
Expand Down
36 changes: 34 additions & 2 deletions packages/jsii-calc/lib/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1438,7 +1438,7 @@ export class EraseUndefinedHashValues {
/**
* We expect "prop2" to be erased
*/
public static prop2IsUndefined(): any {
public static prop2IsUndefined(): { [key: string]: any } {
return {
prop1: 'value1',
prop2: undefined
Expand All @@ -1448,7 +1448,7 @@ export class EraseUndefinedHashValues {
/**
* We expect "prop1" to be erased
*/
public static prop1IsNull(): any {
public static prop1IsNull(): { [key: string]: any } {
return {
prop1: null,
prop2: 'value2'
Expand Down Expand Up @@ -1944,3 +1944,35 @@ export interface SupportsNiceJavaBuilderProps {
*/
readonly bar: number;
}

/**
* We can return an anonymous interface implementation from an override without losing the interface
* declarations.
*/
export interface IAnonymousImplementationProvider {
provideAsInterface(): IAnonymouslyImplementMe;
provideAsClass(): Implementation;
}
export class AnonymousImplementationProvider implements IAnonymousImplementationProvider {
private readonly instance = new PrivateType();

public provideAsClass(): Implementation {
return this.instance;
}

public provideAsInterface(): IAnonymouslyImplementMe {
return this.instance;
}
}
export class Implementation {
readonly value = 1337;
}
export interface IAnonymouslyImplementMe {
readonly value: number;
verb(): string;
}
class PrivateType extends Implementation implements IAnonymouslyImplementMe {
public verb() {
return 'to implement';
}
}
193 changes: 190 additions & 3 deletions packages/jsii-calc/test/assembly.jsii
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,57 @@
],
"name": "AllowedMethodNames"
},
"jsii-calc.AnonymousImplementationProvider": {
"assembly": "jsii-calc",
"docs": {
"stability": "experimental"
},
"fqn": "jsii-calc.AnonymousImplementationProvider",
"initializer": {},
"interfaces": [
"jsii-calc.IAnonymousImplementationProvider"
],
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1956
},
"methods": [
{
"docs": {
"stability": "experimental"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1959
},
"name": "provideAsClass",
"overrides": "jsii-calc.IAnonymousImplementationProvider",
"returns": {
"type": {
"fqn": "jsii-calc.Implementation"
}
}
},
{
"docs": {
"stability": "experimental"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1963
},
"name": "provideAsInterface",
"overrides": "jsii-calc.IAnonymousImplementationProvider",
"returns": {
"type": {
"fqn": "jsii-calc.IAnonymouslyImplementMe"
}
}
}
],
"name": "AnonymousImplementationProvider"
},
"jsii-calc.AsyncVirtualMethods": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -3318,7 +3369,12 @@
"name": "prop1IsNull",
"returns": {
"type": {
"primitive": "any"
"collection": {
"elementtype": {
"primitive": "any"
},
"kind": "map"
}
}
},
"static": true
Expand All @@ -3335,7 +3391,12 @@
"name": "prop2IsUndefined",
"returns": {
"type": {
"primitive": "any"
"collection": {
"elementtype": {
"primitive": "any"
},
"kind": "map"
}
}
},
"static": true
Expand Down Expand Up @@ -3790,6 +3851,102 @@
],
"name": "GreetingAugmenter"
},
"jsii-calc.IAnonymousImplementationProvider": {
"assembly": "jsii-calc",
"docs": {
"stability": "experimental",
"summary": "We can return an anonymous interface implementation from an override without losing the interface declarations."
},
"fqn": "jsii-calc.IAnonymousImplementationProvider",
"kind": "interface",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1952
},
"methods": [
{
"abstract": true,
"docs": {
"stability": "experimental"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1954
},
"name": "provideAsClass",
"returns": {
"type": {
"fqn": "jsii-calc.Implementation"
}
}
},
{
"abstract": true,
"docs": {
"stability": "experimental"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1953
},
"name": "provideAsInterface",
"returns": {
"type": {
"fqn": "jsii-calc.IAnonymouslyImplementMe"
}
}
}
],
"name": "IAnonymousImplementationProvider"
},
"jsii-calc.IAnonymouslyImplementMe": {
"assembly": "jsii-calc",
"docs": {
"stability": "experimental"
},
"fqn": "jsii-calc.IAnonymouslyImplementMe",
"kind": "interface",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1970
},
"methods": [
{
"abstract": true,
"docs": {
"stability": "experimental"
},
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1972
},
"name": "verb",
"returns": {
"type": {
"primitive": "string"
}
}
}
],
"name": "IAnonymouslyImplementMe",
"properties": [
{
"abstract": true,
"docs": {
"stability": "experimental"
},
"immutable": true,
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1971
},
"name": "value",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.IAnotherPublicInterface": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -4740,6 +4897,36 @@
}
]
},
"jsii-calc.Implementation": {
"assembly": "jsii-calc",
"docs": {
"stability": "experimental"
},
"fqn": "jsii-calc.Implementation",
"initializer": {},
"kind": "class",
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1967
},
"name": "Implementation",
"properties": [
{
"docs": {
"stability": "experimental"
},
"immutable": true,
"locationInModule": {
"filename": "lib/compliance.ts",
"line": 1968
},
"name": "value",
"type": {
"primitive": "number"
}
}
]
},
"jsii-calc.ImplementsInterfaceWithInternal": {
"assembly": "jsii-calc",
"docs": {
Expand Down Expand Up @@ -9932,5 +10119,5 @@
}
},
"version": "0.19.0",
"fingerprint": "98k0qPH9S801EvX681aTDIxgufKA90iJ4SlfZKrm90c="
"fingerprint": "MZT68aeJ7MEeDJORDPKkIyqOqOLC+Yb3LcDU7XrxgCQ="
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Amazon.JSII.JsonModel.Api
{
[JsonDictionary]
public class ObjectReference : JsonDictionaryBase<string, string>
public class ObjectReference : JsonDictionaryBase<string, object>
{
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@

[assembly: CollectionBehavior(DisableTestParallelization = true)]

#pragma warning disable CS0612

namespace Amazon.JSII.Runtime.IntegrationTests
{
/// <summary>
/// Ported from packages/jsii-java-runtime/src/test/java/org/jsii/testing/ComplianceTest.java.
/// </summary>
public class ComplianceTests : IClassFixture<ServiceContainerFixture>
public sealed class ComplianceTests : IClassFixture<ServiceContainerFixture>
{
class RuntimeException : Exception
{
Expand Down Expand Up @@ -127,12 +129,18 @@ public void DynamicTypes()
Assert.Equal(UnixEpoch.AddSeconds(1234), types.AnyProperty);

// json (notice that when deserialized, it is deserialized as a map).
types.AnyProperty = new JObject(new JProperty("Goo",
new JArray(
"Hello",
new JObject(new JProperty("World", 123))
)
));
types.AnyProperty = new Dictionary<string, object>
{
{ "Goo", new object[]
{
"Hello",
new Dictionary<string, object>
{
{ "World", 123 }
}
}
}
};
var @object = (IDictionary<string, object>) types.AnyProperty;
var array = (object[]) @object["Goo"];
var innerObject = (IDictionary<string, object>) array[1];
Expand Down Expand Up @@ -999,6 +1007,15 @@ public void MethodCanReturnArraysOfInterfaces()
Assert.Equal(4, interfaces.Length);
}

[Fact(DisplayName = Prefix + nameof(CanLeverageIndirectInterfacePolymorphism))]
public void CanLeverageIndirectInterfacePolymorphism()
{
var provider = new AnonymousImplementationProvider();
Assert.Equal(1337d, provider.ProvideAsClass().Value);
Assert.Equal(1337d, provider.ProvideAsInterface().Value);
Assert.Equal("to implement", provider.ProvideAsInterface().Verb());
}

class DataRendererSubclass : DataRenderer
{
[JsiiMethod("renderMap", returnsJson: "{\"type\":{\"primitive\":\"string\"}}", parametersJson: "[{\"name\":\"map\",\"type\":{\"collection\":{\"kind\":\"map\",\"elementtype\":{\"primitive\":\"any\"}}}}]", isOverride: true)]
Expand Down
Loading