Before C# 9, to make a property immutable, you had to use constructor injection. This broke object initializers (`new Obj { Prop = val }`). The `init` accessor solves this by allowing setting a property only during object initialization. The ‘init’ Keyword Why this matters for DTOs It allows for consistent, valid state without massive […]
Read more →Category: Microsoft
Microsoft Corporation (NASDAQ: MSFT) is an American multinational corporation headquartered in Redmond, Washington, United States that develops, manufactures, licenses, and supports a wide range of products and services predominantly related to computing through its various product divisions. Established on April 4, 1975 to develop and sell BASIC interpreters for the Altair 8800, Microsoft rose to dominate the home computer operating system market with MS-DOS in the mid-1980s, followed by the Microsoft Windows line of operating systems.
Microsoft would also come to dominate the office suite market with Microsoft Office. The company has diversified in recent years into the video game industry with the Xbox and its successor, the Xbox 360 as well as into the consumer electronics and digital services market with Zune, MSN and the Windows Phone OS. The ensuing rise of stock in the company’s 1986 initial public offering (IPO) made an estimated three billionaires and 12,000 millionaires…
C# 9.0 Records: Immutable Data Types Done Right
Immutability is a cornerstone of robust distributed systems, but achieving it in C# has historically required copious boilerplate. C# 9.0 introduces Records, a first-class citizen for immutable data. Records provide value-based equality, non-destructive mutation, and concise syntax. The Syntax Evolution Value-Based Equality Records check equality by properties, not reference. Non-Destructive Mutation (‘with’ expressions) To modify […]
Read more →Blazor CSS Isolation: Scoped Styles in .NET 5
A preview feature for .NET 5 (arriving Nov 2020) is CSS Isolation. Similar to Vue’s `scoped` styles or React Modules, this prevents style leakage between components. How it Works Create a file matching the component name: `Counter.razor.css`. At build time, Blazor rewrites HTML with a unique attribute `b-123abc` and rewrites CSS: The Deep Combinator To […]
Read more →GraphQL with .NET: Hot Chocolate Library
Hot Chocolate is the premier GraphQL server for .NET. Unlike Rest APIs, GraphQL allows clients to ask for exactly what they need, solving over-fetching. Hot Chocolate 11 brings massive performance improvements and the “Banana Cake Pop” IDE. Schema Definition (Code-First) Handling Relationships (DataLoaders) The “N+1 Problem” is the enemy of GraphQL. Use DataLoaders to batch […]
Read more →Blazor Component Libraries: Building Reusable UI
Razor Class Libraries (RCLs) allow you to share Blazor components across multiple apps. With .NET Core 3.1 and upcoming .NET 5, they now support including static assets (CSS, JS, images) inside the NuGet package. This guide builds a reusable “Modal” component library. Project Structure Create a new RCL project: Static Web Assets Place CSS in […]
Read more →.NET 5 Preview: What’s Coming This November
.NET 5 unifies .NET Core and .NET Framework. Here’s what to expect when it releases in November. The Unification One .NET going forward C# 9 and F# 5 Single BCL across all platforms Top-level programs Records and init-only setters Performance Significant perf improvements in GC, JIT, and libraries. ARM64 support improved. References .NET 5 Preview
Read more →