Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ public static void EmitJsonAcceptsMetadata(this Endpoint endpoint, CodeWriter co
{
codeWriter.WriteLine($$"""({{(parameter.IsOptional ? "true" : "false")}}, typeof({{parameter.Type.ToDisplayString(EmitterConstants.DisplayFormatWithoutNullability)}})),""");
}
codeWriter.WriteLine("#nullable restore");
codeWriter.WriteLine("#nullable enable");
codeWriter.Indent--;
codeWriter.WriteLine("};");
codeWriter.WriteLine("foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ namespace Microsoft.AspNetCore.Http.Generated
#nullable disable
(false, typeof(global::Microsoft.AspNetCore.Http.Generators.Tests.Todo)),
(false, typeof(global::Microsoft.AspNetCore.Http.Generators.Tests.TestService)),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::Microsoft.AspNetCore.Http.Generators.Tests.CustomMetadataEmitter)),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ namespace Microsoft.AspNetCore.Http.Generated
var jsonBodyOrServiceTypeTuples = new (bool, Type)[] {
#nullable disable
(false, typeof(global::System.String[])),
#nullable restore
#nullable enable
};
foreach (var (isOptional, type) in jsonBodyOrServiceTypeTuples)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,7 @@ public static IEndpointRouteBuilder MapPost(this IEndpointRouteBuilder app, int
public async Task TestHandlingOfGenericWithNullableReferenceTypes()
{
var source = """
#nullable enable
Copy link
Member

Choose a reason for hiding this comment

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

Is this the only test that tests nullability in user code 😮
Kind of surprising.

Copy link
Member Author

Choose a reason for hiding this comment

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

@BrennanConroy The other tests do use nullable annotations but they make use of the source template that is in the base class which enables it there:

using System;
using System.Globalization;
using Microsoft.AspNetCore.Builder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ internal static Project CreateProject(Func<CSharpCompilationOptions, CSharpCompi
{
var projectName = $"TestProject-{Guid.NewGuid()}";
var compilationOptions = new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)
.WithNullableContextOptions(NullableContextOptions.Enable);
.WithNullableContextOptions(NullableContextOptions.Disable);
if (modifyCompilationOptions is not null)
{
compilationOptions = modifyCompilationOptions(compilationOptions);
Expand Down