diff --git a/src/formatters/mod.rs b/src/formatters/mod.rs index cc27a17..8aba955 100644 --- a/src/formatters/mod.rs +++ b/src/formatters/mod.rs @@ -64,20 +64,23 @@ pub mod zigfmt; #[inline] pub fn setup_snippet(code: &str, file_ext: &str) -> std::io::Result { - let _ = std::fs::create_dir_all(".mdsf-cache"); - - let mut f = tempfile::Builder::new() - .rand_bytes(12) - .suffix(file_ext) - .prefix( - // ktlint wants PascalCase file names - if file_ext == Language::Kotlin.to_file_ext() { - "MdsfFile" - } else { - "mdsf" - }, - ) - .tempfile_in(".mdsf-cache")?; + let mut b = tempfile::Builder::new(); + + b.rand_bytes(12).suffix(file_ext).prefix( + // ktlint wants PascalCase file names + if file_ext == Language::Kotlin.to_file_ext() { + "MdsfFile" + } else { + "mdsf" + }, + ); + + let mut f = if file_ext == ".cs" { + let _ = std::fs::create_dir_all(".mdsf-cache"); + b.tempfile_in(".mdsf-cache") + } else { + b.tempfile() + }?; f.write_all(code.as_bytes())?; f.flush()?; diff --git a/src/formatters/usort.rs b/src/formatters/usort.rs index 40731f1..f1b4de2 100644 --- a/src/formatters/usort.rs +++ b/src/formatters/usort.rs @@ -12,7 +12,7 @@ pub fn format_using_usort( } #[cfg(test)] -mod test_isort { +mod test_usort { use crate::{formatters::setup_snippet, languages::Language}; use super::format_using_usort;