Skip to content

Commit f001524

Browse files
committed
Depend on roslyn test utilities, use their diagnostic verification.
1 parent 288adb8 commit f001524

File tree

10 files changed

+214
-186
lines changed

10 files changed

+214
-186
lines changed

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@
8787
<Uri>https://github.com/dotnet/roslyn</Uri>
8888
<Sha>419ee237406466eebd6bdfbf932a31e26971ec4c</Sha>
8989
</Dependency>
90-
<Dependency Name="Microsoft.VisualStudio.LanguageServices" Version="4.7.0-3.23314.5">
90+
<Dependency Name="Microsoft.CodeAnalysis.Test.Utilities" Version="4.7.0-3.23326.2">
9191
<Uri>https://github.com/dotnet/roslyn</Uri>
92-
<Sha>f6725f6f04ce03574fcf89faa4b20b72ef83e4dd</Sha>
92+
<Sha>419ee237406466eebd6bdfbf932a31e26971ec4c</Sha>
9393
</Dependency>
9494
</ProductDependencies>
9595
<ToolsetDependencies>

eng/Versions.props

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@
6767
<MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisEditorFeaturesTextPackageVersion>
6868
<MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisEditorFeaturesWpfPackageVersion>
6969
<MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisRemoteServiceHubPackageVersion>
70+
<MicrosoftCodeAnalysisTestUtilitiesPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisTestUtilitiesPackageVersion>
7071
<MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisVisualBasicWorkspacesPackageVersion>
7172
<MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisWorkspacesCommonPackageVersion>
7273
<MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>4.7.0-3.23326.2</MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace Microsoft.CodeAnalysis;
5+
6+
/// <summary>
7+
/// Keep names and codes in sync with Roslyn's ErrorCode.cs. Add as necessary.
8+
/// </summary>
9+
public enum ErrorCode
10+
{
11+
ERR_SingleTypeNameNotFound = 246,
12+
WRN_AsyncLacksAwaits = 1998,
13+
WRN_UninitializedNonNullableField = 8618,
14+
}

src/Compiler/test/Microsoft.AspNetCore.Razor.Test.Common/Language/IntegrationTests/IntegrationTestBase.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,12 @@ protected IntegrationTestBase(bool? generateBaselines = null, string? projectDir
112112
// Used by the test framework to set the 'base' name for test files.
113113
public static string FileName
114114
{
115-
get { return _fileName.Value; }
115+
get
116+
{
117+
var value = _fileName.Value;
118+
Assert.NotNull(value);
119+
return value;
120+
}
116121
set { _fileName.Value = value; }
117122
}
118123

@@ -140,6 +145,7 @@ private RazorProjectItem CreateProjectItemFromText(string text, string filePath,
140145
{
141146
// Consider the file path to be relative to the 'FileName' of the test.
142147
var workingDirectory = Path.GetDirectoryName(FileName);
148+
Assert.NotNull(workingDirectory);
143149

144150
// Since these paths are used in baselines, we normalize them to windows style. We
145151
// use "" as the base path by convention to avoid baking in an actual file system

src/Compiler/test/Microsoft.AspNetCore.Razor.Test.Common/Microsoft.AspNetCore.Razor.Test.Common.Compiler.csproj

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44
<!-- To generate baselines, run tests with /p:GenerateBaselines=true -->
55
<DefineConstants Condition="'$(GenerateBaselines)'=='true'">$(DefineConstants);GENERATE_BASELINES</DefineConstants>
66
<DefineConstants>$(DefineConstants);__RemoveThisBitTo__GENERATE_BASELINES</DefineConstants>
7-
<TargetFrameworks>$(DefaultNetFxTargetFramework);netstandard2.0</TargetFrameworks>
7+
<TargetFrameworks>$(DefaultNetCoreTargetFrameworks)</TargetFrameworks>
8+
<TargetFrameworks Condition="'$(OS)' == 'Windows_NT'">$(TargetFrameworks);$(DefaultNetFxTargetFramework)</TargetFrameworks>
89
</PropertyGroup>
910

10-
<ItemGroup>
11-
<Compile Include="..\..\..\Razor\test\Microsoft.AspNetCore.Razor.Test.Common\WorkItemAttribute.cs" />
12-
</ItemGroup>
13-
1411
<ItemGroup>
1512
<ProjectReference Include="..\Microsoft.AspNetCore.Razor.Test.ComponentShim\Microsoft.AspNetCore.Razor.Test.ComponentShim.Compiler.csproj" />
1613

@@ -24,6 +21,7 @@
2421
<PackageReference Include="xunit.assert" PrivateAssets="all" />
2522
<PackageVersion Include="xunit.assert" Version="$(XunitAssertVersion)" />
2623
<PackageReference Include="xunit.extensibility.execution" />
24+
<PackageReference Include="Microsoft.CodeAnalysis.Test.Utilities" />
2725
</ItemGroup>
2826

2927
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
global using static Roslyn.Test.Utilities.TestHelpers;

src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorComponentTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Razor.Test.Common;
5+
using Roslyn.Test.Utilities;
66
using Xunit;
77

88
namespace Microsoft.NET.Sdk.Razor.SourceGenerators;
@@ -23,7 +23,7 @@ public async Task PartialClass()
2323
""",
2424
["Shared/Component2.razor"] = """
2525
@inherits ComponentBase
26-
26+
2727
Value: @(Param + 1)
2828
2929
@code {

src/Compiler/test/Microsoft.NET.Sdk.Razor.SourceGenerators.Tests/RazorSourceGeneratorTagHelperTests.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
using System.Linq;
77
using System.Threading.Tasks;
8-
using Microsoft.AspNetCore.Razor.Test.Common;
98
using Microsoft.CodeAnalysis.CSharp;
9+
using Roslyn.Test.Utilities;
1010
using Xunit;
1111

1212
namespace Microsoft.NET.Sdk.Razor.SourceGenerators;
@@ -275,21 +275,21 @@ public async Task Form_Employee()
275275
["Views/Home/Index.cshtml"] = """
276276
@model TestProject.Models.Employee
277277
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
278-
278+
279279
@{
280280
Html.Html5DateRenderingMode = Html5DateRenderingMode.Rfc3339;
281281
}
282-
282+
283283
<!DOCTYPE html>
284284
<html>
285285
<head>
286286
<meta name="viewport" content="width=device-width" />
287287
<title>Create</title>
288288
</head>
289289
<body>
290-
290+
291291
<form asp-antiforgery="false">
292-
292+
293293
<div class="form-horizontal">
294294
<h4>Employee</h4>
295295
<hr />
@@ -339,7 +339,7 @@ @model TestProject.Models.Employee
339339
<span asp-validation-for="Salary"></span>
340340
</div>
341341
</div>
342-
342+
343343
<div class="form-group">
344344
<div class="col-md-offset-2 col-md-10">
345345
<input type="submit" value="Create" class="btn btn-default" />
@@ -1087,7 +1087,7 @@ public async Task ViewImports(string name)
10871087
<nested>some-content</nested>
10881088
""",
10891089
["Views/RemoveInheritedTagHelpers/_ViewStart.cshtml"] = """
1090-
@{
1090+
@{
10911091
Layout = "~/Views/Shared/_LayoutWithRootTagHelper.cshtml";
10921092
}
10931093
""",
@@ -1100,7 +1100,7 @@ public async Task ViewImports(string name)
11001100
<nested>some-content</nested>
11011101
""",
11021102
["Views/InheritedTagHelperPrefix/_ViewStart.cshtml"] = """
1103-
@{
1103+
@{
11041104
Layout = "~/Views/Shared/_LayoutWithRootTagHelper.cshtml";
11051105
}
11061106
""",

0 commit comments

Comments
 (0)