Common Code Snippets

C# Related Snippets

Convert object to JSON in VS Package Manager Window

Newtonsoft.Json.JsonConvert.SerializeObject(theObject, Newtonsoft.Json.Formatting.Indented),nq

Default GUID string


Human readable GUID strings for unit tests

00000000-0000-0000-0000-000000000b0b (Bob)
00000000-0000-0000-0000-0000000ff1ce (Office)
00000000-0000-0000-0000-00000000f00d (Food)
00000000-0000-0000-0000-000000c0ffee (Coffee)
00000000-0000-0000-0000-000000000bad (Bad)

100 character comment line

// ----------------------------------------------------------------------------------------------------

Make internals visible to another assembly / unit test project

Add the following code to the file “Properties/StaticAssemblyInfo.cs”

using System.Runtime.CompilerServices;

[assembly: InternalsVisibleTo("Other.Project.Name")]

JavaScript Related Code Snippets

Delay by X seconds (using async and await)

async function save() {
const secondsDelay = 1;
await new Promise(resolve => setTimeout(resolve, secondsDelay * 1000));

Chrome network tab, filter for just JSON responses