Skip to content

Commit 50f3a16

Browse files
author
John Luo
committed
aspnetcore-tooling migration fixups
1 parent c565c2a commit 50f3a16

File tree

75 files changed

+425
-388
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+425
-388
lines changed

.azure/pipelines/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ stages:
151151
$(_InternalRuntimeDownloadArgs)
152152
displayName: Build x86
153153

154-
# This is in a separate build step with -forceCoreMsbuild to workaround MAX_PATH limitations - https://github.com/Microsoft/msbuild/issues/53
154+
# This is in a separate build step with to workaround MAX_PATH limitations - https://github.com/Microsoft/msbuild/issues/53
155155
- script: .\src\SiteExtensions\build.cmd
156156
-ci
157157
-nobl

Directory.Build.props

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757
<IncludeSymbols>true</IncludeSymbols>
5858

59+
<!-- Also update the DefaultNetCoreTargetFramework defined at src/Razor/test/testassets/Directory.Build.props -->
5960
<DefaultNetCoreTargetFramework>net5.0</DefaultNetCoreTargetFramework>
6061
</PropertyGroup>
6162

@@ -70,6 +71,9 @@
7071
<NoWarn>$(NoWarn);NU5131</NoWarn>
7172
<!-- Needed until we resolve https://github.com/dotnet/aspnetcore-internal/issues/3103 -->
7273
<NoWarn>$(NoWarn);NU5048</NoWarn>
74+
75+
<!-- TODO: Figure out why these warnings are occuring -->
76+
<NoWarn Condition="'$(IsAnalyzersProject)' == 'true'">$(NoWarn);RS1024;RS1025;RS1026</NoWarn>
7377
</PropertyGroup>
7478

7579
<!-- Source code settings -->

eng/Build.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@
166166
Exclude="
167167
@(ProjectToBuild);
168168
@(ProjectToExclude);
169+
$(RepoRoot)src\Razor\test\testassets\**\*.*proj;
169170
$(RepoRoot)**\node_modules\**\*;
170171
$(RepoRoot)**\bin\**\*;
171172
$(RepoRoot)**\obj\**\*;"
@@ -202,6 +203,7 @@
202203
Exclude="
203204
@(ProjectToBuild);
204205
@(ProjectToExclude);
206+
$(RepoRoot)src\Razor\test\testassets\**\*.*proj;
205207
$(RepoRoot)**\node_modules\**\*;
206208
$(RepoRoot)**\bin\**\*;
207209
$(RepoRoot)**\obj\**\*;"

eng/Dependencies.props

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,10 @@ and are generated based on the last package release.
2020
</ItemDefinitionGroup>
2121

2222
<ItemGroup Label=".NET team dependencies">
23-
<LatestPackageReference Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="$(MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion)" />
24-
<LatestPackageReference Include="Microsoft.AspNetCore.Razor.Language" Version="$(MicrosoftAspNetCoreRazorLanguagePackageVersion)" />
2523
<LatestPackageReference Include="Microsoft.Azure.SignalR" Version="$(MicrosoftAzureSignalRPackageVersion)" />
2624
<LatestPackageReference Include="Microsoft.CodeAnalysis.Common" Version="$(MicrosoftCodeAnalysisCommonPackageVersion)" />
2725
<LatestPackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="$(MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion)" />
2826
<LatestPackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="$(MicrosoftCodeAnalysisCSharpPackageVersion)" />
29-
<LatestPackageReference Include="Microsoft.CodeAnalysis.Razor" Version="$(MicrosoftCodeAnalysisRazorPackageVersion)" />
3027
<LatestPackageReference Include="Microsoft.CSharp" Version="$(MicrosoftCSharpPackageVersion)" />
3128
<LatestPackageReference Include="Microsoft.DotNet.GenAPI" Version="$(MicrosoftDotNetGenApiPackageVersion)" />
3229
<LatestPackageReference Include="Microsoft.Extensions.Caching.Abstractions" Version="$(MicrosoftExtensionsCachingAbstractionsPackageVersion)" />
@@ -71,6 +68,7 @@ and are generated based on the last package release.
7168
<LatestPackageReference Include="System.CommandLine.Experimental" Version="$(SystemCommandlineExperimentalPackageVersion)" />
7269
<LatestPackageReference Include="System.ComponentModel" Version="$(SystemComponentModelPackageVersion)" />
7370
<LatestPackageReference Include="System.ComponentModel.Annotations" Version="$(SystemComponentModelAnnotationsPackageVersion)" />
71+
<LatestPackageReference Include="System.Diagnostics.DiagnosticSource" Version="$(SystemDiagnosticsDiagnosticSourcePackageVersion)" />
7472
<LatestPackageReference Include="System.Diagnostics.EventLog" Version="$(SystemDiagnosticsEventLogPackageVersion)" />
7573
<LatestPackageReference Include="System.Drawing.Common" Version="$(SystemDrawingCommonPackageVersion)" />
7674
<LatestPackageReference Include="System.IO.Pipelines" Version="$(SystemIOPipelinesPackageVersion)" />

eng/ProjectReferences.props

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
<ProjectReferenceProvider Include="Microsoft.AspNetCore.NodeServices" ProjectPath="$(RepoRoot)src\Middleware\NodeServices\src\Microsoft.AspNetCore.NodeServices.csproj" />
4242
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SpaServices.Extensions" ProjectPath="$(RepoRoot)src\Middleware\SpaServices.Extensions\src\Microsoft.AspNetCore.SpaServices.Extensions.csproj" />
4343
<ProjectReferenceProvider Include="Microsoft.AspNetCore.SpaServices" ProjectPath="$(RepoRoot)src\Middleware\SpaServices\src\Microsoft.AspNetCore.SpaServices.csproj" />
44+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X" ProjectPath="$(RepoRoot)src\Razor\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version1_X.csproj" />
45+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X" ProjectPath="$(RepoRoot)src\Razor\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.Version2_X.csproj" />
46+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Mvc.Razor.Extensions" ProjectPath="$(RepoRoot)src\Razor\Microsoft.AspNetCore.Mvc.Razor.Extensions\src\Microsoft.AspNetCore.Mvc.Razor.Extensions.csproj" />
47+
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Razor.Language" ProjectPath="$(RepoRoot)src\Razor\Microsoft.AspNetCore.Razor.Language\src\Microsoft.AspNetCore.Razor.Language.csproj" />
48+
<ProjectReferenceProvider Include="rzc" ProjectPath="$(RepoRoot)src\Razor\Microsoft.AspNetCore.Razor.Tools\src\Microsoft.AspNetCore.Razor.Tools.csproj" />
49+
<ProjectReferenceProvider Include="Microsoft.CodeAnalysis.Razor" ProjectPath="$(RepoRoot)src\Razor\Microsoft.CodeAnalysis.Razor\src\Microsoft.CodeAnalysis.Razor.csproj" />
50+
<ProjectReferenceProvider Include="Microsoft.NET.Sdk.Razor" ProjectPath="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\Microsoft.NET.Sdk.Razor.csproj" />
4451
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" ProjectPath="$(RepoRoot)src\Mvc\Mvc.NewtonsoftJson\src\Microsoft.AspNetCore.Mvc.NewtonsoftJson.csproj" />
4552
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" ProjectPath="$(RepoRoot)src\Mvc\Mvc.Razor.RuntimeCompilation\src\Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.csproj" />
4653
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Mvc.Testing" ProjectPath="$(RepoRoot)src\Mvc\Mvc.Testing\src\Microsoft.AspNetCore.Mvc.Testing.csproj" />

eng/Version.Details.xml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,6 @@
1313
<Uri>https://github.com/dotnet/blazor</Uri>
1414
<Sha>dd7fb4d3931d556458f62642c2edfc59f6295bfb</Sha>
1515
</Dependency>
16-
<Dependency Name="Microsoft.AspNetCore.Razor.Language" Version="5.0.0-preview.6.20265.5">
17-
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
18-
<Sha>e759982cb63d5205b87ad0d968b09033ab778d12</Sha>
19-
</Dependency>
20-
<Dependency Name="Microsoft.AspNetCore.Mvc.Razor.Extensions" Version="5.0.0-preview.6.20265.5">
21-
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
22-
<Sha>e759982cb63d5205b87ad0d968b09033ab778d12</Sha>
23-
</Dependency>
24-
<Dependency Name="Microsoft.CodeAnalysis.Razor" Version="5.0.0-preview.6.20265.5">
25-
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
26-
<Sha>e759982cb63d5205b87ad0d968b09033ab778d12</Sha>
27-
</Dependency>
28-
<Dependency Name="Microsoft.NET.Sdk.Razor" Version="5.0.0-preview.6.20265.5">
29-
<Uri>https://github.com/dotnet/aspnetcore-tooling</Uri>
30-
<Sha>e759982cb63d5205b87ad0d968b09033ab778d12</Sha>
31-
</Dependency>
3216
<Dependency Name="dotnet-ef" Version="5.0.0-preview.6.20264.4">
3317
<Uri>https://github.com/dotnet/efcore</Uri>
3418
<Sha>7f81b608c2ceb19f6072b8b3cec6ad45fcc2d6a9</Sha>
@@ -205,6 +189,10 @@
205189
<Uri>https://github.com/dotnet/runtime</Uri>
206190
<Sha>bdd7235c43d762cea051cfc2071e14de48175f0c</Sha>
207191
</Dependency>
192+
<Dependency Name="System.Diagnostics.DiagnosticSource" Version="5.0.0-preview.6.20264.1" CoherentParentDependency="Microsoft.AspNetCore.Razor.Language">
193+
<Uri>https://github.com/dotnet/runtime</Uri>
194+
<Sha>bdd7235c43d762cea051cfc2071e14de48175f0c</Sha>
195+
</Dependency>
208196
<Dependency Name="System.Diagnostics.EventLog" Version="5.0.0-preview.6.20264.1" CoherentParentDependency="Microsoft.AspNetCore.Razor.Language">
209197
<Uri>https://github.com/dotnet/runtime</Uri>
210198
<Sha>bdd7235c43d762cea051cfc2071e14de48175f0c</Sha>

eng/Versions.props

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
<MicrosoftExtensionsPrimitivesPackageVersion>5.0.0-preview.6.20264.1</MicrosoftExtensionsPrimitivesPackageVersion>
108108
<MicrosoftExtensionsInternalTransportPackageVersion>5.0.0-preview.6.20264.1</MicrosoftExtensionsInternalTransportPackageVersion>
109109
<SystemComponentModelAnnotationsPackageVersion>5.0.0-preview.6.20264.1</SystemComponentModelAnnotationsPackageVersion>
110+
<SystemDiagnosticsDiagnosticSourcePackageVersion>5.0.0-preview.6.20264.1</SystemDiagnosticsDiagnosticSourcePackageVersion>
110111
<SystemDiagnosticsEventLogPackageVersion>5.0.0-preview.6.20264.1</SystemDiagnosticsEventLogPackageVersion>
111112
<SystemDrawingCommonPackageVersion>5.0.0-preview.6.20264.1</SystemDrawingCommonPackageVersion>
112113
<SystemIOPipelinesPackageVersion>5.0.0-preview.6.20264.1</SystemIOPipelinesPackageVersion>
@@ -136,11 +137,6 @@
136137
<MicrosoftEntityFrameworkCoreSqlServerPackageVersion>5.0.0-preview.6.20264.4</MicrosoftEntityFrameworkCoreSqlServerPackageVersion>
137138
<MicrosoftEntityFrameworkCoreToolsPackageVersion>5.0.0-preview.6.20264.4</MicrosoftEntityFrameworkCoreToolsPackageVersion>
138139
<MicrosoftEntityFrameworkCorePackageVersion>5.0.0-preview.6.20264.4</MicrosoftEntityFrameworkCorePackageVersion>
139-
<!-- Packages from dotnet/aspnetcore-tooling -->
140-
<MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>5.0.0-preview.6.20265.5</MicrosoftAspNetCoreMvcRazorExtensionsPackageVersion>
141-
<MicrosoftAspNetCoreRazorLanguagePackageVersion>5.0.0-preview.6.20265.5</MicrosoftAspNetCoreRazorLanguagePackageVersion>
142-
<MicrosoftCodeAnalysisRazorPackageVersion>5.0.0-preview.6.20265.5</MicrosoftCodeAnalysisRazorPackageVersion>
143-
<MicrosoftNETSdkRazorPackageVersion>5.0.0-preview.6.20265.5</MicrosoftNETSdkRazorPackageVersion>
144140
</PropertyGroup>
145141
<!--
146142
@@ -187,9 +183,9 @@
187183
<MicrosoftBuildFrameworkPackageVersion>15.8.166</MicrosoftBuildFrameworkPackageVersion>
188184
<MicrosoftBuildLocatorPackageVersion>1.2.6</MicrosoftBuildLocatorPackageVersion>
189185
<MicrosoftBuildUtilitiesCorePackageVersion>15.8.166</MicrosoftBuildUtilitiesCorePackageVersion>
190-
<MicrosoftCodeAnalysisCommonPackageVersion>3.0.0</MicrosoftCodeAnalysisCommonPackageVersion>
191-
<MicrosoftCodeAnalysisCSharpPackageVersion>3.0.0</MicrosoftCodeAnalysisCSharpPackageVersion>
192-
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>3.0.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
186+
<MicrosoftCodeAnalysisCommonPackageVersion>3.4.0</MicrosoftCodeAnalysisCommonPackageVersion>
187+
<MicrosoftCodeAnalysisCSharpPackageVersion>3.4.0</MicrosoftCodeAnalysisCSharpPackageVersion>
188+
<MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>3.4.0</MicrosoftCodeAnalysisCSharpWorkspacesPackageVersion>
193189
<MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>3.19.8</MicrosoftIdentityModelClientsActiveDirectoryPackageVersion>
194190
<MicrosoftIdentityModelLoggingPackageVersion>5.5.0</MicrosoftIdentityModelLoggingPackageVersion>
195191
<MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>5.5.0</MicrosoftIdentityModelProtocolsOpenIdConnectPackageVersion>
@@ -226,6 +222,9 @@
226222
<MonoCecilPackageVersion>0.10.1</MonoCecilPackageVersion>
227223
<NewtonsoftJsonBsonPackageVersion>1.0.2</NewtonsoftJsonBsonPackageVersion>
228224
<NewtonsoftJsonPackageVersion>12.0.2</NewtonsoftJsonPackageVersion>
225+
<!-- Begin: STOP!!! Razor need to reference the version of JSON that our HOSTS support. -->
226+
<Razor_NewtonsoftJsonPackageVersion>9.0.1</Razor_NewtonsoftJsonPackageVersion>
227+
<!-- End: STOP!!! Razor need to reference the version of JSON that our HOSTS support. -->
229228
<NSwagApiDescriptionClientPackageVersion>13.0.4</NSwagApiDescriptionClientPackageVersion>
230229
<SeleniumSupportPackageVersion>3.12.1</SeleniumSupportPackageVersion>
231230
<SeleniumWebDriverMicrosoftDriverPackageVersion>17.17134.0</SeleniumWebDriverMicrosoftDriverPackageVersion>

eng/targets/CSharp.Common.props

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,29 @@
1414
<PackageReference Condition="'$(DotNetBuildFromSource)' != 'true'" Include="Microsoft.DotNet.GenAPI" PrivateAssets="All" Version="$(MicrosoftDotNetGenApiPackageVersion)" IsImplicitlyDefined="true" />
1515
</ItemGroup>
1616

17-
<ItemGroup Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
18-
<!--
19-
Use the Razor SDK as a package reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
20-
several versions older than latest. To avoid a cyclical dependency, this package reference is added to override the bundled version.
21-
-->
22-
<PackageReference Include="Microsoft.NET.Sdk.Razor" PrivateAssets="All" Version="$(MicrosoftNETSdkRazorPackageVersion)" IsImplicitlyDefined="true" />
23-
</ItemGroup>
17+
<Choose>
18+
<When Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''">
19+
<ItemGroup>
20+
<!--
21+
Use the Razor SDK as a project reference. The version of the .NET Core SDK we build with often contains a version of the Razor SDK
22+
several versions older than latest. We reference the project to ensure it's built before the other projects that use it. Since this
23+
is a project reference, we must explicitly import the props file and also specify the output location of the SDK directory.
24+
-->
25+
<ProjectReference Include="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\Microsoft.NET.Sdk.Razor.csproj" PrivateAssets="All" IsImplicitlyDefined="true" ReferenceOutputAssembly="false" >
26+
<!-- Use the same logic as Sdk.Razor.CurrentVersion.Targets -->
27+
<SetTargetFramework Condition=" '$(MSBuildRuntimeType)' == 'Core'">TargetFramework=$(DefaultNetCoreTargetFramework)</SetTargetFramework>
28+
<SetTargetFramework Condition=" '$(MSBuildRuntimeType)' != 'Core'">TargetFramework=net46</SetTargetFramework>
29+
</ProjectReference>
30+
</ItemGroup>
31+
32+
<PropertyGroup>
33+
<RazorSdkDirectoryRoot>$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</RazorSdkDirectoryRoot>
34+
</PropertyGroup>
35+
</When>
36+
</Choose>
37+
38+
<Import Project="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props" Condition="'$(UsingMicrosoftNETSdkWeb)' == 'true' OR '$(RazorSdkCurrentVersionProps)' != ''" />
39+
2440

2541
<ItemGroup Condition=" '$(IsTestProject)' == 'true' ">
2642
<Reference Include="Microsoft.AspNetCore.Testing" />

eng/targets/ResolveReferences.targets

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@
8686
@(AspNetCoreAppReferenceAndPackage);
8787
@(ExternalAspNetCoreAppReference);
8888
@(_CompilationOnlyReference);
89-
@(Reference->WithMetadataValue('IsSharedSource', 'true'))" />
89+
@(Reference->WithMetadataValue('IsSharedSource', 'true'));
90+
@(Reference->WithMetadataValue('PrivateAssets', 'All'))" />
9091
<_OriginalReferences Include="@(Reference)" />
9192
<!--
9293
Turn Reference items into a ProjectReference when UseProjectReferences is true.

global.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"dotnet": "5.0.100-preview.5.20258.4",
77
"runtimes": {
88
"dotnet/x64": [
9+
"2.1.11",
910
"$(MicrosoftNETCoreAppInternalPackageVersion)"
1011
],
1112
"dotnet/x86": [

src/Components/Blazor/Build/test/BuildIntegrationTests/ProjectDirectory.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ static void CopyDirectory(DirectoryInfo source, DirectoryInfo destination, bool
100100

101101
static void SetupDirectoryBuildFiles(string repoRoot, string testAppsRoot, string projectDestination)
102102
{
103+
var razorSdkDirectoryRoot = Assembly.GetExecutingAssembly().GetCustomAttributes<AssemblyMetadataAttribute>().SingleOrDefault(a => a.Key == "RazorSdkDirectoryRoot").Value;
103104
var beforeDirectoryPropsContent =
104105
$@"<Project>
105106
<PropertyGroup>
106107
<RepoRoot>{repoRoot}</RepoRoot>
108+
<RazorSdkDirectoryRoot>{razorSdkDirectoryRoot}</RazorSdkDirectoryRoot>
107109
</PropertyGroup>
108110
</Project>";
109111
File.WriteAllText(Path.Combine(projectDestination, "Before.Directory.Build.props"), beforeDirectoryPropsContent);

src/Components/Blazor/Build/test/Microsoft.AspNetCore.Blazor.Build.Tests.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@
4747
<_Parameter1>Testing.RepoRoot</_Parameter1>
4848
<_Parameter2>$(RepoRoot)</_Parameter2>
4949
</AssemblyAttribute>
50+
51+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
52+
<_Parameter1>RazorSdkDirectoryRoot</_Parameter1>
53+
<_Parameter2>$(ArtifactsBinDir)Microsoft.NET.Sdk.Razor\$(Configuration)\sdk-output\</_Parameter2>
54+
</AssemblyAttribute>
5055
</ItemGroup>
5156

5257
<Target Name="RestoreTestAssets" AfterTargets="Restore;Build" Condition="'$(DotNetBuildFromSource)' != 'true'">

src/Components/Blazor/Build/testassets/Directory.Build.props

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,7 @@
2222
Version="$(MicrosoftNetCompilersToolsetPackageVersion)"
2323
PrivateAssets="all"
2424
IsImplicitlyDefined="true" />
25-
26-
<PackageReference Include="Microsoft.NET.Sdk.Razor"
27-
Version="$(MicrosoftNETSdkRazorPackageVersion)"
28-
PrivateAssets="All"
29-
IsImplicitlyDefined="true" />
3025
</ItemGroup>
26+
27+
<Import Project="$(RepoRoot)src\Razor\Microsoft.NET.Sdk.Razor\src\build\netstandard2.0\Microsoft.NET.Sdk.Razor.props"/>
3128
</Project>

src/Mvc/Mvc.Analyzers/src/CodeAnalysisExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ public static bool HasAttribute(this ISymbol symbol, ITypeSymbol attribute)
139139
return false;
140140
}
141141

142-
private static IEnumerable<ITypeSymbol> GetTypeHierarchy(this ITypeSymbol typeSymbol)
142+
private static IEnumerable<ITypeSymbol> GetTypeHierarchy(this ITypeSymbol? typeSymbol)
143143
{
144144
while (typeSymbol != null)
145145
{

src/Mvc/Mvc.Analyzers/src/MvcFacts.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ private static INamedTypeSymbol GetDeclaringType(IMethodSymbol method)
103103
{
104104
while (method.IsOverride)
105105
{
106+
if (method.OverriddenMethod == null)
107+
{
108+
throw new ArgumentNullException(nameof(method.OverriddenMethod));
109+
}
110+
106111
method = method.OverriddenMethod;
107112
}
108113

src/Mvc/Mvc.Api.Analyzers/src/ActualApiResponseMetadataFactory.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,10 @@ internal static bool TryGetActualResponseMetadata(
101101

102102
case ObjectCreationExpressionSyntax creation:
103103
{
104+
if (creation.ArgumentList == null)
105+
{
106+
throw new ArgumentNullException(nameof(creation.ArgumentList));
107+
}
104108
// Read values from 'return new StatusCodeResult(200) case.
105109
var result = InspectMethodArguments(semanticModel, creation, creation.ArgumentList, cancellationToken);
106110
statusCode = result.statusCode ?? statusCode;
@@ -126,7 +130,7 @@ internal static bool TryGetActualResponseMetadata(
126130
private static (int? statusCode, ITypeSymbol? returnType) InspectInitializers(
127131
in ApiControllerSymbolCache symbolCache,
128132
SemanticModel semanticModel,
129-
InitializerExpressionSyntax initializer,
133+
InitializerExpressionSyntax? initializer,
130134
CancellationToken cancellationToken)
131135
{
132136
int? statusCode = null;
@@ -201,7 +205,13 @@ private static (int? statusCode, ITypeSymbol? returnType) InspectMethodArguments
201205
private static ITypeSymbol GetExpressionObjectType(SemanticModel semanticModel, ExpressionSyntax expression, CancellationToken cancellationToken)
202206
{
203207
var typeInfo = semanticModel.GetTypeInfo(expression, cancellationToken);
204-
return typeInfo.Type;
208+
209+
if (typeInfo.Type == null)
210+
{
211+
throw new ArgumentNullException(nameof(typeInfo.Type));
212+
}
213+
214+
return typeInfo.Type!;
205215
}
206216

207217
private static bool TryGetExpressionStatusCode(

0 commit comments

Comments
 (0)