File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed
CSharpier.Cli/EditorConfig Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ CancellationToken cancellationToken
31
31
var file = fileSystem . FileInfo . New (
32
32
fileSystem . Path . Combine ( directoryInfo . FullName , ".editorconfig" )
33
33
) ;
34
- if ( file . Exists && ! ignoreFile . IsIgnored ( file . FullName ) )
34
+ if ( file . Exists )
35
35
{
36
36
var dirName = fileSystem . Path . GetDirectoryName ( file . FullName ) ;
37
37
ArgumentNullException . ThrowIfNull ( dirName ) ;
Original file line number Diff line number Diff line change @@ -901,6 +901,44 @@ public void Should_Support_Config_Path_With_Editor_Config()
901
901
context . GetFileContent ( fileName ) . Should ( ) . Be ( "var myVariable =\n someLongValue;\n " ) ;
902
902
}
903
903
904
+ [ Test ]
905
+ public void Should_Not_Fail_With_Invalid_Editor_Config ( )
906
+ {
907
+ var context = new TestContext ( ) ;
908
+ context . WhenAFileExists (
909
+ ".editorconfig" ,
910
+ """
911
+ [*
912
+ max_line_length 10
913
+ """
914
+ ) ;
915
+ var fileName = context . WhenAFileExists ( "file1.cs" , "var myVariable = someLongValue;" ) ;
916
+
917
+ Format ( context ) ;
918
+
919
+ context . GetFileContent ( fileName ) . Should ( ) . Be ( "var myVariable = someLongValue;\n " ) ;
920
+ }
921
+
922
+ [ TestCase ( ".gitignore" ) ]
923
+ [ TestCase ( ".csharpierignore" ) ]
924
+ public void Should_Respect_Ignored_Editor_Config ( string ignoreFileName )
925
+ {
926
+ var context = new TestContext ( ) ;
927
+ context . WhenAFileExists (
928
+ ".editorconfig" ,
929
+ """
930
+ [*]
931
+ max_line_length = 10
932
+ """
933
+ ) ;
934
+ context . WhenAFileExists ( ignoreFileName , ".editorconfig" ) ;
935
+ var fileName = context . WhenAFileExists ( "file1.cs" , "var myVariable = someLongValue;" ) ;
936
+
937
+ Format ( context ) ;
938
+
939
+ context . GetFileContent ( fileName ) . Should ( ) . Be ( "var myVariable =\n someLongValue;\n " ) ;
940
+ }
941
+
904
942
[ TestCase ( "\r \n " ) ]
905
943
[ TestCase ( "\n " ) ]
906
944
public void Format_XML_With_Multiline_Comment_Uses_Consistent_Line_Breaks ( string lineBreak )
Original file line number Diff line number Diff line change @@ -719,7 +719,7 @@ public async Task Should_Ignore_Invalid_EditorConfig_Lines()
719
719
}
720
720
721
721
[ Test ]
722
- public async Task Should_Ignore_Ignored_EditorConfig ( )
722
+ public async Task Should_Not_Ignore_Ignored_EditorConfig ( )
723
723
{
724
724
var context = new TestContext ( ) ;
725
725
context . WhenAFileExists (
@@ -744,7 +744,7 @@ public async Task Should_Ignore_Ignored_EditorConfig()
744
744
"c:/test" ,
745
745
"c:/test/subfolder/test.cs"
746
746
) ;
747
- result . IndentSize . Should ( ) . Be ( 1 ) ;
747
+ result . IndentSize . Should ( ) . Be ( 2 ) ;
748
748
}
749
749
750
750
[ Test ]
You can’t perform that action at this time.
0 commit comments