search for Error Message Read more →
Exception capture in .NET Core
app.UseExceptionHandler(options => { options.Run( async context => { var error = context.Features.Get<IExceptionHandlerFeature>(); if (error is object) { Log.Error( “EXCEPTION {method} {url} {query} => {exception}”, context.Request.Method, context.Request.Path.Value, context.Request.QueryString.Value, error.Error); } }); }); Read more →
Debug XmlSerializer
var serializer = new XmlSerializer(typeof(<x>)); serializer.UnknownAttribute += (sender, args) => System.Diagnostics.Debug.Fail($”Unknown attribute { args.Attr.Name }=\'{ args.Attr.Value }\'”); serializer.UnknownNode += (sender, args) => System.Diagnostics.Debug.Fail($”Unknown Node: {args.Name}\t{args.Text}”); serializer.UnknownElement += (sender, args) => System.Diagnostics.Debug.Fail($”Unknown Element: { args.Element.Name }\t{ args.Element.InnerXml}”); serializer.UnreferencedObject += (sender, args) => System.Diagnostics.Debug.Fail($”Unreferenced Object: { args.UnreferencedId }\t{ args.UnreferencedObject.ToString() }”); Read more →
3 Little Pigs
The fable of the 3 little pigs was written using what is now known as the the rule of 3. This simple principle has been used countless times and is as effective today as it has ever been. We are not limited to two polar opposites when developing software: quick to write; hard to change or slow to write; easy… Read more →
Access app.config from a texttemplate
<#@ template debug=”false” hostspecific=”true” language=”C#” #> <#@ assembly name=”System.Core” #> <#@ assembly name=”System.Configuration” #> <#@ import namespace=”System.Linq” #> <#@ import namespace=”System.Text” #> <#@ import namespace=”System.Collections.Generic” #> <#@ import namespace=”System.Configuration” #> <#@ output extension=”.tt.cs” #> <# var projectPath = Host.ResolveAssemblyReference(“$(ProjectDir)”); var configFile = projectPath + “App.config”; var map = new ExeConfigurationFileMap() { ExeConfigFilename = configFile }; Configuration config = ConfigurationManager.OpenMappedExeConfiguration(map, ConfigurationUserLevel.None);… Read more →
Beware Package Managers
It’s evident that package managers such as npm and nuget are an effective way for hackers to bypass some of the core elements of enterprise security defences. Compromised code can travel undetected through the firewall and passed the virus checker – straight from the internet to the device (e.g. the production server) – fully automated by the development platforms, and… Read more →
TextTemplate reference local assembly
<#@ assembly name=”$(TargetDir)<name>.dll” #> Read more →
CMD Find in Files
Simple search, all subfolders findstr /s /i <text> Regular Expression all subfolders findstr /s /r /c:”<text to search for>” Read more →
CQS & CQRS
CQS means “Command-query separation”. It was introduced by Bertrand Meyer as part of his work on the Eiffel programming language. A method is either a command performing an action, or a query that returns data, but not both. Being purely action-performing methods, commands always have a void return type. Queries, on the other hand, should not have any observable side… Read more →
Software Development Principles & Patterns
Who even gives a ****? I do. My Software Development Principles Unit Testing / Test Driven Development / Behaviour Driven Development CQRS Command and Query Responsibility Separation SOLID Single Responsibility Principle Open/Closed Principle Liskov’s Substitution Principle Interface Segregation Principle Dependency Inversion Principle AOP Aspect-Oriented Programming Unit Testing A unit as the smallest testable part of an application. In object-oriented programming, a… Read more →