Skip to content

Commit 76b7f9d

Browse files
committed
Fixup
1 parent 5500c69 commit 76b7f9d

27 files changed

+552
-194
lines changed

src/Mvc/Mvc.DataAnnotations/test/CompareAttributeAdapterTest.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,17 @@ public void AddValidation_DoesNotTrounceExistingAttributes()
240240
private class PropertyDisplayNameModel
241241
{
242242
[Display(Name = "MyPropertyDisplayName")]
243-
public string? MyProperty { get; set; }
243+
public string MyProperty { get; set; }
244244

245245
[Display(Name = "OtherPropertyDisplayName")]
246-
public string? OtherProperty { get; set; }
246+
public string OtherProperty { get; set; }
247247
}
248248

249249
private class PropertyNameModel
250250
{
251-
public string? MyProperty { get; set; }
251+
public string MyProperty { get; set; }
252252

253-
public string? OtherProperty { get; set; }
253+
public string OtherProperty { get; set; }
254254
}
255255
}
256256
}

src/Mvc/Mvc.NewtonsoftJson/src/NewtonsoftJsonInputFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public override async Task<InputFormatterResult> ReadRequestBodyAsync(
208208
}
209209
}
210210

211-
if (exception is not null && exception is not JsonException or OverflowException or FormatException)
211+
if (exception is not null && exception is not (JsonException or OverflowException or FormatException))
212212
{
213213
// At this point we've already recorded all exceptions as an entry in the ModelStateDictionary.
214214
// We only need to rethrow an exception if we believe it needs to be handled by something further up

src/Mvc/Mvc.Razor/src/ApplicationParts/CompiledRazorAssemblyPart.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -28,7 +28,7 @@ public CompiledRazorAssemblyPart(Assembly assembly)
2828
public Assembly Assembly { get; }
2929

3030
/// <inheritdoc />
31-
public override string Name => Assembly.GetName().Name;
31+
public override string Name => Assembly.GetName().Name!;
3232

3333
IEnumerable<RazorCompiledItem> IRazorCompiledItemProvider.CompiledItems
3434
{

src/Mvc/Mvc.Razor/src/Compilation/CompiledViewDescriptor.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -33,7 +33,6 @@ public CompiledViewDescriptor(RazorCompiledItem item)
3333
}
3434

3535
Item = item;
36-
ExpirationTokens = Array.Empty<IChangeToken>();
3736
RelativePath = ViewPath.NormalizePath(item.Identifier);
3837
}
3938

@@ -69,14 +68,13 @@ public CompiledViewDescriptor(RazorCompiledItem item, RazorViewAttribute attribu
6968
// We don't have access to the file provider here so we can't check if the files
7069
// even exist or what their checksums are. For now leave this empty, it will be updated
7170
// later.
72-
ExpirationTokens = Array.Empty<IChangeToken>();
7371
RelativePath = ViewPath.NormalizePath(item?.Identifier ?? attribute.Path);
7472
}
7573

7674
/// <summary>
7775
/// The normalized application relative path of the view.
7876
/// </summary>
79-
public string RelativePath { get; set; }
77+
public string RelativePath { get; set; } = default!;
8078

8179
#pragma warning disable CS0618
8280
// Type or member is obsolete
@@ -87,22 +85,22 @@ public CompiledViewDescriptor(RazorCompiledItem item, RazorViewAttribute attribu
8785
/// May be <c>null</c>.
8886
/// </remarks>
8987
[Obsolete("Use Item instead. RazorViewAttribute has been superseded by RazorCompiledItem and will not be used by the runtime.")]
90-
public RazorViewAttribute ViewAttribute { get; set; }
88+
public RazorViewAttribute? ViewAttribute { get; set; }
9189
#pragma warning restore CS0618 // Type or member is obsolete
9290

9391
/// <summary>
9492
/// <see cref="IChangeToken"/> instances that indicate when this result has expired.
9593
/// </summary>
96-
public IList<IChangeToken> ExpirationTokens { get; set; }
94+
public IList<IChangeToken>? ExpirationTokens { get; set; }
9795

9896
/// <summary>
9997
/// Gets the <see cref="RazorCompiledItem"/> descriptor for this view.
10098
/// </summary>
101-
public RazorCompiledItem Item { get; set; }
99+
public RazorCompiledItem? Item { get; set; }
102100

103101
/// <summary>
104102
/// Gets the type of the compiled item.
105103
/// </summary>
106-
public Type Type => Item?.Type;
104+
public Type? Type => Item?.Type;
107105
}
108106
}

src/Mvc/Mvc.Razor/src/Compilation/DefaultRazorPageFactoryProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public RazorPageFactoryResult CreateFactory(string relativePath)
4747
if (viewType != null)
4848
{
4949
var newExpression = Expression.New(viewType);
50-
var pathProperty = viewType.GetProperty(nameof(IRazorPage.Path));
50+
var pathProperty = viewType.GetProperty(nameof(IRazorPage.Path))!;
5151

5252
// Generate: page.Path = relativePath;
5353
// Use the normalized path specified from the result.

src/Mvc/Mvc.Razor/src/DefaultTagHelperFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ private static void InitializeTagHelper<TTagHelper>(TTagHelper tagHelper, ViewCo
7676
{
7777
// Run any tag helper initializers in the container
7878
var serviceProvider = context.HttpContext.RequestServices;
79-
var initializers = serviceProvider.GetService<IEnumerable<ITagHelperInitializer<TTagHelper>>>();
79+
var initializers = serviceProvider.GetService<IEnumerable<ITagHelperInitializer<TTagHelper>>>()!;
8080

8181
foreach (var initializer in initializers)
8282
{

src/Mvc/Mvc.Razor/src/IRazorPage.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public interface IRazorPage
2121
/// <summary>
2222
/// Gets or sets the body content.
2323
/// </summary>
24-
IHtmlContent BodyContent { get; set; }
24+
IHtmlContent? BodyContent { get; set; }
2525

2626
/// <summary>
2727
/// Gets or sets a flag that determines if the layout of this page is being rendered.
@@ -41,7 +41,7 @@ public interface IRazorPage
4141
/// <summary>
4242
/// Gets or sets the path of a layout page.
4343
/// </summary>
44-
string Layout { get; set; }
44+
string? Layout { get; set; }
4545

4646
/// <summary>
4747
/// Gets or sets the sections that can be rendered by this page.
@@ -67,4 +67,4 @@ public interface IRazorPage
6767
/// defined and the body was not rendered.</exception>
6868
void EnsureRenderedBodyOrSections();
6969
}
70-
}
70+
}

src/Mvc/Mvc.Razor/src/IRazorViewEngine.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ public interface IRazorViewEngine : IViewEngine
4545
/// <paramref name="pagePath"/> is a relative path. The <paramref name="pagePath"/> value (unchanged)
4646
/// otherwise.
4747
/// </returns>
48-
string GetAbsolutePath(string executingFilePath, string pagePath);
48+
string? GetAbsolutePath(string? executingFilePath, string? pagePath);
4949
}
50-
}
50+
}

src/Mvc/Mvc.Razor/src/Microsoft.AspNetCore.Mvc.Razor.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;aspnetcoremvc;cshtml;razor</PackageTags>
99
<IsPackable>false</IsPackable>
10+
<Nullable>enable</Nullable>
1011
</PropertyGroup>
1112

1213
<ItemGroup>

src/Mvc/Mvc.Razor/src/MvcRazorLoggerExtensions.cs

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -11,25 +11,24 @@ internal static class MvcRazorLoggerExtensions
1111
{
1212
private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency;
1313

14-
private static readonly Action<ILogger, string, Exception> _generatedCodeToAssemblyCompilationStart;
15-
private static readonly Action<ILogger, string, double, Exception> _generatedCodeToAssemblyCompilationEnd;
14+
private static readonly Action<ILogger, string, Exception?> _generatedCodeToAssemblyCompilationStart;
15+
private static readonly Action<ILogger, string, double, Exception?> _generatedCodeToAssemblyCompilationEnd;
1616

17-
private static readonly Action<ILogger, string, Exception> _viewCompilerStartCodeGeneration;
18-
private static readonly Action<ILogger, string, double, Exception> _viewCompilerEndCodeGeneration;
19-
private static readonly Action<ILogger, string, Exception> _viewCompilerLocatedCompiledView;
20-
private static readonly Action<ILogger, Exception> _viewCompilerNoCompiledViewsFound;
21-
private static readonly Action<ILogger, string, Exception> _viewCompilerLocatedCompiledViewForPath;
22-
private static readonly Action<ILogger, string, Exception> _viewCompilerRecompilingCompiledView;
23-
private static readonly Action<ILogger, string, Exception> _viewCompilerCouldNotFindFileToCompileForPath;
24-
private static readonly Action<ILogger, string, Exception> _viewCompilerFoundFileToCompileForPath;
25-
private static readonly Action<ILogger, string, Exception> _viewCompilerInvalidatingCompiledFile;
17+
private static readonly Action<ILogger, string, Exception?> _viewCompilerStartCodeGeneration;
18+
private static readonly Action<ILogger, string, double, Exception?> _viewCompilerEndCodeGeneration;
19+
private static readonly Action<ILogger, string, Exception?> _viewCompilerLocatedCompiledView;
20+
private static readonly Action<ILogger, Exception?> _viewCompilerNoCompiledViewsFound;
21+
private static readonly Action<ILogger, string, Exception?> _viewCompilerLocatedCompiledViewForPath;
22+
private static readonly Action<ILogger, string, Exception?> _viewCompilerCouldNotFindFileToCompileForPath;
23+
private static readonly Action<ILogger, string, Exception?> _viewCompilerFoundFileToCompileForPath;
24+
private static readonly Action<ILogger, string, Exception?> _viewCompilerInvalidatingCompiledFile;
2625

27-
private static readonly Action<ILogger, string, string, Exception> _viewLookupCacheMiss;
28-
private static readonly Action<ILogger, string, string, Exception> _viewLookupCacheHit;
29-
private static readonly Action<ILogger, string, Exception> _precompiledViewFound;
26+
private static readonly Action<ILogger, string, string?, Exception?> _viewLookupCacheMiss;
27+
private static readonly Action<ILogger, string, string?, Exception?> _viewLookupCacheHit;
28+
private static readonly Action<ILogger, string, Exception?> _precompiledViewFound;
3029

31-
private static readonly Action<ILogger, string, Exception> _tagHelperComponentInitialized;
32-
private static readonly Action<ILogger, string, Exception> _tagHelperComponentProcessed;
30+
private static readonly Action<ILogger, string, Exception?> _tagHelperComponentInitialized;
31+
private static readonly Action<ILogger, string, Exception?> _tagHelperComponentProcessed;
3332

3433

3534
static MvcRazorLoggerExtensions()
@@ -59,11 +58,6 @@ static MvcRazorLoggerExtensions()
5958
new EventId(5, "ViewCompilerLocatedCompiledViewForPath"),
6059
"Located compiled view for view at path '{Path}'.");
6160

62-
_viewCompilerRecompilingCompiledView = LoggerMessage.Define<string>(
63-
LogLevel.Trace,
64-
new EventId(6, "ViewCompilerRecompilingCompiledView"),
65-
"Invalidating compiled view for view at path '{Path}'.");
66-
6761
_viewCompilerCouldNotFindFileToCompileForPath = LoggerMessage.Define<string>(
6862
LogLevel.Trace,
6963
new EventId(7, "ViewCompilerCouldNotFindFileAtPath"),
@@ -79,12 +73,12 @@ static MvcRazorLoggerExtensions()
7973
new EventId(9, "ViewCompilerInvalidingCompiledFile"),
8074
"Invalidating compiled view at path '{Path}' with a file since the checksum did not match.");
8175

82-
_viewLookupCacheMiss = LoggerMessage.Define<string, string>(
76+
_viewLookupCacheMiss = LoggerMessage.Define<string, string?>(
8377
LogLevel.Debug,
8478
new EventId(1, "ViewLookupCacheMiss"),
8579
"View lookup cache miss for view '{ViewName}' in controller '{ControllerName}'.");
8680

87-
_viewLookupCacheHit = LoggerMessage.Define<string, string>(
81+
_viewLookupCacheHit = LoggerMessage.Define<string, string?>(
8882
LogLevel.Debug,
8983
new EventId(2, "ViewLookupCacheHit"),
9084
"View lookup cache hit for view '{ViewName}' in controller '{ControllerName}'.");
@@ -161,12 +155,12 @@ public static void ViewCompilerInvalidingCompiledFile(this ILogger logger, strin
161155
_viewCompilerInvalidatingCompiledFile(logger, path, null);
162156
}
163157

164-
public static void ViewLookupCacheMiss(this ILogger logger, string viewName, string controllerName)
158+
public static void ViewLookupCacheMiss(this ILogger logger, string viewName, string? controllerName)
165159
{
166160
_viewLookupCacheMiss(logger, viewName, controllerName, null);
167161
}
168162

169-
public static void ViewLookupCacheHit(this ILogger logger, string viewName, string controllerName)
163+
public static void ViewLookupCacheHit(this ILogger logger, string viewName, string? controllerName)
170164
{
171165
_viewLookupCacheHit(logger, viewName, controllerName, null);
172166
}

0 commit comments

Comments
 (0)