Skip to content

Commit

Permalink
Build and run tests on .NET 7
Browse files Browse the repository at this point in the history
  • Loading branch information
jcouv committed Oct 5, 2022
1 parent 86432cd commit 9d3d153
Show file tree
Hide file tree
Showing 69 changed files with 127 additions and 126 deletions.
12 changes: 6 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/net6.0/BuildValidator.dll",
"program": "${workspaceFolder}/artifacts/bin/BuildValidator/Debug/net7.0/BuildValidator.dll",
"args": [
"--assembliesPath", "./artifacts/obj/csc/Debug/net6.0",
"--assembliesPath", "./artifacts/obj/csc/Debug/net7.0",
"--referencesPath", "./artifacts/bin",
"--referencesPath", "C:/Program Files/dotnet/packs/Microsoft.AspNetCore.App.Ref",
"--referencesPath", "C:/Program Files/dotnet/packs/Microsoft.NETCore.App.Ref",
Expand All @@ -29,8 +29,8 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/RunTests/Debug/net6.0/RunTests.dll",
"args": ["--tfm", "net6.0", "--sequential", "--html"],
"program": "${workspaceFolder}/artifacts/bin/RunTests/Debug/net7.0/RunTests.dll",
"args": ["--tfm", "net7.0", "--sequential", "--html"],
"cwd": "${workspaceFolder}/artifacts/bin/RunTests",
"stopAtEntry": false,
"console": "internalConsole"
Expand All @@ -41,7 +41,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/PrepareTests/Debug/net6.0/PrepareTests.dll",
"program": "${workspaceFolder}/artifacts/bin/PrepareTests/Debug/net7.0/PrepareTests.dll",
"args": [
"--source", "${workspaceFolder}",
"--destination", "${workspaceFolder}/artifacts/testPayload"
Expand All @@ -56,7 +56,7 @@
"request": "launch",
"preLaunchTask": "build",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/artifacts/bin/csc/Debug/net6.0/csc.dll",
"program": "${workspaceFolder}/artifacts/bin/csc/Debug/net7.0/csc.dll",
"args": [],
"cwd": "${workspaceFolder}/src/Compilers/CSharp/csc",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
Expand Down
2 changes: 1 addition & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@
<SystemCommandLineExperimentalVersion>0.3.0-alpha.19577.1</SystemCommandLineExperimentalVersion>
<SystemComponentModelCompositionVersion>6.0.0</SystemComponentModelCompositionVersion>
<SystemConfigurationConfigurationManagerVersion>6.0.0</SystemConfigurationConfigurationManagerVersion>
<SystemDrawingCommonVersion>6.0.0</SystemDrawingCommonVersion>
<SystemDrawingCommonVersion>7.0.0-rtm.22504.4</SystemDrawingCommonVersion>
<SystemIOFileSystemVersion>4.3.0</SystemIOFileSystemVersion>
<SystemIOFileSystemPrimitivesVersion>4.3.0</SystemIOFileSystemPrimitivesVersion>
<SystemIOPipesAccessControlVersion>5.0.0</SystemIOPipesAccessControlVersion>
Expand Down
6 changes: 3 additions & 3 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ function TestUsingRunTests() {
$env:ROSLYN_TEST_USEDASSEMBLIES = "true"
}

$runTests = GetProjectOutputBinary "RunTests.dll" -tfm "net6.0"
$runTests = GetProjectOutputBinary "RunTests.dll" -tfm "net7.0"

if (!(Test-Path $runTests)) {
Write-Host "Test runner not found: '$runTests'. Run Build.cmd first." -ForegroundColor Red
Expand All @@ -382,12 +382,12 @@ function TestUsingRunTests() {
$args += " --configuration $configuration"

if ($testCoreClr) {
$args += " --tfm net6.0"
$args += " --tfm net7.0"
$args += " --timeout 90"
if ($testCompilerOnly) {
$args += GetCompilerTestAssembliesIncludePaths
} else {
$args += " --tfm net6.0-windows"
$args += " --tfm net7.0-windows"
$args += " --include '\.UnitTests'"
}
}
Expand Down
2 changes: 1 addition & 1 deletion eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,6 @@ if [[ "$test_core_clr" == true ]]; then
if [[ "$ci" != true ]]; then
runtests_args="$runtests_args --html"
fi
dotnet exec "$scriptroot/../artifacts/bin/RunTests/${configuration}/net6.0/RunTests.dll" --tfm net6.0 --configuration ${configuration} --logs ${log_dir} --dotnet ${_InitializeDotNetCli}/dotnet $runtests_args
dotnet exec "$scriptroot/../artifacts/bin/RunTests/${configuration}/net7.0/RunTests.dll" --tfm net7.0 --configuration ${configuration} --logs ${log_dir} --dotnet ${_InitializeDotNetCli}/dotnet $runtests_args
fi
ExitWithExitCode 0
6 changes: 3 additions & 3 deletions eng/generate-compiler-code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function Run-LanguageCore($language, $languageSuffix, $languageDir, $syntaxProje
$errorFileName = if ($language -eq "CSharp") { "ErrorCode.cs" } else { "Errors.vb" }
$errorFilePath = Join-Path $languageDir "Errors\$errorFileName"
$errorGeneratedFilePath = Join-Path $generatedDir "ErrorFacts.Generated.$($languageSuffix)"
$targetFramework = "net6.0"
$targetFramework = "net7.0"

Create-Directory $generatedDir
Create-Directory $generatedTestDir
Expand Down Expand Up @@ -74,7 +74,7 @@ function Run-IOperation($coreDir, $ioperationProject) {
$operationsDir = Join-Path $coreDir "Operations"
$operationsXml = Join-Path $operationsDir "OperationInterfaces.xml"
$generationDir = Join-Path $coreDir "Generated"
$targetFramework = "net6.0"
$targetFramework = "net7.0"

if (-not $test) {
Run-Tool $ioperationProject "`"$operationsXml`" `"$generationDir`"" $targetFramework
Expand All @@ -91,7 +91,7 @@ function Run-GetTextCore($generatedDir) {
$syntaxTextFilePath = Join-Path $generatedDir "Syntax.xml.GetText.Generated.vb"

Create-Directory $generatedDir
Run-Tool $basicSyntaxProject "`"$syntaxFilePath`" `"$syntaxTextFilePath`" /gettext" "net6.0"
Run-Tool $basicSyntaxProject "`"$syntaxFilePath`" `"$syntaxTextFilePath`" /gettext" "net7.0"
}

function Run-GetText() {
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/test-unix-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- task: ShellScript@2
displayName: Rehydrate RunTests
inputs:
scriptPath: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net6.0/rehydrate.sh
scriptPath: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net7.0/rehydrate.sh
env:
HELIX_CORRELATION_PAYLOAD: '$(Build.SourcesDirectory)/.duplicate'

Expand Down
6 changes: 3 additions & 3 deletions eng/pipelines/test-windows-job-single-machine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ jobs:
steps:
- checkout: none

# A .NET 6 runtime is needed since our unit tests target net6.0
# A .NET 7 runtime is needed since our unit tests target net7.0
- task: UseDotNet@2
displayName: 'Install .NET 6 Runtime'
displayName: 'Install .NET 7 Runtime'
inputs:
packageType: runtime
version: 6.0.8
version: 7.0.1
installationPath: '$(Build.SourcesDirectory)/.dotnet'

- task: DownloadPipelineArtifact@2
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/test-windows-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
- task: BatchScript@1
displayName: Rehydrate RunTests
inputs:
filename: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net6.0/rehydrate.cmd
filename: ./artifacts/bin/RunTests/${{ parameters.configuration }}/net7.0/rehydrate.cmd
env:
HELIX_CORRELATION_PAYLOAD: '$(Build.SourcesDirectory)\.duplicate'

Expand Down
2 changes: 1 addition & 1 deletion eng/prepare-tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ try {
$dotnet = Ensure-DotnetSdk
# permissions issues make this a pain to do in PrepareTests itself.
Remove-Item -Recurse -Force "$RepoRoot\artifacts\testPayload" -ErrorAction SilentlyContinue
Exec-Console $dotnet "$RepoRoot\artifacts\bin\PrepareTests\$configuration\net6.0\PrepareTests.dll --source $RepoRoot --destination $RepoRoot\artifacts\testPayload --dotnetPath `"$dotnet`""
Exec-Console $dotnet "$RepoRoot\artifacts\bin\PrepareTests\$configuration\net7.0\PrepareTests.dll --source $RepoRoot --destination $RepoRoot\artifacts\testPayload --dotnetPath `"$dotnet`""
exit 0
}
catch {
Expand Down
2 changes: 1 addition & 1 deletion eng/prepare-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ InitializeDotNetCli true
# permissions issues make this a pain to do in PrepareTests itself.
rm -rf "$repo_root/artifacts/testPayload"

dotnet "$repo_root/artifacts/bin/PrepareTests/Debug/net6.0/PrepareTests.dll" --source "$repo_root" --destination "$repo_root/artifacts/testPayload" --unix --dotnetPath ${_InitializeDotNetCli}/dotnet
dotnet "$repo_root/artifacts/bin/PrepareTests/Debug/net7.0/PrepareTests.dll" --source "$repo_root" --destination "$repo_root/artifacts/testPayload" --unix --dotnetPath ${_InitializeDotNetCli}/dotnet
2 changes: 1 addition & 1 deletion eng/targets/Settings.props
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
These may be overridden by projects that need to be skipped.
-->
<TestTargetFrameworks Condition="'$(TestRuntime)' == 'Mono'">net46;net472</TestTargetFrameworks>
<TestTargetFrameworks Condition="'$(TestRuntime)' == 'Core'">net6.0</TestTargetFrameworks>
<TestTargetFrameworks Condition="'$(TestRuntime)' == 'Core'">net7.0</TestTargetFrameworks>

<XUnitDesktopSettingsFile>$(MSBuildThisFileDirectory)..\config\xunit.runner.json</XUnitDesktopSettingsFile>
<XUnitCoreSettingsFile>$(MSBuildThisFileDirectory)..\config\xunit.runner.json</XUnitCoreSettingsFile>
Expand Down
10 changes: 7 additions & 3 deletions src/Compilers/CSharp/Test/CommandLine/CommandLineTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,11 @@ public void RunWithShiftJisFile()
[ConditionalFact(typeof(WindowsDesktopOnly), Reason = "https://github.com/dotnet/roslyn/issues/30321")]
public void CompilerBinariesAreAnyCPU()
{
// TODO2
// warning SYSLIB0037: 'AssemblyName.ProcessorArchitecture' is obsolete: 'AssemblyName members HashAlgorithm, ProcessorArchitecture, and VersionCompatibility are obsolete and not supported.'
#pragma warning disable SYSLIB0037
Assert.Equal(ProcessorArchitecture.MSIL, AssemblyName.GetAssemblyName(s_CSharpCompilerExecutable).ProcessorArchitecture);
#pragma warning restore SYSLIB0037
}

[Fact]
Expand Down Expand Up @@ -8615,7 +8619,7 @@ public void FileShareDeleteCompatibility_Windows()
fsDll.Dispose();
fsPdb.Dispose();

AssertEx.Equal(new[] { "Lib.cs", "Lib.dll", "Lib.pdb" }, Directory.GetFiles(dir.Path).Select(p => Path.GetFileName(p)).Order());
AssertEx.Equal(new[] { "Lib.cs", "Lib.dll", "Lib.pdb" }, Roslyn.Utilities.EnumerableExtensions.Order(Directory.GetFiles(dir.Path).Select(p => Path.GetFileName(p))));
}

/// <summary>
Expand Down Expand Up @@ -8672,7 +8676,7 @@ public void FileShareDeleteCompatibility_Xplat()
peDll.Dispose();
pePdb.Dispose();

AssertEx.Equal(new[] { "Lib.cs", "Lib.dll", "Lib.pdb" }, Directory.GetFiles(dir.Path).Select(p => Path.GetFileName(p)).Order());
AssertEx.Equal(new[] { "Lib.cs", "Lib.dll", "Lib.pdb" }, Roslyn.Utilities.EnumerableExtensions.Order(Directory.GetFiles(dir.Path).Select(p => Path.GetFileName(p))));

// files can be deleted now:
File.Delete(libSrc.Path);
Expand Down Expand Up @@ -8713,7 +8717,7 @@ public void FileShareDeleteCompatibility_ReadOnlyFiles()

fsDll.Dispose();

AssertEx.Equal(new[] { "Lib.cs", "Lib.dll" }, Directory.GetFiles(dir.Path).Select(p => Path.GetFileName(p)).Order());
AssertEx.Equal(new[] { "Lib.cs", "Lib.dll" }, Roslyn.Utilities.EnumerableExtensions.Order(Directory.GetFiles(dir.Path).Select(p => Path.GetFileName(p))));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.CommandLine.UnitTests</RootNamespace>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<GenerateMicrosoftCodeAnalysisCommitHashAttribute>true</GenerateMicrosoftCodeAnalysisCommitHashAttribute>
</PropertyGroup>
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Label="Project References">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ public void TestProgrammaticSuppressionInfo_DiagnosticSuppressor()
Assert.Single(diagnostics);
var programmaticSuppression = diagnostics.Select(d => d.ProgrammaticSuppressionInfo).Single();
Assert.Equal(2, programmaticSuppression.Suppressions.Count);
var orderedSuppressions = programmaticSuppression.Suppressions.Order().ToImmutableArrayOrEmpty();
var orderedSuppressions = Roslyn.Utilities.EnumerableExtensions.Order(programmaticSuppression.Suppressions).ToImmutableArrayOrEmpty();
Assert.Equal(suppressionId, orderedSuppressions[0].Id);
Assert.Equal(suppressor.SuppressionDescriptor.Justification, orderedSuppressions[0].Justification);
Assert.Equal(suppressionId2, orderedSuppressions[1].Id);
Expand Down
8 changes: 1 addition & 7 deletions src/Compilers/CSharp/Test/Emit2/Emit/NumericIntPtrTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,12 @@
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
using ReferenceEqualityComparer = Roslyn.Utilities.ReferenceEqualityComparer;

namespace Microsoft.CodeAnalysis.CSharp.UnitTests.Semantics
{
public class NumericIntPtrTests : CSharpTestBase
{
private static string IncludeExpectedOutput(string expectedOutput) =>
#if NET7_0_OR_GREATER
expectedOutput ;
#else
null;
#endif
private static string IncludeExpectedOutput(string expectedOutput) => ExecutionConditionUtil.IsCoreClr ? expectedOutput : null;

internal static readonly ConversionKind[] Identity = new[] { ConversionKind.Identity };
internal static readonly ConversionKind[] NoConversion = new[] { ConversionKind.NoConversion };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Label="Project References">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.UnitTests</RootNamespace>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.IOperation.UnitTests</RootNamespace>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests</RootNamespace>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup Label="Project References">
<ProjectReference Include="..\..\..\Test\Core\Microsoft.CodeAnalysis.Test.Utilities.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3510,7 +3510,7 @@ where node.IsKind(SyntaxKind.CollectionInitializerExpression)
Assert.Equal(2, symbolInfo.CandidateSymbols.Length);
Assert.Equal(new[] {"void X.Add(System.Collections.Generic.List<System.Byte> x)",
"void X.Add(X x)"},
symbolInfo.CandidateSymbols.Select(s => s.ToTestDisplayString()).Order().ToArray());
Roslyn.Utilities.EnumerableExtensions.Order(symbolInfo.CandidateSymbols.Select(s => s.ToTestDisplayString())).ToArray());
}

[WorkItem(529787, "http://vstfdevdiv:8080/DevDiv2/DevDiv/_workitems/edit/529787")]
Expand Down
19 changes: 1 addition & 18 deletions src/Compilers/CSharp/Test/Semantic/Semantics/RefFieldTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,7 @@ namespace Microsoft.CodeAnalysis.CSharp.UnitTests
{
public class RefFieldTests : CSharpTestBase
{
private static bool IsNet70OrGreater()
{
#if NET7_0_OR_GREATER
return true;
#else
return false;
#endif
}

private static string IncludeExpectedOutput(string expectedOutput) => IsNet70OrGreater() ? expectedOutput : null;

private static IEnumerable<MetadataReference> CopyWithoutSharingCachedSymbols(IEnumerable<MetadataReference> references)
{
foreach (var reference in references)
{
yield return ((AssemblyMetadata)((MetadataImageReference)reference).GetMetadata()).CopyWithoutSharingCachedSymbols().GetReference();
}
}
private static string IncludeExpectedOutput(string expectedOutput) => ExecutionConditionUtil.IsCoreClr ? expectedOutput : null;

[CombinatorialData]
[Theory]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<OutputType>Library</OutputType>
<RootNamespace>Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests</RootNamespace>
<NoStdLib>true</NoStdLib>
<TargetFrameworks>net6.0;net472</TargetFrameworks>
<TargetFrameworks>net7.0;net472</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup Label="Project References">
Expand Down
Loading

0 comments on commit 9d3d153

Please sign in to comment.