diff --git a/fetch-dotnet-snk.sh b/fetch-dotnet-snk.sh
index ce4dc28ebf..a4d78e5f6f 100644
--- a/fetch-dotnet-snk.sh
+++ b/fetch-dotnet-snk.sh
@@ -50,7 +50,6 @@ TMP_KEY="$TMP_DIR/key.snk"
echo $SNK_SECRET | jq -r .SecretBinary | base64 --decode > $TMP_KEY
cp $TMP_KEY packages/jsii-dotnet-jsonmodel/src/Amazon.JSII.JsonModel/
-cp $TMP_KEY packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/
cp $TMP_KEY packages/jsii-dotnet-runtime/src/Amazon.JSII.Runtime/
rm -rf $TMP_DIR
diff --git a/packages/jsii-dotnet-generator/.gitignore b/packages/jsii-dotnet-generator/.gitignore
deleted file mode 100644
index 66d8e6fb6f..0000000000
--- a/packages/jsii-dotnet-generator/.gitignore
+++ /dev/null
@@ -1,16 +0,0 @@
-src/Amazon.JSII.Generator/JsiiVersion.cs
-src/Directory.Build.props
-src/NuGet.Metadata.props
-
-!*.t.js
-
-*.js
-*.d.ts
-node_modules/
-.nyc_output/
-coverage/
-
-*.nupkg
-bin/
-cli/
-obj/
\ No newline at end of file
diff --git a/packages/jsii-dotnet-generator/.npmignore b/packages/jsii-dotnet-generator/.npmignore
deleted file mode 100644
index 3cb24af2cb..0000000000
--- a/packages/jsii-dotnet-generator/.npmignore
+++ /dev/null
@@ -1,9 +0,0 @@
-# by default, exclude everything
-*
-
-# bundle only...
-!*.nupkg
-!package.json
-!index.js
-!cli/**/*
-
diff --git a/packages/jsii-dotnet-generator/CHANGELOG.md b/packages/jsii-dotnet-generator/CHANGELOG.md
deleted file mode 100644
index 9f9984d3cc..0000000000
--- a/packages/jsii-dotnet-generator/CHANGELOG.md
+++ /dev/null
@@ -1,388 +0,0 @@
-# Change Log
-
-All notable changes to this project will be documented in this file.
-See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
-
-## [0.14.2](https://github.com/aws/jsii/compare/v0.14.1...v0.14.2) (2019-07-19)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.14.1](https://github.com/aws/jsii/compare/v0.14.0...v0.14.1) (2019-07-17)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-# [0.14.0](https://github.com/aws/jsii/compare/v0.13.4...v0.14.0) (2019-07-08)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.13.4](https://github.com/aws/jsii/compare/v0.13.3...v0.13.4) (2019-07-03)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.13.3](https://github.com/aws/jsii/compare/v0.13.2...v0.13.3) (2019-07-01)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.13.2](https://github.com/aws/jsii/compare/v0.12.1...v0.13.2) (2019-07-01)
-
-
-### Features
-
-* **pacmak:** support adding suffix to .NET package versions ([#557](https://github.com/aws/jsii/issues/557)) ([99adf19](https://github.com/aws/jsii/commit/99adf19))
-
-
-
-
-
-## [0.12.1](https://github.com/aws/jsii/compare/v0.12.0...v0.12.1) (2019-06-25)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-# [0.12.0](https://github.com/aws/jsii/compare/v0.11.3...v0.12.0) (2019-06-24)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.11.3](https://github.com/aws/jsii/compare/v0.11.2...v0.11.3) (2019-06-18)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.11.2](https://github.com/aws/jsii/compare/v0.11.1...v0.11.2) (2019-06-07)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.11.1](https://github.com/aws/jsii/compare/v0.11.0...v0.11.1) (2019-06-07)
-
-
-### Features
-
-* Register module-level stability ([#515](https://github.com/aws/jsii/issues/515)) ([efae447](https://github.com/aws/jsii/commit/efae447)), closes [awslabs/cdk-ops#367](https://github.com/awslabs/cdk-ops/issues/367)
-* **jsii:** Propagate stability to members ([#522](https://github.com/aws/jsii/issues/522)) ([20507e6](https://github.com/aws/jsii/commit/20507e6))
-* **jsii-spec:** Add optional metadata field ([#512](https://github.com/aws/jsii/issues/512)) ([10e2bfe](https://github.com/aws/jsii/commit/10e2bfe))
-
-
-
-
-
-# [0.11.0](https://github.com/aws/jsii/compare/v0.10.5...v0.11.0) (2019-05-21)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.10.5](https://github.com/aws/jsii/compare/v0.10.4...v0.10.5) (2019-05-06)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.10.4](https://github.com/aws/jsii/compare/v0.10.3...v0.10.4) (2019-05-05)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.10.3](https://github.com/aws/jsii/compare/v0.10.2...v0.10.3) (2019-04-24)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.10.2](https://github.com/aws/jsii/compare/v0.10.1...v0.10.2) (2019-04-18)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.10.1](https://github.com/aws/jsii/compare/v0.10.0...v0.10.1) (2019-04-17)
-
-
-### Bug Fixes
-
-* **dotnet:** Correctly generate "optional" markers ([#466](https://github.com/aws/jsii/issues/466)) ([17403dc](https://github.com/aws/jsii/commit/17403dc))
-
-
-
-
-
-# [0.10.0](https://github.com/aws/jsii/compare/v0.9.0...v0.10.0) (2019-04-16)
-
-
-### Bug Fixes
-
-* **dotnet:** fix doc comment model parsing in .NET generator ([#455](https://github.com/aws/jsii/issues/455)) ([ae85aa5](https://github.com/aws/jsii/commit/ae85aa5))
-
-
-### Features
-
-* **jsii-spec:** Model parameter optionality ([#432](https://github.com/aws/jsii/issues/432)) ([21e485a](https://github.com/aws/jsii/commit/21e485a)), closes [#296](https://github.com/aws/jsii/issues/296) [#414](https://github.com/aws/jsii/issues/414)
-
-
-### BREAKING CHANGES
-
-* **jsii-spec:** JSII assemblies generated by older versions of the tool
-will fail loading with this new version, and vice-versa. Re-compile your
-projects in order to fix this.
-
-
-
-
-
-# [0.9.0](https://github.com/aws/jsii/compare/v0.8.2...v0.9.0) (2019-04-04)
-
-
-### Features
-
-* **jsii-diff:** standardize doc comments, add API compatibility tool ([#415](https://github.com/aws/jsii/issues/415)) ([9cfd867](https://github.com/aws/jsii/commit/9cfd867))
-
-
-
-
-
-## [0.8.2](https://github.com/aws/jsii/compare/v0.8.1...v0.8.2) (2019-03-28)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-## [0.8.1](https://github.com/aws/jsii/compare/v0.8.0...v0.8.1) (2019-03-28)
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-
-
-
-# [0.8.0](https://github.com/aws/jsii/compare/v0.7.15...v0.8.0) (2019-03-20)
-
-
-### Features
-
-* pass data types (structs) by-value instead of by-ref ([#376](https://github.com/aws/jsii/issues/376)) ([db3ccdf](https://github.com/aws/jsii/commit/db3ccdf)), closes [awslabs/aws-cdk#965](https://github.com/awslabs/aws-cdk/issues/965) [#375](https://github.com/aws/jsii/issues/375)
-
-
-### BREAKING CHANGES
-
-* all properties in interfaces which represent data types must be marked as `readonly`. Otherwise, jsii compilation will fail.
-
-
-
-
-
-
-## [0.7.15](https://github.com/aws/jsii/compare/v0.7.14...v0.7.15) (2019-02-27)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.14](https://github.com/aws/jsii/compare/v0.7.13...v0.7.14) (2019-02-04)
-
-
-### Features
-
-* Generate NuGet symbol and source packages ([#243](https://github.com/aws/jsii/issues/243)) ([aafd405](https://github.com/aws/jsii/commit/aafd405))
-
-
-
-
-
-## [0.7.13](https://github.com/aws/jsii/compare/v0.7.12...v0.7.13) (2019-01-03)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.12](https://github.com/aws/jsii/compare/v0.7.11...v0.7.12) (2018-12-11)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.11](https://github.com/aws/jsii/compare/v0.7.10...v0.7.11) (2018-11-18)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.10](https://github.com/aws/jsii/compare/v0.7.9...v0.7.10) (2018-11-12)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.9](https://github.com/aws/jsii/compare/v0.7.8...v0.7.9) (2018-11-12)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.8](https://github.com/aws/jsii/compare/v0.7.7...v0.7.8) (2018-10-23)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.7](https://github.com/aws/jsii/compare/v0.7.6...v0.7.7) (2018-10-10)
-
-
-### Bug Fixes
-
-* **dotnet:** abstract classes should have proxy implementations ([#241](https://github.com/aws/jsii/issues/241)) ([828a26f](https://github.com/aws/jsii/commit/828a26f)), closes [#223](https://github.com/aws/jsii/issues/223)
-* **jsii:** support public autoproperties in private constructor ([#256](https://github.com/aws/jsii/issues/256)) ([181012e](https://github.com/aws/jsii/commit/181012e))
-* **jsii-dotnet-generator:** Use FQ type returns in conflict. ([#258](https://github.com/aws/jsii/issues/258)) ([a78784a](https://github.com/aws/jsii/commit/a78784a)), closes [#252](https://github.com/aws/jsii/issues/252)
-
-
-
-
-
-## [0.7.6](https://github.com/aws/jsii/compare/v0.7.5...v0.7.6) (2018-09-20)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.5](https://github.com/aws/jsii/compare/v0.7.4...v0.7.5) (2018-09-13)
-
-
-### Bug Fixes
-
-* **java:** support abstract return types ([#224](https://github.com/aws/jsii/issues/224)) ([3257223](https://github.com/aws/jsii/commit/3257223)), closes [#220](https://github.com/aws/jsii/issues/220) [#223](https://github.com/aws/jsii/issues/223) [awslabs/aws-cdk#680](https://github.com/awslabs/aws-cdk/issues/680)
-
-
-
-
-
-## [0.7.4](https://github.com/aws/jsii/compare/v0.7.3...v0.7.4) (2018-09-10)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.3](https://github.com/aws/jsii/compare/v0.7.2...v0.7.3) (2018-09-06)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.2](https://github.com/aws/jsii/compare/v0.7.1...v0.7.2) (2018-09-06)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.7.1](https://github.com/aws/jsii/compare/v0.7.0...v0.7.1) (2018-08-28)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-# [0.7.0](https://github.com/aws/jsii/compare/v0.6.4...v0.7.0) (2018-08-21)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-# [0.7.0](https://github.com/aws/jsii/compare/v0.6.4...v0.7.0) (2018-08-21)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.6.4](https://github.com/aws/jsii/compare/v0.6.3...v0.6.4) (2018-08-08)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## [0.6.3](https://github.com/aws/jsii/compare/v0.6.2...v0.6.3) (2018-08-08)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
-
-
-## 0.6.2 (2018-08-07)
-
-
-
-
-**Note:** Version bump only for package jsii-dotnet-generator
diff --git a/packages/jsii-dotnet-generator/Directory.Build.props.t.js b/packages/jsii-dotnet-generator/Directory.Build.props.t.js
deleted file mode 100644
index 77bca5d03c..0000000000
--- a/packages/jsii-dotnet-generator/Directory.Build.props.t.js
+++ /dev/null
@@ -1,9 +0,0 @@
-const version = require('./package.json').version.replace(/\+.+$/, ''); // omit "+build" suffix
-
-process.stdout.write(`
-
- ${version}
- netstandard2.0
-
-
-`);
diff --git a/packages/jsii-dotnet-generator/JsiiVersion.t.js b/packages/jsii-dotnet-generator/JsiiVersion.t.js
deleted file mode 100644
index 498cbdd13f..0000000000
--- a/packages/jsii-dotnet-generator/JsiiVersion.t.js
+++ /dev/null
@@ -1,10 +0,0 @@
-const path = require('path');
-const version = require('./package.json').version.replace(/\+.+$/, ''); // omit "+build" postfix;
-process.stdout.write(`namespace Amazon.JSII.Generator
-{
- public static class JsiiVersion
- {
- public static readonly string Version = "${version}";
- }
-}
-`);
diff --git a/packages/jsii-dotnet-generator/LICENSE b/packages/jsii-dotnet-generator/LICENSE
deleted file mode 100644
index 129acd53d9..0000000000
--- a/packages/jsii-dotnet-generator/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
\ No newline at end of file
diff --git a/packages/jsii-dotnet-generator/NOTICE b/packages/jsii-dotnet-generator/NOTICE
deleted file mode 100644
index dc4ac3f857..0000000000
--- a/packages/jsii-dotnet-generator/NOTICE
+++ /dev/null
@@ -1,2 +0,0 @@
-jsii
-Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
diff --git a/packages/jsii-dotnet-generator/NuGet.Metadata.props.t.js b/packages/jsii-dotnet-generator/NuGet.Metadata.props.t.js
deleted file mode 100644
index a16129c39c..0000000000
--- a/packages/jsii-dotnet-generator/NuGet.Metadata.props.t.js
+++ /dev/null
@@ -1,19 +0,0 @@
-const package = require('./package.json');
-
-process.stdout.write(`
-
- True
- True
- True
- ..\\..\\bin\\$(Configuration)\\NuGet\\
- $(JsiiVersion)
- ${package.description}
- ${package.homepage}
- https://spdx.org/licenses/${package.license}.html
- ${package.author.name}
- ${package.author.name}
- key.snk
- True
-
-
-`);
diff --git a/packages/jsii-dotnet-generator/build.sh b/packages/jsii-dotnet-generator/build.sh
deleted file mode 100644
index 6da18654bb..0000000000
--- a/packages/jsii-dotnet-generator/build.sh
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-
-npm run gen
-
-dotnet build --force -c Release ./src/Amazon.JSII.Generator.sln
-dotnet publish -c Release src/Amazon.JSII.Generator.CLI/
-
-mkdir -p cli
-rsync -av ./src/Amazon.JSII.Generator.CLI/bin/Release/netcoreapp2.0/ ./cli/
-
-cp -f ./bin/Release/NuGet/*.nupkg .
diff --git a/packages/jsii-dotnet-generator/generate.sh b/packages/jsii-dotnet-generator/generate.sh
deleted file mode 100644
index 223d19008d..0000000000
--- a/packages/jsii-dotnet-generator/generate.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-set -euo pipefail
-src="./src"
-
-# Generate metadata files based on package.json.
-/usr/bin/env node ./Directory.Build.props.t.js > ${src}/Directory.Build.props
-/usr/bin/env node ./NuGet.Metadata.props.t.js > ${src}/NuGet.Metadata.props
-/usr/bin/env node JsiiVersion.t.js > ${src}/Amazon.JSII.Generator/JsiiVersion.cs
diff --git a/packages/jsii-dotnet-generator/index.js b/packages/jsii-dotnet-generator/index.js
deleted file mode 100644
index e04488cec0..0000000000
--- a/packages/jsii-dotnet-generator/index.js
+++ /dev/null
@@ -1 +0,0 @@
-// Do not delete. Required for require.resolve('jsii-dotnet-generator') to succeed.
diff --git a/packages/jsii-dotnet-generator/package-lock.json b/packages/jsii-dotnet-generator/package-lock.json
deleted file mode 100644
index 2a6c579be3..0000000000
--- a/packages/jsii-dotnet-generator/package-lock.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "jsii-dotnet-generator",
- "version": "0.14.0",
- "lockfileVersion": 1,
- "requires": true,
- "dependencies": {
- "jsii-build-tools": {
- "version": "file:../jsii-build-tools",
- "dev": true,
- "requires": {
- "fs-extra": "^8.1.0"
- }
- },
- "jsii-dotnet-jsonmodel": {
- "version": "file:../jsii-dotnet-jsonmodel"
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/package.json b/packages/jsii-dotnet-generator/package.json
deleted file mode 100644
index b69afc315e..0000000000
--- a/packages/jsii-dotnet-generator/package.json
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- "name": "jsii-dotnet-generator",
- "version": "0.14.2",
- "description": ".NET code generator for jsii assemblies",
- "main": "index.js",
- "private": true,
- "scripts": {
- "gen": "/bin/bash ./generate.sh",
- "build": "/bin/bash ./build.sh",
- "test": "/bin/bash ./test.sh",
- "package": "package-dotnet"
- },
- "dependencies": {
- "jsii-dotnet-jsonmodel": "file:../jsii-dotnet-jsonmodel"
- },
- "devDependencies": {
- "jsii-build-tools": "file:../jsii-build-tools"
- },
- "author": {
- "name": "Amazon Web Services",
- "url": "https://aws.amazon.com",
- "email": "aws-jsii@amazon.com"
- },
- "license": "Apache-2.0",
- "repository": {
- "type": "git",
- "url": "https://github.com/aws/jsii.git"
- },
- "homepage": "https://github.com/aws/jsii"
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Amazon.JSII.Generator.CLI.csproj b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Amazon.JSII.Generator.CLI.csproj
deleted file mode 100644
index e62a84d41c..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Amazon.JSII.Generator.CLI.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- Exe
- netcoreapp2.0
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Options.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Options.cs
deleted file mode 100644
index feee40ede4..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Options.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using CommandLine;
-
-namespace Amazon.JSII.Generator.CLI
-{
- class Options
- {
- [Option('j', "jsii", Required = true, HelpText = "Path to the .jsii spec file")]
- public string JsiiFile { get; set; }
-
- [Option('t', "tarball", Required = true, HelpText = "The location of the module's .tgz file")]
- public string Tarball { get; set; }
-
- [Option('o', "output", Required = true, HelpText = "Directory in which to place generated code.")]
- public string OutputDirectory { get; set; }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Program.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Program.cs
deleted file mode 100644
index ee697a72ad..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Program.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using CommandLine;
-using System;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.CLI
-{
- class Program
- {
- static void Main(string[] args)
- {
- Parser.Default.ParseArguments(args)
- .WithParsed(Generate)
- .WithNotParsed(errs => HandleParseError(errs));
- }
-
- static void HandleParseError(IEnumerable errors)
- {
- Environment.Exit(1);
- }
-
- static void Generate(Options options)
- {
- AssemblyGenerator generator = new AssemblyGenerator(options.OutputDirectory);
-
- generator.Generate(options.JsiiFile, options.Tarball);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Properties/PublishProfiles/FolderProfile.pubxml b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Properties/PublishProfiles/FolderProfile.pubxml
deleted file mode 100644
index f901e37e2c..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.CLI/Properties/PublishProfiles/FolderProfile.pubxml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- FileSystem
- Release
- Any CPU
- netcoreapp2.0
- bin\Debug\netcoreapp2.0\publish\
-
-
\ No newline at end of file
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Amazon.JSII.Generator.UnitTests.csproj b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Amazon.JSII.Generator.UnitTests.csproj
deleted file mode 100644
index d9aee9bbeb..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Amazon.JSII.Generator.UnitTests.csproj
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- netcoreapp2.0
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/AssemblyExtensionsTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/AssemblyExtensionsTests.cs
deleted file mode 100644
index 2480d6ef2f..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/AssemblyExtensionsTests.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Xml.Linq;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class AssemblyExtensionsTests
- {
- const string Prefix = nameof(Generator) + "." + nameof(AssemblyExtensions) + ".";
-
- public class GetNativeName
- {
- const string _Prefix = Prefix + nameof(GetNativeName) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullAssembly))]
- public void ThrowsOnNullAssembly()
- {
- ArgumentNullException exception = Assert.Throws(() => ((Assembly)null).GetNativeNamespace());
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnMissingDotNetKey))]
- public void ThrowsOnMissingDotNetKey()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: null,
- version: "myVersion",
- types: new Dictionary()
- );
-
- ArgumentException exception = Assert.Throws(() => assembly.GetNativeNamespace());
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnEmptyDotNetNamespace))]
- public void ThrowsOnEmptyDotNetNamespace()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: " ",
- packageId: "")
- ),
- version: "myVersion",
- types: new Dictionary()
- );
-
- ArgumentException exception = Assert.Throws(() => assembly.GetNativeNamespace());
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(RetrievesDotNetName))]
- public void RetrievesDotNetName()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId"
- )),
- version: "myVersion",
- types: new Dictionary()
- );
-
- string actual = assembly.GetNativeNamespace();
- Assert.Equal("myNativeName", actual);
- }
- }
-
- public class GetNativeName_WithPackage
- {
- const string _Prefix = Prefix + nameof(GetNativeName_WithPackage) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullAssembly))]
- public void ThrowsOnNullAssembly()
- {
- ArgumentNullException exception = Assert.Throws(() => ((Assembly)null).GetNativeNamespace("myPackage"));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnMissingPackage))]
- public void ThrowsOnMissingPackage()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId1"
- )),
- dependencies: new Dictionary
- {
- {
- "myPackage",
- new PackageVersion(
- "0.0.1",
- new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myPackageNativeName",
- packageId: "myPackageId2"
-
- ))
- )
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- ArgumentException exception = Assert.Throws(() => assembly.GetNativeNamespace("notMyPackage"));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnMissingDotNetKey))]
- public void ThrowsOnMissingDotNetKey()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId"
- )),
- dependencies: new Dictionary
- {
- {
- "myPackage",
- new PackageVersion("0.0.1")
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- ArgumentException exception = Assert.Throws(() => assembly.GetNativeNamespace("myPackage"));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnEmptyDotNetKey))]
- public void ThrowsOnEmptyDotNetKey()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId1"
- )),
- dependencies: new Dictionary
- {
- {
- "myPackage",
- new PackageVersion(
- "0.0.1",
- new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: " ",
- packageId: "myPackageId2"
- ))
- )
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- ArgumentException exception = Assert.Throws(() => assembly.GetNativeNamespace("myPackage"));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(RetrievesDotNetName))]
- public void RetrievesDotNetName()
- {
- Assembly assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId1"
- )),
- dependencies: new Dictionary
- {
- {
- "myPackage",
- new PackageVersion(
- "0.0.1",
- new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myPackageNativeName",
- packageId: "myPackageId2"
- ))
- )
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- string actual = assembly.GetNativeNamespace("myPackage");
- Assert.Equal("myPackageNativeName", actual);
- }
- }
-
- public class GetMsBuildProperties
- {
- const string _Prefix = Prefix + nameof(GetMsBuildProperties) + ".";
-
- public void IncludesAllPresentProperties()
- {
- Assembly assembly = new Assembly(
- name: "my-assembly",
- description: "my description",
- homepage: "https://www.example.com/",
- repository: new Assembly.AssemblyRepository
- (
- type: "git",
- url: "https://github.com/"
- ),
- author: new Person
- (
- name: "Jane Doe",
- roles: new string[] { "Administrator" }
- ),
- fingerprint: "myFingerprint",
- version: "1.2.3",
- license: "Apache-2.0",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace",
- packageId: "My.PackageId",
- title: "My Human Readable Title",
- signAssembly: true,
- assemblyOriginatorKeyFile: "key.snk",
- iconUrl: "https://www.example.com/icon.svg"
- ))
- );
-
- IEnumerable actual = assembly.GetMsBuildProperties();
- Assert.Collection(actual,
- element => Assert.Equal("netstandard2.0", element.ToString()),
- element => Assert.Equal("true", element.ToString()),
- element => Assert.Equal("True", element.ToString()),
- element => Assert.Equal("True", element.ToString()),
- element => Assert.Equal("1.2.3", element.ToString()),
- element => Assert.Equal("My.PackageId", element.ToString()),
- element => Assert.Equal("my description", element.ToString()),
- element => Assert.Equal("https://www.example.com/", element.ToString()),
- element => Assert.Equal("https://spdx.org/licenses/Apache-2.0.html", element.ToString()),
- element => Assert.Equal("Jane Doe", element.ToString()),
- element => Assert.Equal("My Human Readable Title", element.ToString()),
- element => Assert.Equal("true", element.ToString()),
- element => Assert.Equal("key.snk", element.ToString()),
- element => Assert.Equal("http://www.example.com/icon.svg", element.ToString())
- );
- }
-
- public void SkipsNullProperties()
- {
- Assembly assembly = new Assembly(
- description: "my description",
- homepage: "https://www.example.com/",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person
- (
- name: "Jane Doe",
- roles: new string[] { }
- ),
- fingerprint: "",
- license: "Apache-2.0",
- name: "my-assembly",
- version: "1.2.3",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace",
- packageId: "My.PackageId"
- ))
- );
-
- IEnumerable actual = assembly.GetMsBuildProperties();
- Assert.Collection(actual,
- element => Assert.Equal("netstandard2.0", element.ToString()),
- element => Assert.Equal("true", element.ToString()),
- element => Assert.Equal("1.2.3", element.ToString()),
- element => Assert.Equal("My.PackageId", element.ToString()),
- element => Assert.Equal("my description", element.ToString()),
- element => Assert.Equal("https://www.example.com/", element.ToString()),
- element => Assert.Equal("https://spdx.org/licenses/Apache-2.0.html", element.ToString()),
- element => Assert.Equal("Jane Doe", element.ToString())
- );
- }
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/AssemblyGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/AssemblyGeneratorTests.cs
deleted file mode 100644
index 3f54745c24..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/AssemblyGeneratorTests.cs
+++ /dev/null
@@ -1,648 +0,0 @@
-using Amazon.JSII.JsonModel.FileSystem;
-using Amazon.JSII.JsonModel.Spec;
-using NSubstitute;
-using System.IO;
-using Xunit;
-using Xunit.Sdk;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class AssemblyGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(AssemblyGenerator) + ".";
-
- const string InputRoot = "myInputRoot";
- const string OutputRoot = "myOutputRoot";
-
- static string GetJsonPath(string jsiiPackage)
- {
- return Path.Combine(InputRoot, jsiiPackage, "dist", Constants.SPEC_FILE_NAME);
- }
-
- static string GetPackageOutputRoot(string dotnetPackage)
- {
- return Path.Combine(OutputRoot, dotnetPackage);
- }
-
- static string GetProjectFilePath(string dotnetPackage, string dotnetAssembly)
- {
- return $"{Path.Combine(GetPackageOutputRoot(dotnetPackage), dotnetAssembly)}.csproj";
- }
-
- static string GetAnchorFilePath(string dotnetPackage, string dotnetNamespace)
- {
- string path = GetPackageOutputRoot(dotnetPackage);
-
- foreach (string token in dotnetNamespace.Split('.')) {
- path = Path.Combine(path, token);
- }
-
- return Path.Combine(path, "Internal", "DependencyResolution", "Anchor.cs");
- }
-
- static string GetTypeFilePath(string dotnetPackage, string dotnetNamespace, string dotnetType)
- {
- string directory = Path.Combine(GetPackageOutputRoot(dotnetPackage), Path.Combine(dotnetNamespace.Split('.')));
- return $"{Path.Combine(directory, dotnetType)}.cs";
- }
-
- [Fact(DisplayName = Prefix + nameof(AccessesFileSystemThroughShim))]
- public void AccessesFileSystemThroughShim()
- {
- const string json =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""version"": """",
- ""types"": {
- ""jsii$aws_cdk_cx_api$.MissingContext"": {
- ""kind"": ""class"",
- ""fqn"": ""jsii$aws_cdk_cx_api$.MissingContext"",
- ""assembly"": ""jsii$aws_cdk_cx_api$"",
- ""name"": ""MissingContext"",
- ""initializer"": {
- ""initializer"": true
- }
- }
- }
-}";
-
- string jsonPath = GetJsonPath("aws-cdk-cx-api");
- string packageOutputRoot = GetPackageOutputRoot("Aws.Cdk.CxApiPackageId");
- string projectFilePath = GetProjectFilePath("Aws.Cdk.CxApiPackageId", "Aws.Cdk.CxApiPackageId");
- string typeFilePath = GetTypeFilePath("Aws.Cdk.CxApiPackageId", "Aws.Cdk.CxApiNamespace", "MissingContext");
-
- IDirectory directory = Substitute.For();
- directory.Exists(packageOutputRoot).Returns(true, false);
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(directory);
- fileSystem.File.Returns(file);
-
- //Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApi");
- Symbols.MapNamespace("jsii$aws_cdk_cx_api$", "Aws.Cdk.CxApiNamespace");
- Symbols.MapTypeName("jsii$aws_cdk_cx_api$.MissingContext", "MissingContext", TypeKind.Class);
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk-cx-api", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk-cx-api", "aws-cdk-cx-api-1.2.3.5.tgz"),
- Symbols
- );
-
- directory.Received().Delete(packageOutputRoot, true);
- directory.Received().CreateDirectory(packageOutputRoot);
- file.Received().ReadAllText(jsonPath);
- file.Received().WriteAllText(projectFilePath, Arg.Any());
- file.Received().WriteAllText(typeFilePath, Arg.Any());
- }
-
- [Fact(DisplayName = Prefix + nameof(CopiesJsiiToOutput))]
- public void CopiesJsiiToOutput()
- {
- const string json =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""version"": """",
- ""types"": {}
-}";
-
- string jsonPath = GetJsonPath("aws-cdk-cx-api");
- string projectFilePath = GetProjectFilePath("Aws.Cdk.CxApi", "Aws.Cdk.CxApi");
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(Substitute.For());
- fileSystem.File.Returns(file);
-
- Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApiPackageId");
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk-cx-api", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk-cx-api", "aws-cdk-cx-api-1.2.3.5.tgz"),
- Symbols
- );
-
- file.Received().Copy(jsonPath, Path.Combine(OutputRoot, "Aws.Cdk.CxApiPackageId", ".jsii"));
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesBasicProjectFile))]
- public void CreatesBasicProjectFile()
- {
- const string json =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""version"": ""1.2.3"",
- ""types"": {}
-}";
-
- string jsonPath = GetJsonPath("aws-cdk-cx-api");
- string projectFilePath = GetProjectFilePath("Aws.Cdk.CxApiPackageId", "Aws.Cdk.CxApiPackageId");
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(Substitute.For());
- fileSystem.File.Returns(file);
-
- Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApiPackageId");
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk-cx-api", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk-cx-api", "aws-cdk-cx-api-1.2.3.5.tgz"),
- Symbols
- );
-
- string expected =
-@"
-
- netstandard2.0
- true
- true
- true
- myAuthors
- myCompany
- 1.2.3
-
-
-
-
-
-
-
-";
- file.Received().WriteAllText(projectFilePath, Arg.Do(actual => PlatformIndependentEqual(expected, actual)));
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesProjectFileWithDependencies))]
- public void CreatesProjectFileWithDependencies()
- {
- string json =
-@"{
- ""name"": ""jsii$aws_cdk$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.CdkNamespace"",
- ""packageId"": ""Aws.CdkPackageId""
- }
- },
- ""version"": ""1.2.3"",
- ""types"": {},
- ""dependencies"": {
- ""jsii$aws_cdk_cx_api$"": {
- ""package"": ""aws-cdk-cx-api"",
- ""version"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApi"",
- ""packageId"": ""Aws.Cdk.CxApi""
- }
- }
- }
- }
-}";
- string cxJson =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""version"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""types"": {}
-}";
-
- string jsonPath = GetJsonPath("aws-cdk");
- string cxJsonPath = Path.Combine(Path.GetDirectoryName(jsonPath), "node_modules", "jsii$aws_cdk_cx_api$");
- string projectFilePath = GetProjectFilePath("Aws.CdkPackageId", "Aws.CdkPackageId");
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
- file.ReadAllText(Path.Combine(cxJsonPath, ".jsii")).Returns(cxJson);
-
- IDirectory directory = Substitute.For();
- directory.Exists(cxJsonPath).Returns(true);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(directory);
- fileSystem.File.Returns(file);
-
- Symbols.MapTypeToPackage("aws-cdk", "Aws.CdkPackageId");
- Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApiNamespace");
- Symbols.MapAssemblyName("jsii$aws_cdk_cx_api$", "Aws.Cdk.CxApiPackageId");
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk", "aws-cdk-1.2.3.4.tgz"),
- Symbols
- );
-
- string expected =
-@"
-
- netstandard2.0
- true
- myAuthors
- myCompany
- 1.2.3
-
-
-
-
-
-
-
-
-";
- file.Received().WriteAllText(projectFilePath, Arg.Do(actual => PlatformIndependentEqual(expected, actual)));
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesAnchorFile))]
- public void CreatesAnchorFile()
- {
- string json =
-@"{
- ""name"": ""jsii$aws_cdk$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.CdkNamespace"",
- ""packageId"": ""Aws.CdkPackageId""
- }
- },
- ""version"": ""1.2.3"",
- ""types"": {},
- ""dependencies"": {
- ""jsii$aws_cdk_cx_api$"": {
- ""package"": ""aws-cdk-cx-api"",
- ""version"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApi"",
- ""packageId"": ""Aws.Cdk.CxApi""
- }
- }
- }
- }
-}";
- string cxJson =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""version"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""types"": {}
-}";
-
- string jsonPath = GetJsonPath("aws-cdk");
- string cxJsonPath = Path.Combine(Path.GetDirectoryName(jsonPath), "node_modules", "jsii$aws_cdk_cx_api$");
- string anchorFilePath = GetAnchorFilePath("Aws.CdkPackageId", "Aws.CdkNamespace");
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
- file.ReadAllText(Path.Combine(cxJsonPath, ".jsii")).Returns(cxJson);
-
- IDirectory directory = Substitute.For();
- directory.Exists(cxJsonPath).Returns(true);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(directory);
- fileSystem.File.Returns(file);
-
- Symbols.MapTypeToPackage("aws-cdk", "Aws.CdkPackageId");
- Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApiNamespace");
- Symbols.MapAssemblyName("jsii$aws_cdk_cx_api$", "Aws.Cdk.CxApiPackageId");
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk", "aws-cdk-1.2.3.4.tgz"),
- Symbols
- );
-
- string expected =
-@"namespace Aws.CdkNamespace.Internal.DependencyResolution
-{
- public class Anchor
- {
- public Anchor()
- {
- new Aws.Cdk.CxApiNamespace.Internal.DependencyResolution.Anchor();
- }
- }
-}";
- file.Received().WriteAllText(anchorFilePath, Arg.Do(actual => PlatformIndependentEqual(expected, actual)));
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesAssemblyInfo))]
- public void CreatesAssemblyInfo()
- {
- const string json =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""version"": """",
- ""types"": {}
-}";
-
- string jsonPath = GetJsonPath("aws-cdk-cx-api");
- string projectFilePath = GetProjectFilePath("Aws.Cdk.CxApiPackageId", "Aws.Cdk.CxApiPackageId");
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(Substitute.For());
- fileSystem.File.Returns(file);
-
- Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApiPackageId");
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk-cx-api", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk-cx-api", "aws-cdk-cx-api-1.2.3.5.tgz"),
- Symbols
- );
-
- file.Received().WriteAllText(Path.Combine(OutputRoot, "Aws.Cdk.CxApiPackageId", "AssemblyInfo.cs"),
- Arg.Do(
- code => Assert.Equal(
-@"using Amazon.JSII.Runtime.Deputy;
-
-[assembly: JsiiAssembly(""jsii$aws_cdk_cx_api$"", """", ""aws-cdk-cx-api-1.2.3.5.tgz"")]",
- code,
- ignoreLineEndingDifferences: true
- )
- )
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesBasicTypeFile))]
- public void CreatesBasicTypeFile()
- {
- const string json =
-@"{
- ""name"": ""jsii$aws_cdk_cx_api$"",
- ""description"": """",
- ""homepage"": """",
- ""repository"": {
- ""type"": """",
- ""url"": """"
- },
- ""author"": {
- ""name"": """",
- ""roles"": []
- },
- ""fingerprint"": """",
- ""license"": """",
- ""targets"": {
- ""dotnet"": {
- ""namespace"": ""Aws.Cdk.CxApiNamespace"",
- ""packageId"": ""Aws.Cdk.CxApiPackageId""
- }
- },
- ""version"": """",
- ""types"": {
- ""jsii$aws_cdk_cx_api$.MissingContext"": {
- ""kind"": ""class"",
- ""fqn"": ""jsii$aws_cdk_cx_api$.MissingContext"",
- ""assembly"": ""jsii$aws_cdk_cx_api$"",
- ""name"": ""MissingContext"",
- ""initializer"": {
- ""initializer"": true
- }
- }
- }
-}";
-
- string jsonPath = GetJsonPath("aws-cdk-cx-api");
- string typeFilePath = GetTypeFilePath("Aws.Cdk.CxApiPackageId", "Aws.Cdk.CxApiNamespace", "MissingContext");
-
- IFile file = Substitute.For();
- file.ReadAllText(jsonPath).Returns(json);
-
- IFileSystem fileSystem = Substitute.For();
- fileSystem.Directory.Returns(Substitute.For());
- fileSystem.File.Returns(file);
-
- Symbols.MapTypeToPackage("aws-cdk-cx-api", "Aws.Cdk.CxApiPackageId");
- Symbols.MapNamespace("jsii$aws_cdk_cx_api$", "Aws.Cdk.CxApiNamespace");
- Symbols.MapTypeName("jsii$aws_cdk_cx_api$.MissingContext", "MissingContext", TypeKind.Class);
-
- AssemblyGenerator generator = new AssemblyGenerator
- (
- OutputRoot,
- fileSystem
- );
- generator.Generate
- (
- Path.Combine(InputRoot, "aws-cdk-cx-api", "dist", Constants.SPEC_FILE_NAME),
- Path.Combine(InputRoot, "aws-cdk-cx-api", "aws-cdk-cx-api-1.1.1.tgz"),
- Symbols
- );
-
-
- string expected =
-@"using Amazon.JSII.Runtime.Deputy;
-
-namespace Aws.Cdk.CxApiNamespace
-{
- [JsiiClass(nativeType: typeof(MissingContext), fullyQualifiedName: ""jsii$aws_cdk_cx_api$.MissingContext"")]
- public class MissingContext : DeputyBase
- {
- public MissingContext(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MissingContext(ByRefValue reference): base(reference)
- {
- }
-
- protected MissingContext(DeputyProps props): base(props)
- {
- }
- }
-}";
-
- file.Received().WriteAllText(typeFilePath,
- Arg.Is(actual => PlatformIndependentEqual(expected, actual))
- );
- }
-
- bool PlatformIndependentEqual(string expected, string actual)
- {
- try
- {
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- catch (EqualException)
- {
- return false;
- }
-
- return true;
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/AbstractClassProxyGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/AbstractClassProxyGeneratorTests.cs
deleted file mode 100644
index aa94abb45d..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/AbstractClassProxyGeneratorTests.cs
+++ /dev/null
@@ -1,184 +0,0 @@
-using Amazon.JSII.Generator.Class;
-using Amazon.JSII.JsonModel.Spec;
-using Xunit;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Class
-{
- public class AbstractClassProxyGeneratorTests : GeneratorTestBase
- {
- private const string Prefix = nameof(Generator) + "." + nameof(AbstractClassProxyGenerator) + ".";
-
- private string Render(ClassType classType)
- {
- Symbols.MapTypeToPackage("myFqn", classType.Assembly);
- Symbols.MapNamespace(classType.QualifiedNamespace, "MyNamespace");
- Symbols.MapTypeName("myFqn", "MyClass", TypeKind.Class);
-
- var generator = new AbstractClassProxyGenerator(classType.Assembly, classType, Symbols, Namespaces);
-
- var syntaxTree = generator.CreateSyntaxTree();
- return syntaxTree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- var classType = new ClassType
- (
- "myFqn",
- "myPackage",
- "myClass",
- true,
- initializer: new Initializer()
- );
-
- var actual = Render(classType);
- var expected =
- @"namespace MyNamespace
-{
- [JsiiTypeProxy(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- internal sealed class MyClassProxy : MyClass
- {
- private MyClassProxy(ByRefValue reference): base(reference)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesDocs))]
- public void IncludesDocs()
- {
- // Docs are not currently generated as part of the C# code.
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: true,
- initializer: new Initializer(),
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- /// foo: bar
- [JsiiTypeProxy(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- internal sealed class MyClassProxy : MyClass
- {
- private MyClassProxy(ByRefValue reference): base(reference)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesProperties))]
- public void IncludesProperties()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: true,
- initializer: new Initializer(),
- properties: new[]
- {
- new Property
- (
- name: "myProp",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: false,
- isAbstract: true,
- isProtected: false
- ),
- new Property
- (
- name: "notMyProp",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: false,
- isAbstract: false,
- isProtected: false
- )
- }
- );
-
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", TypeKind.Class);
- Symbols.MapPropertyName("myFqn", "myProp", "MyProp");
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiTypeProxy(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- internal sealed class MyClassProxy : MyClass
- {
- private MyClassProxy(ByRefValue reference): base(reference)
- {
- }
-
- [JsiiProperty(name: ""myProp"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
- public override MyPropType MyProp
- {
- get => GetInstanceProperty();
- set => SetInstanceProperty(value);
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMethods))]
- public void IncludesMethods()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: true,
- initializer: new Initializer(),
- methods: new[]
- {
- new Method
- (
- isAbstract: true,
- name: "myMethod"
- ),
- new Method
- (
- name: "notMyMethod"
- )
- }
- );
-
- Symbols.MapMethodName("myFqn", "myMethod", "MyMethod");
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiTypeProxy(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- internal sealed class MyClassProxy : MyClass
- {
- private MyClassProxy(ByRefValue reference): base(reference)
- {
- }
-
- [JsiiMethod(name: ""myMethod"")]
- public override void MyMethod()
- {
- InvokeInstanceVoidMethod(new object[]{});
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
\ No newline at end of file
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassGeneratorTests.cs
deleted file mode 100644
index b4fe4d7caa..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassGeneratorTests.cs
+++ /dev/null
@@ -1,351 +0,0 @@
-using Amazon.JSII.Generator.Class;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-using TypeKind = Amazon.JSII.JsonModel.Spec.TypeKind;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Class
-{
- public class ClassGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(ClassGenerator) + ".";
-
- private string Render(ClassType classType)
- {
- Symbols.MapTypeToPackage("myFqn", classType.Assembly);
- Symbols.MapNamespace(classType.QualifiedNamespace, "MyNamespace");
- Symbols.MapTypeName("myFqn", "MyClass", TypeKind.Class);
-
- ClassGenerator generator = new ClassGenerator(classType.Assembly, classType, Symbols, Namespaces);
-
- SyntaxTree syntaxTree = generator.CreateSyntaxTree();
- return syntaxTree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- initializer: new Initializer()
- );
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : DeputyBase
- {
- public MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(AllowsPrivateConstructor))]
- public void AllowsPrivateConstructor()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false
- );
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : DeputyBase
- {
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAbstractKeyword))]
- public void IncludesAbstractKeyword()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: true,
- initializer: new Initializer()
- );
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public abstract class MyClass : DeputyBase
- {
- protected MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesDocs))]
- public void IncludesDocs()
- {
- // Docs are not currently generated as part of the C# code.
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- initializer: new Initializer(),
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- /// foo: bar
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : DeputyBase
- {
- public MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesProperties))]
- public void IncludesProperties()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- initializer: new Initializer(),
- properties: new[]
- {
- new Property
- (
- name: "myProp",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: false,
- isAbstract: false,
- isProtected: false
- )
- }
- );
-
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", TypeKind.Class);
- Symbols.MapPropertyName("myFqn", "myProp", "MyProp");
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : DeputyBase
- {
- public MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
-
- [JsiiProperty(name: ""myProp"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
- public virtual MyPropType MyProp
- {
- get => GetInstanceProperty();
- set => SetInstanceProperty(value);
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMethods))]
- public void IncludesMethods()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- initializer: new Initializer(),
- methods: new[]
- {
- new Method
- (
- name: "myMethod"
- )
- }
- );
-
- Symbols.MapMethodName("myFqn", "myMethod", "MyMethod");
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : DeputyBase
- {
- public MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
-
- [JsiiMethod(name: ""myMethod"")]
- public virtual void MyMethod()
- {
- InvokeInstanceVoidMethod(new object[]{});
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesBase))]
- public void IncludesBase()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- initializer: new Initializer(),
- @base: "myBaseTypeFqn"
- );
-
- Symbols.MapTypeName("myBaseTypeFqn", "MyBaseType", TypeKind.Class);
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : MyBaseType
- {
- public MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesInterfaces))]
- public void IncludesInterfaces()
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- initializer: new Initializer(),
- interfaces: new[]
- {
- "myInterfaceFqn1",
- "myInterfaceFqn2",
- }
- );
-
- Symbols.MapTypeName("myInterfaceFqn1", "MyInterface1", TypeKind.Interface);
- Symbols.MapTypeName("myInterfaceFqn2", "MyInterface2", TypeKind.Interface);
-
- string actual = Render(classType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiClass(nativeType: typeof(MyClass), fullyQualifiedName: ""myFqn"")]
- public class MyClass : DeputyBase, IMyInterface1, IMyInterface2
- {
- public MyClass(): base(new DeputyProps(new object[]{}))
- {
- }
-
- protected MyClass(ByRefValue reference): base(reference)
- {
- }
-
- protected MyClass(DeputyProps props): base(props)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
\ No newline at end of file
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassMethodGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassMethodGeneratorTests.cs
deleted file mode 100644
index 204b1e44f3..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassMethodGeneratorTests.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using Amazon.JSII.Generator.Class;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Xunit;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Class
-{
- public class ClassMethodGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(ClassMethodGenerator) + ".";
-
- string Render(Method method)
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myClassFqn",
- assembly: "myModule",
- name: "myClass",
- isAbstract: true,
- initializer: new Initializer(),
- methods: new[] { method }
- );
-
- Symbols.MapTypeToPackage("myClassFqn", "myPackage");
- Symbols.MapNamespace("myNamespace", "MyNamespace");
- Symbols.MapTypeName("myClassFqn", "MyClass", JsonModel.Spec.TypeKind.Class);
-
- ClassMethodGenerator generator = new ClassMethodGenerator(classType, method, Symbols, Namespaces);
-
- MethodDeclarationSyntax methodSyntax = generator.CreateMethod();
- return methodSyntax.NormalizeWhitespace(elasticTrivia: true).ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesProtectedKeyword))]
- public void IncludesAttribute()
- {
- Method method = new Method(name: "myMethod");
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-public virtual void MyMethod()
-{
- InvokeInstanceVoidMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesProtectedKeyword))]
- public void IncludesProtectedKeyword()
- {
- Method method = new Method(isProtected: true, name: "myMethod");
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-protected virtual void MyMethod()
-{
- InvokeInstanceVoidMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAbstractKeyword))]
- public void IncludesAbstractKeyword()
- {
- Method method = new Method(isAbstract: true, name: "myMethod");
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-public abstract void MyMethod();";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncluesParameters))]
- public void IncluesParameters()
- {
- Method method = new Method
- (
- name: "myMethod",
- parameters: new[]
- {
- new Parameter(name: "myParam", type: new TypeReference("myParamTypeFqn")),
- new Parameter(name: "event", type: new TypeReference(primitive: PrimitiveType.String))
- }
- );
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
- Symbols.MapTypeName("myParamTypeFqn", "MyParamType", JsonModel.Spec.TypeKind.Class);
- Symbols.MapParameterName("myParam", "myParam");
- Symbols.MapParameterName("event", "@event");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", parametersJson: ""[{\""name\"":\""myParam\"",\""type\"":{\""fqn\"":\""myParamTypeFqn\""}},{\""name\"":\""event\"",\""type\"":{\""primitive\"":\""string\""}}]"")]
-public virtual void MyMethod(MyParamType myParam, string @event)
-{
- InvokeInstanceVoidMethod(new object[]{myParam, @event});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotIncludeDocs))]
- public void DoesNotIncludeDocs()
- {
- Method method = new Method
- (
- name: "myMethod",
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-public virtual void MyMethod()
-{
- InvokeInstanceVoidMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesReturnTypeForNonVoid))]
- public void IncludesReturnTypeForNonVoid()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod",
- returns: new OptionalValue(type: new TypeReference("myReturnTypeFqn"))
- );
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
- Symbols.MapTypeName("myReturnTypeFqn", "MyReturnType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", returnsJson: ""{\""type\"":{\""fqn\"":\""myReturnTypeFqn\""}}"")]
-public virtual MyReturnType MyMethod()
-{
- return InvokeInstanceMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(SupportsStaticMethods))]
- public void SupportsStaticMethods()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod",
- returns: new OptionalValue(type: new TypeReference("myReturnTypeFqn")),
- isStatic: true
- );
-
- Symbols.MapMethodName("myClassFqn", "myMethod", "MyMethod");
- Symbols.MapTypeName("myReturnTypeFqn", "MyReturnType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", returnsJson: ""{\""type\"":{\""fqn\"":\""myReturnTypeFqn\""}}"")]
-public static MyReturnType MyMethod()
-{
- return InvokeStaticMethod(typeof(MyClass), new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassPropertyGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassPropertyGeneratorTests.cs
deleted file mode 100644
index 7b4fc3b06f..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Class/ClassPropertyGeneratorTests.cs
+++ /dev/null
@@ -1,218 +0,0 @@
-using Amazon.JSII.Generator.Class;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Xunit;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Class
-{
- public class ClassPropertyGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(ClassPropertyGenerator) + ".";
-
- string Render(Property property)
- {
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myClassFqn",
- assembly: "myModule",
- name: "myClass",
- @namespace: "myNamespace",
- isAbstract: true,
- initializer: new Initializer(),
- properties: new[] { property }
- );
-
- Symbols.MapTypeToPackage("myClassFqn", "myPackage");
- Symbols.MapNamespace("myNamespace", "MyNamespace");
- Symbols.MapTypeName("myClassFqn", "MyClass", JsonModel.Spec.TypeKind.Class);
-
- ClassPropertyGenerator generator = new ClassPropertyGenerator(classType, property, Symbols, Namespaces);
-
- PropertyDeclarationSyntax methodSyntax = generator.CreateProperty();
- return methodSyntax.NormalizeWhitespace(elasticTrivia: true).ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: true,
- isAbstract: false,
- isProtected: false
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-public virtual MyPropType MyProperty
-{
- get => GetInstanceProperty();
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesGetter))]
- public void IncludesGetter()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: true,
- isAbstract: false,
- isProtected: false
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-public virtual MyPropType MyProperty
-{
- get => GetInstanceProperty();
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSetter))]
- public void IncludesSetter()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: false,
- isAbstract: false,
- isProtected: false
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-public virtual MyPropType MyProperty
-{
- get => GetInstanceProperty();
- set => SetInstanceProperty(value);
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesProtectedKeyword))]
- public void IncludesProtectedKeyword()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: true,
- isAbstract: false,
- isProtected: true
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-protected virtual MyPropType MyProperty
-{
- get => GetInstanceProperty();
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(SupportsStaticProperties))]
- public void SupportsStaticProperties()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: false,
- isAbstract: false,
- isProtected: false,
- isStatic: true
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-public static MyPropType MyProperty
-{
- get => GetStaticProperty(typeof(MyClass));
- set => SetStaticProperty(typeof(MyClass), value);
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(OptimizesConstantProperties))]
- public void OptimizesConstantProperties()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isAbstract: false,
- isProtected: false,
- isConstant: true
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-public static MyPropType MyProperty
-{
- get;
-}
-
-= GetStaticProperty(typeof(MyClass));";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotIncludeDocs))]
- public void DoesNotIncludeDocs()
- {
- Property property = new Property
- (
- name: "myProperty",
- type: new TypeReference("myPropTypeFqn"),
- isImmutable: true,
- isAbstract: false,
- isProtected: false,
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- Symbols.MapPropertyName("myClassFqn", "myProperty", "MyProperty");
- Symbols.MapTypeName("myPropTypeFqn", "MyPropType", JsonModel.Spec.TypeKind.Class);
-
- string actual = Render(property);
- string expected =
-@"[JsiiProperty(name: ""myProperty"", typeJson: ""{\""fqn\"":\""myPropTypeFqn\""}"")]
-public virtual MyPropType MyProperty
-{
- get => GetInstanceProperty();
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DelegateComparerTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DelegateComparerTests.cs
deleted file mode 100644
index 57a1def311..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DelegateComparerTests.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using System.Collections.Generic;
-using System.Linq;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class DelegateComparerTests
- {
- const string Prefix = nameof(Generator) + ".DelegateComparer.";
-
- [Fact(DisplayName = Prefix + nameof(DistinctComparesByComparator))]
- public void DistinctComparesByComparator()
- {
- var comparer = new DelegateComparer, string>(p => p.Key);
-
- int actual = new[]
- {
- new KeyValuePair("myKey", "myValue1"),
- new KeyValuePair("myKey", "myValue2"),
- }
- .Distinct(comparer)
- .Count();
-
- Assert.Equal(1, actual);
- }
-
- [Fact(DisplayName = Prefix + nameof(DistinctComparesByComparator))]
- public void HashSetComparesByComparator()
- {
- var comparer = new DelegateComparer, string>(p => p.Key);
-
- var items = new[] {
- new KeyValuePair("myKey", "myValue1"),
- new KeyValuePair("myKey", "myValue2"),
- };
- int actual = new HashSet>(items, comparer).Count;
-
- Assert.Equal(1, actual);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/EnumMemberDocCommentGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/EnumMemberDocCommentGeneratorTests.cs
deleted file mode 100644
index 18215a7d2a..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/EnumMemberDocCommentGeneratorTests.cs
+++ /dev/null
@@ -1,150 +0,0 @@
-using Amazon.JSII.Generator.DocComment;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.DocComment
-{
- public class EnumMemberDocCommentGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(EnumMemberDocCommentGenerator) + ".";
-
- string Render(Docs docs)
- {
- EnumMember member = new EnumMember("member", docs);
- EnumMemberDocCommentGenerator generator = new EnumMemberDocCommentGenerator(member);
-
- SyntaxTrivia docComment = generator.CreateDocComment();
- SyntaxTree tree = SF.SyntaxTree(
- SF.EnumMemberDeclaration("Member")
- .WithLeadingTrivia(generator.CreateDocComment())
- .NormalizeWhitespace(elasticTrivia: true)
- );
-
- return tree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineSummary))]
- public void IncludesSingleLineSummary()
- {
- Docs docs = new Docs
- (
- summary: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// my comment
- Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = Prefix + nameof(IncludesMultiLineSummary))]
- [InlineData("my\ncomment")]
- [InlineData("my\r\ncomment")]
- public void IncludesMultiLineSummary(string summary)
- {
- Docs docs = new Docs
- (
- summary: summary
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// my
-/// comment
-///
- Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineRemarks))]
- public void IncludesSingleLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{ "myKey", "my comment" }}
- );
-
- string actual = Render(docs);
- string expected =
-@"/// myKey: my comment
- Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMultiLineRemarks))]
- public void IncludesMultiLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{
- { "myKey1", "my\ncomment" },
- { "myKey2", "my\r\ncomment" }
- }
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// myKey1: my
-/// comment
-/// myKey2: my
-/// comment
-///
- Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(SeparatesSingleLineLink))]
- public void SeparatesSingleLineLink()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{ "link", "www.example.com" }}
- );
-
- string actual = Render(docs);
- string expected =
-@"/// link: www.example.com
- Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresParam))]
- public void IgnoresParam()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{ "param", "my comment" }}
- );
-
- string actual = Render(docs);
- string expected = @"Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresReturns))]
- public void IgnoresReturns()
- {
- Docs docs = new Docs
- (
- returns: "my comment"
- );
-
- string actual = Render(docs);
- string expected = @"Member";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/MethodDocCommentGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/MethodDocCommentGeneratorTests.cs
deleted file mode 100644
index 2e49a4827c..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/MethodDocCommentGeneratorTests.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-using Amazon.JSII.Generator.DocComment;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.DocComment
-{
- public class MethodDocCommentGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(MethodDocCommentGenerator) + ".";
-
- string Render(Docs docs, params Parameter[] parameters)
- {
- Method method = new Method(
- parameters: parameters,
- docs: docs,
- name: "method"
- );
-
- MethodDocCommentGenerator generator = new MethodDocCommentGenerator(method, Symbols);
-
- SyntaxTrivia docComment = generator.CreateDocComment();
- SyntaxTree tree = SF.SyntaxTree(
- SF.MethodDeclaration(SF.ParseTypeName("void"), "Method")
- .WithLeadingTrivia(generator.CreateDocComment())
- .NormalizeWhitespace(elasticTrivia: true)
- );
-
- return tree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineSummary))]
- public void IncludesSingleLineSummary()
- {
- Docs docs = new Docs
- (
- summary: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// my comment
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = Prefix + nameof(IncludesMultiLineSummary))]
- [InlineData("my\ncomment")]
- [InlineData("my\r\ncomment")]
- public void IncludesMultiLineSummary(string summary)
- {
- Docs docs = new Docs
- (
- summary: summary
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// my
-/// comment
-///
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineRemarks))]
- public void IncludesSingleLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{ "myKey", "my comment" }}
- );
-
- string actual = Render(docs);
- string expected =
-@"/// myKey: my comment
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMultiLineRemarks))]
- public void IncludesMultiLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{
- { "myKey1", "my\ncomment" },
- { "myKey2", "my\r\ncomment" }
- }
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// myKey1: my
-/// comment
-/// myKey2: my
-/// comment
-///
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(SeparatesSingleLineLink))]
- public void SeparatesSingleLineLink()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{ { "link", "www.example.com" } }
- );
-
- string actual = Render(docs);
- string expected =
-@"/// link: www.example.com
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresParam))]
- public void IgnoresParam()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{ { "param", "my comment" } }
- );
-
- string actual = Render(docs);
- string expected = @"void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesReturns))]
- public void IncludesReturns()
- {
- Docs docs = new Docs
- (
- returns: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// my comment
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresParameterParam))]
- public void IgnoresParameterParam()
- {
- Parameter parameter = new Parameter(
- name: "myParam",
- type: new TypeReference(primitive: PrimitiveType.String),
- docs: new Docs
- (
- custom: new Dictionary{ { "param", "my comment" } }
- )
- );
-
- Symbols.MapParameterName("myParam", "myParam");
-
- string actual = Render(null, parameter);
- string expected = @"void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresParameterParam))]
- public void TrimsParameterSummary()
- {
- Parameter parameter = new Parameter(
- name: "myParam",
- type: new TypeReference(primitive: PrimitiveType.String),
- docs: new Docs
- (
- summary: "my comment"
- )
- );
-
- Symbols.MapParameterName("myParam", "myParam");
-
- string actual = Render(null, parameter);
- string expected =
-@"/// my comment
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesParameterSummary))]
- public void IncludesParameterSummary()
- {
- Parameter parameter = new Parameter(
- name: "myParam",
- type: new TypeReference(primitive: PrimitiveType.String),
- docs: new Docs
- (
- summary: "This parameter is swell"
- )
- );
-
- Symbols.MapParameterName("myParam", "myParam");
-
- string actual = Render(null, parameter);
- string expected =
-@"/// This parameter is swell
- void Method()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/PropertyDocCommentGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/PropertyDocCommentGeneratorTests.cs
deleted file mode 100644
index 9f9608983d..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/PropertyDocCommentGeneratorTests.cs
+++ /dev/null
@@ -1,182 +0,0 @@
-using Amazon.JSII.Generator.DocComment;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.DocComment
-{
- public class PropertyDocCommentGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(PropertyDocCommentGenerator) + ".";
-
- string Render(Docs docs)
- {
- Property property = new Property(
- name: "myProp",
- type: new TypeReference(primitive: PrimitiveType.String),
- isImmutable: false,
- isAbstract: false,
- isStatic: false,
- docs: docs
- );
-
- PropertyDocCommentGenerator generator = new PropertyDocCommentGenerator(property);
-
- SyntaxTrivia docComment = generator.CreateDocComment();
- SyntaxTree tree = SF.SyntaxTree(
- SF.PropertyDeclaration(SF.ParseTypeName("string"), "MyProp")
- .WithLeadingTrivia(generator.CreateDocComment())
- .NormalizeWhitespace(elasticTrivia: true)
- );
-
- return tree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineSummary))]
- public void IncludesSingleLineSummary()
- {
- Docs docs = new Docs
- (
- summary: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// my comment
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = Prefix + nameof(IncludesMultiLineSummary))]
- [InlineData("my\ncomment")]
- [InlineData("my\r\ncomment")]
- public void IncludesMultiLineSummary(string summary)
- {
- Docs docs = new Docs
- (
- summary: summary
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// my
-/// comment
-///
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineRemarks))]
- public void IncludesSingleLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{ "myKey", "my comment" }}
- );
-
- string actual = Render(docs);
- string expected =
-@"/// myKey: my comment
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMultiLineRemarks))]
- public void IncludesMultiLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{
- { "myKey1", "my\ncomment" },
- { "myKey2", "my\r\ncomment" }
- }
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// myKey1: my
-/// comment
-/// myKey2: my
-/// comment
-///
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(SeparatesSingleLineLink))]
- public void SeparatesSingleLineLink()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{"link", "www.example.com" }}
- );
-
- string actual = Render(docs);
- string expected =
-@"/// link: www.example.com
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresParam))]
- public void IgnoresParam()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{"param", "my comment" }}
- );
-
- string actual = Render(docs);
- string expected = @"string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesReturns))]
- public void IncludesReturns()
- {
- Docs docs = new Docs
- (
- returns: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// my comment
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(ShowsDefault))]
- public void ShowsDefault()
- {
- Docs docs = new Docs
- (
- summary: "A property",
- remarks: "Some remarks.",
- @default: "Tis a default"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// A property
-///
-/// Some remarks.
-/// default: Tis a default
-///
- string MyProp";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/TypeDocCommentGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/TypeDocCommentGeneratorTests.cs
deleted file mode 100644
index 638272854e..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/DocComment/TypeDocCommentGeneratorTests.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-using Amazon.JSII.Generator.DocComment;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-using System.Collections.Generic;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Amazon.JSII.Generator.UnitTests.DocComment
-{
- public class TypeDocCommentGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(TypeDocCommentGenerator) + ".";
-
- string Render(Docs docs)
- {
- Type type = new InterfaceType(
- "myFqn",
- "myModule",
- "myInterfaceName",
- "myInterfaceNamespace",
- docs
- );
-
- TypeDocCommentGenerator generator = new TypeDocCommentGenerator(type);
-
- SyntaxTrivia docComment = generator.CreateDocComment();
- SyntaxTree tree = SF.SyntaxTree(
- SF.InterfaceDeclaration("MyInterface")
- .WithLeadingTrivia(generator.CreateDocComment())
- .NormalizeWhitespace(elasticTrivia: true)
- );
-
- return tree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineSummary))]
- public void IncludesSingleLineSummary()
- {
- Docs docs = new Docs
- (
- summary: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"/// my comment
- interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = Prefix + nameof(IncludesMultiLineSummary))]
- [InlineData("my\ncomment")]
- [InlineData("my\r\ncomment")]
- public void IncludesMultiLineSummary(string summary)
- {
- Docs docs = new Docs
- (
- summary: summary
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// my
-/// comment
-///
- interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesSingleLineRemarks))]
- public void IncludesSingleLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{{ "myKey", "my comment" }}
- );
-
- string actual = Render(docs);
- string expected =
-@"/// myKey: my comment
- interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMultiLineRemarks))]
- public void IncludesMultiLineRemarks()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{
- { "myKey1", "my\ncomment" },
- { "myKey2", "my\r\ncomment" }
- }
- );
-
- string actual = Render(docs);
- string expected =
-@"///
-/// myKey1: my
-/// comment
-/// myKey2: my
-/// comment
-///
- interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(SeparatesSingleLineLink))]
- public void SeparatesSingleLineLink()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{ { "link", "www.example.com" } }
- );
-
- string actual = Render(docs);
- string expected =
-@"/// link: www.example.com
- interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresParam))]
- public void IgnoresParam()
- {
- Docs docs = new Docs
- (
- custom: new Dictionary{ { "param", "my comment" } }
- );
-
- string actual = Render(docs);
- string expected =
-@"interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IgnoresReturns))]
- public void IgnoresReturns()
- {
- Docs docs = new Docs
- (
- returns: "my comment"
- );
-
- string actual = Render(docs);
- string expected =
-@"interface MyInterface
-{
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Enum/EnumGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Enum/EnumGeneratorTests.cs
deleted file mode 100644
index 55f4606cbd..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Enum/EnumGeneratorTests.cs
+++ /dev/null
@@ -1,144 +0,0 @@
-using Amazon.JSII.Generator.Enum;
-using Amazon.JSII.Generator.Interface;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Enum
-{
- public class EnumGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(InterfaceGenerator) + ".";
-
- string Render(EnumType enumType)
- {
- Symbols.MapTypeToPackage("myEnumFqn", enumType.Assembly);
- Symbols.MapNamespace(enumType.QualifiedNamespace, "MyNamespace");
- Symbols.MapTypeName("myEnumFqn", "MyEnum", JsonModel.Spec.TypeKind.Enum);
-
- EnumGenerator generator = new EnumGenerator(enumType.Assembly, enumType, Symbols, Namespaces);
-
- SyntaxTree syntaxTree = generator.CreateSyntaxTree();
- return syntaxTree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- EnumType enumType = new EnumType
- (
- fullyQualifiedName: "myEnumFqn",
- assembly: "myPackage",
- name: "myEnum",
- members: new EnumMember[] { }
- );
-
- string actual = Render(enumType);
- string expected =
-@"namespace MyNamespace
-{
- [JsiiEnum(nativeType: typeof(MyEnum), fullyQualifiedName: ""myEnumFqn"")]
- public enum MyEnum
- {
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMembers))]
- public void IncludesMembers()
- {
- EnumType enumType = new EnumType
- (
- fullyQualifiedName: "myEnumFqn",
- assembly: "myPackage",
- name: "myEnum",
- members: new EnumMember[]
- {
- new EnumMember("member1"),
- new EnumMember("member2"),
- }
- );
-
- Symbols.MapEnumMemberName("myEnumFqn", "member1", "Member1");
- Symbols.MapEnumMemberName("myEnumFqn", "member2", "Member2");
-
- string actual = Render(enumType);
- string expected =
-@"namespace MyNamespace
-{
- [JsiiEnum(nativeType: typeof(MyEnum), fullyQualifiedName: ""myEnumFqn"")]
- public enum MyEnum
- {
- [JsiiEnumMember(name: ""member1"")]
- Member1,
- [JsiiEnumMember(name: ""member2"")]
- Member2
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesDocs))]
- public void IncludesDocs()
- {
- EnumType enumType = new EnumType
- (
- fullyQualifiedName: "myEnumFqn",
- assembly: "myPackage",
- name: "myEnum",
- members: new EnumMember[] { },
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- string actual = Render(enumType);
- string expected =
-@"namespace MyNamespace
-{
- /// foo: bar
- [JsiiEnum(nativeType: typeof(MyEnum), fullyQualifiedName: ""myEnumFqn"")]
- public enum MyEnum
- {
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMemberDocs))]
- public void IncludesMemberDocs()
- {
- EnumType enumType = new EnumType
- (
- fullyQualifiedName: "myEnumFqn",
- assembly: "myPackage",
- name: "myEnum",
- members: new EnumMember[]
- {
- new EnumMember("member1", docs: new Docs(custom: new Dictionary{{"foo", "bar"}})),
- new EnumMember("member2", docs: new Docs(custom: new Dictionary{{"foo", "bar"}}))
- }
- );
-
- Symbols.MapEnumMemberName("myEnumFqn", "member1", "Member1");
- Symbols.MapEnumMemberName("myEnumFqn", "member2", "Member2");
-
- string actual = Render(enumType);
- string expected =
-@"namespace MyNamespace
-{
- [JsiiEnum(nativeType: typeof(MyEnum), fullyQualifiedName: ""myEnumFqn"")]
- public enum MyEnum
- {
- /// foo: bar
- [JsiiEnumMember(name: ""member1"")]
- Member1,
- /// foo: bar
- [JsiiEnumMember(name: ""member2"")]
- Member2
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/GeneratorTestBase.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/GeneratorTestBase.cs
deleted file mode 100644
index 419e7e6358..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/GeneratorTestBase.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using NSubstitute;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using Type = Amazon.JSII.JsonModel.Spec.Type;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public abstract class GeneratorTestBase
- {
- public GeneratorTestBase()
- {
- Symbols = Substitute.For();
- Namespaces = Substitute.For();
-
- Symbols
- .GetTypeSyntax(Arg.Is(t => t.Primitive == PrimitiveType.String), false)
- .Returns(SF.ParseTypeName("string"));
- }
-
- protected ISymbolMap Symbols { get; }
-
- protected INamespaceSet Namespaces { get; }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceGeneratorTests.cs
deleted file mode 100644
index 4a4eac350f..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceGeneratorTests.cs
+++ /dev/null
@@ -1,104 +0,0 @@
-using Amazon.JSII.Generator.Interface;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests.Interface
-{
- public class InterfaceGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(InterfaceGenerator) + ".";
-
- string Render(InterfaceType interfaceType)
- {
- Symbols.MapTypeToPackage("myInterfaceFqn", interfaceType.Assembly);
- Symbols.MapNamespace(interfaceType.QualifiedNamespace, "MyNamespace");
- Symbols.MapTypeName("myInterfaceFqn", "MyInterface", kind: JsonModel.Spec.TypeKind.Interface);
-
- InterfaceGenerator generator = new InterfaceGenerator(interfaceType.Assembly, interfaceType, Symbols, Namespaces);
-
- SyntaxTree syntaxTree = generator.CreateSyntaxTree();
- return syntaxTree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- fullyQualifiedName: "myInterfaceFqn",
- assembly: "myPackage",
- name: "MyInterface"
- );
-
- string actual = Render(interfaceType);
- string expected =
-@"namespace MyNamespace
-{
- [JsiiInterface(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- public interface IMyInterface
- {
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesBaseInterfaces))]
- public void IncludesBaseInterfaces()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- fullyQualifiedName: "myInterfaceFqn",
- assembly: "myPackage",
- name: "MyInterface",
- interfaces: new[]
- {
- "myBaseFqn1",
- "myBaseFqn2",
- }
- );
-
- Symbols.MapTypeName("myBaseFqn1", "MyBaseInterface1", kind: JsonModel.Spec.TypeKind.Interface);
- Symbols.MapTypeName("myBaseFqn2", "MyBaseInterface2", kind: JsonModel.Spec.TypeKind.Interface);
-
- string actual = Render(interfaceType);
- string expected =
-@"namespace MyNamespace
-{
- [JsiiInterface(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- public interface IMyInterface : IMyBaseInterface1, IMyBaseInterface2
- {
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMethods))]
- public void IncludesMethods()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- fullyQualifiedName: "myInterfaceFqn",
- assembly: "",
- name: "MyInterface",
- methods: new Method[] { new Method(name: "myMethod", isAbstract: true) }
- );
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
-
- string actual = Render(interfaceType);
- string expected =
-@"namespace MyNamespace
-{
- [JsiiInterface(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- public interface IMyInterface
- {
- [JsiiMethod(name: ""myMethod"")]
- void MyMethod();
- }
-}";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceMethodGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceMethodGeneratorTests.cs
deleted file mode 100644
index 535156c6cb..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceMethodGeneratorTests.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using Amazon.JSII.Generator.Interface;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using NSubstitute;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests.Interface
-{
- public class InterfaceMethodGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(InterfaceMethodGenerator) + ".";
-
- string Render(Method method)
- {
- InterfaceType interfaceType = new InterfaceType
- (
- "myInterfaceFqn",
- "",
- "IMyInterface",
- "myNamespace",
- methods: new[] { method }
- );
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
- Symbols.MapTypeName("myInterfaceFqn", "MyInterface", JsonModel.Spec.TypeKind.Interface);
- Symbols.MapTypeName("myReturnTypeFqn", "MyReturnType", JsonModel.Spec.TypeKind.Class);
-
- InterfaceMethodGenerator generator = new InterfaceMethodGenerator(interfaceType, method, Symbols, Namespaces);
-
- MethodDeclarationSyntax methodSyntax = generator.CreateMethod();
- return methodSyntax.NormalizeWhitespace(elasticTrivia: true).ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(RecordsReferencedReturnType))]
- public void RecordsReferencedReturnType()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: true,
- name: "myMethod",
- returns: new OptionalValue(type: new TypeReference(fullyQualifiedName: "myReturnTypeFqn"))
- );
-
- Render(method);
- Namespaces.Received().Add(Arg.Is(t => t.FullyQualifiedName == "myReturnTypeFqn"));
- }
-
- [Fact(DisplayName = Prefix + nameof(RecordsReferencedParameterType))]
- public void RecordsReferencedParameterType()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: true,
- name: "myMethod",
- parameters: new[]
- {
- new Parameter
- (
- name: "myParameter",
- type: new TypeReference(fullyQualifiedName: "myParameterTypeFqn")
- )
- }
- );
-
- Symbols.MapParameterName("myParameter", "myParameter");
-
- Render(method);
-
- Namespaces.Received().Add(Arg.Is(t => t.FullyQualifiedName == "myParameterTypeFqn"));
- }
-
- [Fact(DisplayName = Prefix + nameof(GeneratesVoidMethodWithNoParameters))]
- public void GeneratesVoidMethodWithNoParameters()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: true,
- name: "myMethod"
- );
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-void MyMethod();";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GeneratesPrimitiveParameters))]
- public void GeneratesPrimitiveParameters()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: true,
- name: "myMethod",
- parameters: new[]
- {
- new Parameter
- (
- name: "myParameter1",
- type: new TypeReference(primitive: PrimitiveType.String)
- ),
- new Parameter
- (
- name: "event",
- type: new TypeReference(primitive: PrimitiveType.String)
- ),
- }
- );
-
- Symbols.MapParameterName("myParameter1", "myParameter1");
- Symbols.MapParameterName("event", "@event");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", parametersJson: ""[{\""name\"":\""myParameter1\"",\""type\"":{\""primitive\"":\""string\""}},{\""name\"":\""event\"",\""type\"":{\""primitive\"":\""string\""}}]"")]
-void MyMethod(string myParameter1, string @event);";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GeneratesPrimitiveReturnType))]
- public void GeneratesPrimitiveReturnType()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: true,
- name: "myMethod",
- returns: new OptionalValue(type: new TypeReference(primitive: PrimitiveType.String))
- );
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", returnsJson: ""{\""type\"":{\""primitive\"":\""string\""}}"")]
-string MyMethod();";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceProxyGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceProxyGeneratorTests.cs
deleted file mode 100644
index 57e6cd6ed6..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceProxyGeneratorTests.cs
+++ /dev/null
@@ -1,278 +0,0 @@
-using Amazon.JSII.Generator.Interface;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Newtonsoft.Json;
-using Xunit;
-using TypeKind = Amazon.JSII.JsonModel.Spec.TypeKind;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Interface
-{
- public class InterfaceProxyGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(InterfaceProxyGenerator) + ".";
-
- string Render(InterfaceType interfaceType, string package = "myPackage", string @namespace = "MyNamespace",
- string typeName = "MyInterface")
- {
- Symbols.MapTypeToPackage(interfaceType.FullyQualifiedName, package);
- string suffix = interfaceType.Namespace != null ? "." + interfaceType.Namespace : "";
- Symbols.MapNamespace(interfaceType.Assembly + suffix, @namespace);
- Symbols.MapTypeName(interfaceType.FullyQualifiedName, typeName, TypeKind.Interface);
-
- var generator = new InterfaceProxyGenerator(package, interfaceType, Symbols, Namespaces);
-
- SyntaxTree syntaxTree = generator.CreateSyntaxTree();
- return syntaxTree.ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- "myInterfaceFqn",
- "myPackage",
- "myInterface",
- "myNamespace",
- methods: new Method[] { }
- );
-
- string actual = Render(interfaceType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiTypeProxy(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- internal sealed class MyInterfaceProxy : DeputyBase, IMyInterface
- {
- private MyInterfaceProxy(ByRefValue reference): base(reference)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesMethods))]
- public void IncludesMethods()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- "myInterfaceFqn",
- "myPackage",
- "myInterface",
- "myNamespace",
- methods: new Method[] {new Method(isAbstract: true, name: "myMethod")}
- );
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
-
- string actual = Render(interfaceType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiTypeProxy(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- internal sealed class MyInterfaceProxy : DeputyBase, IMyInterface
- {
- private MyInterfaceProxy(ByRefValue reference): base(reference)
- {
- }
-
- [JsiiMethod(name: ""myMethod"")]
- public void MyMethod()
- {
- InvokeInstanceVoidMethod(new object[]{});
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAncestorInterfaceMethods))]
- public void IncludesAncestorInterfaceMethods()
- {
- InterfaceType ancestorInterface = new InterfaceType
- (
- "myAncestorInterfaceFqn",
- "myPackage",
- "myAncestorInterface",
- "myNamespace",
- methods: new[] {new Method(isAbstract: true, name: "myAncestorMethod")}
- );
- InterfaceType baseInterface = new InterfaceType
- (
- "myBaseInterfaceFqn",
- "myPackage",
- "myBaseInterface",
- "myNamespace",
- methods: new[] {new Method(isAbstract: true, name: "myBaseMethod")},
- interfaces: new[] {"myAncestorInterfaceFqn"}
- );
- InterfaceType interfaceType = new InterfaceType
- (
- "myInterfaceFqn",
- "myPackage",
- "myInterface",
- "myNamespace",
- interfaces: new[] {"myBaseInterfaceFqn"}
- );
-
- Symbols.MapTypeName("myAncestorInterfaceFqn", "MyAncestorInterface", TypeKind.Interface);
- Symbols.MapFullyQualifiedNameToType("myAncestorInterfaceFqn", ancestorInterface);
- Symbols.MapMethodName("myInterfaceFqn", "myAncestorMethod", "MyAncestorMethod");
-
- Symbols.MapTypeName("myBaseInterfaceFqn", "MyBaseInterface", TypeKind.Interface);
- Symbols.MapFullyQualifiedNameToType("myBaseInterfaceFqn", baseInterface);
- Symbols.MapMethodName("myInterfaceFqn", "myBaseMethod", "MyBaseMethod");
-
- string actual = Render(interfaceType);
- string expected =
- @"namespace MyNamespace
-{
- [JsiiTypeProxy(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- internal sealed class MyInterfaceProxy : DeputyBase, IMyInterface
- {
- private MyInterfaceProxy(ByRefValue reference): base(reference)
- {
- }
-
- [JsiiMethod(name: ""myBaseMethod"")]
- public void MyBaseMethod()
- {
- InvokeInstanceVoidMethod(new object[]{});
- }
-
- [JsiiMethod(name: ""myAncestorMethod"")]
- public void MyAncestorMethod()
- {
- InvokeInstanceVoidMethod(new object[]{});
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesDocs))]
- public void IncludesDocs()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- "myInterfaceFqn",
- "myPackage",
- "myInterface",
- "myNamespace",
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- string actual = Render(interfaceType);
- string expected =
- @"namespace MyNamespace
-{
- /// foo: bar
- [JsiiTypeProxy(nativeType: typeof(IMyInterface), fullyQualifiedName: ""myInterfaceFqn"")]
- internal sealed class MyInterfaceProxy : DeputyBase, IMyInterface
- {
- private MyInterfaceProxy(ByRefValue reference): base(reference)
- {
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(EnvironmentRegression))]
- public void EnvironmentRegression()
- {
- const string json =
- @" {
- ""docs"": {
- ""summary"": ""Models an AWS execution environment, for use within the CDK toolkit.""
- },
- ""kind"": ""interface"",
- ""properties"": [
- {
- ""docs"": {
- ""summary"": ""The arbitrary name of this environment (user-set, or at least user-meaningful) ""
- },
- ""abstract"": true,
- ""name"": ""name"",
- ""type"": {
- ""primitive"": ""string""
- }
- },
- {
- ""docs"": {
- ""summary"": ""The 12-digit AWS account ID for the account this environment deploys into ""
- },
- ""abstract"": true,
- ""name"": ""account"",
- ""type"": {
- ""primitive"": ""string""
- }
- },
- {
- ""docs"": {
- ""summary"": ""The AWS region name where this environment deploys into ""
- },
- ""abstract"": true,
- ""name"": ""region"",
- ""type"": {
- ""primitive"": ""string""
- }
- }
- ],
- ""fqn"": ""jsii$aws_cdk_cx_api$.Environment"",
- ""assembly"": ""jsii$aws_cdk_cx_api$"",
- ""namespace"": ""jsii$aws_cdk_cx_api$"",
- ""name"": ""Environment"",
- ""datatype"": true
- }";
-
- InterfaceType interfaceType = JsonConvert.DeserializeObject(json);
-
- Symbols.MapPropertyName("jsii$aws_cdk_cx_api$.Environment", "name", "Name");
- Symbols.MapPropertyName("jsii$aws_cdk_cx_api$.Environment", "account", "Account");
- Symbols.MapPropertyName("jsii$aws_cdk_cx_api$.Environment", "region", "Region");
-
- string actual = Render(interfaceType, package: "aws-cdk-cx-api", @namespace: "Aws.Cdk.CxApi",
- typeName: "Environment");
- string expected =
- @"namespace Aws.Cdk.CxApi
-{
- /// Models an AWS execution environment, for use within the CDK toolkit.
- [JsiiTypeProxy(nativeType: typeof(IEnvironment), fullyQualifiedName: ""jsii$aws_cdk_cx_api$.Environment"")]
- internal sealed class EnvironmentProxy : DeputyBase, IEnvironment
- {
- private EnvironmentProxy(ByRefValue reference): base(reference)
- {
- }
-
- /// The arbitrary name of this environment (user-set, or at least user-meaningful)
- [JsiiProperty(name: ""name"", typeJson: ""{\""primitive\"":\""string\""}"")]
- public string Name
- {
- get => GetInstanceProperty();
- set => SetInstanceProperty(value);
- }
-
- /// The 12-digit AWS account ID for the account this environment deploys into
- [JsiiProperty(name: ""account"", typeJson: ""{\""primitive\"":\""string\""}"")]
- public string Account
- {
- get => GetInstanceProperty();
- set => SetInstanceProperty(value);
- }
-
- /// The AWS region name where this environment deploys into
- [JsiiProperty(name: ""region"", typeJson: ""{\""primitive\"":\""string\""}"")]
- public string Region
- {
- get => GetInstanceProperty();
- set => SetInstanceProperty(value);
- }
- }
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
\ No newline at end of file
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceProxyMethodGeneratorTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceProxyMethodGeneratorTests.cs
deleted file mode 100644
index e53cad895f..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/Interface/InterfaceProxyMethodGeneratorTests.cs
+++ /dev/null
@@ -1,124 +0,0 @@
-using Amazon.JSII.Generator.Interface;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Xunit;
-using TypeKind = Amazon.JSII.JsonModel.Spec.TypeKind;
-using System.Collections.Generic;
-
-namespace Amazon.JSII.Generator.UnitTests.Interface
-{
- public class InterfaceProxyMethodGeneratorTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(InterfaceProxyMethodGenerator) + ".";
-
- string Render(Method method)
- {
- InterfaceType interfaceType = new InterfaceType
- (
- "myInterfaceFqn",
- "myModule",
- "myClass",
- "myNamespace",
- methods: new Method[] { method }
- );
-
- Symbols.MapTypeToPackage("myInterfaceFqn", "myPackage");
- Symbols.MapNamespace("", "MyNamespace");
- Symbols.MapTypeName("myInterfaceFqn", "MyInterface", TypeKind.Interface);
-
- var generator = new InterfaceProxyMethodGenerator(interfaceType, method, Symbols, Namespaces);
-
- MethodDeclarationSyntax methodSyntax = generator.CreateMethod();
- return methodSyntax.NormalizeWhitespace(elasticTrivia: true).ToString();
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesAttribute))]
- public void IncludesAttribute()
- {
- Method method = new Method(isAbstract: true, name: "myMethod");
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-public void MyMethod()
-{
- InvokeInstanceVoidMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncluesParameters))]
- public void IncluesParameters()
- {
- Method method = new Method
- (
- isAbstract: true, name: "myMethod",
- parameters: new[]
- {
- new Parameter(name: "myParam", type: new TypeReference("myParamTypeFqn")),
- new Parameter(name: "event", type: new TypeReference(primitive: PrimitiveType.String))
- }
- );
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
- Symbols.MapTypeName("myParamTypeFqn", "MyParamType", TypeKind.Class);
- Symbols.MapParameterName("myParam", "myParam");
- Symbols.MapParameterName("event", "@event");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", parametersJson: ""[{\""name\"":\""myParam\"",\""type\"":{\""fqn\"":\""myParamTypeFqn\""}},{\""name\"":\""event\"",\""type\"":{\""primitive\"":\""string\""}}]"")]
-public void MyMethod(MyParamType myParam, string @event)
-{
- InvokeInstanceVoidMethod(new object[]{myParam, @event});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotIncludeDocs))]
- public void DoesNotIncludeDocs()
- {
- Method method = new Method
- (
- isAbstract: true, name: "myMethod",
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- );
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"")]
-public void MyMethod()
-{
- InvokeInstanceVoidMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(IncludesReturnTypeForNonVoid))]
- public void IncludesReturnTypeForNonVoid()
- {
- Method method = new Method
- (
- isAbstract: true, name: "myMethod",
- returns: new OptionalValue(type: new TypeReference("myReturnTypeFqn"))
- );
-
- Symbols.MapMethodName("myInterfaceFqn", "myMethod", "MyMethod");
- Symbols.MapTypeName("myReturnTypeFqn", "MyReturnType", TypeKind.Class);
-
- string actual = Render(method);
- string expected =
-@"[JsiiMethod(name: ""myMethod"", returnsJson: ""{\""type\"":{\""fqn\"":\""myReturnTypeFqn\""}}"")]
-public MyReturnType MyMethod()
-{
- return InvokeInstanceMethod(new object[]{});
-}";
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/MethodExtensionsTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/MethodExtensionsTests.cs
deleted file mode 100644
index 55514bc488..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/MethodExtensionsTests.cs
+++ /dev/null
@@ -1,173 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Collections.Generic;
-using NSubstitute;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class MethodExtensionsTests
- {
- const string Prefix = nameof(Generator) + "." + nameof(CallableExtensions) + ".";
-
- public class GetParameterListSyntax : GeneratorTestBase
- {
- const string _Prefix = Prefix + nameof(CallableExtensions.GetParameterListSyntax) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(IncludesAllParameters))]
- public void IncludesAllParameters()
- {
- Method method = new Method
- (
- name: "myMethod",
- parameters: new[]
- {
- new Parameter(name: "myParam1", type: new TypeReference("myParamTypeFqn1")),
- new Parameter(name: "myParam2", type: new TypeReference("myParamTypeFqn2")),
- }
- );
-
- Symbols.MapTypeName("myParamTypeFqn1", "MyParamType1", JsonModel.Spec.TypeKind.Class);
- Symbols.MapTypeName("myParamTypeFqn2", "MyParamType2", JsonModel.Spec.TypeKind.Class);
- Symbols.MapParameterName("myParam1", "myParam1");
- Symbols.MapParameterName("myParam2", "myParam2");
-
- ParameterListSyntax syntax = method.GetParameterListSyntax(Namespaces, Symbols);
-
- string actual = syntax.NormalizeWhitespace(elasticTrivia: true).ToString();
- string expected = @"(MyParamType1 myParam1, MyParamType2 myParam2)";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DoesNotThrowOnMissingParameterList))]
- public void DoesNotThrowOnMissingParameterList()
- {
- Method method = new Method
- (
- name: "myMethod"
- );
-
- ParameterListSyntax syntax = method.GetParameterListSyntax(Namespaces, Symbols);
-
- string actual = syntax.NormalizeWhitespace(elasticTrivia: true).ToString();
- string expected = @"()";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(AddsNamespacesToSet))]
- public void AddsNamespacesToSet()
- {
- Type paramType1 = new EnumType
- (
- fullyQualifiedName: "myParamTypeFqn1",
- assembly: "myPackage",
- name: "myParamType",
- members: new EnumMember[] { }
- );
- Type paramType2 = new EnumType
- (
- fullyQualifiedName: "myParamTypeFqn2",
- assembly: "myPackage",
- name: "myParamType",
- members: new EnumMember[] { }
- );
- Method method = new Method
- (
- name: "myMethod",
- parameters: new[]
- {
- new Parameter(name: "myParam1", type: new TypeReference("myParamTypeFqn1")),
- new Parameter(name: "myParam2", type: new TypeReference("myParamTypeFqn2")),
- }
- );
-
- Symbols.MapTypeName("myParamTypeFqn1", "MyParamType1", JsonModel.Spec.TypeKind.Enum);
- Symbols.MapTypeName("myParamTypeFqn2", "MyParamType2", JsonModel.Spec.TypeKind.Enum);
- Symbols.MapFullyQualifiedNameToType("myParamTypeFqn1", paramType1);
- Symbols.MapFullyQualifiedNameToType("myParamTypeFqn2", paramType2);
- Symbols.MapNamespace("myNamespace1", "MyNamespace1");
- Symbols.MapNamespace("myNamespace2", "MyNamespace2");
- Symbols.MapParameterName("myParam1", "myParam1");
- Symbols.MapParameterName("myParam2", "myParam2");
-
- method.GetParameterListSyntax(Namespaces, Symbols);
-
- Namespaces.Received().Add(Arg.Is(r => r.FullyQualifiedName == "myParamTypeFqn1"));
- Namespaces.Received().Add(Arg.Is(r => r.FullyQualifiedName == "myParamTypeFqn2"));
- }
- }
-
- public class GetParametersJsonSyntaxToken : GeneratorTestBase
- {
- const string _Prefix = Prefix + nameof(CallableExtensions.GetParametersJsonSyntaxToken) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(StripsDocs))]
- public void StripsDocs()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod",
- parameters: new[]
- {
- new Parameter
- (
- name: "myParam1",
- type: new TypeReference("myParamTypeFqn1"),
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- ),
- new Parameter
- (
- name: "myParam2",
- type: new TypeReference("myParamTypeFqn2"),
- docs: new Docs(custom: new Dictionary{{"foo", "bar"}})
- )
- }
- );
-
- SyntaxToken token = method.GetParametersJsonSyntaxToken();
-
- string actual = token.ToString();
- string expected = @"""[{\""name\"":\""myParam1\"",\""type\"":{\""fqn\"":\""myParamTypeFqn1\""}},{\""name\"":\""myParam2\"",\""type\"":{\""fqn\"":\""myParamTypeFqn2\""}}]""";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(PreservesOptionality))]
- public void PreservesOptionality()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod",
- parameters: new[]
- {
- new Parameter
- (
- name: "myParam1",
- type: new TypeReference("myParamTypeFqn1")
- ),
- new Parameter
- (
- name: "myParam2",
- type: new TypeReference("myParamTypeFqn2"),
- isOptional: true
- )
- }
- );
-
- SyntaxToken token = method.GetParametersJsonSyntaxToken();
-
- string actual = token.ToString();
- string expected = @"""[{\""name\"":\""myParam1\"",\""type\"":{\""fqn\"":\""myParamTypeFqn1\""}},{\""name\"":\""myParam2\"",\""type\"":{\""fqn\"":\""myParamTypeFqn2\""},\""optional\"":true}]""";
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/NameUtilsTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/NameUtilsTests.cs
deleted file mode 100644
index 56268e8a5b..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/NameUtilsTests.cs
+++ /dev/null
@@ -1,181 +0,0 @@
-using System;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class NameUtilsTests
- {
- const string Prefix = nameof(Generator) + "." + nameof(NameUtils) + ".";
-
- public class ConvertPackageName
- {
- const string _Prefix = Prefix + nameof(NameUtils.ConvertPackageName) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(ConvertsValid))]
- [InlineData("aws-cdk", "Aws.Cdk")]
- [InlineData("aws-cdk-resources", "Aws.Cdk.Resources")]
- [InlineData("aws_cdk_resources", "Aws_cdk_resources")]
- public void ConvertsValid(string original, string expected)
- {
- string actual = NameUtils.ConvertPackageName(original);
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(ThrowsOnInvalid))]
- [InlineData("jsii$aws_cdk_resources$")]
- [InlineData("")]
- public void ThrowsOnInvalid(string original)
- {
- Assert.Throws(() => NameUtils.ConvertPackageName(original));
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNull))]
- public void ThrowsOnNull()
- {
- Assert.Throws(() => NameUtils.ConvertPackageName(null));
- }
- }
-
- public class ConvertTypeName
- {
- const string _Prefix = Prefix + nameof(NameUtils.ConvertTypeName) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(ConvertsValid))]
- [InlineData("myTypeName", "MyTypeName")]
- public void ConvertsValid(string original, string expected)
- {
- string actual = NameUtils.ConvertTypeName(original);
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(ThrowsOnInvalid))]
- [InlineData("jsii$myTypeName")]
- [InlineData("")]
- public void ThrowsOnInvalid(string original)
- {
- Assert.Throws(() => NameUtils.ConvertTypeName(original));
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNull))]
- public void ThrowsOnNull()
- {
- Assert.Throws(() => NameUtils.ConvertTypeName(null));
- }
- }
-
- public class ConvertPropertyName
- {
- const string _Prefix = Prefix + nameof(NameUtils.ConvertPropertyName) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(ConvertsValid))]
- [InlineData("myPropertyName", "MyPropertyName")]
- public void ConvertsValid(string original, string expected)
- {
- string actual = NameUtils.ConvertPropertyName(original);
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(ThrowsOnInvalid))]
- [InlineData("jsii$myPropertyName")]
- [InlineData("")]
- public void ThrowsOnInvalid(string original)
- {
- Assert.Throws(() => NameUtils.ConvertPropertyName(original));
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNull))]
- public void ThrowsOnNull()
- {
- Assert.Throws(() => NameUtils.ConvertPropertyName(null));
- }
- }
-
- public class ConvertMethodName
- {
- const string _Prefix = Prefix + nameof(NameUtils.ConvertMethodName) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(ConvertsValid))]
- [InlineData("myMethodName", "MyMethodName")]
- public void ConvertsValid(string original, string expected)
- {
- string actual = NameUtils.ConvertMethodName(original);
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(ThrowsOnInvalid))]
- [InlineData("jsii$myMethodName")]
- [InlineData("")]
- public void ThrowsOnInvalid(string original)
- {
- Assert.Throws(() => NameUtils.ConvertMethodName(original));
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNull))]
- public void ThrowsOnNull()
- {
- Assert.Throws(() => NameUtils.ConvertMethodName(null));
- }
- }
-
- public class ConvertEnumMemberName
- {
- const string _Prefix = Prefix + nameof(NameUtils.ConvertEnumMemberName) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(ConvertsValid))]
- [InlineData("myEnumMemberName", "MyEnumMemberName")]
- public void ConvertsValid(string original, string expected)
- {
- string actual = NameUtils.ConvertEnumMemberName(original);
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(ThrowsOnInvalid))]
- [InlineData("jsii$myEnumMemberName")]
- [InlineData("")]
- public void ThrowsOnInvalid(string original)
- {
- Assert.Throws(() => NameUtils.ConvertEnumMemberName(original));
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNull))]
- public void ThrowsOnNull()
- {
- Assert.Throws(() => NameUtils.ConvertEnumMemberName(null));
- }
- }
-
- public class ConvertParameterName
- {
- const string _Prefix = Prefix + nameof(NameUtils.ConvertParameterName) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(ConvertsValid))]
- [InlineData("myParameterName", "myParameterName")]
- [InlineData("event", "@event")]
- public void ConvertsValid(string original, string expected)
- {
- string actual = NameUtils.ConvertParameterName(original);
-
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(ThrowsOnInvalid))]
- [InlineData("jsii$myParameterName")]
- [InlineData("")]
- public void ThrowsOnInvalid(string original)
- {
- Assert.Throws(() => NameUtils.ConvertParameterName(original));
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNull))]
- public void ThrowsOnNull()
- {
- Assert.Throws(() => NameUtils.ConvertParameterName(null));
- }
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/NamespaceSetTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/NamespaceSetTests.cs
deleted file mode 100644
index d02995b89a..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/NamespaceSetTests.cs
+++ /dev/null
@@ -1,242 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using System.Linq;
-using Xunit;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class NamespaceSetTests : GeneratorTestBase
- {
- const string Prefix = nameof(Generator) + "." + nameof(NamespaceSet) + ".";
-
- void AssertUsings(SyntaxList usings, params string[] expectations)
- {
- Assert.Collection(usings, expectations.Select(GetInspector).ToArray());
-
- System.Action GetInspector(string expected)
- {
- return u => Assert.Equal(
- expected,
- u.NormalizeWhitespace(elasticTrivia: true).ToString(),
- ignoreLineEndingDifferences: true
- );
- }
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesUsingStatementForObjectReference))]
- public void CreatesUsingStatementForObjectReference()
- {
- Symbols.MapTypeToNamespace("myFqn", "MyNamespace");
-
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference("myFqn"));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesUsingStatementForDateReference))]
- public void CreatesUsingStatementForDateReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Date));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using System;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesUsingStatementForJsonReference))]
- public void CreatesUsingStatementForJsonReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Json));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using Newtonsoft.Json.Linq;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotCreateUsingStatementForSystemPrimitive))]
- public void DoesNotCreateUsingStatementForSystemPrimitive()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Any));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Boolean));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Number));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.String));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(CreatesUsingStatementForMapReference))]
- public void CreatesUsingStatementForMapReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Map,
- elementType: new TypeReference(primitive: PrimitiveType.String)
- )));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using System.Collections.Generic;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(RecursivelyCreatesUsingStatementForMapElementReference))]
- public void RecursivelyCreatesUsingStatementForMapElementReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(collection: new CollectionTypeReference(
- CollectionKind.Map,
- new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Map,
- elementType: new TypeReference(primitive: PrimitiveType.Json)
- )
- ))));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using Newtonsoft.Json.Linq;",
- "using System.Collections.Generic;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotCreateUsingStatementForArrayReference))]
- public void DoesNotCreateUsingStatementForArrayReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Array,
- elementType: new TypeReference(primitive: PrimitiveType.String)
- )));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(RecursivelyCreatesUsingStatementForArrayElementReference))]
- public void RecursivelyCreatesUsingStatementForArrayElementReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Array,
- elementType: new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Array,
- elementType: new TypeReference(primitive: PrimitiveType.Json)
- )
- ))));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using Newtonsoft.Json.Linq;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(RecursivelyCreatesUsingStatementForEachTypeInUnionReference))]
- public void RecursivelyCreatesUsingStatementForEachTypeInUnionReference()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(union: new UnionTypeReference(new[] {
- new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Array,
- elementType: new TypeReference(collection: new CollectionTypeReference(
- kind: CollectionKind.Array,
- elementType: new TypeReference(primitive: PrimitiveType.Json)
- )
- ))),
- new TypeReference(primitive: PrimitiveType.Date)
- })));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using Newtonsoft.Json.Linq;",
- "using System;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotCreateDuplicateUsingStatements))]
- public void DoesNotCreateDuplicateUsingStatements()
- {
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Json));
- namespaces.Add(new TypeReference(primitive: PrimitiveType.Json));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;",
- "using Newtonsoft.Json.Linq;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotCreateUsingStatementForCurrentNamespace))]
- public void DoesNotCreateUsingStatementForCurrentNamespace()
- {
- Symbols.MapTypeToNamespace("myFqn", "MyCurrentNamespace");
-
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference("myFqn"));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;"
- );
- }
-
- [Fact(DisplayName = Prefix + nameof(SortsUsingStatementsAlphaNumerically))]
- public void SortsUsingStatementsAlphaNumerically()
- {
- Symbols.MapTypeToNamespace("myFqn", "AAA");
-
- NamespaceSet namespaces = new NamespaceSet(Symbols, SF.ParseName("MyCurrentNamespace"));
- namespaces.Add(new TypeReference("myFqn"));
-
- SyntaxList usings = namespaces.GetUsings();
- AssertUsings
- (
- usings,
- "using Amazon.JSII.Runtime.Deputy;"
- );
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/SymbolMapExtensions.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/SymbolMapExtensions.cs
deleted file mode 100644
index 1eb07c579a..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/SymbolMapExtensions.cs
+++ /dev/null
@@ -1,195 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using NSubstitute;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- static class SymbolMapExtensions
- {
- public static void MapPropertyName(this ISymbolMap symbols, string ownerFullyQualifiedName, string jsiiName, string frameworkName)
- {
- symbols.GetName(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(p => p.Name == jsiiName)
- ).Returns(frameworkName);
- symbols.GetNameSyntaxToken(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(p => p.Name == jsiiName)
- ).Returns(SF.ParseToken(frameworkName));
- symbols.GetNameSyntax(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(p => p.Name == jsiiName)
- ).Returns(SF.ParseName(frameworkName));
- }
-
- public static void MapMethodName(this ISymbolMap symbols, string ownerFullyQualifiedName, string jsiiName, string frameworkName)
- {
- symbols.GetName(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(m => m.Name == jsiiName)
- ).Returns(frameworkName);
- symbols.GetNameSyntaxToken(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(m => m.Name == jsiiName)
- ).Returns(SF.ParseToken(frameworkName));
- symbols.GetNameSyntax(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(m => m.Name == jsiiName)
- ).Returns(SF.ParseName(frameworkName));
- }
-
- public static void MapEnumMemberName(this ISymbolMap symbols, string ownerFullyQualifiedName, string jsiiName, string frameworkName)
- {
- symbols.GetName(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(m => m.Name == jsiiName)
- ).Returns(frameworkName);
- symbols.GetNameSyntaxToken(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(m => m.Name == jsiiName)
- ).Returns(SF.ParseToken(frameworkName));
- symbols.GetNameSyntax(
- Arg.Is(t => t.FullyQualifiedName == ownerFullyQualifiedName),
- Arg.Is(m => m.Name == jsiiName)
- ).Returns(SF.ParseName(frameworkName));
- }
-
- public static void MapParameterName(this ISymbolMap symbols, string jsiiName, string frameworkName)
- {
- symbols.GetName(Arg.Is(t => t.Name == jsiiName)).Returns(frameworkName);
- symbols.GetNameSyntaxToken(Arg.Is(t => t.Name == jsiiName)).Returns(SF.ParseToken(frameworkName));
- symbols.GetNameSyntax(Arg.Is(t => t.Name == jsiiName)).Returns(SF.ParseName(frameworkName));
- }
-
- public static void MapTypeName(this ISymbolMap symbols, string fullyQualifiedName, string frameworkName, TypeKind kind)
- {
- var proxyName = $"{frameworkName}Proxy";
- switch (kind)
- {
- case TypeKind.Interface:
- var defaultName = frameworkName;
-
- symbols
- .GetInterfaceProxyName(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(proxyName);
- symbols
- .GetInterfaceDefaultName(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(defaultName);
- symbols
- .GetInterfaceProxyNameSyntaxToken(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseToken(proxyName));
- symbols
- .GetInterfaceDefaultNameSyntaxToken(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseToken(defaultName));
- symbols
- .GetInterfaceProxyNameSyntax(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseName(proxyName));
- symbols
- .GetInterfaceDefaultNameSyntax(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseName(defaultName));
-
- frameworkName = $"I{frameworkName}";
- break;
- case TypeKind.Class:
- symbols
- .GetAbstractClassProxyName(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(proxyName);
- break;
- }
-
- symbols
- .GetName(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(frameworkName);
- symbols
- .GetName(Arg.Is(fqn => fqn == fullyQualifiedName), qualified: Arg.Any())
- .Returns(frameworkName);
- symbols
- .GetNameSyntaxToken(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseToken(frameworkName));
- symbols
- .GetNameSyntaxToken(Arg.Is(fqn => fqn == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseToken(frameworkName));
- symbols
- .GetNameSyntax(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseName(frameworkName));
- symbols
- .GetNameSyntax(Arg.Is(fqn => fqn == fullyQualifiedName), qualified: Arg.Any())
- .Returns(SF.ParseName(frameworkName));
- symbols
- .GetTypeSyntax(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName), false)
- .Returns(SF.ParseTypeName(frameworkName));
- }
-
- public static void MapAssemblyName(this ISymbolMap symbols, string jsiiName, string frameworkName)
- {
- symbols
- .GetName(Arg.Is(a => a.Name == jsiiName))
- .Returns(frameworkName);
- symbols
- .GetNameSyntaxToken(Arg.Is(a => a.Name == jsiiName))
- .Returns(SF.ParseToken(frameworkName));
- symbols
- .GetNameSyntax(Arg.Is(a => a.Name == jsiiName))
- .Returns(SF.ParseName(frameworkName));
-
- symbols
- .GetAssemblyName(Arg.Is(n => n == jsiiName))
- .Returns(frameworkName);
- }
-
- public static void MapNamespace(this ISymbolMap symbols, string jsiiNamespace, string frameworkNamespace)
- {
- symbols
- .GetNamespace(Arg.Is(t => t.QualifiedNamespace == jsiiNamespace))
- .Returns(frameworkNamespace);
- symbols
- .GetNamespaceSyntaxToken(Arg.Is(t => t.QualifiedNamespace == jsiiNamespace))
- .Returns(SF.ParseToken(frameworkNamespace));
- symbols
- .GetNamespaceSyntax(Arg.Is(t => t.QualifiedNamespace == jsiiNamespace))
- .Returns(SF.ParseName(frameworkNamespace));
- }
-
- public static void MapTypeToNamespace(this ISymbolMap symbols, string fullyQualifiedName, string frameworkNamespace)
- {
- symbols
- .GetNamespace(Arg.Is(n => n == fullyQualifiedName))
- .Returns(frameworkNamespace);
- symbols
- .GetNamespaceSyntaxToken(Arg.Is(n => n == fullyQualifiedName))
- .Returns(SF.ParseToken(frameworkNamespace));
- symbols
- .GetNamespaceSyntax(Arg.Is(n => n == fullyQualifiedName))
- .Returns(SF.ParseName(frameworkNamespace));
- }
-
- public static void MapTypeToPackage(this ISymbolMap symbols, string fullyQualifiedName, string package)
- {
- symbols
- .GetPackage(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName))
- .Returns(package);
- symbols
- .GetPackage(Arg.Is(n => n == fullyQualifiedName))
- .Returns(package);
- symbols
- .GetPackageSyntaxToken(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName))
- .Returns(SF.ParseToken(package));
- symbols
- .GetPackageSyntaxToken(Arg.Is(n => n == fullyQualifiedName))
- .Returns(SF.ParseToken(package));
- symbols
- .GetPackageSyntax(Arg.Is(t => t.FullyQualifiedName == fullyQualifiedName))
- .Returns(SF.ParseName(package));
- symbols
- .GetPackageSyntax(Arg.Is(n => n == fullyQualifiedName))
- .Returns(SF.ParseName(package));
- }
-
- public static void MapFullyQualifiedNameToType(this ISymbolMap symbols, string fullyQualifiedName, Type type)
- {
- symbols
- .GetTypeFromFullyQualifiedName(Arg.Is(n => n == fullyQualifiedName))
- .Returns(type);
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/SymbolMapTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/SymbolMapTests.cs
deleted file mode 100644
index c0aaa5301e..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/SymbolMapTests.cs
+++ /dev/null
@@ -1,1344 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using System.Collections.Generic;
-using System.Linq;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class SymbolMapTests
- {
- const string Prefix = nameof(Generator) + "." + nameof(SymbolMap) + ".";
-
- static ISymbolMap GetSymbolMap(params Type[] types)
- {
- return GetSymbolMap(out Assembly assembly, types);
- }
-
- static ISymbolMap GetSymbolMap(out Assembly assembly, params Type[] types)
- {
- assembly = new Assembly
- (
- name: "my-package",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace",
- packageId: "My.PackageId"
- )),
- version: "myVersion",
- types: types.ToDictionary(t => t.FullyQualifiedName)
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly);
-
- return symbolMap;
- }
-
- public class Add
- {
- const string _Prefix = Prefix + nameof(SymbolMap.Add) + ".";
-
- [Fact(DisplayName = Prefix + nameof(LoadsEmptyAssembly))]
- public void LoadsEmptyAssembly()
- {
- ISymbolMap symbolMap = GetSymbolMap(out Assembly assembly);
-
- string actual = symbolMap.GetName(assembly);
- Assert.Equal("My.PackageId", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(RenamesTypeOnNamespaceConflict))]
- public void RenamesTypeOnNamespaceConflict()
- {
- Type type1 = new ClassType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package",
- name: "MyType",
- isAbstract: false
- );
- Type type2 = new ClassType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package",
- name: "myType2",
- @namespace: "MyType",
- isAbstract: false
- );
-
- Assembly assembly = new Assembly
- (
- name: "my-package",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace",
- packageId: "My.PackageId"
- )),
- version: "myVersion",
- types: new Dictionary
- {
- { type1.FullyQualifiedName, type1 },
- { type2.FullyQualifiedName, type2 },
- }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly);
-
- string actual = symbolMap.GetName(type1);
- Assert.Equal("MyType_", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(RenamesTypeOnMemberConflict))]
- public void RenamesTypeOnMemberConflict()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- properties: new[]
- {
- new Property(
- name: "myType",
- type: new TypeReference("myFqn"),
- isImmutable: false,
- isProtected: false,
- isStatic: false
- )
- }
- );
-
- Assembly assembly = new Assembly
- (
- name: "my-package",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace",
- packageId: "My.PackageId"
- )),
- version: "myVersion",
- types: new Dictionary
- {
- { type.FullyQualifiedName, type }
- }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly);
-
- string actual = symbolMap.GetName(type);
- Assert.Equal("MyType_", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetName
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetName) + ".";
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromType))]
- public void GetsFrameworkNameFromType()
- {
- Type type = new EnumType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetName(type);
- Assert.Equal("MyType", actual, ignoreLineEndingDifferences: true);
-
- actual = symbolMap.GetName("myFqn");
- Assert.Equal("MyType", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DisambiguatesTypeNameOnConflict))]
- public void DisambiguatesTypeNameOnConflict()
- {
- Type type1 = new EnumType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package-1",
- name: "myType",
- members: new EnumMember[] { }
- );
- Type type2 = new EnumType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package-2",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- Assembly assembly1 = new Assembly
- (
- name: "my-package-1",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace1",
- packageId: "My.PackageId1"
- )),
- version: "myVersion",
- types: new Dictionary { { type1.FullyQualifiedName, type1 } },
- dependencies: new Dictionary
- {
- {
- "my-package-2",
- new PackageVersion(
- version: "myVersion",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- ))
- )
- }
- }
- );
- Assembly assembly2 = new Assembly
- (
- name: "my-package-2",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- )),
- version: "myVersion",
- types: new Dictionary { { type2.FullyQualifiedName, type2 } }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly1);
- symbolMap.Add(assembly2);
-
- // GetName(Type type)
- string actual1 = symbolMap.GetName(type1, true);
- string actual2 = symbolMap.GetName(type2, true);
- Assert.Equal("My.Namespace1.MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("My.Namespace2.MyType", actual2, ignoreLineEndingDifferences: true);
-
- // GetName(string fullyQualifiedName)
- actual1 = symbolMap.GetName("myFqn1", true);
- actual2 = symbolMap.GetName("myFqn2", true);
- Assert.Equal("My.Namespace1.MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("My.Namespace2.MyType", actual2, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotDisambiguateTypeNameIfFlagNotSet))]
- public void DoesNotDisambiguateTypeNameIfFlagNotSet()
- {
- Type type1 = new EnumType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package-1",
- name: "myType",
- members: new EnumMember[] { }
- );
- Type type2 = new EnumType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package-2",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- Assembly assembly1 = new Assembly
- (
- name: "my-package-1",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace1",
- packageId: "My.PackageId1"
- )),
- version: "myVersion",
- types: new Dictionary { { type1.FullyQualifiedName, type1 } },
- dependencies: new Dictionary
- {
- {
- "my-package-2",
- new PackageVersion(
- version: "myVersion",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- ))
- )
- }
- }
- );
- Assembly assembly2 = new Assembly
- (
- name: "my-package-2",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- )),
- version: "myVersion",
- types: new Dictionary { { type2.FullyQualifiedName, type2 } }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly1);
- symbolMap.Add(assembly2);
-
- // GetName(Type type)
- string actual1 = symbolMap.GetName(type1);
- string actual2 = symbolMap.GetName(type2);
- Assert.Equal("MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("MyType", actual2, ignoreLineEndingDifferences: true);
-
- // GetName(string fullyQualifiedName)
- actual1 = symbolMap.GetName("myFqn1");
- actual2 = symbolMap.GetName("myFqn2");
- Assert.Equal("MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("MyType", actual2, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromMethod))]
- public void GetsFrameworkNameFromMethod()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod"
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- methods: new[] { method }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetName(type, method);
- Assert.Equal("MyMethod", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromProperty))]
- public void GetsFrameworkNameFromProperty()
- {
- Property property = new Property
- (
- name: "myProp",
- type: new TypeReference("myFqn"),
- isImmutable: false,
- isProtected: false,
- isAbstract: false
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- properties: new[] { property }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetName(type, property);
- Assert.Equal("MyProp", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromEnumMember))]
- public void GetsFrameworkNameFromEnumMember()
- {
- EnumMember member = new EnumMember("myMember");
- Type type = new EnumType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- members: new[] { member }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetName(type, member);
- Assert.Equal("MyMember", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromParameter))]
- public void GetsFrameworkNameFromParameter()
- {
- Parameter parameter = new Parameter(name: "myParam", type: new TypeReference("myFqn"));
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- parameters: new[] { parameter },
- name: "myMethod"
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- methods: new[] { method }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetName(parameter);
- Assert.Equal("myParam", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetNameSyntaxToken
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetNameSyntaxToken) + ".";
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromType))]
- public void GetsFrameworkNameFromType()
- {
- Type type = new EnumType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntaxToken(type).ToString();
- Assert.Equal("MyType", actual, ignoreLineEndingDifferences: true);
-
- actual = symbolMap.GetName("myFqn");
- Assert.Equal("MyType", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DisambiguatesTypeNameOnConflict))]
- public void DisambiguatesTypeNameOnConflict()
- {
- Type type1 = new EnumType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package-1",
- name: "myType",
- members: new EnumMember[] { }
- );
- Type type2 = new EnumType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package-2",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- Assembly assembly1 = new Assembly
- (
- name: "my-package-1",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace1",
- packageId: "My.PackageId1"
- )),
- version: "myVersion",
- types: new Dictionary { { type1.FullyQualifiedName, type1 } },
- dependencies: new Dictionary
- {
- {
- "my-package-2",
- new PackageVersion(
- version: "myVersion",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- ))
- )
- }
- }
- );
- Assembly assembly2 = new Assembly
- (
- name: "my-package-2",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- )),
- version: "myVersion",
- types: new Dictionary { { type2.FullyQualifiedName, type2 } }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly1);
- symbolMap.Add(assembly2);
-
- // GetNameSyntaxToken(Type type)
- string actual1 = symbolMap.GetNameSyntaxToken(type1, true).ToString();
- string actual2 = symbolMap.GetNameSyntaxToken(type2, true).ToString();
- Assert.Equal("My.Namespace1.MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("My.Namespace2.MyType", actual2, ignoreLineEndingDifferences: true);
-
- // GetNameSyntaxToken(string fullyQualifiedName)
- actual1 = symbolMap.GetNameSyntaxToken("myFqn1", true).ToString();
- actual2 = symbolMap.GetNameSyntaxToken("myFqn2", true).ToString();
- Assert.Equal("My.Namespace1.MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("My.Namespace2.MyType", actual2, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotDisambiguateTypeNameIfFlagNotSet))]
- public void DoesNotDisambiguateTypeNameIfFlagNotSet()
- {
- Type type1 = new EnumType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package-1",
- name: "myType",
- members: new EnumMember[] { }
- );
- Type type2 = new EnumType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package-2",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- Assembly assembly1 = new Assembly
- (
- name: "my-package-1",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace1",
- packageId: "My.PackageId1"
- )),
- version: "myVersion",
- types: new Dictionary { { type1.FullyQualifiedName, type1 } },
- dependencies: new Dictionary
- {
- {
- "my-package-2",
- new PackageVersion(
- version: "myVersion",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- ))
- )
- }
- }
- );
- Assembly assembly2 = new Assembly
- (
- name: "my-package-2",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- )),
- version: "myVersion",
- types: new Dictionary { { type2.FullyQualifiedName, type2 } }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly1);
- symbolMap.Add(assembly2);
-
- // GetNameSyntaxToken(Type type)
- string actual1 = symbolMap.GetNameSyntaxToken(type1).ToString();
- string actual2 = symbolMap.GetNameSyntaxToken(type2).ToString();
- Assert.Equal("MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("MyType", actual2, ignoreLineEndingDifferences: true);
-
- // GetNameSyntaxToken(string fullyQualifiedName)
- actual1 = symbolMap.GetNameSyntaxToken("myFqn1").ToString();
- actual2 = symbolMap.GetNameSyntaxToken("myFqn2").ToString();
- Assert.Equal("MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("MyType", actual2, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromMethod))]
- public void GetsFrameworkNameFromMethod()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod"
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- methods: new[] { method }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntaxToken(type, method).ToString();
- Assert.Equal("MyMethod", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromProperty))]
- public void GetsFrameworkNameFromProperty()
- {
- Property property = new Property
- (
- name: "myProp",
- type: new TypeReference("myFqn"),
- isImmutable: false,
- isProtected: false,
- isAbstract: false
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- properties: new[] { property }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntaxToken(type, property).ToString();
- Assert.Equal("MyProp", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromEnumMember))]
- public void GetsFrameworkNameFromEnumMember()
- {
- EnumMember member = new EnumMember("myMember");
- Type type = new EnumType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- members: new[] { member }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntaxToken(type, member).ToString();
- Assert.Equal("MyMember", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromParameter))]
- public void GetsFrameworkNameFromParameter()
- {
- Parameter parameter = new Parameter(name: "myParam", type: new TypeReference("myFqn"));
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- parameters: new[] { parameter },
- name: "myMethod"
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- methods: new[] { method }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntaxToken(parameter).ToString();
- Assert.Equal("myParam", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetNameSyntax
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetNameSyntax) + ".";
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromType))]
- public void GetsFrameworkNameFromType()
- {
- Type type = new EnumType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntax(type).ToString();
- Assert.Equal("MyType", actual, ignoreLineEndingDifferences: true);
-
- actual = symbolMap.GetName("myFqn");
- Assert.Equal("MyType", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DisambiguatesTypeNameOnConflict))]
- public void DisambiguatesTypeNameOnConflict()
- {
- Type type1 = new EnumType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package-1",
- name: "myType",
- members: new EnumMember[] { }
- );
- Type type2 = new EnumType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package-2",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- Assembly assembly1 = new Assembly
- (
- name: "my-package-1",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace1",
- packageId: "My.PackageId1"
- )),
- version: "myVersion",
- types: new Dictionary { { type1.FullyQualifiedName, type1 } },
- dependencies: new Dictionary
- {
- {
- "my-package-2",
- new PackageVersion(
- version: "myVersion",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- ))
- )
- }
- }
- );
- Assembly assembly2 = new Assembly
- (
- name: "my-package-2",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- )),
- version: "myVersion",
- types: new Dictionary { { type2.FullyQualifiedName, type2 } }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly1);
- symbolMap.Add(assembly2);
-
- // GetNameSyntax(Type type)
- string actual1 = symbolMap.GetNameSyntax(type1, true).ToString();
- string actual2 = symbolMap.GetNameSyntax(type2, true).ToString();
- Assert.Equal("My.Namespace1.MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("My.Namespace2.MyType", actual2, ignoreLineEndingDifferences: true);
-
- // GetNameSyntax(string fullyQualifiedName)
- actual1 = symbolMap.GetNameSyntax("myFqn1", true).ToString();
- actual2 = symbolMap.GetNameSyntax("myFqn2", true).ToString();
- Assert.Equal("My.Namespace1.MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("My.Namespace2.MyType", actual2, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(DoesNotDisambiguateTypeNameIfFlagNotSet))]
- public void DoesNotDisambiguateTypeNameIfFlagNotSet()
- {
- Type type1 = new EnumType
- (
- fullyQualifiedName: "myFqn1",
- assembly: "my-package-1",
- name: "myType",
- members: new EnumMember[] { }
- );
- Type type2 = new EnumType
- (
- fullyQualifiedName: "myFqn2",
- assembly: "my-package-2",
- name: "myType",
- members: new EnumMember[] { }
- );
-
- Assembly assembly1 = new Assembly
- (
- name: "my-package-1",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace1",
- packageId: "My.PackageId1"
- )),
- version: "myVersion",
- types: new Dictionary { { type1.FullyQualifiedName, type1 } },
- dependencies: new Dictionary
- {
- {
- "my-package-2",
- new PackageVersion(
- "myVersion",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- ))
- )
- }
- }
- );
- Assembly assembly2 = new Assembly
- (
- name: "my-package-2",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(dotnet: new AssemblyTargets.DotNetTarget(
- @namespace: "My.Namespace2",
- packageId: "My.PackageId2"
- )),
- version: "myVersion",
- types: new Dictionary { { type2.FullyQualifiedName, type2 } }
- );
-
- ISymbolMap symbolMap = new SymbolMap();
- symbolMap.Add(assembly1);
- symbolMap.Add(assembly2);
-
- // GetNameSyntax(Type type)
- string actual1 = symbolMap.GetNameSyntax(type1).ToString();
- string actual2 = symbolMap.GetNameSyntax(type2).ToString();
- Assert.Equal("MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("MyType", actual2, ignoreLineEndingDifferences: true);
-
- // GetNameSyntax(string fullyQualifiedName)
- actual1 = symbolMap.GetNameSyntax("myFqn1").ToString();
- actual2 = symbolMap.GetNameSyntax("myFqn2").ToString();
- Assert.Equal("MyType", actual1, ignoreLineEndingDifferences: true);
- Assert.Equal("MyType", actual2, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromMethod))]
- public void GetsFrameworkNameFromMethod()
- {
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- name: "myMethod"
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- methods: new[] { method }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntax(type, method).ToString();
- Assert.Equal("MyMethod", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromProperty))]
- public void GetsFrameworkNameFromProperty()
- {
- Property property = new Property
- (
- name: "myProp",
- type: new TypeReference("myFqn"),
- isImmutable: false,
- isProtected: false,
- isAbstract: false
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- properties: new[] { property }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntax(type, property).ToString();
- Assert.Equal("MyProp", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromEnumMember))]
- public void GetsFrameworkNameFromEnumMember()
- {
- EnumMember member = new EnumMember("myMember");
- Type type = new EnumType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- members: new[] { member }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntax(type, member).ToString();
- Assert.Equal("MyMember", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = Prefix + nameof(GetsFrameworkNameFromParameter))]
- public void GetsFrameworkNameFromParameter()
- {
- Parameter parameter = new Parameter(name: "myParam", type: new TypeReference("myFqn"));
- Method method = new Method
- (
- isProtected: false,
- isAbstract: false,
- parameters: new[] { parameter },
- name: "myMethod"
- );
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myType",
- isAbstract: false,
- methods: new[] { method }
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNameSyntax(parameter).ToString();
- Assert.Equal("myParam", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetNamespace
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetNamespace) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkNamespaceFromType))]
- public void GetsFrameworkNamespaceFromType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNamespace(type);
- Assert.Equal("My.Namespace", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkNamespaceFromFqn))]
- public void GetsFrameworkNamespaceFromFqn()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNamespace("myFqn");
- Assert.Equal("My.Namespace", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetNamespaceSyntaxToken
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetNamespaceSyntaxToken) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkNamespaceFromType))]
- public void GetsFrameworkNamespaceFromType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNamespaceSyntaxToken(type).ToString();
- Assert.Equal("My.Namespace", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkNamespaceFromFqn))]
- public void GetsFrameworkNamespaceFromFqn()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNamespaceSyntaxToken("myFqn").ToString();
- Assert.Equal("My.Namespace", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetNamespaceSyntax
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetNamespaceSyntax) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkNamespaceFromType))]
- public void GetsFrameworkNamespaceFromType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNamespaceSyntax(type).ToString();
- Assert.Equal("My.Namespace", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkNamespaceFromFqn))]
- public void GetsFrameworkNamespaceFromFqn()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetNamespaceSyntax("myFqn").ToString();
- Assert.Equal("My.Namespace", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetPackage
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetPackage) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkPackageFromType))]
- public void GetsFrameworkPackageFromType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetPackage(type);
- Assert.Equal("my-package", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkPackageFromFqn))]
- public void GetsFrameworkPackageFromFqn()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetPackage("myFqn");
- Assert.Equal("my-package", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetPackageSyntaxToken
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetPackageSyntaxToken) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkPackageFromType))]
- public void GetsFrameworkPackageFromType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetPackageSyntaxToken(type).ToString();
- Assert.Equal("my-package", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkPackageFromFqn))]
- public void GetsFrameworkPackageFromFqn()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetPackageSyntaxToken("myFqn").ToString();
- Assert.Equal("my-package", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetPackageSyntax
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetPackageSyntax) + ".";
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkPackageFromType))]
- public void GetsFrameworkPackageFromType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetPackageSyntax(type).ToString();
- Assert.Equal("my-package", actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsFrameworkPackageFromFqn))]
- public void GetsFrameworkPackageFromFqn()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
-
- string actual = symbolMap.GetPackageSyntax("myFqn").ToString();
- Assert.Equal("my-package", actual, ignoreLineEndingDifferences: true);
- }
- }
-
- public class GetTypeSyntax
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetTypeSyntax) + ".";
-
- [Theory(DisplayName = _Prefix + nameof(GetsPrimitiveFrameworkType))]
- [InlineData(PrimitiveType.Any, false, "object")]
- [InlineData(PrimitiveType.Any, true, "object")]
- [InlineData(PrimitiveType.Boolean, false, "bool")]
- [InlineData(PrimitiveType.Boolean, true, "bool?")]
- [InlineData(PrimitiveType.Date, false, "DateTime")]
- [InlineData(PrimitiveType.Date, true, "DateTime?")]
- [InlineData(PrimitiveType.Json, false, "JObject")]
- [InlineData(PrimitiveType.Json, true, "JObject")]
- [InlineData(PrimitiveType.Number, false, "double")]
- [InlineData(PrimitiveType.Number, true, "double?")]
- [InlineData(PrimitiveType.String, false, "string")]
- [InlineData(PrimitiveType.String, true, "string")]
- public void GetsPrimitiveFrameworkType(PrimitiveType type, bool isOptional, string expected)
- {
- ISymbolMap symbolMap = new SymbolMap();
-
- var reference = new TypeReference(primitive: type);
-
- var actual = symbolMap.GetTypeSyntax(reference, isOptional).ToString();
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(GetsRecursiveCollectionFrameworkType))]
- [InlineData(CollectionKind.Array, false, "double[][]")]
- [InlineData(CollectionKind.Array, true, "double[][]")]
- [InlineData(CollectionKind.Map, false, "IDictionary>")]
- [InlineData(CollectionKind.Map, true, "IDictionary>")]
- public void GetsRecursiveCollectionFrameworkType(CollectionKind kind, bool isOptional, string expected)
- {
- ISymbolMap symbolMap = new SymbolMap();
-
- var reference = new TypeReference
- (
- collection: new CollectionTypeReference
- (
- kind: kind,
- elementType: new TypeReference(
- collection: new CollectionTypeReference(kind, new TypeReference(primitive: PrimitiveType.Number))
- )
- )
- );
-
- string actual = symbolMap.GetTypeSyntax(reference, isOptional).ToString();
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Theory(DisplayName = _Prefix + nameof(GetsUnionFrameworkType))]
- [InlineData(false, "object")]
- [InlineData(true, "object")]
- public void GetsUnionFrameworkType(bool isOptional, string expected)
- {
- ISymbolMap symbolMap = new SymbolMap();
-
- var reference = new TypeReference
- (
- union: new UnionTypeReference(new[] {
- new TypeReference(primitive: PrimitiveType.Number)
- })
- );
-
- string actual = symbolMap.GetTypeSyntax(reference, isOptional).ToString();
- Assert.Equal(expected, actual, ignoreLineEndingDifferences: true);
- }
-
- [Fact(DisplayName = _Prefix + nameof(GetsObjectFrameworkType))]
- public void GetsObjectFrameworkType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
- TypeReference reference = new TypeReference("myFqn");
-
- string actual = symbolMap.GetTypeSyntax(reference, false).ToString();
- Assert.Equal("My.Namespace.MyName", actual, ignoreLineEndingDifferences: true);
-
- }
- }
-
- public class GetTypeFromFullyQualifiedName
- {
- const string _Prefix = Prefix + nameof(SymbolMap.GetTypeFromFullyQualifiedName) + ".";
-
- public void GetsObjectFrameworkType()
- {
- Type type = new ClassType
- (
- fullyQualifiedName: "myFqn",
- assembly: "my-package",
- name: "myName",
- isAbstract: false
- );
-
- ISymbolMap symbolMap = GetSymbolMap(type);
- TypeReference reference = new TypeReference("myFqn");
-
- ClassType actual = symbolMap.GetTypeFromFullyQualifiedName("myFqn") as ClassType;
- Assert.NotNull(actual);
- Assert.Equal("myFqn", actual.FullyQualifiedName, ignoreLineEndingDifferences: true);
- Assert.Equal("my-package", actual.Assembly, ignoreLineEndingDifferences: true);
- Assert.Equal("myName", actual.Name, ignoreLineEndingDifferences: true);
- Assert.Equal("my-package", actual.Namespace, ignoreLineEndingDifferences: true);
- Assert.False(actual.IsAbstract);
- }
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/TypeExtensionsTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/TypeExtensionsTests.cs
deleted file mode 100644
index 8f19a32c7a..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/TypeExtensionsTests.cs
+++ /dev/null
@@ -1,132 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using NSubstitute;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class TypeExtensionsTests
- {
- const string Prefix = nameof(Generator) + "." + nameof(TypeExtensions) + ".";
-
- public class AnyAncestor : GeneratorTestBase
- {
- const string _Prefix = Prefix + nameof(TypeExtensions.AnyAncestor);
-
- ClassType CreateType(bool includeParent, bool includeGrandparent)
- {
- ClassType grandParentType = null;
- if (includeGrandparent)
- {
- grandParentType = new ClassType
- (
- fullyQualifiedName: "myGrandParentTypeFqn",
- assembly: "myPackage",
- name: "myGrandParentType",
- isAbstract: false
- );
-
- Symbols.MapFullyQualifiedNameToType("myGrandParentTypeFqn", grandParentType);
- }
-
- ClassType parentType = null;
- if (includeParent)
- {
- parentType = new ClassType
- (
- fullyQualifiedName: "myParentTypeFqn",
- assembly: "myPackage",
- name: "myParentType",
- isAbstract: false,
- @base: includeGrandparent ? "myGrandParentTypeFqn" : null
- );
- Symbols.MapFullyQualifiedNameToType("myParentTypeFqn", parentType);
- }
-
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myClassFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- @base: includeParent ? "myParentTypeFqn" : null
- );
- Symbols.MapFullyQualifiedNameToType("myClassFqn", classType);
-
- return classType;
- }
-
- [Fact(DisplayName = _Prefix + nameof(ReturnsFalseIfNoAncestorExists))]
- public void ReturnsFalseIfNoAncestorExists()
- {
- ClassType classType = CreateType(false, false);
-
- bool actual = classType.AnyAncestor(Symbols, t => t.Name != string.Empty);
- Assert.False(actual);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ReturnsFalseIfNoAncestorMatches))]
- public void ReturnsFalseIfNoAncestorMatches()
- {
- ClassType classType = CreateType(true, true);
-
- bool actual = classType.AnyAncestor(Symbols, t => t.Name == "myNephewType");
- Assert.False(actual);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ReturnsTrueIfBaseMatches))]
- public void ReturnsTrueIfBaseMatches()
- {
- ClassType classType = CreateType(true, true);
-
- bool actual = classType.AnyAncestor(Symbols, t => t.Name == "myParentType");
- Assert.True(actual);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ReturnsTrueIfAncestorMatches))]
- public void ReturnsTrueIfAncestorMatches()
- {
- ClassType classType = CreateType(true, true);
-
- bool actual = classType.AnyAncestor(Symbols, t => t.Name == "myGrandParentType");
- Assert.True(actual);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DoesNotAttemptToMatchSelf))]
- public void DoesNotAttemptToMatchSelf()
- {
- ClassType classType = CreateType(true, true);
-
- bool actual = classType.AnyAncestor(Symbols, t => t.Name == "myClass");
- Assert.False(actual);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DoesNotAttemptToMatchInterfaces))]
- public void DoesNotAttemptToMatchInterfaces()
- {
- InterfaceType interfaceType = new InterfaceType
- (
- fullyQualifiedName: "myInterfaceFqn",
- assembly: "myPackage",
- name: "myInterface"
- );
- Symbols.MapFullyQualifiedNameToType("myInterfaceFqn", interfaceType);
-
- ClassType classType = new ClassType
- (
- fullyQualifiedName: "myClassFqn",
- assembly: "myPackage",
- name: "myClass",
- isAbstract: false,
- interfaces: new[] { "myInterfaceFqn" }
- );
- Symbols.MapFullyQualifiedNameToType("myClassFqn", classType);
-
- bool actual = classType.AnyAncestor(Symbols, t => t.Name == "myInterface");
- Assert.False(actual);
- }
- }
-
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/TypeMetadataTests.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/TypeMetadataTests.cs
deleted file mode 100644
index 895ef7aff5..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.UnitTests/TypeMetadataTests.cs
+++ /dev/null
@@ -1,462 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Xunit;
-
-namespace Amazon.JSII.Generator.UnitTests
-{
- public class TypeMetadataTests
- {
- const string Prefix = nameof(Generator) + "." + nameof(TypeMetadata) + ".";
-
- public class Class
- {
- const string _Prefix = Prefix + nameof(Class) + ".";
-
- readonly Assembly _assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId1"
- )),
- dependencies: new Dictionary
- {
- {
- "myModule",
- new PackageVersion(
- "0.0.1",
- new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myPackageNativeName",
- packageId: "myPackageId2"
- ))
- )
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- readonly ClassType _type = new ClassType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- isAbstract: false
- );
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullType))]
- public void ThrowsOnNullType()
- {
- ArgumentNullException exception = Assert.Throws(() => new ClassTypeMetadata(null, _assembly));
- Assert.Equal("type", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullAssembly))]
- public void ThrowsOnNullAssembly()
- {
- ArgumentNullException exception = Assert.Throws(() => new ClassTypeMetadata(_type, null));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsName))]
- public void SetsName()
- {
- ClassTypeMetadata metadata = new ClassTypeMetadata(_type, _assembly);
-
- Assert.Equal("MyName", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsFrameworkFullyQualifiedName))]
- public void SetsFrameworkFullyQualifiedName()
- {
- ClassTypeMetadata metadata = new ClassTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace.MyName", metadata.FrameworkFullyQualifiedName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsPackage))]
- public void SetsPackage()
- {
- ClassTypeMetadata metadata = new ClassTypeMetadata(_type, _assembly);
-
- Assert.Equal("myModule", metadata.Package);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsNamespace))]
- public void SetsNamespace()
- {
- ClassTypeMetadata metadata = new ClassTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace", metadata.Namespace);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesNamespaceConflicts))]
- public void DisambiguatesNamespaceConflicts()
- {
- ClassTypeMetadata metadata = new ClassTypeMetadata(_type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet(new[] {
- "myPackageNativeName.myNamespace.MyName"
- }));
-
- Assert.Equal("MyName_", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesPropertyConflicts))]
- public void DisambiguatesPropertyConflicts()
- {
- ClassType type = new ClassType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- isAbstract: false,
- properties: new[] {
- new Property(
- name: "myName",
- type: new TypeReference(primitive: PrimitiveType.String)
- )
- }
- );
-
- ClassTypeMetadata metadata = new ClassTypeMetadata(type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet());
-
- Assert.Equal("MyName_", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesMethodConflicts))]
- public void DisambiguatesMethodConflicts()
- {
- ClassType type = new ClassType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- isAbstract: false,
- methods: new[] {
- new Method(
- isProtected: false,
- isAbstract: false,
- name: "myName",
- returns: new OptionalValue(type: new TypeReference(primitive: PrimitiveType.String))
- )
- }
- );
-
- ClassTypeMetadata metadata = new ClassTypeMetadata(type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet());
-
- Assert.Equal("MyName_", metadata.Name);
- }
- }
-
- public class Enum
- {
- const string _Prefix = Prefix + nameof(Enum) + ".";
-
- readonly Assembly _assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId1"
- )),
- dependencies: new Dictionary
- {
- {
- "myModule",
- new PackageVersion(
- "0.0.1",
- new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myPackageNativeName",
- packageId: "myPackageId2"
- ))
- )
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- readonly EnumType _type = new EnumType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- members: new EnumMember[] { }
- );
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullType))]
- public void ThrowsOnNullType()
- {
- ArgumentNullException exception = Assert.Throws(() => new EnumTypeMetadata(null, _assembly));
- Assert.Equal("type", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullAssembly))]
- public void ThrowsOnNullAssembly()
- {
- ArgumentNullException exception = Assert.Throws(() => new EnumTypeMetadata(_type, null));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsName))]
- public void SetsName()
- {
- EnumTypeMetadata metadata = new EnumTypeMetadata(_type, _assembly);
-
- Assert.Equal("MyName", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsFrameworkFullyQualifiedName))]
- public void SetsFrameworkFullyQualifiedName()
- {
- EnumTypeMetadata metadata = new EnumTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace.MyName", metadata.FrameworkFullyQualifiedName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsPackage))]
- public void SetsPackage()
- {
- EnumTypeMetadata metadata = new EnumTypeMetadata(_type, _assembly);
-
- Assert.Equal("myModule", metadata.Package);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsNamespace))]
- public void SetsNamespace()
- {
- EnumTypeMetadata metadata = new EnumTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace", metadata.Namespace);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesNamespaceConflicts))]
- public void DisambiguatesNamespaceConflicts()
- {
- EnumTypeMetadata metadata = new EnumTypeMetadata(_type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet(new[] {
- "myPackageNativeName.myNamespace.MyName"
- }));
-
- Assert.Equal("MyName_", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesMemberConflicts))]
- public void DisambiguatesMemberConflicts()
- {
- EnumType type = new EnumType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- members: new[] {
- new EnumMember("myName")
- }
- );
-
- EnumTypeMetadata metadata = new EnumTypeMetadata(type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet());
-
- Assert.Equal("MyName_", metadata.Name);
- }
- }
-
- public class Interface
- {
- const string _Prefix = Prefix + nameof(Interface) + ".";
-
- readonly Assembly _assembly = new Assembly(
- name: "myName",
- description: "",
- homepage: "",
- repository: new Assembly.AssemblyRepository(type: "", url: ""),
- author: new Person(name: "", roles: new string[] { }),
- fingerprint: "",
- license: "",
- targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myNativeName",
- packageId: "myPackageId1"
- )),
- dependencies: new Dictionary
- {
- {
- "myModule",
- new PackageVersion(
- "0.0.1",
- new AssemblyTargets(new AssemblyTargets.DotNetTarget(
- @namespace: "myPackageNativeName",
- packageId: "myPackageId2"
- ))
- )
- }
- },
- version: "myVersion",
- types: new Dictionary()
- );
-
- readonly InterfaceType _type = new InterfaceType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- isDataType: true
- );
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullType))]
- public void ThrowsOnNullType()
- {
- ArgumentNullException exception = Assert.Throws(() => new InterfaceTypeMetadata(null, _assembly));
- Assert.Equal("type", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(ThrowsOnNullAssembly))]
- public void ThrowsOnNullAssembly()
- {
- InterfaceType type = new InterfaceType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace"
- );
-
- ArgumentNullException exception = Assert.Throws(() => new InterfaceTypeMetadata(_type, null));
- Assert.Equal("assembly", exception.ParamName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsName))]
- public void SetsName()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("IMyName", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsProxyName))]
- public void SetsProxyName()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("MyNameProxy", metadata.ProxyName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsDefaultName))]
- public void SetsDefaultName()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("MyName", metadata.DefaultName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsFrameworkFullyQualifiedName))]
- public void SetsFrameworkFullyQualifiedName()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace.IMyName", metadata.FrameworkFullyQualifiedName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsFrameworkFullyQualifiedProxyName))]
- public void SetsFrameworkFullyQualifiedProxyName()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace.MyNameProxy", metadata.FrameworkFullyQualifiedProxyName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsFrameworkFullyQualifiedDefaultName))]
- public void SetsFrameworkFullyQualifiedDefaultName()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace.MyName", metadata.FrameworkFullyQualifiedDefaultName);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsPackage))]
- public void SetsPackage()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("myModule", metadata.Package);
- }
-
- [Fact(DisplayName = _Prefix + nameof(SetsNamespace))]
- public void SetsNamespace()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
-
- Assert.Equal("myPackageNativeName.myNamespace", metadata.Namespace);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesNamespaceConflicts))]
- public void DisambiguatesNamespaceConflicts()
- {
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(_type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet(new[] {
- "myPackageNativeName.myNamespace.IMyName"
- }));
-
- Assert.Equal("IMyName_", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesPropertyConflicts))]
- public void DisambiguatesPropertyConflicts()
- {
- InterfaceType type = new InterfaceType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- properties: new[] {
- new Property(
- name: "iMyName",
- type: new TypeReference(primitive: PrimitiveType.String)
- )
- }
- );
-
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet());
-
- Assert.Equal("IMyName_", metadata.Name);
- }
-
- [Fact(DisplayName = _Prefix + nameof(DisambiguatesMethodConflicts))]
- public void DisambiguatesMethodConflicts()
- {
- InterfaceType type = new InterfaceType(
- fullyQualifiedName: "myFqn",
- assembly: "myModule",
- name: "myName",
- @namespace: "myNamespace",
- methods: new[] {
- new Method(
- isProtected: false,
- isAbstract: false,
- name: "iMyName",
- returns: new OptionalValue(type: new TypeReference(primitive: PrimitiveType.String))
- )
- }
- );
-
- InterfaceTypeMetadata metadata = new InterfaceTypeMetadata(type, _assembly);
- metadata.ResolveTypeNameConflicts(new HashSet());
-
- Assert.Equal("IMyName_", metadata.Name);
- }
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.sln b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.sln
deleted file mode 100644
index 9c753ffff9..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator.sln
+++ /dev/null
@@ -1,62 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.26124.0
-MinimumVisualStudioVersion = 15.0.26124.0
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Generator", "Amazon.JSII.Generator\Amazon.JSII.Generator.csproj", "{6C634941-79D4-43F1-95F6-98CFF070BA3D}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Generator.UnitTests", "Amazon.JSII.Generator.UnitTests\Amazon.JSII.Generator.UnitTests.csproj", "{D1F82EE2-73F3-4001-BD53-EA407E7DE180}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Generator.CLI", "Amazon.JSII.Generator.CLI\Amazon.JSII.Generator.CLI.csproj", "{9613D697-2F57-4818-916C-F97F1407D8C1}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Debug|x64 = Debug|x64
- Debug|x86 = Debug|x86
- Release|Any CPU = Release|Any CPU
- Release|x64 = Release|x64
- Release|x86 = Release|x86
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Debug|x64.ActiveCfg = Debug|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Debug|x64.Build.0 = Debug|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Debug|x86.ActiveCfg = Debug|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Debug|x86.Build.0 = Debug|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Release|Any CPU.Build.0 = Release|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Release|x64.ActiveCfg = Release|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Release|x64.Build.0 = Release|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Release|x86.ActiveCfg = Release|Any CPU
- {6C634941-79D4-43F1-95F6-98CFF070BA3D}.Release|x86.Build.0 = Release|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Debug|x64.ActiveCfg = Debug|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Debug|x64.Build.0 = Debug|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Debug|x86.ActiveCfg = Debug|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Debug|x86.Build.0 = Debug|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Release|Any CPU.Build.0 = Release|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Release|x64.ActiveCfg = Release|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Release|x64.Build.0 = Release|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Release|x86.ActiveCfg = Release|Any CPU
- {D1F82EE2-73F3-4001-BD53-EA407E7DE180}.Release|x86.Build.0 = Release|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Debug|x64.ActiveCfg = Debug|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Debug|x64.Build.0 = Debug|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Debug|x86.ActiveCfg = Debug|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Debug|x86.Build.0 = Debug|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Release|Any CPU.Build.0 = Release|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Release|x64.ActiveCfg = Release|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Release|x64.Build.0 = Release|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Release|x86.ActiveCfg = Release|Any CPU
- {9613D697-2F57-4818-916C-F97F1407D8C1}.Release|x86.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/Amazon.JSII.Generator.csproj b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/Amazon.JSII.Generator.csproj
deleted file mode 100644
index 12dc48d768..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/Amazon.JSII.Generator.csproj
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
- Amazon.JSII.Generator
- .NET Code Generator for JSII
-
-
-
-
-
-
-
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/AssemblyExtensions.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/AssemblyExtensions.cs
deleted file mode 100644
index 73226d70d9..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/AssemblyExtensions.cs
+++ /dev/null
@@ -1,106 +0,0 @@
-using Amazon.JSII.JsonModel.Spec;
-using System;
-using System.Collections.Generic;
-using System.Xml.Linq;
-
-namespace Amazon.JSII.Generator
-{
- public static class AssemblyExtensions
- {
- public static string GetNativePackageId(this Assembly assembly, string targetPackageName = null)
- {
- assembly = assembly ?? throw new ArgumentNullException(nameof(assembly));
-
- string packageId = assembly.GetNativeProperty
- (
- assembly.Name,
- targetPackageName ?? assembly.Name,
- d => d.Targets?.DotNet?.PackageId
- );
-
- if (string.IsNullOrWhiteSpace(packageId))
- {
- throw new ArgumentException
- (
- $"Assembly {assembly.Name} does not include a package id mapping for {targetPackageName ?? assembly.Name}",
- nameof(assembly)
- );
- }
-
- return packageId;
- }
-
- public static string GetNativeNamespace(this Assembly assembly, string targetPackageName = null)
- {
- assembly = assembly ?? throw new ArgumentNullException(nameof(assembly));
-
- string @namespace = assembly.GetNativeProperty
- (
- assembly.Name,
- targetPackageName ?? assembly.Name,
- d => d.Targets?.DotNet?.Namespace
- );
-
- if (string.IsNullOrWhiteSpace(@namespace))
- {
- throw new ArgumentException
- (
- $"Assembly {assembly.Name} does not include a namespace mapping for {targetPackageName ?? assembly.Name}",
- nameof(assembly)
- );
- }
-
- return @namespace;
- }
-
- public static IEnumerable GetMsBuildProperties(this Assembly assembly)
- {
- yield return new XElement("TargetFramework", "netstandard2.0");
- yield return new XElement("GeneratePackageOnBuild", true);
- yield return new XElement("IncludeSymbols", true);
- yield return new XElement("IncludeSource", true);
- yield return new XElement("PackageVersion", assembly.GetDecoratedVersion());
- yield return new XElement("PackageId", assembly.Targets.DotNet.PackageId);
- yield return new XElement("Description", GetDescription());
- yield return new XElement("ProjectUrl", assembly.Homepage);
- yield return new XElement("LicenseUrl", $"https://spdx.org/licenses/{assembly.License}.html");
- yield return new XElement("Authors", $"{assembly.Author.Name}");
-
- // TODO: Update once we have a localization story.
- yield return new XElement("Language", "en-US");
-
- if (assembly.Targets.DotNet.Title != null)
- {
- yield return new XElement("Title", assembly.Targets.DotNet.Title);
- }
-
- if (assembly.Targets.DotNet.SignAssembly)
- {
- yield return new XElement("SignAssembly",
- new XAttribute("Condition", @"Exists('$(AssemblyOriginatorKeyFile)')"),
- assembly.Targets.DotNet.SignAssembly
- );
- }
-
- if (assembly.Targets.DotNet.AssemblyOriginatorKeyFile != null)
- {
- yield return new XElement("AssemblyOriginatorKeyFile", assembly.Targets.DotNet.AssemblyOriginatorKeyFile);
- }
-
- if (assembly.Targets.DotNet.IconUrl != null)
- {
- yield return new XElement("IconUrl", assembly.Targets.DotNet.IconUrl);
- }
-
- string GetDescription()
- {
- Stability? stability = assembly.Docs?.Stability;
- if (!stability.HasValue)
- {
- return assembly.Description;
- }
- return $"{assembly.Description} (Stability: {stability})";
- }
- }
- }
-}
diff --git a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/AssemblyGenerator.cs b/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/AssemblyGenerator.cs
deleted file mode 100644
index 78a0f6a38e..0000000000
--- a/packages/jsii-dotnet-generator/src/Amazon.JSII.Generator/AssemblyGenerator.cs
+++ /dev/null
@@ -1,362 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Xml;
-using System.Xml.Linq;
-using Amazon.JSII.Generator.Class;
-using Amazon.JSII.Generator.Enum;
-using Amazon.JSII.Generator.Interface;
-using Amazon.JSII.JsonModel.FileSystem;
-using Amazon.JSII.JsonModel.Spec;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Newtonsoft.Json;
-using SF = Microsoft.CodeAnalysis.CSharp.SyntaxFactory;
-using Type = Amazon.JSII.JsonModel.Spec.Type;
-using TypeKind = Amazon.JSII.JsonModel.Spec.TypeKind;
-
-namespace Amazon.JSII.Generator
-{
- public class AssemblyGenerator
- {
- readonly string _outputRoot;
- readonly IFileSystem _fileSystem;
-
- public AssemblyGenerator(
- string outputRoot,
- IFileSystem fileSystem = null
- )
- {
- _outputRoot = outputRoot ?? throw new ArgumentNullException(nameof(outputRoot));
- _fileSystem = fileSystem ?? new FileSystem();
- }
-
- public void Generate(string jsiiFile, string tarballPath, ISymbolMap symbols = null)
- {
- jsiiFile = jsiiFile ?? throw new ArgumentNullException(nameof(jsiiFile));
- symbols = symbols ?? new SymbolMap();
-
- string assemblyJson = _fileSystem.File.ReadAllText(jsiiFile);
- Assembly assembly = JsonConvert.DeserializeObject(assemblyJson);
- symbols.Add(assembly);
-
- LoadDependencies(assembly, Path.GetDirectoryName(jsiiFile));
-
- string packageOutputRoot = Path.Combine(_outputRoot, assembly.GetNativePackageId());
- if (_fileSystem.Directory.Exists(packageOutputRoot))
- {
- _fileSystem.Directory.Delete(packageOutputRoot, true);
- }
- _fileSystem.Directory.CreateDirectory(packageOutputRoot);
-
- // On Windows, the full destination path including the filename is required.
- _fileSystem.File.Copy(tarballPath, Path.Combine(packageOutputRoot, Path.GetFileName(tarballPath)));
- _fileSystem.File.Copy(jsiiFile, Path.Combine(packageOutputRoot, Path.GetFileName(jsiiFile)));
-
- Save(packageOutputRoot, symbols, assembly, new FileInfo(tarballPath).Name, new FileInfo(jsiiFile).Name);
-
- void LoadDependencies(DependencyRoot dependencyRoot, string packageDirectory)
- {
- if (dependencyRoot.Dependencies == null)
- {
- return;
- }
-
- foreach (KeyValuePair entry in dependencyRoot.Dependencies)
- {
- string depRoot = ResolvePackage(entry.Key, packageDirectory);
- string depFile = Path.Combine(depRoot, ".jsii");
- string depJson = _fileSystem.File.ReadAllText(depFile);
- Assembly depAssembly = JsonConvert.DeserializeObject(depJson);
- symbols.Add(depAssembly);
- LoadDependencies(depAssembly, depRoot);
- }
-
- string ResolvePackage(string packageName, string directory)
- {
- if (string.IsNullOrEmpty(directory))
- {
- throw new FileNotFoundException($"Could not resolve package named {packageName}");
- }
- string candidate = Path.Combine(directory, "node_modules", packageName);
- if (_fileSystem.Directory.Exists(candidate))
- {
- return candidate;
- }
- return ResolvePackage(packageName, Path.GetDirectoryName(directory));
- }
- }
- }
-
- void Save(string packageOutputRoot, ISymbolMap symbols, Assembly assembly, string tarballFileName, string jsiiFileName)
- {
- if (assembly.Docs != null)
- {
- // TODO: Use Microsoft.Extensions.Logging instead of Console.Error.
- Console.Error.WriteLine($"Warning: Ignoring documentation comment on assembly {assembly.Name}. Assembly-level documentation comments are not supported for .NET");
- }
-
- SaveProjectFile();
- SaveAssemblyInfo(assembly.Name, assembly.Version, tarballFileName);
- SaveDependencyAnchorFile();
-
- foreach (Type type in assembly.Types?.Values ?? Enumerable.Empty())
- {
- SaveType(type);
- }
-
- void SaveProjectFile()
- {
- XElement project =
- new XElement("Project",
- new XAttribute("Sdk", "Microsoft.NET.Sdk"),
- new XElement("PropertyGroup", assembly.GetMsBuildProperties()),
- new XElement("ItemGroup",
- new XElement("EmbeddedResource",
- new XAttribute("Include", tarballFileName)
- )
- ),
- new XElement("ItemGroup",
- new XElement("PackageReference",
- new XAttribute("Include", "Amazon.JSII.Runtime"),
- new XAttribute("Version", JsiiVersion.Version)
- ),
- GetDependencies()
- .Distinct()
- .Select(d => new { Package = symbols.GetAssemblyName(d.Key), Version = d.Value.GetDecoratedVersion() })
- .Select(d =>
- new XElement("PackageReference",
- new XAttribute("Include", d.Package),
- new XAttribute("Version", d.Version)
- )
- )
- )
- );
-
- if (!_fileSystem.Directory.Exists(packageOutputRoot))
- {
- _fileSystem.Directory.CreateDirectory(packageOutputRoot);
- }
-
- // Save to StringBuilder instead of directly to path, so that we can
- // redirect the output through the filesystem shim. Project files are
- // small, so this shouldn't be a memory hog.
- StringBuilder builder = new StringBuilder();
- XmlWriterSettings settings = new XmlWriterSettings
- {
- // Visual Studio omits the XML declaration when creating project files, so we do too.
- OmitXmlDeclaration = true,
- // Visual Studio indents project files (they are often edited by hand), so we do too.
- Indent = true,
- };
- using (XmlWriter writer = XmlWriter.Create(builder, settings))
- {
- project.Save(writer);
- }
-
- string csProjPath = Path.Combine(packageOutputRoot, $"{assembly.GetNativePackageId()}.csproj");
- _fileSystem.File.WriteAllText(csProjPath, builder.ToString());
-
- IEnumerable> GetDependencies()
- {
- foreach (KeyValuePair dependency in GetDependenciesCore(assembly))
- {
- yield return dependency;
- }
-
- IEnumerable> GetDependenciesCore(DependencyRoot root)
- {
- if (root.Dependencies == null)
- {
- yield break;
- }
- foreach (var kvp in root.Dependencies)
- {
- yield return kvp;
- foreach (KeyValuePair dependency in GetDependenciesCore(kvp.Value))
- {
- yield return dependency;
- }
- }
- }
- }
- }
-
- void SaveDependencyAnchorFile()
- {
- string anchorNamespace = $"{assembly.GetNativeNamespace()}.Internal.DependencyResolution";
- var syntaxTree = SF.SyntaxTree(
- SF.CompilationUnit(
- SF.List(),
- SF.List(),
- SF.List(),
- SF.List(new[] {
- SF.NamespaceDeclaration(
- SF.IdentifierName(anchorNamespace),
- SF.List