Skip to content

Instantly share code, notes, and snippets.

@plainionist
plainionist / file_watcher.rs
Created February 25, 2024 15:57
Observes a folder and uploads all files if anything changes in that folder
use notify::{Config, RecommendedWatcher, RecursiveMode, Watcher};
use reqwest::blocking::{multipart, Client};
use std::fs;
use std::path::Path;
fn main() {
let path = std::env::args().nth(1).expect("Argument 1 needs to be a path");
println!("Watching {path}");
@plainionist
plainionist / nsdepcop-config.xml
Created October 6, 2022 05:42
NsDepCop example rule file
<NsDepCopConfig IsEnabled="true" ChildCanDependOnParentImplicitly="true">
<Allowed From="*" To="System.*" />
<Allowed From="App.BusinessLogic.*" To="App.Domain.*" />
<Allowed From="App.Infrastructure.*" To="App.BusinessLogic.*" />
<Allowed From="App.Infrastructure.*" To="App.Persistance.*" />
</NsDepCopConfig>
@plainionist
plainionist / UnitTestAssembliesMustNotBeReferenced.cs
Created October 6, 2022 05:40
Code analyzer preventing test assemblies from being referenced
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class UnitTestAssembliesMustNotBeReferenced : DiagnosticAnalyzer
{
public const string DiagnosticId = "Architecture";
private static DiagnosticDescriptor Descriptor { get; } =
new DiagnosticDescriptor("AR0001",
"UnitTest assemblies must not be referenced by other assemblies",
"The assembly '{0}' references the unit test assembly: {1}",
category: "Architecture",