Skip to content

Commit 815b449

Browse files
RomainMullermergify[bot]
authored andcommitted
fix(dotnet/analyzer): remove dependency on Runtime (#927)
* fix(dotnet/analyzer): remove dependency on Runtime Remove the dependency from the Amazon.JSII.Analyzers package to the Amazon.JSII.Runtime package - as that dependency was not used and turned out to be a source of problems. Also - pins the version of the runtimes to the exact version (this could later be extended to a range). * relax runtime version constraint * fix test expectations
1 parent 32be0d9 commit 815b449

34 files changed

Lines changed: 709 additions & 14 deletions

File tree

packages/jsii-dotnet-analyzers/src/Amazon.JSII.Analyzers/Amazon.JSII.Analyzers.csproj

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<Import Project="../NuGet.Metadata.props" />
33

44
<PropertyGroup>
@@ -10,9 +10,7 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Amazon.JSII.Runtime" Version="$(JsiiVersion)" />
14-
<PackageReference Include="Microsoft.CodeAnalysis" Version="3.2.0" />
15-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.2.0" />
13+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.2.0" PrivateAssets="all" />
1614
</ItemGroup>
1715

1816
<ItemGroup>

packages/jsii-dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests.sln

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
22
Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio 15
44
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Amazon.JSII.Runtime.IntegrationTests", "Amazon.JSII.Runtime.IntegrationTests\Amazon.JSII.Runtime.IntegrationTests.csproj", "{CE3CAFBD-25F8-422D-925A-8F9CCEA1F548}"

packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { CodeMaker } from 'codemaker';
22
import { Assembly } from 'jsii-spec';
33
import path = require('path');
44
import xmlbuilder = require('xmlbuilder');
5-
import logging = require('../../logging');
65
import { DotNetNameUtils } from './nameutils';
6+
import logging = require('../../logging');
7+
import { nextMajorVersion } from '../../util';
78

89
// Represents a dependency in the dependency tree.
910
export class DotNetDependency {
@@ -95,13 +96,14 @@ export class FileGenerator {
9596
const embeddedResource = itemGroup1.ele('EmbeddedResource');
9697
embeddedResource.att('Include', this.tarballFileName);
9798

99+
// Strip " (build abcdef)" from the jsii version
100+
const jsiiVersion = assembly.jsiiVersion.replace(/ .*$/, '');
101+
const jsiiVersionNextMajor = nextMajorVersion(jsiiVersion);
102+
98103
const itemGroup2 = rootNode.ele('ItemGroup');
99104
const packageReference = itemGroup2.ele('PackageReference');
100105
packageReference.att('Include', 'Amazon.JSII.Runtime');
101-
102-
// Strip " (build abcdef)" from the jsii version
103-
const jsiiVersionSimple = assembly.jsiiVersion.replace(/ .*$/, '');
104-
packageReference.att('Version', jsiiVersionSimple);
106+
packageReference.att('Version', `[${jsiiVersion},${jsiiVersionNextMajor})`);
105107

106108
dependencies.forEach((value: DotNetDependency) => {
107109
const dependencyReference = itemGroup2.ele('PackageReference');

packages/jsii-pacmak/lib/util.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import fs = require('fs-extra');
33
import spec = require('jsii-spec');
44
import os = require('os');
55
import path = require('path');
6+
import semver = require('semver');
67
import logging = require('./logging');
78

89
export interface ShellOptions extends SpawnOptions {
@@ -120,4 +121,26 @@ export class Scratch<A> {
120121
await fs.remove(this.directory);
121122
}
122123
}
123-
}
124+
}
125+
126+
/**
127+
* Determines the next major version from a given current version. This honors
128+
* the specificities of pre-1.0.0 releases, too.
129+
*
130+
* @param version the current version from which to bump.
131+
*
132+
* @returns the next Major Version string.
133+
*/
134+
export function nextMajorVersion(version: string): string {
135+
const v = semver.parse(version);
136+
if (!v) {
137+
throw new Error(`Invalid semantic version identifier: ${version}`);
138+
}
139+
if (v.major !== 0) {
140+
return v.inc('major').version;
141+
}
142+
if (v.minor !== 0) {
143+
return v.inc('minor').version;
144+
}
145+
return v.inc('patch').version;
146+
}

packages/jsii-pacmak/test/diff-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ function assert-generator() {
7272
done
7373
}
7474

75+
assert-generator jsii-calc-base-of-base
7576
assert-generator jsii-calc-base
7677
assert-generator jsii-calc-lib
7778
assert-generator jsii-calc
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
{
2+
"author": {
3+
"name": "Amazon Web Services",
4+
"organization": true,
5+
"roles": [
6+
"author"
7+
],
8+
"url": "https://aws.amazon.com"
9+
},
10+
"description": "An example transitive dependency for jsii-calc.",
11+
"homepage": "https://github.com/aws/jsii",
12+
"jsiiVersion": "0.20.0",
13+
"license": "Apache-2.0",
14+
"name": "@scope/jsii-calc-base-of-base",
15+
"repository": {
16+
"directory": "packages/jsii-calc-base-of-base",
17+
"type": "git",
18+
"url": "https://github.com/aws/jsii.git"
19+
},
20+
"schema": "jsii/0.10.0",
21+
"targets": {
22+
"dotnet": {
23+
"namespace": "Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace",
24+
"packageId": "Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId"
25+
},
26+
"java": {
27+
"maven": {
28+
"artifactId": "calculator-base-of-base",
29+
"groupId": "software.amazon.jsii.tests"
30+
},
31+
"package": "software.amazon.jsii.tests.calculator.baseofbase"
32+
},
33+
"js": {
34+
"npm": "@scope/jsii-calc-base-of-base"
35+
},
36+
"python": {
37+
"distName": "scope.jsii-calc-base-of-base",
38+
"module": "scope.jsii_calc_base_of_base"
39+
}
40+
},
41+
"types": {
42+
"@scope/jsii-calc-base-of-base.IVeryBaseInterface": {
43+
"assembly": "@scope/jsii-calc-base-of-base",
44+
"fqn": "@scope/jsii-calc-base-of-base.IVeryBaseInterface",
45+
"kind": "interface",
46+
"locationInModule": {
47+
"filename": "lib/index.ts",
48+
"line": 1
49+
},
50+
"methods": [
51+
{
52+
"abstract": true,
53+
"locationInModule": {
54+
"filename": "lib/index.ts",
55+
"line": 2
56+
},
57+
"name": "foo"
58+
}
59+
],
60+
"name": "IVeryBaseInterface"
61+
},
62+
"@scope/jsii-calc-base-of-base.Very": {
63+
"assembly": "@scope/jsii-calc-base-of-base",
64+
"fqn": "@scope/jsii-calc-base-of-base.Very",
65+
"initializer": {},
66+
"kind": "class",
67+
"locationInModule": {
68+
"filename": "lib/index.ts",
69+
"line": 9
70+
},
71+
"methods": [
72+
{
73+
"locationInModule": {
74+
"filename": "lib/index.ts",
75+
"line": 10
76+
},
77+
"name": "hey",
78+
"returns": {
79+
"type": {
80+
"primitive": "number"
81+
}
82+
}
83+
}
84+
],
85+
"name": "Very"
86+
},
87+
"@scope/jsii-calc-base-of-base.VeryBaseProps": {
88+
"assembly": "@scope/jsii-calc-base-of-base",
89+
"datatype": true,
90+
"fqn": "@scope/jsii-calc-base-of-base.VeryBaseProps",
91+
"kind": "interface",
92+
"locationInModule": {
93+
"filename": "lib/index.ts",
94+
"line": 5
95+
},
96+
"name": "VeryBaseProps",
97+
"properties": [
98+
{
99+
"abstract": true,
100+
"immutable": true,
101+
"locationInModule": {
102+
"filename": "lib/index.ts",
103+
"line": 6
104+
},
105+
"name": "foo",
106+
"type": {
107+
"fqn": "@scope/jsii-calc-base-of-base.Very"
108+
}
109+
}
110+
]
111+
}
112+
},
113+
"version": "0.20.0",
114+
"fingerprint": "4yJsyi5ch/E1bHSJMcEEBX/WvJK/zroW/a+Ta8Tc6lk="
115+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<!-- Package Identification -->
4+
<Description>An example transitive dependency for jsii-calc.</Description>
5+
<PackageId>Amazon.JSII.Tests.CalculatorPackageId.BaseOfBasePackageId</PackageId>
6+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
7+
<PackageVersion>0.20.0</PackageVersion>
8+
<!-- Additional Metadata -->
9+
<Authors>Amazon Web Services</Authors>
10+
<Company>Amazon Web Services</Company>
11+
<Language>en-US</Language>
12+
<ProjectUrl>https://github.com/aws/jsii</ProjectUrl>
13+
<RepositoryUrl>https://github.com/aws/jsii.git</RepositoryUrl>
14+
<RepositoryType>git</RepositoryType>
15+
<!-- Build Configuration -->
16+
<GenerateDocumentationFile>true</GenerateDocumentationFile>
17+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
18+
<IncludeSymbols>true</IncludeSymbols>
19+
<IncludeSource>true</IncludeSource>
20+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
21+
<TargetFramework>netcoreapp3.0</TargetFramework>
22+
</PropertyGroup>
23+
<ItemGroup>
24+
<EmbeddedResource Include="scope-jsii-calc-base-of-base-0.20.0.tgz" />
25+
</ItemGroup>
26+
<ItemGroup>
27+
<PackageReference Include="Amazon.JSII.Runtime" Version="[0.20.0,0.21.0)" />
28+
</ItemGroup>
29+
</Project>
30+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using Amazon.JSII.Runtime.Deputy;
2+
3+
namespace Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace
4+
{
5+
[JsiiInterface(nativeType: typeof(IVeryBaseInterface), fullyQualifiedName: "@scope/jsii-calc-base-of-base.IVeryBaseInterface")]
6+
public interface IVeryBaseInterface
7+
{
8+
[JsiiMethod(name: "foo")]
9+
void Foo();
10+
}
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using Amazon.JSII.Runtime.Deputy;
2+
3+
namespace Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace
4+
{
5+
[JsiiTypeProxy(nativeType: typeof(IVeryBaseInterface), fullyQualifiedName: "@scope/jsii-calc-base-of-base.IVeryBaseInterface")]
6+
internal sealed class IVeryBaseInterfaceProxy : DeputyBase, Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace.IVeryBaseInterface
7+
{
8+
private IVeryBaseInterfaceProxy(ByRefValue reference): base(reference)
9+
{
10+
}
11+
12+
[JsiiMethod(name: "foo")]
13+
public void Foo()
14+
{
15+
InvokeInstanceVoidMethod(new System.Type[]{}, new object[]{});
16+
}
17+
}
18+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Amazon.JSII.Runtime.Deputy;
2+
3+
namespace Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace
4+
{
5+
[JsiiInterface(nativeType: typeof(IVeryBaseProps), fullyQualifiedName: "@scope/jsii-calc-base-of-base.VeryBaseProps")]
6+
public interface IVeryBaseProps
7+
{
8+
[JsiiProperty(name: "foo", typeJson: "{\"fqn\":\"@scope/jsii-calc-base-of-base.Very\"}")]
9+
Amazon.JSII.Tests.CalculatorNamespace.BaseOfBaseNamespace.Very Foo
10+
{
11+
get;
12+
}
13+
}
14+
}

0 commit comments

Comments
 (0)