Advanced Search
Search Results
61 total results found
Nuget Package Reference
Here’s the golden reference for all things Nuget: docs.microsoft.com-nuget/docs at main · NuGet/docs.microsoft.com-nuget How to publish NuGet symbol packages using the new symbol package format '.snupkg' Non-Trivial Multi-Targeting with .NET Multi-targetin...
NET Core Background Services
NOTE: Refer to this page for how to register and consume a background service: Consuming NET Core Background Service with DI General Lots of the ceremony of a background service has been wrapped up and tested, in this class: BackgroundService_Base NOTE: As ...
Getting Correct Scheme, Host, Port Behind a Proxy
When running an API behind a reverse proxy, such as NGINX, the service will not, by default, see the scheme and port of the incoming call. By default, the API service will see the scheme and port of the direct call to it, which will likely be http and some int...
How to Create IOptions Instance
It’s pretty standard for classes to require configuration in their constructors in the IOptions form.But, this doesn’t make testing very easy. Here’s a workaround for pushing an IOptions instance into a class constructor, that needs config. This example is f...
IServiceProvider vs IServiceScopeFactory
References: Net Core DI Truths Internet’s Claim of Anti-Patterns Contrary to what the internet says about service locator usage as anti-pattern, there will always be the need for logic to dynamically access services from DI.This is because the NET Core runti...
Net Core DI Truths
References: NET Core DI Best Practices Here’s a list of behaviors of the NET Core DI registry: All dynamic access to services (from DI) are requested through a service provider.This is what people call a service locator. For example:var foosvc = _servic...
HowTo Make .Net Desktop App DPI Aware
For a better desktop UI experience, it is necessary to have access to the current screen size and pixel density of the display (DPI), so that an application controls and text fonts can be adjusted as needed for good layout and presentation. Here is a list of ...
Unit Tests with PostgreSQL Backends
In order to easily stand up a Postgres database for unit and integration testing, we need a class that can encapsulate the effort, to an easy call surface. Below we have a helper class that will manage the life-cycle of a test database, in PostgreSQL. Given ...
EF - Backend vs .NET Datatypes
Here's a list of what datatypes that Entity Framework uses to store .NET datatypes in a couple different database engines. .NET Datatype SQL Server PostgreSQL SQLite Comments bool bit boolean INTEGER byte tinyint smallint (Postgr...
Unit Testing Conventions
Suppress Async Warning Project-Wide Since we have several calls to base classes for diagnostics and such that are async, it's a good idea to standardize on all Test methods be async. The problem is that not every test method contains an awaited call. so, we ...
Base Domain Type
Here are notes about the base domain type, its usage, and design choices. NOTE: Some of these are restrictions of the C# compiler, that makes it necessary to include some boilerplate in domain objects. Design Requirements Here are design requirements for ou...
Example Derived Type
Here's a working example of a domain type that derives from the base type in this page: Base Domain Type /// <summary> /// This is a sample domain type that uses our base type. /// It is only for testing. /// For this type to exist, it requ...
OGA.PostGres.Lib Usage
Here’s notes on how to create and manage databases with OGA.PostGres.Lib. This applies to use cases for: Standing up a temporary database for unit and integration testing. Creating live database tables with compatible column types for storing class ...
EF: Logging
Here's some notes on how we implement logging in EF. We've currently implemented it in our dynamic domain dbcontext, DynamicDbContext. To make it work, we just have to create an instance of DbContextLoggingConfig, and pass it to our top-level dbcontext const...
EF: Data Contexts - DbContexts
When working in EF, you will come across the need to create a DbContext type. MS has a base class that you inherit from, called: DbContext. It is useful to implement either a two or three layer DbContext. See this page for EF Logging implementation: EF: Log...
Mocking a DBContext for Testing
The easiest means to mock a data context for testing, is to use an in-memory database. An in-memory database is known by its string-name within a process. Each data context accessing the database instance must use its name, via options. See this page for EF ...
HowTo Run DotNet Core App as Standalone
How to startup a net core application and specify the listening IP address and port: exename.exe run --urls "http://192.168.1.110:6000" Here's an alternate for starting a service that exists as a dll: dotnet OGA.HostControl.Service.dll --urls http://192.168...
VS Library - csproj Contents
Here are some standard things for the csproj file of a .NET library project. The top Property Group should list the following things: <PropertyGroup> <TargetFramework>net6.0</TargetFramework> <PackageId>OGA.NugetRepoClient.Lib</PackageId> <P...
.NET 5 Global Using Error
If you have a project that is targeting a .NET 5, and you see the following error, follow this page: The error indicates that your csproj file likely has a statement that only works in .NET6 (C# v10) and later. Open your csproj file and look for a statemen...
Create Nuget for Multiple Targets or Architectures
Creating nuget packages that contain libraries for multiple frameworks or runtimes, requires some non-trivial effort.So, this page explains the steps required. Some of this was taken from here: Non-Trivial Multi-Targeting with .NET Project Setup For multipl...