Skip to content

Instantly share code, notes, and snippets.

View kkolodziejczak's full-sized avatar

Krzysztof Kołodziejczak kkolodziejczak

View GitHub Profile
@kkolodziejczak
kkolodziejczak / BasePageViewModelAnalyzer.cs
Created March 17, 2019 18:54
Make sure that all classes that inherit BasePageViewModel invoke Initialize() in the constructor.
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using System.Collections.Immutable;
using System.Linq;
namespace Analyzer1
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class BasePageViewModelAnalyzer : DiagnosticAnalyzer
@kkolodziejczak
kkolodziejczak / in-memory-http-server.cs
Created March 11, 2019 19:00 — forked from yetanotherchris/in-memory-http-server.cs
In memory http server for C# unit and integration tests
public static Task BasicHttpServer(string url, string outputHtml)
{
return Task.Run(() =>
{
HttpListener listener = new HttpListener();
listener.Prefixes.Add(url);
listener.Start();
// GetContext method blocks while waiting for a request.
HttpListenerContext context = listener.GetContext();