Skip to content
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All changes to the project will be documented in this file.
## [4.0.x] - Not Yet Released
### Merged PRs:
- [Combine --check and --dry-run into a single option. (541)](https://github.com/dotnet/format/pull/541)
- [Use space-separated paths instead of comma-separated for --include and --exclude (551)](https://github.com/dotnet/format/pull/551)
- [Support loading commandline options from response files (552)](https://github.com/dotnet/format/pull/552)
- [Support file globbing in --include and --exclude options (555)](https://github.com/dotnet/format/pull/555)

## [3.3.111304] - 2020-02-13
[View Complete Diff of Changes](https://github.com/dotnet/format/compare/3ecea99de4bb82b724bf11134279b5aaf8dd1f2f...7c8f67a570f5fde6a247704733d6742f93c0fa48)
Expand Down
21 changes: 18 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
condition: not(succeeded())

- job: Linux
pool:
pool:
name: NetCorePublic-Pool
queue: BuildPool.Ubuntu.1604.Amd64.Open
variables:
Expand Down Expand Up @@ -73,9 +73,9 @@ jobs:
ArtifactName: '$(_os) $(_configuration)'
continueOnError: true
condition: not(succeeded())

- job: Windows_Spanish
pool:
pool:
name: NetCorePublic-Pool
queue: buildpool.windows.10.amd64.es.vs2017.open
variables:
Expand Down Expand Up @@ -105,3 +105,18 @@ jobs:
ArtifactName: 'Spanish $(_os) $(_configuration)'
continueOnError: true
condition: not(succeeded())

- job: Formatting_Check
pool:
vmImage: 'vs2017-win2016'
timeoutInMinutes: 5
steps:
- script: dotnet run --project ./src/dotnet-format.csproj -- --folder . --exclude ./tests/projects/ --check --report ./artifacts/log/ -v diag
displayName: Run dotnet-format
- task: PublishBuildArtifacts@1
displayName: Publish Logs
inputs:
PathtoPublish: '$(Build.SourcesDirectory)\artifacts\log\'
ArtifactName: 'Formatting Check'
continueOnError: true
condition: not(succeeded())
13 changes: 6 additions & 7 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ It is required to specify a workspace when running dotnet-format. Choosing a wor

### Filter files to format

You can further narrow the list of files to be formatted by limiting to set of included files that are not excluded.
You can further narrow the list of files to be formatted by limiting to set of included files that are not excluded. File globbing is supported.

- `--include` - A comma separated list of relative file or folder paths to include in formatting.
- `--exclude` - A comma separated list of relative file or folder paths to exclude from formatting.
- `--include` - A list of relative file or folder paths to include in formatting.
- `--exclude` - A list of relative file or folder paths to exclude from formatting.

*Example:*

Other repos built as part of your project can be included using git submodules. These submodules likely contain their own .editorconfig files that are set as `root = true`. This
makes it difficult to validate formatting for your project as formatting mistakes in submodules are treated as errors.
Other repos built as part of your project can be included using git submodules. These submodules likely contain their own .editorconfig files that are set as `root = true`. This makes it difficult to validate formatting for your project as formatting mistakes in submodules are treated as errors.

The following command sets the repo folder as the workspace. It then includes the `./src` and `./tests` folders for formatting. The `submodule-a` folder is excluded from the formatting validation.
The following command sets the repo folder as the workspace. It then includes the `src` and `tests` folders for formatting. The `submodule-a` folder is excluded from the formatting validation.

```console
dotnet format -f . --include ./src,./tests --exclude ./src/submodule-a --check
dotnet format -f . --include ./src/ ./tests/ --exclude ./src/submodule-a/ --check
```

### Logging and Reports
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<MicrosoftBuildLocatorVersion>1.2.6</MicrosoftBuildLocatorVersion>
<MicrosoftCodeAnalysisAnalyzerTestingVersion>1.0.1-beta1.20114.4</MicrosoftCodeAnalysisAnalyzerTestingVersion>
<MicrosoftExtensionsDependencyInjectionVersion>$(MicrosoftExtensionsVersion)</MicrosoftExtensionsDependencyInjectionVersion>
<MicrosoftExtensionsFileSystemGlobbingVersion>$(MicrosoftExtensionsVersion)</MicrosoftExtensionsFileSystemGlobbingVersion>
<MicrosoftExtensionsLoggingVersion>$(MicrosoftExtensionsVersion)</MicrosoftExtensionsLoggingVersion>
<MicrosoftVisualStudioCodingConventionsVersion>1.1.20180503.2</MicrosoftVisualStudioCodingConventionsVersion>
<MicrosoftCodeAnalysisAnalyzersVersion>3.0.0-beta2.20114.1</MicrosoftCodeAnalysisAnalyzersVersion>
Expand Down
23 changes: 13 additions & 10 deletions perf/FormattedFiles.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
using System.Collections.Immutable;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Microsoft.CodeAnalysis.Tools.Utilities;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.Logging;

namespace Microsoft.CodeAnalysis.Tools.Perf
{
[SimpleJob(RuntimeMoniker.NetCoreApp21)]
public class FormattedFiles
{
private const string UnformattedProjectPath = "tests/projects/for_code_formatter/unformatted_project";
private const string UnformattedProjectFilePath = UnformattedProjectPath + "/unformatted_project.csproj";
private const string UnformattedProjectPath = "tests/projects/for_code_formatter/unformatted_project/";
private const string UnformattedProjectFilePath = UnformattedProjectPath + "unformatted_project.csproj";
private const string UnformattedSolutionFilePath = "tests/projects/for_code_formatter/unformatted_solution/unformatted_solution.sln";
private static EmptyLogger EmptyLogger = new EmptyLogger();

private static readonly EmptyLogger EmptyLogger = new EmptyLogger();
private static readonly Matcher AllFileMatcher = SourceFileMatcher.CreateMatcher(Array.Empty<string>(), Array.Empty<string>());

[IterationSetup]
public void NoFilesFormattedSetup()
Expand All @@ -30,8 +36,7 @@ public void FilesFormattedFolder()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand All @@ -46,8 +51,7 @@ public void FilesFormattedProject()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand All @@ -62,8 +66,7 @@ public void FilesFormattedSolution()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand Down
22 changes: 12 additions & 10 deletions perf/NoFilesFormatted.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
using System.Collections.Immutable;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Microsoft.CodeAnalysis.Tools.Utilities;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.Logging;

namespace Microsoft.CodeAnalysis.Tools.Perf
{
[SimpleJob(RuntimeMoniker.NetCoreApp21)]
public class NoFilesFormatted
{
private const string FormattedProjectPath = "tests/projects/for_code_formatter/formatted_project";
private const string FormattedProjectFilePath = FormattedProjectPath + "/formatted_project.csproj";
private const string FormattedProjectPath = "tests/projects/for_code_formatter/formatted_project/";
private const string FormattedProjectFilePath = FormattedProjectPath + "formatted_project.csproj";
private const string FormattedSolutionFilePath = "tests/projects/for_code_formatter/formatted_solution/formatted_solution.sln";

private static EmptyLogger EmptyLogger = new EmptyLogger();
private static readonly EmptyLogger EmptyLogger = new EmptyLogger();
private static readonly Matcher AllFileMatcher = SourceFileMatcher.CreateMatcher(Array.Empty<string>(), Array.Empty<string>());

[IterationSetup]
public void NoFilesFormattedSetup()
Expand All @@ -31,8 +36,7 @@ public void NoFilesFormattedFolder()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand All @@ -47,8 +51,7 @@ public void NoFilesFormattedProject()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand All @@ -63,8 +66,7 @@ public void NoFilesFormattedSolution()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand Down
19 changes: 11 additions & 8 deletions perf/RealWorldSolution.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
using System.Collections.Immutable;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Diagnosers;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Horology;
using BenchmarkDotNet.Jobs;
using Microsoft.CodeAnalysis.Tools.Utilities;
using Microsoft.Extensions.FileSystemGlobbing;
using Microsoft.Extensions.Logging;

namespace Microsoft.CodeAnalysis.Tools.Perf
{
[Config(typeof(RealWorldConfig))]
public class RealWorldSolution
{
private const string UnformattedSolutionFilePath = "temp/project-system/ProjectSystem.sln";
private const string UnformattedFolderFilePath = "temp/project-system";
private const string UnformattedFolderFilePath = "temp/project-system/";
private const string UnformattedSolutionFilePath = UnformattedFolderFilePath + "ProjectSystem.sln";

private static EmptyLogger EmptyLogger = new EmptyLogger();
private static readonly Matcher AllFileMatcher = SourceFileMatcher.CreateMatcher(Array.Empty<string>(), Array.Empty<string>());

[IterationSetup]
public void RealWorldSolutionIterationSetup()
Expand All @@ -33,8 +38,7 @@ public void FilesFormattedSolution()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand All @@ -49,8 +53,7 @@ public void FilesFormattedFolder()
LogLevel.Error,
saveFormattedFiles: false,
changesAreErrors: false,
ImmutableHashSet<string>.Empty,
ImmutableHashSet<string>.Empty,
AllFileMatcher,
reportPath: string.Empty);
_ = CodeFormatter.FormatWorkspaceAsync(options, EmptyLogger, default).GetAwaiter().GetResult();
}
Expand Down
14 changes: 5 additions & 9 deletions perf/Utilities/EmptyLogger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using System;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using Microsoft.CodeAnalysis.Tools.Logging;
using Microsoft.Extensions.Logging;

namespace Microsoft.CodeAnalysis.Tools.Perf
Expand All @@ -16,13 +19,6 @@ public void Log<TState>(LogLevel logLevel,

public bool IsEnabled(LogLevel logLevel) => false;

public IDisposable BeginScope<TState>(TState state) => new EmptyScope();

private class EmptyScope : IDisposable
{
public void Dispose()
{
}
}
public IDisposable BeginScope<TState>(TState state) => NullScope.Instance;
}
}
4 changes: 3 additions & 1 deletion perf/Utilities/MSBuildRegister.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Linq;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis.Tools.MSBuild;

Expand Down
4 changes: 3 additions & 1 deletion perf/Utilities/SolutionPathSetter.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System;
using System.IO;
using System.Threading;

Expand Down
4 changes: 3 additions & 1 deletion perf/Utilities/WorkspacePathHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.IO;
// Copyright (c) Microsoft. All Rights Reserved. Licensed under the MIT license. See License.txt in the project root for license information.

using System.IO;

namespace Microsoft.CodeAnalysis.Tools.Perf
{
Expand Down
Loading