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

fix: dotnet abstract classes should have proxy implementations #241

Merged
merged 4 commits into from
Sep 22, 2018

Conversation

costleya
Copy link
Contributor

Abstract classes have can implementations that are not shared through jsii. When trying to instantiate one for these types as a return value, the runtime crashes. This change creates proxy class types for abstract classes. These types can be instantiated, and have implementations for any methods/properties marked as abstract.

Fixes #223

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Abstract classes have can implementations that are not shared thorugh jsii. When trying to instantiate one for these types as a return value, the runtime crashes.
This change creates proxy class types for abstract classes. These types can be instantiated, and have implementations for any methods/properties marked as abstract.

Fixes aws#223
Copy link
Contributor

@rix0rrr rix0rrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having a hard time reviewing this. Are you okay with me just trusting you?

@eladb
Copy link
Contributor

eladb commented Sep 21, 2018

Please make sure you add the conformance test returnAbstract

It would be nice if we could find a way to enforce that all language bindings implement all the conformance tests...

Add the ReturnsAbstract test to the complaince suite. This test ensures that proxy implementations are returned from methods that return a abstract class or interface.
* Add .DS_Store to .gitignore
* Rename JsiiInterfaceProxyAttribute to JsiiTypeProxy
* Proxy implementations are sealed
* Removed redundant checks for proxy resolution in runtime.

Refactor of aws#241
@costleya
Copy link
Contributor Author

@eladb can you approve this and merge when you get the chance if there are no more issues?

@eladb eladb merged commit 828a26f into aws:master Sep 22, 2018
@IndikaUdagedara
Copy link

Has this already been released as nuget?

eladb pushed a commit that referenced this pull request Oct 9, 2018
### Bug Fixes

* **dotnet:** abstract classes should have proxy implementations ([#241](#241)) ([828a26f](828a26f)), closes [#223](#223)
* **jsii:** better usage reporting of private types ([#247](#247)) ([96ac5d6](96ac5d6))
* **jsii-runtime:** Use buffer factory methods instead of constructor. ([#246](#246)) ([6ad6b9d](6ad6b9d))
* **kernel:** Return object literals as references ([#249](#249)) ([61cb3a4](61cb3a4)), closes [#248](#248) [aws/aws-cdk#774](aws/aws-cdk#774)
@eladb eladb mentioned this pull request Oct 9, 2018
eladb pushed a commit that referenced this pull request Oct 10, 2018
Bug Fixes
=========

* **dotnet:** abstract classes should have proxy implementations ([#241](#241)) ([828a26f](828a26f)), closes [#223](#223)
* **jsii:** better usage reporting of private types ([#247](#247)) ([96ac5d6](96ac5d6))
* **jsii:** support  public autoproperties in private constructor ([#256](#256)) ([181012e](181012e))
* **jsii:** use default jsx compiler options ([#260](#260)) ([660ae79](660ae79)), closes [aws/aws-cdk#830](aws/aws-cdk#830)
* **jsii-dotnet-generator:** Use FQ type returns in conflict. ([#258](#258)) ([a78784a](a78784a)), closes [#252](#252)
* **jsii-runtime:** Use buffer factory methods instead of constructor. ([#246](#246)) ([6ad6b9d](6ad6b9d))
* **kernel:** Return object literals as references ([#249](#249)) ([61cb3a4](61cb3a4)), closes [#248](#248) [aws/aws-cdk#774](aws/aws-cdk#774)

Misc
====

bump.sh was updated to let "lerna publish" automatically determine
the version number using conventional commits.
eladb pushed a commit that referenced this pull request Oct 10, 2018
Bug Fixes
=========

* **dotnet:** abstract classes should have proxy implementations ([#241](#241)) ([828a26f](828a26f)), closes [#223](#223)
* **jsii:** better usage reporting of private types ([#247](#247)) ([96ac5d6](96ac5d6))
* **jsii:** support  public autoproperties in private constructor ([#256](#256)) ([181012e](181012e))
* **jsii:** use default jsx compiler options ([#260](#260)) ([660ae79](660ae79)), closes [aws/aws-cdk#830](aws/aws-cdk#830)
* **jsii-dotnet-generator:** Use FQ type returns in conflict. ([#258](#258)) ([a78784a](a78784a)), closes [#252](#252)
* **jsii-runtime:** Use buffer factory methods instead of constructor. ([#246](#246)) ([6ad6b9d](6ad6b9d))
* **kernel:** Return object literals as references ([#249](#249)) ([61cb3a4](61cb3a4)), closes [#248](#248) [aws/aws-cdk#774](aws/aws-cdk#774)

Misc
====

bump.sh was updated to let "lerna publish" automatically determine
the version number using conventional commits.
mergify bot pushed a commit that referenced this pull request Apr 4, 2022
…2 in /packages/@jsii/python-runtime (#3470)

Updates the requirements on [cattrs](https://github.com/python-attrs/cattrs) to permit the latest version.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/python-attrs/cattrs/blob/main/HISTORY.rst">cattrs's changelog</a>.</em></p>
<blockquote>
<h2>22.1.0 (2022-04-03)</h2>
<ul>
<li>cattrs now uses the CalVer versioning convention.</li>
<li>cattrs now has a detailed validation mode, which is enabled by default. Learn more <code>here &lt;https://cattrs.readthedocs.io/en/latest/validation.html&gt;</code>_.
The old behavior can be restored by creating the converter with <code>detailed_validation=False</code>.</li>
<li><code>attrs</code> and dataclass structuring is now ~25% faster.</li>
<li>Fix an issue structuring bare <code>typing.List</code> s on Pythons lower than 3.9.
(<code>[#209](python-attrs/cattrs#209) &lt;https://github.com/python-attrs/cattrs/issues/209&gt;</code>_)</li>
<li>Fix structuring of non-parametrized containers like <code>list/dict/...</code> on Pythons lower than 3.9.
(<code>[#218](python-attrs/cattrs#218) &lt;https://github.com/python-attrs/cattrs/issues/218&gt;</code>_)</li>
<li>Fix structuring bare <code>typing.Tuple</code> on Pythons lower than 3.9.
(<code>[#218](python-attrs/cattrs#218) &lt;https://github.com/python-attrs/cattrs/issues/218&gt;</code>_)</li>
<li>Fix a wrong <code>AttributeError</code> of an missing <code>__parameters__</code> attribute. This could happen
when inheriting certain generic classes – for example <code>typing.*</code> classes are affected.
(<code>[#217](python-attrs/cattrs#217) &lt;https://github.com/python-attrs/cattrs/issues/217&gt;</code>_)</li>
<li>Fix structuring of <code>enum.Enum</code> instances in <code>typing.Literal</code> types.
(<code>[#231](python-attrs/cattrs#231) &lt;https://github.com/python-attrs/cattrs/pull/231&gt;</code>_)</li>
<li>Fix unstructuring all tuples - unannotated, variable-length, homogenous and heterogenous - to <code>list</code>.
(<code>[#226](python-attrs/cattrs#226) &lt;https://github.com/python-attrs/cattrs/issues/226&gt;</code>_)</li>
<li>For <code>forbid_extra_keys</code> raise custom <code>ForbiddenExtraKeyError</code> instead of generic <code>Exception</code>.
(<code>[#225](python-attrs/cattrs#225) &lt;https://github.com/python-attrs/cattrs/pull/225&gt;</code>_)</li>
<li>All preconf converters now support <code>loads</code> and <code>dumps</code> directly. See an example <code>here &lt;https://cattrs.readthedocs.io/en/latest/preconf.html&gt;</code>_.</li>
<li>Fix mappings with byte keys for the orjson, bson and tomlkit converters.
(<code>[#241](python-attrs/cattrs#241) &lt;https://github.com/python-attrs/cattrs/issues/241&gt;</code>_)</li>
</ul>
<h2>1.10.0 (2022-01-04)</h2>
<ul>
<li>Add PEP 563 (string annotations) support for dataclasses.
(<code>[#195](python-attrs/cattrs#195) &lt;https://github.com/python-attrs/cattrs/issues/195&gt;</code>_)</li>
<li>Fix handling of dictionaries with string Enum keys for bson, orjson, and tomlkit.</li>
<li>Rename the <code>cattr.gen.make_dict_unstructure_fn.omit_if_default</code> parameter to <code>_cattrs_omit_if_default</code>, for consistency. The <code>omit_if_default</code> parameters to <code>GenConverter</code> and <code>override</code> are unchanged.</li>
<li>Following the changes in <code>attrs</code> 21.3.0, add a <code>cattrs</code> package mirroring the existing <code>cattr</code> package. Both package names may be used as desired, and the <code>cattr</code> package isn't going away.</li>
</ul>
<h2>1.9.0 (2021-12-06)</h2>
<ul>
<li>Python 3.10 support, including support for the new union syntax (<code>A | B</code> vs <code>Union[A, B]</code>).</li>
<li>The <code>GenConverter</code> can now properly structure generic classes with generic collection fields.
(<code>[#149](python-attrs/cattrs#149) &lt;https://github.com/python-attrs/cattrs/issues/149&gt;</code>_)</li>
<li><code>omit=True</code> now also affects generated structuring functions.
(<code>[#166](python-attrs/cattrs#166) &lt;https://github.com/python-attrs/cattrs/issues/166&gt;</code>_)</li>
<li><code>cattr.gen.{make_dict_structure_fn, make_dict_unstructure_fn}</code> now resolve type annotations automatically when PEP 563 is used.
(<code>[#169](python-attrs/cattrs#169) &lt;https://github.com/python-attrs/cattrs/issues/169&gt;</code>_)</li>
<li>Protocols are now unstructured as their runtime types.
(<code>[#177](python-attrs/cattrs#177) &lt;https://github.com/python-attrs/cattrs/pull/177&gt;</code>_)</li>
<li>Fix an issue generating structuring functions with renaming and <code>_cattrs_forbid_extra_keys=True</code>.
(<code>[#190](python-attrs/cattrs#190) &lt;https://github.com/python-attrs/cattrs/issues/190&gt;</code>_)</li>
</ul>
<h2>1.8.0 (2021-08-13)</h2>
<ul>
<li>Fix <code>GenConverter</code> mapping structuring for unannotated dicts on Python 3.8.</li>
</ul>

</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li>See full diff in <a href="https://github.com/python-attrs/cattrs/commits">compare view</a></li>
</ul>
</details>
<br />


Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants