Skip to content
This repository was archived by the owner on Sep 24, 2019. It is now read-only.
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
4 changes: 4 additions & 0 deletions package.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CALL .\build /p:Configuration=Release

SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe
%CACHED_NUGET% pack src\nuget\Octokit.CodeFormatter.nuspec -NoPackageAnalysis
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ private IEnumerable<TRule> GetOrderedRules<TRule>(IEnumerable<Lazy<TRule, IRuleM
where TRule : IFormattingRule
{
return rules
.Where(r => !r.Metadata.Skip)
.OrderBy(r => r.Metadata.Order)
.Where(r => r.Metadata.FormattingLevel <= FormattingLevel)
.Select(r => r.Value)
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.DotNet.CodeFormatting/IRuleMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ public interface IRuleMetadata

[DefaultValue(FormattingLevel.Simple)]
FormattingLevel FormattingLevel { get; }

[DefaultValue(false)]
bool Skip { get; }
}
}
9 changes: 9 additions & 0 deletions src/Microsoft.DotNet.CodeFormatting/RuleAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ public SyntaxRuleAttribute(int order)

[DefaultValue(FormattingLevel.Simple)]
public FormattingLevel FormattingLevel { get; set; }

[DefaultValue(false)]
public bool Skip { get; set; }
}

[MetadataAttribute]
Expand All @@ -43,6 +46,9 @@ public LocalSemanticRuleAttribute(int order)

[DefaultValue(FormattingLevel.Simple)]
public FormattingLevel FormattingLevel { get; set; }

[DefaultValue(false)]
public bool Skip { get; set; }
}

[MetadataAttribute]
Expand All @@ -60,5 +66,8 @@ public GlobalSemanticRuleAttribute(int order)

[DefaultValue(FormattingLevel.Simple)]
public FormattingLevel FormattingLevel { get; set; }

[DefaultValue(false)]
public bool Skip { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace Microsoft.DotNet.CodeFormatting.Rules
{
[LocalSemanticRule(LocalSemanticRuleOrder.ExplicitVisibilityRule)]
[LocalSemanticRule(LocalSemanticRuleOrder.ExplicitVisibilityRule, Skip = true)]
internal sealed partial class ExplicitVisibilityRule : ILocalSemanticFormattingRule
{
public bool SupportsLanguage(string languageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Microsoft.DotNet.CodeFormatting.Rules
/// <summary>
/// Ensure there is a blank line above the first using and namespace in the file.
/// </summary>
[SyntaxRule(SyntaxRuleOrder.NewLineAboveFormattingRule)]
[SyntaxRule(SyntaxRuleOrder.NewLineAboveFormattingRule, Skip = true)]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's wrong with tis?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of it, but mostly due to when you don't specify a copyright header it'll insert a newline before all your using statements anyway.

internal sealed class NewLineAboveRule : CSharpOnlyFormattingRule, ISyntaxFormattingRule
{
public SyntaxNode Process(SyntaxNode syntaxRoot, string languageName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

namespace Microsoft.DotNet.CodeFormatting.Rules
{
[GlobalSemanticRule(GlobalSemanticRuleOrder.PrivateFieldNamingRule)]
[GlobalSemanticRule(GlobalSemanticRuleOrder.PrivateFieldNamingRule, Skip = true)]
internal partial class PrivateFieldNamingRule : IGlobalSemanticFormattingRule
{
#region CommonRule
Expand Down
42 changes: 42 additions & 0 deletions src/nuget/Octokit.CodeFormatter.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>Octokit.CodeFormatter</id>
<version>1.0.0-preview</version>
<title>Octokit's CodeFormatter</title>
<authors>Brendan Forster</authors>
<owners>Microsoft</owners>
<description>A fork of the CodeFormatter tool which enforces a subset of the coding guidelines.</description>
<copyright>Copyright © Microsoft Corporation</copyright>
</metadata>
<files>
<file src="..\..\bin\CodeFormatter.exe" target="tools" />
<file src="..\..\bin\CodeFormatter\Release\CopyrightHeader.md" target="tools" />
<file src="..\..\bin\CodeFormatter\Release\IllegalHeaders.md" target="tools" />
<file src="..\..\bin\Microsoft.DotNet.CodeFormatting.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.CSharp.Desktop.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.CSharp.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.CSharp.Workspaces.Desktop.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.CSharp.Workspaces.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.Desktop.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.VisualBasic.Desktop.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.VisualBasic.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.VisualBasic.Workspaces.Desktop.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.VisualBasic.Workspaces.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.Workspaces.Desktop.dll" target="tools" />
<file src="..\..\bin\Microsoft.CodeAnalysis.Workspaces.dll" target="tools" />
<file src="..\..\bin\Microsoft.DotNet.CodeFormatting.dll" target="tools" />
<file src="..\..\bin\Microsoft.DotNet.CodeFormatting.Tests.dll" target="tools" />
<file src="..\..\bin\Microsoft.DotNet.DeadRegionAnalysis.dll" target="tools" />
<file src="..\..\bin\Microsoft.DotNet.DeadRegionAnalysis.Tests.dll" target="tools" />
<file src="..\..\bin\System.Collections.Immutable.dll" target="tools" />
<file src="..\..\bin\System.Composition.AttributedModel.dll" target="tools" />
<file src="..\..\bin\System.Composition.Convention.dll" target="tools" />
<file src="..\..\bin\System.Composition.Hosting.dll" target="tools" />
<file src="..\..\bin\System.Composition.Runtime.dll" target="tools" />
<file src="..\..\bin\System.Composition.TypedParts.dll" target="tools" />
<file src="..\..\bin\System.Reflection.Metadata.dll" target="tools" />
<file src="..\..\bin\MSTestNamespaces.txt" target="tools" />
</files>
</package>