Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add whitespace editorconfig and run dotnet format whitespace #1090

Merged
merged 1 commit into from
Apr 26, 2022
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
49 changes: 49 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
###############################
# Core EditorConfig Options #
###############################

root = true

# All files
[*]
indent_style = space

# Shell scripts
[*.sh]
end_of_line = lf
[*.{cmd,bat}]
end_of_line = crlf

# Visual Studio XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

# Visual Studio and .NET related XML config files
[*.{props,targets,ruleset,config,nuspec,resx,vsixmanifest,vsct}]
indent_size = 2
insert_final_newline = true
trim_trailing_whitespace = true

# YAML files
[*.{yml,yaml}]
indent_size = 2
trim_trailing_whitespace = true

# Markdown files
[*.md]
indent_size = 2

# PowerShell scripts
[*.ps1]
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4
tab_width = 4
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Project>
<Import Project="scripts\build\TestFx.props" />
</Project>
</Project>
14 changes: 7 additions & 7 deletions TestFx.sln
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Universal", "Universal", "{
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{929A3EDE-893B-4801-82BA-01FD947291CB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Nuget.config = Nuget.config
EndProjectSection
EndProject
Expand Down Expand Up @@ -147,7 +148,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{BCF5
ProjectSection(SolutionItems) = preProject
scripts\Build.ps1 = scripts\Build.ps1
scripts\common.lib.ps1 = scripts\common.lib.ps1
scripts\SetBuildNumber.ps1 = scripts\SetBuildNumber.ps1
scripts\test.ps1 = scripts\test.ps1
EndProjectSection
EndProject
Expand Down Expand Up @@ -230,12 +230,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Desktop.Legacy", "Desktop.L
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Adapter\PlatformServices.Shared\PlatformServices.Shared.projitems*{2177c273-ae07-43b3-b87a-443e47a23c5a}*SharedItemsImports = 13
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{23b9d9a2-4aee-47e6-97b5-060df21539fb}*SharedItemsImports = 5
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{272ca5e1-8e81-4825-9e47-86cce02f700d}*SharedItemsImports = 13
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{df131865-84ee-4540-8112-e88acebdea09}*SharedItemsImports = 4
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Code Analysis Debug|Any CPU = Code Analysis Debug|Any CPU
Code Analysis Debug|ARM = Code Analysis Debug|ARM
Expand Down Expand Up @@ -1457,4 +1451,10 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {31E0F4D5-975A-41CC-933E-545B2201FAF9}
EndGlobalSection
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Adapter\PlatformServices.Shared\PlatformServices.Shared.projitems*{2177c273-ae07-43b3-b87a-443e47a23c5a}*SharedItemsImports = 13
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{23b9d9a2-4aee-47e6-97b5-060df21539fb}*SharedItemsImports = 5
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{272ca5e1-8e81-4825-9e47-86cce02f700d}*SharedItemsImports = 13
src\TestFramework\Extension.Shared\Extension.Shared.projitems*{df131865-84ee-4540-8112-e88acebdea09}*SharedItemsImports = 4
EndGlobalSection
EndGlobal
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
displayName: 'Pull in NuGet 5.8.1'
inputs:
versionSpec: 5.8.1

- powershell: |
reg DELETE "HKLM\Software\Microsoft\StrongName\Verification" /f
reg ADD "HKLM\Software\Microsoft\StrongName\Verification\*,*" /f
Expand All @@ -35,7 +35,7 @@ jobs:
filename: test.cmd
arguments: '-configuration $(BuildConfiguration) -all -parallel'
modifyEnvironment: false

- task: ComponentGovernanceComponentDetection@0
displayName: 'Component Governance'
inputs:
Expand Down
52 changes: 26 additions & 26 deletions scripts/Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
# Build script for MSTest Test Framework.

[CmdletBinding(PositionalBinding = $false)]
Param(
Param(
[ValidateSet("Debug", "Release")]
[Alias("c")]
[string] $Configuration = "Debug",

[Alias("fv")]
[string] $FrameworkVersion = "99.99.99",

[Alias("av")]
[string] $AdapterVersion = "99.99.99",

[Alias("vs")]
[string] $VersionSuffix = "dev",

[string] $BuildVersionPrefix = "14.0",

[string] $BuildVersionSuffix = "9999.99",

[string] $Target = "Build",

[Alias("h")]
[Switch] $Help,

Expand Down Expand Up @@ -53,7 +53,7 @@ Param(
[Switch] $DisallowPrereleaseMSBuild,

[Alias("f")]
[Switch] $Force,
[Switch] $Force,

[Alias("s")]
[String[]] $Steps = @("UpdateTPVersion", "Restore", "Build", "Publish")
Expand All @@ -80,16 +80,16 @@ $TFB_IsLocalizedBuild = $IsLocalizedBuild -or $TFB_Official
$TPB_BRANCH = "LOCALBRANCH"
$TPB_COMMIT = "LOCALBUILD"
try {
$TPB_BRANCH = $env:BUILD_SOURCEBRANCH -replace "^refs/heads/"
if ([string]::IsNullOrWhiteSpace($TPB_BRANCH)) {
$TPB_BRANCH = $env:BUILD_SOURCEBRANCH -replace "^refs/heads/"
if ([string]::IsNullOrWhiteSpace($TPB_BRANCH)) {
$TPB_BRANCH = git -C "." rev-parse --abbrev-ref HEAD
}
}
catch { }

try {
$TPB_COMMIT = $env:BUILD_SOURCEVERSION
if ([string]::IsNullOrWhiteSpace($TPB_COMMIT)) {
if ([string]::IsNullOrWhiteSpace($TPB_COMMIT)) {
$TPB_COMMIT = git -C "." rev-parse HEAD
}
}
Expand Down Expand Up @@ -124,7 +124,7 @@ function Print-Help {
Write-Host -object " Official - [switch] - Indicates that this is an official build. Only used in CI builds."
Write-Host -object " Full - [switch] - Indicates to perform a full build which includes Adapter, Framework"
Write-Host -object " DisallowPrereleaseMSBuild (-np) - [switch] - Uses an RTM version of MSBuild to build the projects"
Write-Host -object ""
Write-Host -object ""
Write-Host -object " Configuration (-c) - [string] - Specifies the build configuration. Defaults to 'Debug'."
Write-Host -object " FrameworkVersion (-fv) - [string] - Specifies the version of the Test Framework nuget package."
Write-Host -object " AdapterVersion (-av) - [string] - Specifies the version of the Test Adapter nuget package."
Expand All @@ -150,7 +150,7 @@ function Install-WindowsSDK {
}
finally {
Pop-Location

Remove-Item $temp -Force -Recurse | Out-Null
}

Expand All @@ -163,7 +163,7 @@ function Perform-Restore {
$timer = Start-Timer

Write-Log "Perform-Restore: Started."

if ($TFB_SkipRestore) {
Write-Log "Perform-Restore: Skipped."
return;
Expand Down Expand Up @@ -202,7 +202,7 @@ function Perform-Build {
Write-Log " Clean build requested."
foreach ($folder in $foldersToDel) {
$outDir = Join-Path $env:TF_OUT_DIR -ChildPath $folder

if (Test-Path $outDir) {
Write-Output " Deleting $outDir"
Remove-Item -Recurse -Force $outDir
Expand All @@ -211,7 +211,7 @@ function Perform-Build {
}

Invoke-MSBuild -solution "TestFx.sln"

Write-Log "Perform-Build: Completed. {$(Get-ElapsedTime($timer))}"
}

Expand All @@ -234,17 +234,17 @@ function Invoke-MSBuild([string]$solution, $buildTarget = $Target, $hasVsixExten
"-p:IsLocalizedBuild=$TFB_IsLocalizedBuild",
"-p:UpdateXlf=$TFB_UpdateXlf",
"-p:BuildVersion=$TFB_BuildVersion",
"-restore:$restore",
"-restore:$restore",
"`"$solutionPath`"",
"-bl:`"$binLog`"",
"-m")

Write-Log " $buildTarget`: $solution..."
& {
& {
$PSNativeCommandArgumentPassing = 'Legacy'
& "$msbuild" $argument;
}

if ($lastExitCode -ne 0) {
throw "Build failed with an exit code of '$lastExitCode'."
}
Expand All @@ -266,18 +266,18 @@ function Create-NugetPackages {

# Copy over the nuspecs to the staging directory
$nuspecFiles = @(
"MSTest.nuspec",
"MSTest.TestAdapter.nuspec",
"MSTest.TestAdapter.symbols.nuspec",
"MSTest.TestFramework.nuspec",
"MSTest.TestFramework.symbols.nuspec",
"MSTest.nuspec",
"MSTest.TestAdapter.nuspec",
"MSTest.TestAdapter.symbols.nuspec",
"MSTest.TestFramework.nuspec",
"MSTest.TestFramework.symbols.nuspec",
"MSTest.Internal.TestFx.Documentation.nuspec"
)

foreach ($file in $nuspecFiles) {
Copy-Item $tfSrcPackageDir\$file $stagingDir -Force
}

Copy-Item (Join-Path $tfSrcPackageDir "Icon.png") $stagingDir -Force

Copy-Item -Path "$($env:TF_PACKAGES_DIR)\microsoft.testplatform.adapterutilities\$TestPlatformVersion\lib" -Destination "$($stagingDir)\Microsoft.TestPlatform.AdapterUtilities" -Recurse -Force
Expand All @@ -287,7 +287,7 @@ function Create-NugetPackages {

foreach ($file in $nuspecFiles) {
$version = $TFB_FrameworkVersion

if ($file.Contains("TestAdapter")) {
$version = $TFB_AdapterVersion
}
Expand All @@ -311,7 +311,7 @@ function ShouldRunStep([string[]]$CurrentSteps) {
if ($Force) {
return $true
}

foreach ($step in $CurrentSteps) {
if ($Steps -contains $step) {
return $true
Expand Down Expand Up @@ -341,4 +341,4 @@ if (ShouldRunStep @("Build")) {

if (ShouldRunStep @("Publish")) {
Create-NugetPackages
}
}
6 changes: 3 additions & 3 deletions scripts/Install-WindowsSDK.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ Write-Host "Installing Windows SDK, if setup requests elevation please approve."
$process = Start-Process -Wait sdksetup.exe -ArgumentList "/quiet", "/norestart", "/ceip off", "/features OptionId.WindowsSoftwareDevelopmentKit" -PassThru
Remove-Item sdksetup.exe -Force

if($process.ExitCode -eq 0)
if($process.ExitCode -eq 0)
{
Write-Host "Done" -ForegroundColor Green
}
else
else
{
Write-Error "Failed to install Windows SDK (Exit code: $($process.ExitCode))"
}
}
14 changes: 7 additions & 7 deletions scripts/PortableToFullPdb.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function Locate-PdbConverterTool
{
$pdbConverter = Join-Path -path $TF_PACKAGES_DIR -ChildPath "Microsoft.DiaSymReader.Pdb2Pdb\$PdbConverterToolVersion\tools\Pdb2Pdb.exe"

if (!(Test-Path -path $pdbConverter))
if (!(Test-Path -path $pdbConverter))
{
throw "Unable to locate Microsoft.DiaSymReader.Pdb2Pdb converter exe in path '$pdbConverter'."
}
Expand All @@ -35,30 +35,30 @@ function Locate-PdbConverterTool
}

function ConvertPortablePdbToWindowsPdb
{
{
foreach($TF_PortablePdb in $TF_PortablePdbs)
{
$portablePdbs += Join-Path -path $TF_OUT_DIR\$Configuration -childPath $TF_PortablePdb
}

$pdbConverter = Locate-PdbConverterTool

foreach($portablePdb in $portablePdbs)
{
# First check if corresponding dll exists
$dllOrExePath = $portablePdb -replace ".pdb",".dll"

if(!(Test-Path -path $dllOrExePath))
{
# If no corresponding dll found, check if exe exists
$dllOrExePath = $portablePdb -replace ".pdb",".exe"

if(!(Test-Path -path $dllOrExePath))
{
throw "Unable to locate dll/exe corresponding to $portablePdb"
}
}

$fullpdb = $portablePdb -replace ".pdb",".pdbfull"

Write-Verbose "$pdbConverter $dll /pdb $portablePdb /out $fullpdb"
Expand Down
6 changes: 3 additions & 3 deletions scripts/build/TestFx.Loc.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<EmbeddedResource Include="$(ResourceDirectory)\%(LocResourceFile.Filename).%(LocResourceFile.Language).resx" />
</ItemGroup>
</Target>

<!-- Localization for documentation files. -->
<Target Name="CopyLocalizedXmls" BeforeTargets="BeforeBuild" Condition=" '$(LocDocumentationSubPath)' != ''">
<PropertyGroup>
Expand All @@ -83,13 +83,13 @@
<Target Name="CopyStaticResourcesToOutput">
<!-- Until we have a process of converting to/from loc friendly file formats like resx files, the already localized vsixlangpacks are checked in and packaged in the vsix.-->
<!-- If we have new vsix projects before we have a process setup, they would not contain localized descriptive information until the above process is setup.-->
<Copy SourceFiles="$(ProjectDir)Resources"
<Copy SourceFiles="$(ProjectDir)Resources"
DestinationFolder="$(OutDir)localize"
SkipUnchangedFiles="True" OverwriteReadOnlyFiles="True" Retries="3" RetryDelayMilliseconds="500"
UseHardlinksIfPossible="False" UseSymboliclinksIfPossible="False" ErrorIfLinkFails="True"

Condition="Exists('$(ProjectDir)Resources')">

<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/TestFx.Sign.props
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
<DelaySign Condition=" '$(IsLocalizedBuild)' == 'true' ">true</DelaySign>
<OutputPath Condition=" '$(OutputPath)' == '' ">$(RepoRoot)artifacts\$(Configuration)\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion scripts/build/TestFx.Sign.targets
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
</FilesToSign>
</ItemGroup>
</Target>
</Project>
</Project>
2 changes: 1 addition & 1 deletion scripts/build/TestFx.props
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)stylecop.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet Condition=" '$(IsTest)' == 'true' ">$(MSBuildThisFileDirectory)stylecop.test.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
</Project>
</Project>
Loading