Skip to content

Instantly share code, notes, and snippets.

{
"servers": {
"github/github-mcp-server": {
"type": "http",
"url": "https://api.githubcopilot.com/mcp/",
"version": "0.13.0"
}
}
}
ImmutableStack<int> stack = [1, 2, 3, 4, 5];
[CollectionBuilder(typeof(ImmutableStackBuilder), nameof(ImmutableStackBuilder.Create))]
public class ImmutableStack<T>
{
private readonly ImmutableList<T> _items;
internal ImmutableStack(){}
internal ImmutableStack(ImmutableList<T> items)
{
_items = items;
var stack = new ImmutableStack<int>(new[] { 1, 2, 3, 4, 5 });
public class ImmutableStack<T>
{
private readonly ImmutableList<T> _items;
public ImmutableStack(IEnumerable<T> items)
{
_items = ImmutableList.CreateRange(items);
}
// Stack operations...
int[] numbers = [1, 2, 3, 4, 5];
List<string> names = ["Alice", "Bob", "Charlie"];
new ServiceProviderOptions
{
ValidateOnBuild = true,
ValidateScopes = true // Enabled by default in Development
}
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddScoped<OrderService>();
// Still forgot IPaymentProcessor...
// Enable validation
builder.Host.UseServiceProviderFactory(new ServiceProviderFactory(
new ServiceProviderOptions
{
ValidateOnBuild = true
services.AddScoped<OrderService>(); // Depends on IPaymentProcessor
// Oops! Forgot to register IPaymentProcessor
[AllowAnonymous]
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
[AllowAnonymous]
public IActionResult About()