Skip to content

Instantly share code, notes, and snippets.

@tonysneed
tonysneed / SaveClassAaJson.cs
Created January 26, 2022 21:49
Save class as Json
void SaveLocalSagaConfig(SagaConfigurationDto sagaConfig)
{
var options = new JsonSerializerOptions
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
};
var json = JsonSerializer.Serialize(sagaConfig, options);
File.WriteAllText(settings.SagaConfigPath, json);
}
@tonysneed
tonysneed / RiderMacShortcuts.md
Created January 8, 2022 18:37
Rider Mac Shortcut Settings

Rider Mac Shortcut Settings

Mac Shortcuts to Disable

  • Services: Search man page
    • Cmd + Shift + A
  • Mission Control: Disable all
@tonysneed
tonysneed / MyAppSettings.cs
Created January 2, 2022 20:31
Generic AddConfigSettings Extension method
public class MyAppSettings
{
public string StringSetting { get; set; }
public int IntSetting { get; set; }
public bool BoolSetting { get; set; }
}
@tonysneed
tonysneed / InterfaceConverter.cs
Last active January 12, 2022 06:06
Deserializing Interfaces with System.Text.Json
public class InterfaceConverter<TImplementation, TInterface> : JsonConverter<TInterface>
where TImplementation : class, TInterface
{
public override TInterface? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
=> JsonSerializer.Deserialize<TImplementation>(ref reader, options);
public override void Write(Utf8JsonWriter writer, TInterface value, JsonSerializerOptions options)
{
}
}
@tonysneed
tonysneed / nuget-test-commands.sh
Created December 4, 2021 17:21
Nuget Test Commands
dotnet new classlib --name FolderCopyTest
cd FolderCopyTest
dotnet add package EntityFrameworkCore.Scaffolding.Handlebars --version 6.0.0-preview3
dotnet build
cd bin/Debug/net6.0
ls -R
@tonysneed
tonysneed / csproj-targets.xml
Created December 4, 2021 17:02
Project Custom Build Targets
<Content Include="EntityFrameworkCore.Scaffolding.Handlebars.targets" PackagePath="build/EntityFrameworkCore.Scaffolding.Handlebars.targets" />
@tonysneed
tonysneed / msbuild-target-file.xml
Last active December 4, 2021 17:37
MS Build Target File
<Project>
<ItemGroup>
<Files Include="$(MSBuildThisFileDirectory)/../contentFiles/CodeTemplates/**/*.*" />
</ItemGroup>
<Target Name="CopyFiles" AfterTargets="Build">
<Copy SourceFiles="@(Files)" DestinationFolder="$(TargetDir)/CodeTemplates/%(RecursiveDir)" />
</Target>
</Project>
@tonysneed
tonysneed / nuget-v6-files.xml
Created December 4, 2021 16:36
NuGet v6 Files
<ItemGroup>
<Content Include="CodeTemplates/**/*.*" Pack="true" PackagePath="contentFiles/CodeTemplates">
<PackageCopyToOutput>true</PackageCopyToOutput>
</Content>
</ItemGroup>
@tonysneed
tonysneed / nuget-v5-files.xml
Created December 4, 2021 16:17
NuGet v5 Files
<ItemGroup>
<Content Include="CodeTemplates\CSharpDbContext\DbContext.hbs" PackagePath="lib\netstandard2.1\CodeTemplates\CSharpDbContext\" />
<Content Include="CodeTemplates\CSharpDbContext\Partials\DbImports.hbs" PackagePath="lib\netstandard2.1\CodeTemplates\CSharpDbContext\Partials\" />
<Content Include="CodeTemplates\CSharpDbContext\Partials\DbConstructor.hbs" PackagePath="lib\netstandard2.1\CodeTemplates\CSharpDbContext\Partials\" />
<Content Include="CodeTemplates\CSharpDbContext\Partials\DbOnConfiguring.hbs" PackagePath="lib\netstandard2.1\CodeTemplates\CSharpDbContext\Partials\" />
<Content Include="CodeTemplates\CSharpDbContext\Partials\DbSets.hbs" PackagePath="lib\netstandard2.1\CodeTemplates\CSharpDbContext\Partials\" />
<!-- Remaining items elided for clarity -->
@tonysneed
tonysneed / settings.json
Created December 2, 2021 22:23
My Windows Terminal Settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command":
{
"action": "copy",
"singleLine": false
},