-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(csharp): add support for csharpier (#130)
* feat(csharp): add support for csharpier * ci: install csharpier and fantomas
- Loading branch information
Showing
8 changed files
with
131 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
/target | ||
|
||
.mdsf-cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use super::execute_command; | ||
|
||
#[inline] | ||
pub fn format_using_csharpier( | ||
snippet_path: &std::path::Path, | ||
) -> std::io::Result<(bool, Option<String>)> { | ||
let mut cmd = std::process::Command::new("dotnet"); | ||
|
||
cmd.arg("csharpier").arg(snippet_path); | ||
|
||
execute_command(&mut cmd, snippet_path) | ||
} | ||
|
||
#[cfg(test)] | ||
mod test_csharpier { | ||
use crate::{formatters::setup_snippet, languages::Language}; | ||
|
||
use super::format_using_csharpier; | ||
|
||
#[test_with::executable(dotnet)] | ||
#[test] | ||
fn it_should_format_csharp() { | ||
let input = "namespace Mdsf { | ||
class Adder { | ||
public static int add(int a,int b) { | ||
var c=a+b ; | ||
return c ; | ||
} | ||
} | ||
} "; | ||
|
||
let expected_output = "namespace Mdsf | ||
{ | ||
class Adder | ||
{ | ||
public static int add(int a, int b) | ||
{ | ||
var c = a + b; | ||
return c; | ||
} | ||
} | ||
} | ||
"; | ||
|
||
let snippet = setup_snippet(input, Language::CSharp.to_file_ext()) | ||
.expect("it to create a snippet file"); | ||
|
||
let output = format_using_csharpier(snippet.path()) | ||
.expect("it to be successful") | ||
.1 | ||
.expect("it to be some"); | ||
|
||
assert_eq!(output, expected_output); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters