Posts Tagged - dotnet

.NET Index

Introduction to .NET

VStudio

Visual Studio (shortcuts & debug)

meta

C# coding style
Code documentation in c#
Middleware

config

Launchsettings vs appsettings
User secrets

C# “basics”

Introduction to c#
c# methods
c# classes
Partial classes
Deconstruction
c# collections (lists, tuples…)
c# collections’ index and range operators

C#

Nullables
Class vs struct vs record (reference types vs value types)
Expression bodied members
Pattern matching
Generics

news in C#

C# 12
Collection expressions
Primary constructors
Lambda’s default values

C# 11
Raw string literals

lists and lambdas

Linq examples
Anonymous methods & lambda expressions
Delegates

async / await (TAP programming)

Async programming
Async best practices
Async with parallelism
Async with lambdas

advanced

Parallel code
Servicebus vs Queue
Streams and Files
Anonymous type objects
Events (pub/sub)

Razor Pages

Basic usage
Prevent Overposting

web API

Basic health checks
How to get headers
Caching
Validations
Newtonsoft
Dependency injection (& scope types)
Dependency injections with multiple implementations

testing

Setup testing with XUnit/NUnit, FluentAssertions, Moq & branch coverage
NUnit test examples for c#
XUnit test examples for c#
Mock multiple method calls with the same param type

.NET with AI

Integrate .NET with AI

(ORM) Entity Framework Core

Teoria EF Core
EF Core Scaffolding
EF Core Global Filters
Read-only statements performance improvement
Data models
EF Core multithreading

Read More

Microsoft Agent Framework (MAF)

Microsoft Agent Framework es un SDK y runtime para construir, orquestar y desplegar agentes de IA y workflows multi-agente en .NET y Python.

Antes de entrar en detalle es importante recalcar los avisos que dan en la documentación oficial

Si puedes hacer algo con una función determinista, hazlo. No lo hagas con un agente de IA ni con MAF
Si solo necesitas prompt-in / text-out, hazlo. Con MAF te estás complicando sin necesidad

Dicho esto, ventajas de usar MAF:

  • Proporciona una capa de abstracción para agentes
  • Soporte multi-proveedor (soporta Microsoft Foundry, Anthropic, Azure OpenAI, OpenAI, Ollama y más)
  • Interoperatibilidad de herramientas mediante MCP (Model Context Protocol) y A2A (Agent to Agent)

Agentes vs workflows

Agentes de IA - programas que usan modelos de IA generativa para procesar inputs, llamar herramientas y generar respuestas

Workflows - grafos que conectan agentes y funciones para tareas con múltiples pasos, type-safe, checkpoints y soporte human-in-the-loop

Debemos usar un agente cuando:

  • sea una tarea abierta o conversacional
  • necesitas una herramienta y planning autónomos
  • Una sola petición a un LLM (con tools) sea suficiente

En cambio, debemos usar un workflow cuando:

  • tengamos un proceso con pasos bien definidos
  • necesitamos control explícito sobre el orden de ejecución
  • debamos coordinar multiples agentes o funciones

Reference(s)

Microsoft Agent Framework Overview | Microsoft Learn Step 1: Your First Agent | Microsoft Learn

Read More

Visual Studio (Code)

Shortcuts and QoL features

  • ctrl + F12 - over a method call -> go directly to the method inside the interface’s implementation
  • ctrl + - - go back where you where after entering a method
  • ctrl + G - go to line number
  • ctrl + T - search for a class. If you want to search for UserController.cs you can type UCont and it will find it
  • ctrl + shift + P - search inside Visual Studio options
  • ctrl + D - duplicate actual line
  • alt + ↑ / ↓ - move code lines

Auto-complete placeholders

  • prop - creates a new property for a class
  • ctor - creates a new constructor
  • cw - creates a new Console.WriteLine() statement
  • try - creates a try-catch statement

To create a new property, type prop, hit twice tab and it creates a property template which you can navegate and override

Multi-caret and multi-cursor editing

(check this for more details)

For lines that are aligned

  • alt + mouse click - selects a block to edit
  • alt + shift + arrow - same with keyboard

For multiple places that are not aligned

  • ctrl + alt + mouse click - click where you want to add a caret
  • (select the word you want to match) alt + shift + ; - vstudio selects all locations that match selected text in the current document and you may edit them

    Debug in VsCode

    Watch a variable

    En la pestaña watch se puede introducir el nombre de una variable y al hacer debug mostrará siempre el valor de esta variable.

Read More

Introducción a .NET

CLR (Common language runtime)

Entorno de ejecucion para .NET. En tiempo de ejecucion el compilador de CLR convierte el codigo CIL en codigo nativo para el SO. Facilita la integración entre lenguajes.

CLR es la MV en la que se ejecutan nuestras apps. CLR se hizo para tener una capa de abstraccion entre las propias apps y el SO donde se ejecutaban.

El CLI se puede ejecutar en otros SO. El CLR se ejecuta solo en Windows.

Read More