diff --git a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj
index 0d06ffbb13..171648cd2c 100644
--- a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj
+++ b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Amazon.JSII.Analyzers.UnitTests.csproj
@@ -4,6 +4,9 @@
netcoreapp3.1
false
Amazon.JSII.Analyzers.UnitTests
+
+ enable
+ true
diff --git a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Helpers/DiagnosticVerifier.Helper.cs b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Helpers/DiagnosticVerifier.Helper.cs
index de72e54f8d..4b3663ae48 100755
--- a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Helpers/DiagnosticVerifier.Helper.cs
+++ b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Helpers/DiagnosticVerifier.Helper.cs
@@ -34,7 +34,7 @@ public abstract partial class DiagnosticVerifier
/// The language the source classes are in
/// The analyzer to be run on the sources
/// An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location
- private static Diagnostic[] GetSortedDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer)
+ private static Diagnostic[] GetSortedDiagnostics(string[] sources, string language, DiagnosticAnalyzer? analyzer)
{
return GetSortedDiagnosticsFromDocuments(analyzer, GetDocuments(sources, language));
}
@@ -46,7 +46,7 @@ private static Diagnostic[] GetSortedDiagnostics(string[] sources, string langua
/// The analyzer to run on the documents
/// The Documents that the analyzer will be run on
/// An IEnumerable of Diagnostics that surfaced in the source code, sorted by Location
- protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer analyzer, Document[] documents)
+ protected static Diagnostic[] GetSortedDiagnosticsFromDocuments(DiagnosticAnalyzer? analyzer, Document[] documents)
{
var projects = new HashSet();
foreach (var document in documents)
@@ -162,7 +162,7 @@ private static Project CreateProject(string[] sources, string language = Languag
solution = solution.AddDocument(documentId, newFileName, SourceText.From(source));
count++;
}
- return solution.GetProject(projectId);
+ return solution.GetProject(projectId)!;
}
#endregion
}
diff --git a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Verifiers/DiagnosticVerifier.cs b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Verifiers/DiagnosticVerifier.cs
index 8a66157221..b5ea35d61b 100755
--- a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Verifiers/DiagnosticVerifier.cs
+++ b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers.UnitTests/Verifiers/DiagnosticVerifier.cs
@@ -16,7 +16,7 @@ public abstract partial class DiagnosticVerifier
///
/// Get the CSharp analyzer being tested - to be implemented in non-abstract class
///
- protected virtual DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
+ protected virtual DiagnosticAnalyzer? GetCSharpDiagnosticAnalyzer()
{
return null;
}
@@ -24,7 +24,7 @@ protected virtual DiagnosticAnalyzer GetCSharpDiagnosticAnalyzer()
///
/// Get the Visual Basic analyzer being tested (C#) - to be implemented in non-abstract class
///
- protected virtual DiagnosticAnalyzer GetBasicDiagnosticAnalyzer()
+ protected virtual DiagnosticAnalyzer? GetBasicDiagnosticAnalyzer()
{
return null;
}
@@ -84,7 +84,7 @@ protected void VerifyBasicDiagnostic(string[] sources, params DiagnosticResult[]
/// The language of the classes represented by the source strings
/// The analyzer to be run on the source code
/// DiagnosticResults that should appear after the analyzer is run on the sources
- private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expected)
+ private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnalyzer? analyzer, params DiagnosticResult[] expected)
{
var diagnostics = GetSortedDiagnostics(sources, language, analyzer);
VerifyDiagnosticResults(diagnostics, analyzer, expected);
@@ -100,7 +100,7 @@ private void VerifyDiagnostics(string[] sources, string language, DiagnosticAnal
/// The Diagnostics found by the compiler after running the analyzer on the source code
/// The analyzer that was being run on the sources
/// Diagnostic Results that should have appeared in the code
- private static void VerifyDiagnosticResults(IEnumerable actualResults, DiagnosticAnalyzer analyzer, params DiagnosticResult[] expectedResults)
+ private static void VerifyDiagnosticResults(IEnumerable actualResults, DiagnosticAnalyzer? analyzer, params DiagnosticResult[] expectedResults)
{
int expectedCount = expectedResults.Count();
int actualCount = actualResults.Count();
@@ -176,7 +176,7 @@ private static void VerifyDiagnosticResults(IEnumerable actualResult
/// The diagnostic that was found in the code
/// The Location of the Diagnostic found in the code
/// The DiagnosticResultLocation that should have been found
- private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected)
+ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer? analyzer, Diagnostic diagnostic, Location actual, DiagnosticResultLocation expected)
{
var actualSpan = actual.GetLineSpan();
@@ -217,15 +217,19 @@ private static void VerifyDiagnosticLocation(DiagnosticAnalyzer analyzer, Diagno
/// The analyzer that this verifier tests
/// The Diagnostics to be formatted
/// The Diagnostics formatted as a string
- private static string FormatDiagnostics(DiagnosticAnalyzer analyzer, params Diagnostic[] diagnostics)
+ private static string FormatDiagnostics(DiagnosticAnalyzer? analyzer, params Diagnostic[] diagnostics)
{
var builder = new StringBuilder();
for (int i = 0; i < diagnostics.Length; ++i)
{
builder.AppendLine("// " + diagnostics[i].ToString());
- var analyzerType = analyzer.GetType();
- var rules = analyzer.SupportedDiagnostics;
+ var analyzerType = analyzer?.GetType();
+ if (analyzerType == null)
+ {
+ continue;
+ }
+ var rules = analyzer!.SupportedDiagnostics;
foreach (var rule in rules)
{
diff --git a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers/JsiiOptionalAnalyzer.cs b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers/JsiiOptionalAnalyzer.cs
index 957a093d44..7facb303d1 100644
--- a/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers/JsiiOptionalAnalyzer.cs
+++ b/packages/@jsii/dotnet-analyzers/src/Amazon.JSII.Analyzers/JsiiOptionalAnalyzer.cs
@@ -105,6 +105,10 @@ private static void AnalyzeNode(SyntaxNodeAnalysisContext context)
/// true if the TypeInfo is related to a Jsii class, false otherwise
private static bool IsJsiiClass(TypeInfo typeInfo)
{
+ if (typeInfo.Type == null)
+ {
+ return false;
+ }
var typeAttributes = typeInfo.Type.GetAttributes().ToArray();
return typeAttributes.Any(a => a.AttributeClass.Name == "JsiiClassAttribute");
}
@@ -119,6 +123,10 @@ private static bool IsJsiiClass(TypeInfo typeInfo)
/// true if the TypeInfo is related to a Jsii datatype, false otherwise
private static bool IsJsiiDatatype(TypeInfo typeInfo)
{
+ if (typeInfo.Type == null)
+ {
+ return false;
+ }
var typeAttributes = typeInfo.Type.GetAttributes().ToArray();
return typeAttributes.Any(a => a.AttributeClass.Name == "JsiiByValueAttribute");
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj
index bfa55bf1d6..03e37b0d36 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Amazon.JSII.JsonModel.UnitTests.csproj
@@ -5,6 +5,9 @@
false
Amazon.JSII.JsonModel.UnitTests
Amazon.JSII.JsonModel.UnitTests
+
+ enable
+ true
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/AssemblyTests.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/AssemblyTests.cs
index 6779b2ef22..fcb7ca006e 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/AssemblyTests.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/AssemblyTests.cs
@@ -107,7 +107,9 @@ public void ShouldThrowOnMissingName()
{
Assert.Throws(() => new Assembly
(
+#pragma warning disable CS8625
name: null,
+#pragma warning restore CS8625
description: "",
homepage: "",
repository: new Assembly.AssemblyRepository(type: "", url: ""),
@@ -140,7 +142,9 @@ public void ShouldThrowOnMissingVersion()
repository: new Assembly.AssemblyRepository(type: "", url: ""),
author: new Person(name: "", roles: new string[] { }),
fingerprint: "",
+#pragma warning disable CS8625
version: null,
+#pragma warning restore CS8625
license: "",
targets: new AssemblyTargets(new AssemblyTargets.DotNetTarget(
@namespace: "Dot.Net.Namespace",
@@ -375,7 +379,7 @@ public void ShouldDeserializeAllMembers()
Assert.Empty(actual.Types);
Assert.Empty(actual.Dependencies);
Assert.Empty(actual.Bundled);
- Assert.Equal("hello", actual.Docs.Summary);
+ Assert.Equal("hello", actual.Docs?.Summary);
}
[Fact(DisplayName = Prefix + nameof(ShouldDeserializeAllMembersWithNoTypes))]
@@ -411,7 +415,7 @@ public void ShouldDeserializeAllMembersWithNoTypes()
Assert.Null(actual.Types);
Assert.Empty(actual.Dependencies);
Assert.Empty(actual.Bundled);
- Assert.Equal("hello", actual.Docs.Summary);
+ Assert.Equal("hello", actual.Docs?.Summary);
}
@@ -455,19 +459,19 @@ public void ShouldDeserializeAllMembersWithDotNetTarget()
Assert.Equal("jsii/0.9.0", actual.Schema, ignoreLineEndingDifferences: true);
Assert.Equal("myName", actual.Name, ignoreLineEndingDifferences: true);
- AssemblyTargets.DotNetTarget dotNetTarget = actual.Targets.DotNet;
+ AssemblyTargets.DotNetTarget? dotNetTarget = actual.Targets?.DotNet;
Assert.NotNull(dotNetTarget);
- Assert.Equal("Dot.Net.Namespace", dotNetTarget.Namespace);
- Assert.Equal("Dot.Net.PackageId", dotNetTarget.PackageId);
- Assert.True(dotNetTarget.SignAssembly);
- Assert.Equal("key.snk", dotNetTarget.AssemblyOriginatorKeyFile);
- Assert.Equal("http://www.example.com/icon.png", dotNetTarget.IconUrl);
+ Assert.Equal("Dot.Net.Namespace", dotNetTarget?.Namespace);
+ Assert.Equal("Dot.Net.PackageId", dotNetTarget?.PackageId);
+ Assert.True(dotNetTarget?.SignAssembly);
+ Assert.Equal("key.snk", dotNetTarget?.AssemblyOriginatorKeyFile);
+ Assert.Equal("http://www.example.com/icon.png", dotNetTarget?.IconUrl);
Assert.Equal("myVersion", actual.Version, ignoreLineEndingDifferences: true);
Assert.Empty(actual.Types);
Assert.Empty(actual.Dependencies);
Assert.Empty(actual.Bundled);
- Assert.Equal("hello", actual.Docs.Summary);
+ Assert.Equal("hello", actual.Docs?.Summary);
}
[Fact(DisplayName = Prefix + nameof(ShouldThrowOnMissingName))]
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/ClassTypeTests.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/ClassTypeTests.cs
index e266fae302..5e25c3a8c2 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/ClassTypeTests.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/ClassTypeTests.cs
@@ -1,4 +1,4 @@
-using Amazon.JSII.JsonModel.Spec;
+using Amazon.JSII.JsonModel.Spec;
using Newtonsoft.Json;
using System;
using System.Linq;
@@ -56,7 +56,9 @@ public void ShouldThrowOnMissingFullyQualifiedName()
{
Assert.Throws(() => new ClassType
(
+#pragma warning disable CS8625
fullyQualifiedName: null,
+#pragma warning restore CS8625
assembly: "myModule",
name: "myName",
@namespace: "myNamespace",
@@ -76,7 +78,9 @@ public void ShouldThrowOnMissingAssembly()
Assert.Throws(() => new ClassType
(
fullyQualifiedName: "myFqn",
+#pragma warning disable CS8625
assembly: null,
+#pragma warning restore CS8625
name: "myName",
@namespace: "myNamespace",
isAbstract: true,
@@ -96,7 +100,9 @@ public void ShouldThrowOnMissingName()
(
fullyQualifiedName: "myFqn",
assembly: "myModule",
+#pragma warning disable CS8625
name: null,
+#pragma warning restore CS8625
@namespace: "myNamespace",
isAbstract: true,
docs: new Docs(),
@@ -388,7 +394,7 @@ public void ShouldDeserializeAllMembers()
Assert.Equal("myName", actual.Name, ignoreLineEndingDifferences: true);
Assert.Equal("myNamespace", actual.Namespace, ignoreLineEndingDifferences: true);
Assert.Equal(TypeKind.Class, actual.Kind);
- Assert.Equal("hello", actual.Docs.Summary);
+ Assert.Equal("hello", actual.Docs?.Summary);
}
[Fact(DisplayName = Prefix + nameof(ShouldThrowOnMissingFullyQualifiedName))]
@@ -623,8 +629,8 @@ public void DeserializesAsyncMethod()
ClassType actual = JsonConvert.DeserializeObject(json);
- Assert.True(actual.Methods.Length == 1);
- Assert.True(actual.Methods[0]?.IsAsync);
+ Assert.Equal(1, actual.Methods?.Length);
+ Assert.True(actual.Methods?[0]?.IsAsync);
}
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionKindTests.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionKindTests.cs
index e1c058e6cb..84885bb1ed 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionKindTests.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionKindTests.cs
@@ -1,4 +1,4 @@
-using Amazon.JSII.JsonModel.Spec;
+using Amazon.JSII.JsonModel.Spec;
using Newtonsoft.Json;
using System;
using Xunit;
@@ -41,7 +41,9 @@ public void ShouldDeserialize(string kind, CollectionKind expected)
[Fact(DisplayName = Prefix + nameof(ShouldThrowOnNull))]
public void ShouldThrowOnNull()
{
+#pragma warning disable CS8625
Assert.Throws(() => JsonConvert.DeserializeObject(null));
+#pragma warning restore CS8625
}
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionTypeReferenceTests.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionTypeReferenceTests.cs
index 2800b66e7f..4a6450174d 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionTypeReferenceTests.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/CollectionTypeReferenceTests.cs
@@ -1,4 +1,4 @@
-using Amazon.JSII.JsonModel.Spec;
+using Amazon.JSII.JsonModel.Spec;
using Newtonsoft.Json;
using System;
using Xunit;
@@ -36,7 +36,9 @@ public void ShouldSerializeAllMembers()
[Fact(DisplayName = Prefix + nameof(ShouldThrowOnMissingElementType))]
public void ShouldThrowOnMissingElementType()
{
+#pragma warning disable CS8625
Assert.Throws(() => new CollectionTypeReference(CollectionKind.Array, null));
+#pragma warning restore CS8625
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/EnumMemberTests.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/EnumMemberTests.cs
index c3e43b6224..e56cca7a08 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/EnumMemberTests.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel.UnitTests/Spec/EnumMemberTests.cs
@@ -1,4 +1,4 @@
-using Amazon.JSII.JsonModel.Spec;
+using Amazon.JSII.JsonModel.Spec;
using Newtonsoft.Json;
using System;
using Xunit;
@@ -30,7 +30,9 @@ public void ShouldSerializeAllMembers()
[Fact(DisplayName = Prefix + nameof(ShouldThrowOnMissingName))]
public void ShouldThrowOnMissingName()
{
+#pragma warning disable CS8625
Assert.Throws(() => new EnumMember(null, new Docs()));
+#pragma warning restore CS8625
}
[Fact(DisplayName = Prefix + nameof(ShouldNotSerializeMissingDocs))]
@@ -61,8 +63,8 @@ public void ShouldDeserializeAllMembers()
EnumMember actual = JsonConvert.DeserializeObject(json);
- Assert.Equal("myName", actual.Name, ignoreLineEndingDifferences: true);
- Assert.Equal("hello", actual.Docs.Summary);
+ Assert.Equal("myName", actual?.Name, ignoreLineEndingDifferences: true);
+ Assert.Equal("hello", actual?.Docs?.Summary);
}
[Fact(DisplayName = Prefix + nameof(ShouldThrowOnMissingName))]
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj
index 8e82179c1a..8c97657b68 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Amazon.JSII.JsonModel.csproj
@@ -6,6 +6,9 @@
Amazon.JSII.JsonModel
.NET JsonModel for JSII
icon.png
+
+ enable
+ true
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Callback.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Callback.cs
index 278c6d6237..64edb813fc 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Callback.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Callback.cs
@@ -10,10 +10,10 @@ public class Callback
public Callback
(
string callbackId,
- string cookie = null,
- InvokeRequest invoke = null,
- GetRequest get = null,
- SetRequest set = null
+ string? cookie = null,
+ InvokeRequest? invoke = null,
+ GetRequest? get = null,
+ SetRequest? set = null
)
{
CallbackId = callbackId ?? throw new ArgumentNullException(nameof(callbackId));
@@ -27,15 +27,15 @@ public Callback
public string CallbackId { get; }
[JsonProperty("cookie", NullValueHandling = NullValueHandling.Ignore)]
- public string Cookie { get; }
+ public string? Cookie { get; }
[JsonProperty("invoke", NullValueHandling = NullValueHandling.Ignore)]
- public InvokeRequest Invoke { get; }
+ public InvokeRequest? Invoke { get; }
[JsonProperty("get", NullValueHandling = NullValueHandling.Ignore)]
- public GetRequest Get { get; }
+ public GetRequest? Get { get; }
[JsonProperty("set", NullValueHandling = NullValueHandling.Ignore)]
- public SetRequest Set { get; }
+ public SetRequest? Set { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Override.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Override.cs
index acb2e71e99..bfa1ebcf7f 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Override.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Override.cs
@@ -7,9 +7,9 @@ public class Override
{
public Override
(
- string method = null,
- string property = null,
- string cookie = null
+ string? method = null,
+ string? property = null,
+ string? cookie = null
)
{
Method = method;
@@ -18,12 +18,12 @@ public Override
}
[JsonProperty("method", NullValueHandling = NullValueHandling.Ignore)]
- public string Method { get; }
+ public string? Method { get; }
[JsonProperty("property", NullValueHandling = NullValueHandling.Ignore)]
- public string Property { get; }
+ public string? Property { get; }
[JsonProperty("cookie", NullValueHandling = NullValueHandling.Ignore)]
- public string Cookie { get; }
+ public string? Cookie { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/BeginRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/BeginRequest.cs
index e33fe6a284..c1dd77bacc 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/BeginRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/BeginRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class BeginRequest : IKernelRequest
{
- public BeginRequest(ObjectReference objectReference, string method, object[] arguments = null)
+ public BeginRequest(ObjectReference objectReference, string method, object?[]? arguments = null)
{
ObjectReference = objectReference ?? throw new ArgumentNullException(nameof(objectReference));
Method = method ?? throw new ArgumentNullException(nameof(method));
@@ -23,6 +23,6 @@ public BeginRequest(ObjectReference objectReference, string method, object[] arg
public string Method { get; }
[JsonProperty("args", NullValueHandling = NullValueHandling.Ignore)]
- public object[] Arguments { get; }
+ public object?[]? Arguments { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CompleteRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CompleteRequest.cs
index f9b13eb149..5cf84ffc0b 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CompleteRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CompleteRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class CompleteRequest : IKernelRequest
{
- public CompleteRequest(string callbackId, string error = null, object result = null)
+ public CompleteRequest(string callbackId, string? error = null, object? result = null)
{
CallbackId = callbackId ?? throw new ArgumentNullException(nameof(callbackId));
Error = error;
@@ -20,9 +20,9 @@ public CompleteRequest(string callbackId, string error = null, object result = n
public string CallbackId { get; }
[JsonProperty("err", NullValueHandling = NullValueHandling.Ignore)]
- public string Error { get; }
+ public string? Error { get; }
[JsonProperty("result", NullValueHandling = NullValueHandling.Ignore)]
- public object Result { get; }
+ public object? Result { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CreateRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CreateRequest.cs
index f36ac4bae8..35b465af5e 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CreateRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/CreateRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class CreateRequest : IKernelRequest
{
- public CreateRequest(string fullyQualifiedName, object[] arguments = null, Override[] overrides = null, string[] interfaces = null)
+ public CreateRequest(string fullyQualifiedName, object?[]? arguments = null, Override[]? overrides = null, string[]? interfaces = null)
{
FullyQualifiedName = fullyQualifiedName ?? throw new ArgumentNullException(nameof(fullyQualifiedName));
Arguments = arguments;
@@ -21,7 +21,7 @@ public CreateRequest(string fullyQualifiedName, object[] arguments = null, Overr
public string FullyQualifiedName { get; }
[JsonProperty("args", NullValueHandling = NullValueHandling.Ignore)]
- public object[] Arguments { get; }
+ public object?[]? Arguments { get; }
[JsonProperty("overrides", NullValueHandling = NullValueHandling.Ignore)]
public Override[] Overrides { get; }
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/InvokeRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/InvokeRequest.cs
index aaf2f6698e..17c953ed29 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/InvokeRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/InvokeRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class InvokeRequest : IKernelRequest
{
- public InvokeRequest(ObjectReference objectReference, string method, object[] arguments = null)
+ public InvokeRequest(ObjectReference objectReference, string method, object?[]? arguments = null)
{
ObjectReference = objectReference ?? throw new ArgumentNullException(nameof(objectReference));
Method = method ?? throw new ArgumentNullException(nameof(method));
@@ -23,6 +23,6 @@ public InvokeRequest(ObjectReference objectReference, string method, object[] ar
public string Method { get; }
[JsonProperty("args", NullValueHandling = NullValueHandling.Ignore)]
- public object[] Arguments { get; }
+ public object?[]? Arguments { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/SetRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/SetRequest.cs
index 47ca9c31bd..a67162e77d 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/SetRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/SetRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class SetRequest : IKernelRequest
{
- public SetRequest(ObjectReference objectReference, string property, object value)
+ public SetRequest(ObjectReference objectReference, string property, object? value)
{
ObjectReference = objectReference ?? throw new ArgumentNullException(nameof(objectReference));
Property = property ?? throw new ArgumentNullException(nameof(property));
@@ -23,6 +23,6 @@ public SetRequest(ObjectReference objectReference, string property, object value
public string Property { get; }
[JsonProperty("value")]
- public object Value { get; }
+ public object? Value { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticInvokeRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticInvokeRequest.cs
index fb939a6c11..8a5785d6b6 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticInvokeRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticInvokeRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class StaticInvokeRequest : IKernelRequest
{
- public StaticInvokeRequest(string fullyQualifiedName, string method, object[] arguments = null)
+ public StaticInvokeRequest(string fullyQualifiedName, string method, object?[]? arguments = null)
{
FullyQualifiedName = fullyQualifiedName ?? throw new ArgumentNullException(nameof(fullyQualifiedName));
Method = method ?? throw new ArgumentNullException(nameof(method));
@@ -23,6 +23,6 @@ public StaticInvokeRequest(string fullyQualifiedName, string method, object[] ar
public string Method { get; }
[JsonProperty("args", NullValueHandling = NullValueHandling.Ignore)]
- public object[] Arguments { get; }
+ public object?[]? Arguments { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticSetRequest.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticSetRequest.cs
index 51b0991cb8..3291c4f8f6 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticSetRequest.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Request/StaticSetRequest.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Request
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class StaticSetRequest : IKernelRequest
{
- public StaticSetRequest(string fullyQualifiedName, string property, object value)
+ public StaticSetRequest(string fullyQualifiedName, string property, object? value)
{
FullyQualifiedName = fullyQualifiedName ?? throw new ArgumentNullException(nameof(fullyQualifiedName));
Property = property ?? throw new ArgumentNullException(nameof(property));
@@ -23,6 +23,6 @@ public StaticSetRequest(string fullyQualifiedName, string property, object value
public string Property { get; }
[JsonProperty("value")]
- public object Value { get; }
+ public object? Value { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/ErrorResponse.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/ErrorResponse.cs
index f7d56dd32e..c2369d8cb7 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/ErrorResponse.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/ErrorResponse.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Api.Response
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class ErrorResponse
{
- public ErrorResponse(string error, string stack = null)
+ public ErrorResponse(string error, string? stack = null)
{
Error = error ?? throw new ArgumentNullException(nameof(error));
Stack = stack;
@@ -16,6 +16,6 @@ public ErrorResponse(string error, string stack = null)
public string Error { get; }
[JsonProperty("stack", NullValueHandling = NullValueHandling.Ignore)]
- public string Stack { get; }
+ public string? Stack { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/GetResponse.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/GetResponse.cs
index e0335e4b7f..e40f1ccc9d 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/GetResponse.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/GetResponse.cs
@@ -5,12 +5,12 @@ namespace Amazon.JSII.JsonModel.Api.Response
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class GetResponse : IKernelResponse
{
- public GetResponse(object value)
+ public GetResponse(object? value)
{
Value = value;
}
[JsonProperty("value")]
- public object Value { get; }
+ public object? Value { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/InvokeResponse.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/InvokeResponse.cs
index acd3f9dae0..1661d80f74 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/InvokeResponse.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/InvokeResponse.cs
@@ -5,12 +5,12 @@ namespace Amazon.JSII.JsonModel.Api.Response
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class InvokeResponse : IKernelResponse
{
- public InvokeResponse(object result = null)
+ public InvokeResponse(object? result = null)
{
Result = result;
}
[JsonProperty("result", NullValueHandling = NullValueHandling.Ignore)]
- public object Result { get; }
+ public object? Result { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/NamingResponse.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/NamingResponse.cs
index 339abc627d..144f4ddccd 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/NamingResponse.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Api/Response/NamingResponse.cs
@@ -18,7 +18,7 @@ public NamingResponse(NamingData naming)
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class NamingData
{
- public NamingData(DotNetNaming dotnet, IDictionary others = null)
+ public NamingData(DotNetNaming dotnet, IDictionary? others = null)
{
DotNet = dotnet ?? throw new ArgumentNullException(nameof(dotnet));
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeConverter.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeConverter.cs
index 4a77f4ee16..26e8f778b9 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeConverter.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeConverter.cs
@@ -20,12 +20,12 @@ public override bool CanConvert(System.Type objectType)
return objectType.IsAssignableFrom(typeof(EnumType)) || objectType.IsAssignableFrom(typeof(ClassType));
}
- public override object ReadJson(JsonReader reader, System.Type objectType, object existingValue, JsonSerializer serializer)
+ public override object? ReadJson(JsonReader reader, System.Type objectType, object? existingValue, JsonSerializer serializer)
{
throw new NotImplementedException();
}
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
Spec.Type type = value as Spec.Type ?? throw new ArgumentException($"{value} is not a jsii Type", nameof(value));
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeDictionaryConverter.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeDictionaryConverter.cs
index 31bcaa5128..9176b8250f 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeDictionaryConverter.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/TypeDictionaryConverter.cs
@@ -16,14 +16,14 @@ public override bool CanConvert(Type objectType)
throw new NotImplementedException();
}
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
var untypedDictionary = JObject.Load(reader);
return untypedDictionary.Properties().ToDictionary(p => p.Name, p => Util.ConvertToDerivedType(p.Value));
}
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/Util.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/Util.cs
index f86074efbe..e67d47d375 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/Util.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Converters/Util.cs
@@ -21,9 +21,9 @@ internal static Spec.Type ConvertToDerivedType(JToken token)
return kind switch
{
- TypeKind.Enum => (Spec.Type) token.ToObject(),
- TypeKind.Class => token.ToObject(),
- TypeKind.Interface => token.ToObject(),
+ TypeKind.Enum => (Spec.Type) token.ToObject()!,
+ TypeKind.Class => token.ToObject()!,
+ TypeKind.Interface => token.ToObject()!,
_ => throw new ArgumentException($"Unknown kind {kind} on type {token.ToString(Formatting.Indented)}", nameof(token))
};
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/JsonDictionaryBase.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/JsonDictionaryBase.cs
index 9cf7e0ccf4..9a1a7c2d40 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/JsonDictionaryBase.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/JsonDictionaryBase.cs
@@ -4,6 +4,7 @@
namespace Amazon.JSII.JsonModel
{
public abstract class JsonDictionaryBase : IDictionary
+ where TKey : notnull
{
private readonly IDictionary _members = new Dictionary();
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Assembly.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Assembly.cs
index bcb6bc7fa8..04651edfb9 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Assembly.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Assembly.cs
@@ -34,13 +34,13 @@ public Assembly
string fingerprint,
string version,
string license,
- AssemblyTargets targets = null,
- IDictionary dependencies = null,
- Person[] contributors = null,
- IDictionary bundled = null,
- IDictionary types = null,
- Docs docs = null,
- Readme readme = null
+ AssemblyTargets? targets = null,
+ IDictionary? dependencies = null,
+ Person[]? contributors = null,
+ IDictionary? bundled = null,
+ IDictionary? types = null,
+ Docs? docs = null,
+ Readme? readme = null
): base(targets, dependencies)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
@@ -86,19 +86,19 @@ public Assembly
public string License { get; }
[JsonProperty("contributors", NullValueHandling = NullValueHandling.Ignore)]
- public Person[] Contributors { get; }
+ public Person[]? Contributors { get; }
[JsonProperty("bundled", NullValueHandling = NullValueHandling.Ignore)]
- public IDictionary Bundled { get; }
+ public IDictionary? Bundled { get; }
[JsonProperty("types", ItemConverterType = typeof(TypeConverter))]
[JsonConverter(typeof(TypeDictionaryConverter))]
- public IDictionary Types { get; }
+ public IDictionary? Types { get; }
[JsonProperty("docs", NullValueHandling = NullValueHandling.Ignore)]
- public Docs Docs { get; }
+ public Docs? Docs { get; }
[JsonProperty("readme", NullValueHandling = NullValueHandling.Ignore)]
- public Readme Readme { get; }
+ public Readme? Readme { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/AssemblyTargets.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/AssemblyTargets.cs
index 9e9ad114f0..6d35fcf1d2 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/AssemblyTargets.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/AssemblyTargets.cs
@@ -7,7 +7,7 @@ namespace Amazon.JSII.JsonModel.Spec
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class AssemblyTargets
{
- public AssemblyTargets(DotNetTarget dotnet, IDictionary others = null)
+ public AssemblyTargets(DotNetTarget dotnet, IDictionary? others = null)
{
DotNet = dotnet ?? throw new ArgumentNullException(nameof(dotnet));
}
@@ -22,11 +22,11 @@ public DotNetTarget
(
string @namespace,
string packageId,
- string title = null,
+ string? title = null,
bool signAssembly = false,
- string assemblyOriginatorKeyFile = null,
- string iconUrl = null,
- string versionSuffix = null
+ string? assemblyOriginatorKeyFile = null,
+ string? iconUrl = null,
+ string? versionSuffix = null
)
{
Namespace = @namespace ?? throw new ArgumentNullException(nameof(@namespace));
@@ -51,19 +51,19 @@ public DotNetTarget
public string PackageId { get; }
[JsonProperty("title", NullValueHandling = NullValueHandling.Ignore)]
- public string Title { get; }
+ public string? Title { get; }
[JsonProperty("signAssembly", NullValueHandling = NullValueHandling.Ignore)]
public bool SignAssembly { get; }
[JsonProperty("assemblyOriginatorKeyFile", NullValueHandling = NullValueHandling.Ignore)]
- public string AssemblyOriginatorKeyFile { get; }
+ public string? AssemblyOriginatorKeyFile { get; }
[JsonProperty("iconUrl", NullValueHandling = NullValueHandling.Ignore)]
- public string IconUrl { get; }
+ public string? IconUrl { get; }
[JsonProperty("versionSuffix", NullValueHandling = NullValueHandling.Ignore)]
- public string VersionSuffix { get; }
+ public string? VersionSuffix { get; }
}
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Callable.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Callable.cs
index be517a161c..1a0b66a8db 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Callable.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Callable.cs
@@ -7,11 +7,11 @@ public abstract class Callable : IDocumentable, IOverridable
{
protected Callable
(
- Parameter[] parameters = null,
+ Parameter[]? parameters = null,
bool isProtected = false,
bool isVariadic = false,
- string overrides = null,
- Docs docs = null
+ string? overrides = null,
+ Docs? docs = null
)
{
Parameters = parameters;
@@ -22,7 +22,7 @@ protected Callable
}
[JsonProperty("parameters", NullValueHandling = NullValueHandling.Ignore)]
- public Parameter[] Parameters { get; }
+ public Parameter[]? Parameters { get; }
[JsonProperty("protected", NullValueHandling = NullValueHandling.Ignore)]
public bool IsProtected { get; }
@@ -31,9 +31,9 @@ protected Callable
public bool IsVariadic { get; }
[JsonProperty("docs", NullValueHandling = NullValueHandling.Ignore)]
- public Docs Docs { get; }
+ public Docs? Docs { get; }
[JsonProperty("overrides", NullValueHandling = NullValueHandling.Ignore)]
- public string Overrides { get; }
+ public string? Overrides { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/ClassType.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/ClassType.cs
index 3c9cd6a717..83e0679ad4 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/ClassType.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/ClassType.cs
@@ -15,16 +15,16 @@ public ClassType
// ClassType properties
bool isAbstract = false,
- string @namespace = null,
+ string? @namespace = null,
// Type properties
- Docs docs = null,
+ Docs? docs = null,
// ClassType properties
- string @base = null,
- Initializer initializer = null,
- Property[] properties = null,
- Method[] methods = null,
- string[] interfaces = null
+ string? @base = null,
+ Initializer? initializer = null,
+ Property[]? properties = null,
+ Method[]? methods = null,
+ string[]? interfaces = null
)
: base
(
@@ -49,18 +49,18 @@ public ClassType
public bool IsAbstract { get; }
[JsonProperty("base", NullValueHandling = NullValueHandling.Ignore)]
- public string Base { get; }
+ public string? Base { get; }
[JsonProperty("initializer", NullValueHandling = NullValueHandling.Ignore)]
- public Initializer Initializer { get; }
+ public Initializer? Initializer { get; }
[JsonProperty("properties", NullValueHandling = NullValueHandling.Ignore)]
- public Property[] Properties { get; }
+ public Property[]? Properties { get; }
[JsonProperty("methods", NullValueHandling = NullValueHandling.Ignore)]
- public Method[] Methods { get; }
+ public Method[]? Methods { get; }
[JsonProperty("interfaces", NullValueHandling = NullValueHandling.Ignore)]
- public string[] Interfaces { get; }
+ public string[]? Interfaces { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/DependencyRoot.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/DependencyRoot.cs
index db5e4927c7..27d0ffc313 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/DependencyRoot.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/DependencyRoot.cs
@@ -7,8 +7,8 @@ public abstract class DependencyRoot
{
public DependencyRoot
(
- AssemblyTargets targets = null,
- IDictionary dependencies = null
+ AssemblyTargets? targets = null,
+ IDictionary? dependencies = null
)
{
Targets = targets;
@@ -16,9 +16,9 @@ public DependencyRoot
}
[JsonProperty("dependencies", NullValueHandling = NullValueHandling.Ignore)]
- public IDictionary Dependencies { get; }
+ public IDictionary? Dependencies { get; }
[JsonProperty("targets")]
- public AssemblyTargets Targets { get; }
+ public AssemblyTargets? Targets { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Docs.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Docs.cs
index 1d020f8bdd..60a71aeaa5 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Docs.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Docs.cs
@@ -8,16 +8,16 @@ public class Docs
{
public Docs
(
- string summary = null,
- string remarks = null,
- string deprecated = null,
- string returns = null,
+ string? summary = null,
+ string? remarks = null,
+ string? deprecated = null,
+ string? returns = null,
Stability? stability = null,
- string example = null,
- string see = null,
+ string? example = null,
+ string? see = null,
bool? subclassable = null,
- string @default = null,
- IDictionary custom = null
+ string? @default = null,
+ IDictionary? custom = null
)
{
Summary = summary;
@@ -33,31 +33,31 @@ public Docs
}
[JsonProperty("summary", NullValueHandling = NullValueHandling.Ignore)]
- public string Summary { get; }
+ public string? Summary { get; }
[JsonProperty("remarks", NullValueHandling = NullValueHandling.Ignore)]
- public string Remarks { get; }
+ public string? Remarks { get; }
[JsonProperty("deprecated", NullValueHandling = NullValueHandling.Ignore)]
- public string Deprecated { get; }
+ public string? Deprecated { get; }
[JsonProperty("returns", NullValueHandling = NullValueHandling.Ignore)]
- public string Returns { get; }
+ public string? Returns { get; }
[JsonProperty("stability", NullValueHandling = NullValueHandling.Ignore)]
public Stability? Stability { get; }
[JsonProperty("example", NullValueHandling = NullValueHandling.Ignore)]
- public string Example { get; }
+ public string? Example { get; }
[JsonProperty("see", NullValueHandling = NullValueHandling.Ignore)]
- public string See { get; }
+ public string? See { get; }
[JsonProperty("subclassable", NullValueHandling = NullValueHandling.Ignore)]
public bool? Subclassable { get; }
[JsonProperty("default", NullValueHandling = NullValueHandling.Ignore)]
- public string Default { get; }
+ public string? Default { get; }
[JsonProperty("custom", NullValueHandling = NullValueHandling.Ignore)]
public IDictionary Custom;
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumMember.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumMember.cs
index b134d90483..aa446af3c2 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumMember.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumMember.cs
@@ -6,7 +6,7 @@ namespace Amazon.JSII.JsonModel.Spec
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class EnumMember : IDocumentable
{
- public EnumMember(string name, Docs docs = null)
+ public EnumMember(string name, Docs? docs = null)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
Docs = docs;
@@ -16,6 +16,6 @@ public EnumMember(string name, Docs docs = null)
public string Name { get; }
[JsonProperty("docs", NullValueHandling = NullValueHandling.Ignore)]
- public Docs Docs { get; }
+ public Docs? Docs { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumType.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumType.cs
index 43798245bd..5bfa924c1e 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumType.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/EnumType.cs
@@ -16,9 +16,9 @@ public EnumType
// EnumType properties
EnumMember[] members,
- string @namespace = null,
+ string? @namespace = null,
// Type properties
- Docs docs = null
+ Docs? docs = null
)
: base
(
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IDocumentable.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IDocumentable.cs
index 81099ab756..bf1e39e22f 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IDocumentable.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IDocumentable.cs
@@ -2,6 +2,6 @@
{
public interface IDocumentable
{
- Docs Docs { get; }
+ Docs? Docs { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IOverridable.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IOverridable.cs
index 448104d875..aedf6eee1a 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IOverridable.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/IOverridable.cs
@@ -2,6 +2,6 @@
{
public interface IOverridable
{
- string Overrides { get; }
+ string? Overrides { get; }
}
}
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Initializer.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Initializer.cs
index f537f631de..ffd001f4b6 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Initializer.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Initializer.cs
@@ -7,11 +7,11 @@ public class Initializer : Callable
{
public Initializer
(
- Parameter[] parameters = null,
+ Parameter[]? parameters = null,
bool isProtected = false,
bool isVariadic = false,
- string overrides = null,
- Docs docs = null
+ string? overrides = null,
+ Docs? docs = null
): base(
parameters: parameters,
isProtected: isProtected,
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/InterfaceType.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/InterfaceType.cs
index 41e10338a9..05a6467316 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/InterfaceType.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/InterfaceType.cs
@@ -11,15 +11,15 @@ public InterfaceType
string fullyQualifiedName,
string assembly,
string name,
- string @namespace = null,
+ string? @namespace = null,
// Type properties
- Docs docs = null,
+ Docs? docs = null,
// InterfaceType properties
- string[] interfaces = null,
- Method[] methods = null,
- Property[] properties = null,
+ string[]? interfaces = null,
+ Method[]? methods = null,
+ Property[]? properties = null,
bool isDataType = false
) : base
(
@@ -38,13 +38,13 @@ public InterfaceType
}
[JsonProperty("interfaces", NullValueHandling = NullValueHandling.Ignore)]
- public string[] Interfaces { get; }
+ public string[]? Interfaces { get; }
[JsonProperty("methods", NullValueHandling = NullValueHandling.Ignore)]
- public Method[] Methods { get; }
+ public Method[]? Methods { get; }
[JsonProperty("properties", NullValueHandling = NullValueHandling.Ignore)]
- public Property[] Properties { get; }
+ public Property[]? Properties { get; }
[JsonProperty("datatype", NullValueHandling = NullValueHandling.Ignore)]
public bool IsDataType { get; }
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Method.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Method.cs
index b2f5f039c9..e83f0638ae 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Method.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Method.cs
@@ -8,15 +8,15 @@ public class Method : Callable
public Method
(
string name,
- OptionalValue returns = null,
- Parameter[] parameters = null,
+ OptionalValue? returns = null,
+ Parameter[]? parameters = null,
bool isAbstract = false,
bool isAsync = false,
bool isProtected = false,
bool isVariadic = false,
bool isStatic = false,
- string overrides = null,
- Docs docs = null
+ string? overrides = null,
+ Docs? docs = null
): base
(
parameters: parameters,
@@ -37,7 +37,7 @@ public Method
public string Name { get; }
[JsonProperty("returns", NullValueHandling = NullValueHandling.Ignore)]
- public OptionalValue Returns { get; }
+ public OptionalValue? Returns { get; }
[JsonProperty("abstract", NullValueHandling = NullValueHandling.Ignore)]
public bool IsAbstract { get; }
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/PackageVersion.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/PackageVersion.cs
index 7ffec179ef..1754907357 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/PackageVersion.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/PackageVersion.cs
@@ -10,8 +10,8 @@ public class PackageVersion: DependencyRoot
public PackageVersion
(
string version,
- AssemblyTargets targets = null,
- IDictionary dependencies = null
+ AssemblyTargets? targets = null,
+ IDictionary? dependencies = null
): base(targets, dependencies)
{
Version = version ?? throw new ArgumentNullException(nameof(version));
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Parameter.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Parameter.cs
index 132dd5e925..d05c81280f 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Parameter.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Parameter.cs
@@ -12,7 +12,7 @@ public Parameter
TypeReference type,
bool isOptional = false,
bool isVariadic = false,
- Docs docs = null
+ Docs? docs = null
): base(type: type, isOptional: isOptional)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
@@ -27,6 +27,6 @@ public Parameter
public bool IsVariadic { get; }
[JsonProperty("docs", NullValueHandling = NullValueHandling.Ignore)]
- public Docs Docs { get; }
+ public Docs? Docs { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Person.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Person.cs
index d4dbaea00e..a710f4c677 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Person.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Person.cs
@@ -10,8 +10,8 @@ public Person
(
string name,
string[] roles,
- string email = null,
- string url = null,
+ string? email = null,
+ string? url = null,
bool isOrganization = false
)
{
@@ -29,10 +29,10 @@ public Person
public string[] Roles { get; }
[JsonProperty("email", NullValueHandling = NullValueHandling.Ignore)]
- public string Email { get; }
+ public string? Email { get; }
[JsonProperty("url", NullValueHandling = NullValueHandling.Ignore)]
- public string Url { get; }
+ public string? Url { get; }
[JsonProperty("organization", NullValueHandling = NullValueHandling.Ignore)]
public bool IsOrganization { get; }
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Property.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Property.cs
index 0bd08fc087..73df010e2c 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Property.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Property.cs
@@ -16,8 +16,8 @@ public Property
bool isAbstract = false,
bool isStatic = false,
bool isConstant = false,
- string overrides = null,
- Docs docs = null
+ string? overrides = null,
+ Docs? docs = null
): base(type: type, isOptional: isOptional)
{
Name = name ?? throw new ArgumentNullException(nameof(name));
@@ -49,9 +49,9 @@ public Property
public bool IsStatic { get; }
[JsonProperty("overrides", NullValueHandling = NullValueHandling.Ignore)]
- public string Overrides { get; }
+ public string? Overrides { get; }
[JsonProperty("docs", NullValueHandling = NullValueHandling.Ignore)]
- public Docs Docs { get; }
+ public Docs? Docs { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Type.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Type.cs
index e4fcd2797f..3e5b1a1d86 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Type.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/Type.cs
@@ -11,9 +11,9 @@ protected Type
string fullyQualifiedName,
string assembly,
string name,
- string @namespace,
+ string? @namespace,
TypeKind kind,
- Docs docs = null
+ Docs? docs = null
)
{
FullyQualifiedName = fullyQualifiedName ?? throw new ArgumentNullException(nameof(fullyQualifiedName));
@@ -34,13 +34,13 @@ protected Type
public string Name { get; }
[JsonProperty("namespace", NullValueHandling = NullValueHandling.Ignore)]
- public string Namespace { get; }
+ public string? Namespace { get; }
[JsonProperty("kind", DefaultValueHandling = DefaultValueHandling.Include)]
public TypeKind Kind { get; }
[JsonProperty("docs", NullValueHandling = NullValueHandling.Ignore)]
- public Docs Docs { get; }
+ public Docs? Docs { get; }
[JsonIgnore]
public string QualifiedNamespace => this.Assembly + (this.Namespace != null ? $".{this.Namespace}" : "");
diff --git a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/TypeReference.cs b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/TypeReference.cs
index 1e27ec877c..04da801a14 100644
--- a/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/TypeReference.cs
+++ b/packages/@jsii/dotnet-jsonmodel/src/Amazon.JSII.JsonModel/Spec/TypeReference.cs
@@ -7,10 +7,10 @@ public class TypeReference
{
public TypeReference
(
- string fullyQualifiedName = null,
+ string? fullyQualifiedName = null,
PrimitiveType? primitive = null,
- CollectionTypeReference collection = null,
- UnionTypeReference union = null
+ CollectionTypeReference? collection = null,
+ UnionTypeReference? union = null
)
{
FullyQualifiedName = fullyQualifiedName;
@@ -20,15 +20,15 @@ public TypeReference
}
[JsonProperty("fqn", NullValueHandling = NullValueHandling.Ignore)]
- public string FullyQualifiedName { get; }
+ public string? FullyQualifiedName { get; }
[JsonProperty("primitive", NullValueHandling = NullValueHandling.Ignore)]
public PrimitiveType? Primitive { get; }
[JsonProperty("collection", NullValueHandling = NullValueHandling.Ignore)]
- public CollectionTypeReference Collection { get; }
+ public CollectionTypeReference? Collection { get; }
[JsonProperty("union", NullValueHandling = NullValueHandling.Ignore)]
- public UnionTypeReference Union { get; }
+ public UnionTypeReference? Union { get; }
}
}
\ No newline at end of file
diff --git a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj
index 294666587f..3bfefa0e37 100644
--- a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj
+++ b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/Amazon.JSII.Runtime.IntegrationTests.csproj
@@ -4,6 +4,9 @@
netcoreapp3.1
false
+
+ enable
+ true
diff --git a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs
index 1109d2f3b5..49d8f1fbc2 100644
--- a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs
+++ b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs
@@ -61,7 +61,7 @@ public void PrimitiveTypes()
// json
types.JsonProperty = JObject.Parse(@"{ ""Foo"": { ""Bar"": 123 } }");
- Assert.Equal(123d, types.JsonProperty["Foo"]["Bar"].Value());
+ Assert.Equal(123d, types.JsonProperty["Foo"]?["Bar"]?.Value());
}
[Fact(DisplayName = Prefix + nameof(Dates))]
@@ -508,7 +508,7 @@ public override string TheProperty
class InterfaceWithProperties : DeputyBase, IInterfaceWithProperties
{
- string _x;
+ string? _x;
public string ReadOnlyString => "READ_ONLY_STRING";
@@ -863,7 +863,9 @@ public void NullShouldBeTreatedAsUndefined()
obj.GiveMeUndefinedInsideAnObject(new NullShouldBeTreatedAsUndefinedData
{
ThisShouldBeUndefined = null,
+#pragma warning disable CS8625
ArrayWithThreeElementsAndUndefinedAsSecondArgument = new object[] {"hello", null, "world"}
+#pragma warning restore CS8625
});
// property
@@ -888,7 +890,9 @@ public void OptionalAndVariadicArgumentsTest()
var variadicClassNoParams = new VariadicMethod();
// Array with null value in constructor params
+#pragma warning disable CS8625
new VariadicMethod(null);
+#pragma warning restore CS8625
// Array with one value in constructor params
new VariadicMethod(1);
@@ -897,7 +901,9 @@ public void OptionalAndVariadicArgumentsTest()
new VariadicMethod(1, 2, 3, 4);
// Variadic parameter with null passed
+#pragma warning disable CS8625
variadicClassNoParams.AsArray(double.MinValue, null);
+#pragma warning restore CS8625
// Variadic parameter with default value used
variadicClassNoParams.AsArray(double.MinValue);
@@ -1044,7 +1050,9 @@ private sealed class OverrideVariadicMethod : VariadicMethod
{
public override double[] AsArray(double first, params double[] others)
{
+#pragma warning disable CS8604
return base.AsArray(first + 1, others?.Select(n => n + 1).ToArray());
+#pragma warning restore CS8604
}
}
@@ -1216,7 +1224,7 @@ public override string TheProperty
set => AnotherTheProperty = value;
}
- public string AnotherTheProperty { get; set; }
+ public string? AnotherTheProperty { get; set; }
}
class PureNativeFriendlyRandom : DeputyBase, IFriendlyRandomGenerator
@@ -1289,7 +1297,7 @@ public void CanUseInterfaceSetters()
[Fact(DisplayName = Prefix + nameof(StructsAreUndecoratedOntheWayToKernel))]
public void StructsAreUndecoratedOntheWayToKernel()
{
- var json = JsonFormatter.Stringify(new StructB {RequiredString = "Bazinga!", OptionalBoolean = false});
+ var json = JsonFormatter.Stringify(new StructB {RequiredString = "Bazinga!", OptionalBoolean = false})!;
var actual = JObject.Parse(json);
var expected = new JObject();
@@ -1408,7 +1416,7 @@ public void AbstractMembersAreCorrectlyHandled()
private sealed class AbstractSuiteImpl : AbstractSuite
{
- private string _property;
+ private string _property = "";
public AbstractSuiteImpl() {}
diff --git a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/XUnitLogger.cs b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/XUnitLogger.cs
index 2bd4f58b17..dcaf12b831 100644
--- a/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/XUnitLogger.cs
+++ b/packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/XUnitLogger.cs
@@ -40,7 +40,7 @@ public XUnitLogger(ITestOutputHelper output, string categoryName)
public void Log(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func formatter)
{
- _output.WriteLine($"[{_categoryName}] {state.ToString()}");
+ _output.WriteLine($"[{_categoryName}] {state?.ToString()}");
}
public IDisposable BeginScope(TState state)
diff --git a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj
index 2763dc88b9..288902e78b 100644
--- a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj
+++ b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Amazon.JSII.Runtime.UnitTests.csproj
@@ -6,6 +6,9 @@
false
Amazon.JSII.Runtime.UnitTests
+
+ enable
+ true
diff --git a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs
index 10848683df..7301164fe5 100644
--- a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs
+++ b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/FrameworkToJsiiConverterTests.cs
@@ -39,8 +39,8 @@ protected TestBase()
IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
ServiceContainer.ServiceProviderOverride = serviceProvider;
- _typeCache.GetClassType("myClassFqn").Returns(typeof(TestClass));
- _typeCache.GetEnumType("myEnumFqn").Returns(typeof(TestEnum));
+ _typeCache.TryGetClassType("myClassFqn").Returns(typeof(TestClass));
+ _typeCache.TryGetEnumType("myEnumFqn").Returns(typeof(TestEnum));
}
}
@@ -51,7 +51,7 @@ public sealed class Void : TestBase
[Fact(DisplayName = _Prefix + nameof(DoesNotConvert))]
public void DoesNotConvert()
{
- bool success = _converter.TryConvert(null, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(null, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -60,7 +60,7 @@ public void DoesNotConvert()
[Fact(DisplayName = _Prefix + nameof(ThrowsIfValueIsNotNull))]
public void ThrowsIfValueIsNotNull()
{
- Assert.Throws("value", () => _converter.TryConvert(null, _referenceMap, "", out object actual));
+ Assert.Throws("value", () => _converter.TryConvert(null, _referenceMap, "", out object? actual));
}
}
@@ -103,7 +103,7 @@ public void ConvertsPrimitiveValues(PrimitiveType primitive, object value, objec
{
var instance = new OptionalValue(new TypeReference(primitive: primitive), isOptional: isOptional);
- bool success = _converter.TryConvert(instance, _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal(expected, actual);
@@ -115,7 +115,7 @@ public void ConvertsDateValues()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Date));
DateTime now = DateTime.Now;
- bool success = _converter.TryConvert(instance, _referenceMap, now, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, now, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -139,7 +139,7 @@ public void ConvertsOptionalDateValues()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Date), isOptional: true);
DateTime now = DateTime.Now;
- bool success = _converter.TryConvert(instance, _referenceMap, now, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, now, out object? actual);
Assert.True(success);
Assert.IsType(actual);
var expected = new JObject
@@ -172,7 +172,7 @@ public void ConvertsJsonValues()
))
);
- bool success = _converter.TryConvert(instance, _referenceMap, jObject, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, jObject, out object? actual);
Assert.True(success);
Assert.Same(jObject, actual);
@@ -183,7 +183,7 @@ public void FailsOnNullBoolean()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Boolean));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.False(success);
}
@@ -193,7 +193,7 @@ public void FailsOnNullNumber()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Number));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.False(success);
}
@@ -203,7 +203,7 @@ public void ConvertsNullJson()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Json));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -222,7 +222,7 @@ public void ConvertsClassReference()
ByRefValue byRef = new ByRefValue("myClassFqn", "0001");
TestClass myClass = new TestClass(byRef);
- bool success = _converter.TryConvert(instance, _referenceMap, myClass, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, myClass, out object? actual);
Assert.True(success);
Assert.Equal(JObject.FromObject(byRef), actual);
@@ -236,7 +236,7 @@ public void ConvertsEnumValue()
TestEnum myEnum = TestEnum.MyMember2;
- bool success = _converter.TryConvert(instance, _referenceMap, myEnum, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, myEnum, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -252,7 +252,7 @@ public void ConvertsNullClassReference()
{
var instance = new OptionalValue(new TypeReference("myClassFqn"));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -263,7 +263,7 @@ public void DoesNotConvertNullNonOptionalEnumValue()
{
var instance = new OptionalValue(new TypeReference("myEnumFqn"));
- bool success =_converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success =_converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.False(success);
Assert.Null(actual);
@@ -274,7 +274,7 @@ public void ConvertsNullOptionalEnumValue()
{
var instance = new OptionalValue(new TypeReference("myEnumFqn"), isOptional: true);
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -300,7 +300,7 @@ public void ConvertsMap()
{ "myKey2", "myValue2" }
};
- bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -335,7 +335,7 @@ public void RecursivelyConvertsMapElements()
{ "myKey2", new Dictionary { { "mySubKey2", "myValue2" } } },
};
- bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -365,13 +365,13 @@ public void ConvertsArray()
"myValue2",
};
- bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object? actual);
Assert.True(success);
Assert.IsType(actual);
Assert.Collection
(
- (JArray)actual,
+ (JArray)actual!,
value => Assert.Equal("myValue1", value),
value => Assert.Equal("myValue2", value)
);
@@ -398,12 +398,12 @@ public void RecursivelyConvertsArrayElements()
new [] { "myValue2" },
};
- bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object? actual);
Assert.True(success);
Assert.IsType(actual);
Assert.Collection(
- (JArray)actual,
+ (JArray)actual!,
value =>
{
Assert.IsType(value);
@@ -445,7 +445,7 @@ public void RecursivelyConvertsMapElementsWithMapOfAny()
// This will test the call to FrameworkToJsiiConverter.TryConvertCollectionElement()
// In the case of a of a Map of Map of Any
- bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, frameworkMap, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -492,7 +492,7 @@ public void RecursivelyConvertsMapElementsWithArrayOfAny()
// This will test the call to FrameworkToJsiiConverter.TryConvertCollectionElement()
// In the case of a of a Map of Array of Any
- bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, frameworkArray, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -518,7 +518,7 @@ public void ConvertsNullMap()
)
));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -534,7 +534,7 @@ public void ConvertsNullArray()
)
));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -555,7 +555,7 @@ public void FailsIfNoTypeMatches()
})
));
- bool success = _converter.TryConvert(instance, _referenceMap, true, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, true, out object? actual);
Assert.False(success);
Assert.Null(actual);
@@ -570,7 +570,7 @@ public void ConvertsSimpleUnion()
})
));
- bool success = _converter.TryConvert(instance, _referenceMap, "abc", out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, "abc", out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -587,7 +587,7 @@ public void ConvertsAsFirstMatchingType()
})
));
- bool success = _converter.TryConvert(instance, _referenceMap, (ushort)7, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, (ushort)7, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -603,7 +603,7 @@ public void ConvertsNull()
})
));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -619,7 +619,7 @@ public void ConvertsNull()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
- bool success = _converter.TryConvert(instance, _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -633,7 +633,7 @@ public void ConvertsPrimitive(object value, object expected)
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
- bool success = _converter.TryConvert(instance, _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal(expected, actual);
@@ -645,7 +645,7 @@ public void ConvertsDate()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
DateTime now = DateTime.Now;
- bool success = _converter.TryConvert(instance, _referenceMap, now, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, now, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -663,7 +663,7 @@ public void ConvertsJson()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
JObject value = new JObject(new JProperty("myKey", "myValue"));
- bool success = _converter.TryConvert(instance, _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Same(value, actual);
@@ -678,11 +678,11 @@ public void ConvertsMap()
{
{ "myKey", "myValue" }
};
- bool success = _converter.TryConvert(instance, _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsType(actual);
- Assert.Collection((IEnumerable>)actual,
+ Assert.Collection((IEnumerable>)actual!,
kvp =>
{
Assert.IsType(kvp.Value);
@@ -704,11 +704,11 @@ public void ConvertsArray()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
string[] value = new[] { "myValue" };
- bool success = _converter.TryConvert(instance, _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsType(actual);
- Assert.Collection((IEnumerable)actual,
+ Assert.Collection((IEnumerable)actual!,
element => Assert.Equal("myValue", element.Value(), ignoreLineEndingDifferences: true)
);
}
diff --git a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/JsiiToFrameworkConverterTests.cs b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/JsiiToFrameworkConverterTests.cs
index b12ce2b979..01447eae8d 100644
--- a/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/JsiiToFrameworkConverterTests.cs
+++ b/packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime.UnitTests/Deputy/Converters/JsiiToFrameworkConverterTests.cs
@@ -49,7 +49,7 @@ public sealed class Void : TestBase
[Fact(DisplayName = _Prefix + nameof(DoesNotConvert))]
public void DoesNotConvert()
{
- bool success = _converter.TryConvert(null, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(null, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -58,7 +58,7 @@ public void DoesNotConvert()
[Fact(DisplayName = _Prefix + nameof(ThrowsIfValueIsNotNull))]
public void ThrowsIfValueIsNotNull()
{
- Assert.Throws("value", () => _converter.TryConvert(null, typeof(object), _referenceMap, "", out object actual));
+ Assert.Throws("value", () => _converter.TryConvert(null, typeof(object), _referenceMap, "", out object? actual));
}
}
@@ -101,7 +101,7 @@ public void ConvertsPrimitiveValues(PrimitiveType primitive, object value, objec
{
var instance = new OptionalValue(new TypeReference(primitive: primitive), isOptional: isOptional);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal(expected, actual);
@@ -120,7 +120,7 @@ public void ConvertsDateValues()
DateTime now = DateTime.Now;
JObject value = new JObject(new JProperty("$jsii.date", now));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal(now, actual);
@@ -137,7 +137,7 @@ public void ConvertsOptionalDateValues()
DateTime now = DateTime.Now;
JObject value = new JObject(new JProperty("$jsii.date", now));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal(now, actual);
@@ -165,7 +165,7 @@ public void ConvertsJsonValues()
))
);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, jObject, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, jObject, out object? actual);
Assert.True(success);
Assert.Same(jObject, actual);
@@ -176,7 +176,7 @@ public void FailsOnNullBoolean()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Boolean));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.False(success);
}
@@ -186,7 +186,7 @@ public void FailsOnNullNumber()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Number));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.False(success);
}
@@ -196,7 +196,7 @@ public void ConvertsNullJson()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Json));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -209,7 +209,10 @@ public sealed class FullyQualifiedName : TestBase
public FullyQualifiedName()
{
+ _typeCache.TryGetClassType("myClassFqn").Returns(typeof(TestClass));
_typeCache.GetClassType("myClassFqn").Returns(typeof(TestClass));
+
+ _typeCache.TryGetEnumType("myEnumFqn").Returns(typeof(TestEnum));
_typeCache.GetEnumType("myEnumFqn").Returns(typeof(TestEnum));
}
@@ -224,7 +227,7 @@ public void ConvertsClassReference()
.GetOrCreateNativeReference(Arg.Is(v => v.Value == "myClassFqn@0001"))
.Returns(testClass);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, byRef, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, byRef, out object? actual);
Assert.True(success);
Assert.Same(actual, testClass);
@@ -238,7 +241,7 @@ public void ConvertsEnumValue()
var instance = new OptionalValue(new TypeReference("myEnumFqn"));
JObject enumValue = new JObject(new JProperty("$jsii.enum", "myEnumFqn/MyMember1"));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, enumValue, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, enumValue, out object? actual);
Assert.True(success);
Assert.Equal(TestEnum.MyMember1, actual);
@@ -249,7 +252,7 @@ public void ConvertsNullClassReference()
{
var instance = new OptionalValue(new TypeReference("myClassFqn"));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -260,7 +263,7 @@ public void DoesNotConvertNullNonOptionalEnumValue()
{
var instance = new OptionalValue(new TypeReference("myEnumFqn"));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.False(success);
Assert.Null(actual);
@@ -271,7 +274,7 @@ public void ConvertsNullOptionalEnumValue()
{
var instance = new OptionalValue(new TypeReference("myEnumFqn"), isOptional: true);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -313,11 +316,11 @@ public void ConvertsMap()
new JProperty("myKey2", "myValue2")
);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsAssignableFrom>(actual);
- Assert.Collection((IDictionary)actual,
+ Assert.Collection((IDictionary)actual!,
kvp =>
{
Assert.Equal("myKey1", kvp.Key, ignoreLineEndingDifferences: true);
@@ -353,11 +356,11 @@ public void RecursivelyConvertsMapElements()
))
);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsAssignableFrom>>(actual);
- Assert.Collection((IDictionary>)actual,
+ Assert.Collection((IDictionary>)actual!,
kvp =>
{
Assert.Equal("myKey1", kvp.Key, ignoreLineEndingDifferences: true);
@@ -397,11 +400,11 @@ public void ConvertsArray()
new JValue("myValue2")
);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsType(actual);
- Assert.Collection((string[])actual,
+ Assert.Collection((string[])actual!,
element => Assert.Equal("myValue1", element, ignoreLineEndingDifferences: true),
element => Assert.Equal("myValue2", element, ignoreLineEndingDifferences: true)
);
@@ -425,11 +428,11 @@ public void RecursivelyConvertsArrayElements()
new JArray(new JValue("myValue2"))
);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsType(actual);
- Assert.Collection((string[][])actual,
+ Assert.Collection((string[][])actual!,
element => Assert.Collection(element,
subElement => Assert.Equal("myValue1", subElement, ignoreLineEndingDifferences: true)
),
@@ -448,7 +451,7 @@ public void ConvertsNullMap()
)
));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -463,7 +466,7 @@ public void ConvertsNullArray()
)
));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -485,7 +488,7 @@ public void FailsIfNoTypeMatches()
));
JValue value = new JValue(true);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.False(success);
Assert.Null(actual);
@@ -501,7 +504,7 @@ public void ConvertsSimpleUnion()
));
JValue value = new JValue("abc");
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal("abc", actual);
@@ -518,7 +521,7 @@ public void ConvertsAsFirstMatchingType()
));
JValue value = new JValue((ushort)7);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsType(actual);
@@ -534,7 +537,7 @@ public void ConvertsNull()
})
));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -550,7 +553,7 @@ public void ConvertsNull()
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, null, out object? actual);
Assert.True(success);
Assert.Null(actual);
@@ -564,7 +567,7 @@ public void ConvertsPrimitive(object value, object expected)
{
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, new JValue(value), out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, new JValue(value), out object? actual);
Assert.True(success);
Assert.Equal(expected, actual);
@@ -580,7 +583,7 @@ public void ConvertsDate()
new JProperty("$jsii.date", now)
);
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.Equal(now, actual);
@@ -594,11 +597,11 @@ public void ConvertsJson()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
JObject value = new JObject(new JProperty("myKey", "myValue"));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
- Assert.IsAssignableFrom>(actual);
- Assert.Collection((IDictionary)actual,
+ Assert.IsAssignableFrom>(actual);
+ Assert.Collection((IDictionary)actual!,
kvp =>
{
Assert.Equal("myKey", kvp.Key, ignoreLineEndingDifferences: true);
@@ -615,11 +618,11 @@ public void ConvertsMap()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
JObject value = new JObject(new JProperty("myKey", "myValue"));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsAssignableFrom>(actual);
- Assert.Collection((IDictionary)actual,
+ Assert.Collection((IDictionary)actual!,
kvp =>
{
Assert.Equal("myKey", kvp.Key, ignoreLineEndingDifferences: true);
@@ -634,11 +637,11 @@ public void ConvertsArray()
var instance = new OptionalValue(new TypeReference(primitive: PrimitiveType.Any));
JArray value = new JArray(new JValue("myValue"));
- bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object actual);
+ bool success = _converter.TryConvert(instance, typeof(object), _referenceMap, value, out object? actual);
Assert.True(success);
Assert.IsAssignableFrom