tag:blogger.com,1999:blog-277521262024-03-25T08:41:15.423+01:00Variable not foundArtículos, tutoriales, trucos, curiosidades, reflexiones y links sobre programación web
ASP.NET Core, MVC, Blazor, SignalR, Entity Framework, C#, Azure, Javascript...josé M. Aguilarhttp://www.blogger.com/profile/11683750380776435448noreply@blogger.comBlogger1482125tag:blogger.com,1999:blog-27752126.post-23474164130656196072024-03-25T08:05:00.002+01:002024-03-25T08:40:41.316+01:00Enlaces interesantes 561<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/05/entender-codigo-imposible-mediante.html">Entender código imposible mediante troceado y refactorización</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/10/mejoras-en-bloques-trycatch-de-c-6.html">Mejoras en bloques try/catch de C# 6</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/dotnet/introducing-dotnet-smart-components/">Introducing .NET Smart Components - AI-powered UI controls</a><br />
Daniel Roth</li>
<li><a href="https://www.syncfusion.com/blogs/post/yield-in-csharp.aspx">Working with yield in C#: Enhancing Efficiency and Code Clarity</a><br />
A. Yohan Malshika</li>
<li><a href="https://code-maze.com/csharp-avoid-await-in-loop/">Why Should We Avoid Using Await in a Loop in C#</a><br />
Anaedobe Nneka</li>
<li><a href="https://code-maze.com/csharp-how-to-resolve-ioptions-instance-inside-program-class/">How to Resolve IOptions Instance Inside Program Class in C#</a><br />
Georgi Georgiev</li>
<li><a href="https://code-maze.com/csharp-difference-between-await-and-task-wait/">Difference Between await and Task.Wait in C#</a><br />
Georgios Panagopoulos</li>
<li><a href="https://aaronstannard.com/dotnet-eventing-backslide/">.NET Developers Begging for Ecosystem Destruction</a><br />
Aaron Stannard</li>
<li><a href="https://steven-giesel.com/blogPost/f58777b8-e10b-4023-845b-9f5ad3b7e48f">NCronJob - Scheduling made easy</a><br />
Steven Giesel</li>
<li><a href="https://jeremydmiller.com/2024/03/19/conventional-message-routing-in-wolverine/">Conventional Message Routing in Wolverine</a><br />
Jeremy D. Miller</li>
<li><a href="https://code-maze.com/linq-execute-the-select-where-not-exist-sql-query-csharp/">Execute the SELECT WHERE NOT EXIST SQL Query Using LINQ</a><br />
Karthikeyan N. S.</li>
<li><a href="https://www.thomasclaudiushuber.com/2024/03/19/csharp-12-collection-expressions/">C# 12: Collection Expressions</a><br />
Thomas Claudius Huber</li>
<li><a href="https://dotnettips.wordpress.com/2024/03/20/general-performance-tips-for-microsoft-net-logging/">General Performance Tip: Logging</a><br />
David McCarter</li>
<li><a href="https://johnnyreilly.com/generate-word-doc-in-asp-net">Generate a Word document in ASP.NET</a><br />
John Reilly</li>
<li><a href="https://www.telerik.com/blogs/building-interactive-blazor-apps-webassembly">Building Interactive Blazor Apps with WebAssembly</a><br />
Ed Charbeneau</li>
<li><a href="https://code-maze.com/csharp-convert-iasyncenumerable-to-list/">How to Convert IAsyncEnumerable to List</a><br />
Caleb Okechukwu</li>
<li><a href="https://code-maze.com/csharp-benchmark-methods-performance-across-different-net-versions/">Benchmark a Method’s Performance on Different .NET Versions</a><br />
Januarius Njoku<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://pmichaels.net/aspire-net/">.Net Aspire - A Brief Introduction</a><br />
Paul Michaels</li>
<li><a href="https://www.infragistics.com/community/blogs/b/infragistics/posts/best-blazor-component-library">The Best Blazor Component Libraries to Consider</a><br />
Katie Mikova</li>
<li><a href="https://code-maze.com/aspnetcore-automatic-registration-of-minimal-api-endpoints/">Automatic Registration of Minimal API Endpoints in .NET</a><br />
Ivan Gechev</li>
<li><a href="https://www.meziantou.net/generate-openapi-specification-at-build-time-from-the-code-in-asp-net-core.htm">Generate OpenAPI specification at build time from the code in ASP.NET Core</a><br />
Gérald Barré</li>
<li><a href="https://khalidabuhakmeh.com/blazors-css-isolation-deep-issue-and-solution">Blazor’s CSS isolation ::deep issue and solution</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://www.devleader.ca/2024/03/19/autofac-in-asp-net-core-how-to-avoid-this-debugging-nightmare/">Autofac In ASP NET Core - How To Avoid A Debugging Nightmare</a><br />
Nick Cosentino</li>
<li><a href="https://www.syncfusion.com/blogs/post/whats-new-blazor-2024-vol-1.aspx">What’s New in Syncfusion Blazor: 2024 Volume 1</a><br />
Gayathri Ramalingam</li>
<li><a href="https://www.devleader.ca/2024/03/20/mudblazor-list-items-how-to-create-awesome-blazor-list-views/">MudBlazor List Items: How To Create Awesome Blazor List Views</a><br />
Nick Cosentino</li>
<li><a href="https://www.devleader.ca/2024/03/21/blazor-render-mode-how-to-avoid-dependency-injection-woes/">Blazor Render Mode – How To Avoid Dependency Injection Woes</a><br />
Nick Cosentino</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/semantic-kernel/guest-blog-building-your-custom-copilot-with-semantic-kernel/">Guest Blog: Building Your Custom Copilot with Semantic Kernel</a><br />
Sophia Lagerkran</li>
<li><a href="https://bartwullems.blogspot.com/2024/03/azure-static-web-app-api-integration.html">Azure Static Web App – API Integration</a><br />
Bart Wullems</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://blog.sellmair.io/composition-over-inheritance-my-refactoring-recipe">Composition over Inheritance: My refactoring recipe</a><br />
Sebastian Sellmair</li>
<li><a href="https://codeopinion.com/the-worst-domain-modeling-mistakes/">The WORST Domain Modeling Mistakes!</a><br />
Derek Comartin</li>
<li><a href="https://blog.3d-logic.com/2024/03/23/when-was-the-last-time-you-used-this-part-1-data-structures/">“When was the last time you used this?” – Part 1: Data Structures</a><br />
Pawel Kadluczka</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://formatexception.com/2024/03/adding-entityframework-and-sqlite-to-asp-net-core-web-api/">Adding EntityFramework and Sqlite to ASP.NET Core Web API – FormatException</a><br />
Brial Mullen</li>
<li><a href="https://www.milanjovanovic.tech/blog/implementing-soft-delete-with-ef-core">Implementing Soft Delete With EF Core</a><br />
Milan Jovanović</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://www.genbeta.com/inteligencia-artificial/test-manzana-tarea-para-alumnos-primaria-que-muchas-ia-suspenden-miserablemente-esta-razon">El 'test de la manzana': una tarea para alumnos de Primaria que muchas IA suspenden miserablemente. Esta es la razón</a><br />
Marcos Merino</li>
<li><a href="https://dev.to/ebad_k/building-a-gpt-model-from-the-ground-up-3dd0">Building a GPT Model from the Ground Up!</a><br />
Ebad Khan</li>
<li><a href="https://devblogs.microsoft.com/semantic-kernel/image-to-text-with-semantic-kernel-and-huggingface/">Image to Text with Semantic Kernel and HuggingFace</a><br />
Sophia Lagerkran</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://web.dev/blog/array-with?hl=es-419">Actualizaciones de arrays inmutables con Array.prototype.with</a><br />
Jad Joubran</li>
<li><a href="https://dev.to/serenepine/six-novel-features-in-javascript-for-2024-25de">Six Novel Features in JavaScript for 2024</a><br />
Serenepine</li>
<li><a href="https://www.telerik.com/blogs/react-basics-getting-started-react-graphql">React Basics: Getting Started with React and GraphQL</a><br />
Hassan Djirdeh</li>
<li><a href="https://dev.to/antonzo/hoisting-of-variables-functions-classes-types-interfaces-in-javascripttypescript-3el5">Hoisting of Variables, Functions, Classes, Types, Interfaces in JavaScript/TypeScript</a><br />
Anton Zamay</li>
<li><a href="https://briantree.se/angular-animations-tutorial-parallel-animations/">Angular Animations Tutorial: Parallel Animations</a><br />
Brian Treese</li>
<li><a href="https://www.blackslate.io/articles/a-comprehensive-guide-to-trumbowyg-the-wysiwyg-editor-for-web-developers">A Comprehensive Guide to Trumbowyg: The WYSIWYG Editor for Web Developers</a><br />
DevGroves Technologies</li>
<li><a href="https://webkit.org/blog/15190/implementing-vertical-form-controls/">Implementing Vertical Form Controls</a><br />
Aditya Keerthi</li>
<li><a href="https://claritydev.net/blog/immutable-array-operations-tosorted-tospliced-toreversed">Immutable Array Operations In JavaScript: Introducing toSorted, toSpliced, and toReversed</a><br />
Alex Khomenko</li>
<li><a href="https://textslashplain.com/2024/03/20/pushstate-and-url-blocking/">pushState and URL Blocking</a><br />
Eric Lawrence</li>
<li><a href="https://www.telerik.com/blogs/how-does-angular-compare-to-jquery">How Does Angular Compare to jQuery?</a><br />
Hassan Djirdeh</li>
<li><a href="https://makemychance.com/form-submission-in-javascript/?expand_article=1">Form Submission in Javascript: A Comprehensive Guide</a><br />
Malik Arsalan</li>
<li><a href="https://webdesign.tutsplus.com/how-to-build-a-text-to-voice-application-with-javascript--cms-108609t">How to Build a Text-to-Voice Application With JavaScript</a><br />
Esther Vaati</li>
<li><a href="https://www.telerik.com/blogs/exploring-latest-features-coming-javascript-es2023">Exploring the Latest Features Coming to JavaScript—ES2023</a><br />
Thomas Findlay</li>
<li><a href="https://www.bennadel.com/blog/4617-reading-element-attributes-collection-in-javascript.htm">Reading Element Attributes Collection In JavaScript</a><br />
Ben Nadel</li>
<li><a href="https://runjs.app/blog/equations-that-changed-the-world-rewritten-in-javascript">17 Equations that Changed the World - Rewritten in JavaScript</a><br />
RunJS</li>
<li><a href="https://css-tricks.com/accessible-forms-with-pseudo-classes/">Accessible Forms with Pseudo Classes</a><br />
Chris DeMars</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://bartwullems.blogspot.com/2024/03/nuget-offline-support.html">NuGet – Offline support</a><br />
Bart Wullems</li>
<li><a href="https://christianheilmann.com/2024/03/18/giving-your-app-a-temporary-public-url-with-vs-code-port-forwarding/">Giving your app a temporary public URL with VS Code port forwarding</a><br />
Christian Heilmann</li>
<li><a href="https://www.syncfusion.com/blogs/post/dev-tunnel-remote-debug-vs-2022.aspx">Effortless Remote Debugging with Dev Tunnel in Visual Studio 2022</a><br />
Jayakumar Duraisamy</li>
<li><a href="https://techcommunity.microsoft.com/t5/microsoft-developer-community/how-to-use-comments-as-prompts-in-github-copilot-for-visual/ba-p/4091503">How to use Comments as Prompts in GitHub Copilot for Visual Studio</a><br />
Laurent Bugnion</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://johnnys.news/2024/03/Transient-ViewModels-with-NET-MAUI-Blazor-Hybrid">Sharing ViewModels in .NET MAUI Blazor Hybrid</a><br />
Joachim Leonfellner</li>
<li><a href="https://www.mitchelsellers.com/blog/article/deploying-net-maui-blazor-app-to-programfiles">Deploying .NET MAUI Blazor App to ProgramFiles'</a><br />
Mitchel Sellers</li>
<li><a href="https://egvijayanand.in/2024/03/22/dotnet-maui-developer-tips-margin-and-padding/">.NET MAUI – Margin and Padding</a><br />
Vijay Anand</li>
<li><a href="https://www.telerik.com/blogs/beyond-basics-learning-text-speech-net-maui">Beyond the Basics: Learning Text-to-Speech in .NET MAUI</a><br />
Leomaris Reyes</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/actualidad-nuevo-runtime-js-android-15-swift-5-10-gemma-llm-microsoft-y-mistral-ai-wddfs-mitos-sobre-desarrolladores-senior-doom-en-la-consola-del-navegador.aspx">Actualidad: nuevo runtime JS, Android 15, Swift 5.10, Gemma LLM, Microsoft y Mistral AI, WDDFS, mitos sobre desarrolladores senior, Doom en la consola del navegador...</a><br />
CampusMVP</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-7154662174588520032024-03-19T08:05:00.022+01:002024-03-19T08:05:00.129+01:00Cómo saber si un componente Blazor se está renderizando con SSR o de forma interactiva<img alt="Blazor" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBUgEtI1OgBX4GxZGmDIH5m2kDKsfmq0N_mkTa_9NE1jReSlOABaWbJtXM1L5Szkb4uCudiBdzjLebOyvg6Mxv-zMcwgfan8PveUpX5nrHirqjFzJXJQUheXB3vaIEYiXXt8FGTNSpPi_4s5LXOVIKKgcwK-FX_3aciAHC6BYyYZ6rvstXvxo/s16000/Blazor.png" title="Blazor" width="100%" />
<p>Como sabéis, con ASP.NET Core 8 se ha incluido la posibilidad de que una página Blazor sea capaz de procesar directamente una petición HTTP, renderizando sus componentes y retornando el resultado HTML completo al lado cliente de forma estática. Es ya <a href="https://www.variablenotfound.com/2023/11/blazor-server-side-rendering-en-net-8.html">lo vimos hace algún tiempo cuando hablamos de Server-Side Rendering (SSR)</a>, una de las piezas clave para conseguir que Blazor sea un <i>framework</i> <em>fullstack</em>.</p>
<p>En la práctica, esta opción posibilita la implementación de sitios estáticos completos, como los que construiríamos con ASP.NET Core MVC, Razor Pages o cualquier otro tipo de tecnología de servidor, pero con la gran ventaja de que en este caso estaremos <strong>beneficiándonos del fantástico modelo de componentes Blazor, que es una gozada</strong> en términos de productividad y facilidad de uso, y sin perder la posibilidad de activar la interactividad de los componentes (su capacidad para reaccionar ante eventos del usuario), una vez que el HTML ha sido descargado en el navegador.</p>
<p>En aquél momento vimos que SSR no requiere una programación específica: los mismos componentes interactivos que luego podemos ejecutar en el lado cliente o servidor pueden ser renderizados mediante SSR de forma estática en el <em>backend</em>. Sin embargo, en algunos momentos nos <b>podría resultar interesante saber si un componente está funcionando en modo estático (SSR) o interactivo (los tradicionales Blazor WebAssembly o Blazor Server)</b>.<span></span></p><a name='more'></a><p></p>
<p>En principio, no hay una forma "oficial" de saberlo. Sin embargo, podríamos detectarlo de forma sencilla basándonos en algo que <a href="https://www.variablenotfound.com/2024/03/acceder-al-objeto-httpcontext-desde.html">vimos poco tiempo atrás</a>: cuando se está procesando una petición mediante SSR, el <em>framework</em> introduce automáticamente como parámetro en cascada un objeto de tipo <code>HttpContext</code> con toda la información relativa a la petición actual.</p>
<p>Por tanto, <strong>si un componente recibe un parámetro en cascada de tipo <code>HttpContext</code>, podemos estar seguros de que se está ejecutando en modo SSR, mientras que si no lo recibe, es que se está ejecutando de forma interactiva</strong>. De esta forma, podemos definir un parámetro en cascada de este tipo en el componente, y comprobar si es <code>null</code> o no, como vemos a continuación:</p>
<pre><code class="language-blazor">@page "/test"
@if(HttpContext is null)
{
<p>Este componente se está ejecutando en modo interactivo</p>
}
else
{
<p>Este componente se está ejecutando en modo SSR</p>
}
@code {
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
}
</code></pre>
<p>Sin embargo, como también vimos en el post anterior, <strong>esta solución no es correcta del todo</strong>, porque sólo deberíamos acceder a <code>HttpContext</code> desde en el componente raíz de la aplicación (normalmente <code>App.razor</code>). Aunque funcionará bien en componentes definidos en el proyecto principal de una Aplicación Web Blazor, que son ejecutados siempre en el servidor, no funcionaría en componentes definidos en el proyecto que se ejecuta en el lado cliente, <code><MyProject>.Client</code>; de hecho, ni siquiera compilaría, porque <b>la clase <code>HttpContext</code> es una abstracción de servidor</b> y no existe en el lado cliente.</p>
<p>Si queremos dar una solución más general, válida para componentes definidos en servidor y en cliente, tendríamos que <b>determinar si estamos en modo SSR desde el componente raíz</b>, y luego hacer llegar esa información a todos los componentes descendientes en la jerarquía.</p>
<p>Este podría ser el código en el componente raíz. Como podemos ver, hacemos que el componente <code><CascadingValue></code> rodee a <code><Routes></code>, de forma que todas las páginas y sus componentes descendientes podrán recibir el valor de <code>IsSSR</code>, obtenido a partir de la existencia o no de <code>HttpContext</code>:</p>
<pre><code class="language-blazor">...
<body>
<CascadingValue IsFixed="true" Name="IsSSR" Value="IsSSR">
<Routes />
</CascadingValue>
<script src="_framework/blazor.web.js"></script>
</body>
...
@code
{
[CascadingParameter]
public HttpContext? HttpContext { get; set; }
private bool IsSSR => HttpContext is not null;
}
</code></pre>
<p>Y más adelante, en el componente que queramos detectar si se está ejecutando en modo SSR o interactivo, podríamos hacer lo siguiente:</p>
<pre><code class="language-blazor">@page "/mypage"
...
@if(IsSSR)
{
<p>Este componente se está ejecutando en modo SSR</p>
}
else
{
<p>Este componente se está ejecutando en modo interactivo</p>
}
@code {
[CascadingParameter(Name = "IsSSR")]
private bool IsSSR { get; set; }
}
</code></pre>
<p>Espero que os sea de utilidad :)</p>
<p>Publicado en Variable not found.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-44649517275261055342024-03-18T08:28:00.001+01:002024-03-18T08:28:15.167+01:00Enlaces interesantes 560<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/05/constructores-estaticos-inicializadores.html">Constructores estáticos, inicializadores de módulos y startup hooks: tres formas de ejecutar código antes que Program.Main()</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/10/inicializacion-de-diccionarios-en-c-6.html">Inicialización de diccionarios en C# 6</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://aalmada.github.io/posts/Measuring-dotnet-performance/">Measuring .NET Performance: Unleashing the Power of BenchmarkDotNet</a><br />
Antão Almada</li>
<li><a href="https://code-maze.com/csharp-fastest-way-to-get-the-first-n-characters-of-a-string/">Fastest Way to Get the First N Characters of a String in C#</a><br />
Januarius Njoku</li>
<li><a href="https://www.stevejgordon.co.uk/understanding-system-diagnostics-diagnosticsource-and-diagnosticlistener-part-1">Understanding System.Diagnostics DiagnosticSource and DiagnosticListener (Part 1)</a><br />
Steve Gordon</li>
<li><a href="https://www.devleader.ca/2024/03/11/how-to-automatically-cast-between-types-in-c/">How to Automatically Cast Between Types in C#</a><br />
Nick Cosentino</li>
<li><a href="https://andrewlock.net/behind-the-implementation-of-dotnets-priorityqueue/">Behind the implementation of .NET's PriorityQueue</a><br />
Andrew Lock</li>
<li><a href="https://www.thomasclaudiushuber.com/2024/03/11/csharp-12-primary-constructors/">C# 12: Primary Constructors</a><br />
Thomas Claudius Huber</li>
<li><a href="https://blog.elmah.io/mocking-httpclient-requests-for-csharp-unit-tests/">Mocking HttpClient requests for C# unit tests</a><br />
Thomas Ardal</li>
<li><a href="https://devblogs.microsoft.com/dotnet/get-started-with-dotnet-ai-quickstarts/">Get started with .NET 8 and AI using new quickstart tutorials</a><br />
Jordan Matthiesen</li>
<li><a href="https://code-maze.com/csharp-fastest-way-to-generate-a-random-boolean/">Fastest Way to Generate a Random Boolean in C#</a><br />
Matjaz Prtenjak</li>
<li><a href="https://code-maze.com/csharp-use-stringpool-to-reduce-string-allocations/">How to Use StringPool to Reduce String Allocations in C#</a><br />
Osman Sokuoglu</li>
<li><a href="https://www.devleader.ca/2024/03/12/plugin-architecture-in-c-for-improved-software-design/">Plugin Architecture in C# for Improved Software Design</a><br />
Nick Cosentino</li>
<li><a href="https://dev.to/grantdotdev/why-i-dont-use-automapper-in-net-12i6">Why I Don't Use AutoMapper in .Net</a><br />
Grant Riordan</li>
<li><a href="https://jeremydmiller.com/2024/03/14/linq-query-improvements-in-marten-7/">LINQ Query Improvements in Marten 7</a><br />
Jeremy D. Miller</li>
<li><a href="https://www.devleader.ca/2024/03/13/async-event-handlers-in-c-what-you-need-to-know/">Async Event Handlers in C#: What You Need to Know</a><br />
Nick Cosentino</li>
<li><a href="https://code-maze.com/csharp-comparing-performance-of-the-switch-and-if-else-statements/">Comparing Performance of the switch and if-else Statements in C#</a><br />
Michal Kaminski</li>
<li><a href="https://www.devleader.ca/2024/03/14/activator-createinstance-vs-type-invokemember-a-clear-winner/">Activator.CreateInstance vs Type.InvokeMember – A Clear Winner?</a><br />
Nick Cosentino<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://learn.microsoft.com/es-es/dotnet/aspire/whats-new/preview-4">.NET Aspire preview 4</a><br />
David Pine</li>
<li><a href="https://steven-giesel.com/blogPost/0827131c-9b33-4c92-a2fa-5dd6616b72f9">bUnit v2 - The Blazor unit testing library vNext</a><br />
Steven Giesel</li>
<li><a href="https://bartwullems.blogspot.com/2024/03/aspnetcorehttpabstractions-is-deprecated.html">AspNetCore.Http.Abstractions is deprecated</a><br />
Bart Wullems</li>
<li><a href="https://www.telerik.com/blogs/blazor-basics-advanced-blazor-form-validation">Blazor Basics: Advanced Blazor Form Validation</a><br />
Claudio Bernasconi</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/dotnet/generate-dotnet-secrets-automatically-from-azure-deployment/">Generate Local .NET Secrets from Azure Deployments</a><br />
Frank Boucher</li>
<li><a href="https://techcommunity.microsoft.com/t5/azure-sql-blog/azure-sql-trigger-binding-for-azure-functions-goes-ga/ba-p/4082928">Azure SQL Trigger Binding for Azure Functions goes GA</a><br />
Brian Spendolini</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://www.devleader.ca/2024/03/08/the-facade-design-pattern-in-c-how-to-simplify-complex-subsystems/">The Facade Design Pattern in C#: How to Simplify Complex Subsystems</a><br />
Nick Cosentino</li>
<li><a href="https://blog.ploeh.dk/2024/03/11/boundaries-are-explicit/">Boundaries are explicit</a><br />
Mark Seemann</li>
<li><a href="https://www.zainrizvi.io/blog/falsehoods-programmers-believe-about-time-zones/">Falsehoods programmers believe about time zones</a><br />
Zain Rizvi</li>
<li><a href="https://www.code4it.dev/blog/code-coverage-must-not-be-the-target/">Why reaching 100% Code Coverage must NOT be your testing goal (with examples in C#)</a><br />
Davide Bellone</li>
<li><a href="https://codeopinion.com/events-are-an-api-treat-them-like-one/">Events are an API. Treat them like one.</a><br />
Derek Comartin</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://dateo-software.de/blog/transaction-entity-framework">A primer on transaction management in Entity Framework</a><br />
Dennis Frühauff</li>
<li><a href="https://dev.to/admirmujkic/essential-strategies-and-practices-for-entity-framework-core-24kf">Essential Strategies and Practices for Entity Framework Core</a><br />
Admir Mujkic</li>
<li><a href="https://erikdarling.com/the-how-to-write-sql-server-queries-correctly-cheat-sheet-cross-apply-and-outer-apply/">The How To Write SQL Server Queries Correctly Cheat Sheet: Cross Apply And Outer Apply</a><br />
Erik Darling</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://stephenwalther.com/how-much-does-it-cost-to-call-openai-apis/">How Much Does It Cost to Call OpenAI APIs?</a><br />
Stephen Walther</li>
<li><a href="https://stephenwalther.com/calling-custom-functions-with-chatgpt/">Calling Custom Functions with ChatGPT</a><br />
Stephen Walther</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://blog.sachinchaurasiya.dev/type-safety-in-typescript-unknown-vs-any">Type Safety in TypeScript</a><br />
Sachin Chaurasiya</li>
<li><a href="https://www.syncfusion.com/blogs/post/javascript-unit-test-frameworks.aspx">7 JavaScript Unit Test Frameworks Every Developer Should Know</a><br />
Binara Prabhanga</li>
<li><a href="https://binaryigor.com/htmx-and-web-components-a-perfect-match.html">HTMX and Web Components: a Perfect Match</a><br />
Igor Roztropiński</li>
<li><a href="https://event-driven.io/en/how_to_tackle_esmodules_compatibility_issues/">How to tackle compatibility issues in ECMA Script modules (and in general)</a><br />
Oskar Dudycz</li>
<li><a href="https://www.telerik.com/blogs/building-real-time-app-react-node-websockets">Building A Real-Time App with React, Node and WebSockets</a><br />
Thomas Findlay</li>
<li><a href="https://khalidabuhakmeh.com/how-to-use-no-class-frameworks-to-move-fast-in-style">How to use No-Class Frameworks to Move Fast in Style</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://www.lambdatest.com/blog/centering-an-image-in-css/">Centering an Image in CSS: A Detailed Guide</a><br />
Alex Anie</li>
<li><a href="https://css-tricks.com/almanac/properties/w/will-change/">CSS: will-change</a><br />
Robin Rendle</li>
<li><a href="https://www.webdevstory.com/advanced-javascript-features-unnoticed/">25 Unnoticeable Features of JavaScript</a><br />
M. Mainul Hasan</li>
<li><a href="https://davidwalsh.name/detect-caps-lock">Detect Caps Lock with JavaScript</a><br />
David Walsh</li>
<li><a href="https://www.kirupa.com/data_structures_algorithms/random_walk.htm">Creating a Random Walk Simulation</a><br />
Kirupa Chinnathambi</li>
<li><a href="https://www.telerik.com/blogs/vue-3-typescript-jump-start">Vue 3 with TypeScript Jump-Start</a><br />
Marina Mosti</li>
<li><a href="https://www.telerik.com/blogs/debouncing-your-framework">Debouncing in Your Framework</a><br />
Jonathan Gamble</li>
<li><a href="https://www.blackslate.io/articles/chartjs-visualization-library-a-detailed-walkthrough">ChartJs Visualization Library</a><br />
DevGroves Technologies</li>
<li><a href="https://www.telerik.com/blogs/react-vs-angular-component-architecture">React vs. Angular: Component Architecture</a><br />
Christian Nwamba</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://jvns.ca/blog/2024/03/08/how-head-works-in-git/">How HEAD works in git</a><br />
Julia Evans</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/introducing-visual-studio-17-10-preview-2-is-here/">Introducing Visual Studio 17.10 – Preview 2 is Here!</a><br />
Mark Downie</li>
<li><a href="https://devblogs.microsoft.com/dotnet/unity-extension-for-visual-studio-code-now-generally-available/">Unity extension for Visual Studio Code - Now Generally Available</a><br />
Jb Evain</li>
<li><a href="https://devblogs.microsoft.com/nuget/refining-your-search-introducing-nuget-orgs-compatible-framework-filters/">Refining Your Search: Introducing NuGet.org's Compatible Framework Filters</a><br />
Advay Tandon</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/03/13/generate-unit-tests-using-ai/">Generate Unit Tests Using AI Assistant</a><br />
Andrii Rublov</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://egvijayanand.in/2024/03/13/what-is-new-in-dotnet-maui-9-preview-2/">What’s New in .NET MAUI 9 Preview 2</a><br />
Vijay Anand</li>
<li><a href="https://www.syncfusion.com/blogs/post/tolerate-typos-maui-autocomplete.aspx">Enhancing User Experience: Implementing Typos Tolerance in .NET MAUI Autocomplete</a><br />
Selva Ganapathy Kathiresan</li>
<li><a href="https://www.telerik.com/blogs/sands-maui-issue-136">Sands of MAUI: Issue #136</a><br />
Sam Basu</li>
<li><a href="https://www.syncfusion.com/blogs/post/dotnet-maui-2024-volume-1.aspx">Introducing the 11th Set of New .NET MAUI Controls and Features</a><br />
Gayathri Ramalingam</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/microsoft-elimina-el-subsistema-android-de-windows.aspx">Microsoft elimina el subsistema Android de Windows</a><br />
CampusMVP</li>
<li><a href="https://www.elladodelmal.com/2024/03/la-historia-del-primer-videojuego.html">La historia del Primer Videojuego Español del que hay constancia</a><br />
Manuel Llaca Carrera</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-17566126061113944732024-03-12T08:05:00.037+01:002024-03-12T08:38:14.908+01:00Acceder al objeto HttpContext desde componentes Blazor<img alt="Blazor" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBUgEtI1OgBX4GxZGmDIH5m2kDKsfmq0N_mkTa_9NE1jReSlOABaWbJtXM1L5Szkb4uCudiBdzjLebOyvg6Mxv-zMcwgfan8PveUpX5nrHirqjFzJXJQUheXB3vaIEYiXXt8FGTNSpPi_4s5LXOVIKKgcwK-FX_3aciAHC6BYyYZ6rvstXvxo/s16000/Blazor.png" title="Blazor" width="100%" />
<p>Los que llevamos muchos años programando con ASP.NET/ASP.NET Core y todos los <em>frameworks</em> que han ido surgiendo en su ecosistema, estamos familiarizados con el concepto de "contexto HTTP".</p>
<p>Materializado en forma de objeto de tipo <code>HttpContext</code>, el contexto HTTP es una de las piezas fundamentales de la infraestructura de ASP.NET Core, y nos permite acceder a información sobre la petición HTTP que se está procesando, como los encabezados, el cuerpo de la petición, las cookies, etc., así como base para la generación de la propia respuesta a través de su propiedad <code>Response</code>. En muchos escenarios, se trata de un recurso imprescindible para procesar la petición de la forma adecuada, por lo que estamos acostumbrados a usarlo cuando es conveniente.</p>
<p>Sin embargo, cuando saltamos a Blazor, pronto nos llama la atención que <code>HttpContext</code> no está disponible. Y si lo pensamos, esto tiene bastante sentido en los dos modos de renderización clásicos:</p>
<ul>
<li>
<p>En Blazor WebAssembly, dado que el código .NET se ejecuta directamente <strong>en el cliente, no existen peticiones que procesar y, por tanto, no existe <code>HttpContext</code></strong>. Se trata de una abstracción que sólo existe en el <em>backend</em>.</p>
</li>
<li>
<p>En Blazor Server, aunque el código se está ejecutando en el servidor, tampoco tenemos disponible <code>HttpContext</code> porque realmente no existen peticiones: el lado cliente y servidor se comunican mediante un canal <em>websockets</em> implementado con SignalR, que es por donde viajan ascendentemente las acciones realizadas por el usuario y descendentemente las actualizaciones del DOM de la página.</p>
</li>
</ul>
<p>Con la llegada de Blazor 8, ha tomado relevancia el nuevo modo de renderizado, llamado <em>Server-Side Rendering</em> (SSR) o renderización en el lado servidor, que ya <a href="https://www.variablenotfound.com/2023/11/blazor-server-side-rendering-en-net-8.html">vimos por aquí hace algún tiempo</a>.</p>
<p>Como ya sabemos, el funcionamiento de Blazor SSR es similar al de otros <em>frameworks</em> de <em>backend</em> puros, como MVC o Razor Pages: el servidor recibe la petición, la procesa y genera una respuesta HTML que se envía al cliente. <strong>En este escenario, durante el proceso del componente Blazor sí existe un contexto HTTP</strong>.<span></span></p><a name='more'></a><p></p>
<p>En estos casos, el <em>framework</em> introduce en la cascada de parámetros un objeto de tipo <code>HttpContext</code> que podemos recuperar fácilmente desde cualquier componente usando el atributo <code>[CascadingParameter]</code> sobre una propiedad pública de este tipo, por ejemplo así:</p>
<pre><code class="language-blazor">@code {
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
}
</code></pre>
<p>Simplemente con esto, ya podríamos usar el objeto <code>HttpContext</code> para acceder a la información de la petición, o incluso modificar la respuesta. En el siguiente bloque de código podemos ver un ejemplo simple, donde mostramos el contenido del encabezado <code>Host</code> de la petición y modificamos el código de estado de la respuesta:</p>
<pre><code class="language-blazor">@page "/Test"
Host: @HttpContext.Request.Host
@code
{
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
protected override void OnInitialized()
{
HttpContext.Response.StatusCode = 210;
}
}
</code></pre>
<p>Eso sí, tened en cuenta que, <strong>dado que <code>HttpContext</code> es una abstracción sólo válida en el lado servidor, no podremos usarla en el proyecto cliente (<code><MiProyecto>.Client)</code></strong> de la Blazor Web App, puesto que sus componentes se ejecutan en el navegador y allí no existe el contexto HTTP. De hecho, según indican <a href="https://learn.microsoft.com/es-es/aspnet/core/blazor/security/?view=aspnetcore-8.0#ihttpcontextaccessorhttpcontext-in-razor-components">en la documentación oficial</a>, sólo deberíamos usarla en el componente raíz (normalmente <code>App.razor</code>).</p><p>Si desde el lado cliente quisiéramos acceder a datos presentes en el contexto, como encabezados, <i>cookies</i> <code>HttpOnly</code> o similares, tendríamos que buscar la forma de obtener esos valores desde el servidor y hacerlos llegar al lado cliente. Publicaré un post futuro donde podamos ver un ejemplo de esto.</p>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-3797309200067313752024-03-11T08:05:00.008+01:002024-03-11T08:05:00.124+01:00Enlaces interesantes 559<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/04/requerir-parametros-de-la-query-string.html">Requerir parámetros de la query string en ASP.NET Core</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/10/rendimiento-de-nameof-en-c-6.html">Rendimiento de nameof en C#</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://anthonysimmon.com/key-derivation-dotnet-using-hkdf/">Key derivation in .NET using HKDF</a><br />
Anthony Simmon</li>
<li><a href="https://andrewlock.net/an-introduction-to-the-heap-data-structure-and-dotnets-priority-queue/">An introduction to the heap data structure and .NET's priority queue</a><br />
Andrew Lock</li>
<li><a href="https://www.devleader.ca/2024/03/03/how-to-use-polly-in-c-easily-handle-faults-and-retries/">How To Use Polly In C#: Easily Handle Faults And Retries</a><br />
Nick Cosentino</li>
<li><a href="https://bartwullems.blogspot.com/2024/03/configureawaitoptions-in-net-8.html">ConfigureAwaitOptions in .NET 8</a><br />
Bart Wullems</li>
<li><a href="https://code-maze.com/dotnet-introduction-to-brighter/">Introduction to Brighter in .NET</a><br />
Code Maze</li>
<li><a href="https://dotnettips.wordpress.com/2024/03/02/unveiling-spargine-8-a-comprehensive-guide-to-net-8-integration-and-exciting-feature-updates/">Unveiling Spargine 8: A Comprehensive Guide to .NET 8 Integration and Exciting Feature Updates</a><br />
David McCarter</li>
<li><a href="https://www.devleader.ca/2024/03/04/implicit-operators-in-c-how-to-simplify-type-conversions/">Implicit Operators in C#: How To Simplify Type Conversions</a><br />
Nick Cosentino</li>
<li><a href="https://www.meziantou.net/optional-parameters.htm">Optional parameters may appear in the middle of the parameter list</a><br />
Gérald Barré</li>
<li><a href="https://nblumhardt.com/2024/03/from-serilog-timings-to-tracing/">From SerilogTimings to SerilogTracing</a><br />
Nicholas Blumhardt</li>
<li><a href="https://code-maze.com/csharp-read-a-text-file-without-specifying-the-full-path/">Read a Text File Without Specifying the Full Path in C#</a><br />
Aneta Muslic</li>
<li><a href="https://steven-giesel.com/blogPost/a8aa3385-8829-444a-b269-7ecb38aeaf2f">Typesafety in xUnit with TheoryData<T></a><br />
Steven Giesel</li>
<li><a href="https://bartwullems.blogspot.com/2024/03/using-parameters-in-benchmarkdotnet.html">Using parameters in BenchmarkDotNet</a><br />
Bart Wullems</li>
<li><a href="https://www.devleader.ca/2024/03/06/extract-method-refactoring-technique-in-c-what-you-need-to-know/">Extract Method Refactoring Technique in C# – What You Need To Know</a><br />
Nick Cosentino</li>
<li><a href="https://www.darrenhorrocks.co.uk/stop-using-stringtolowerinvariant-to-compare-strings-invariantculture-slow/">Stop Using string.ToLowerInvariant() to Compare Strings. InvariantCulture Comparisons are Slow</a><br />
Darren Horrocks</li>
<li><a href="https://code-maze.com/csharp-difference-between-abstraction-and-encapsulation/">Difference Between Abstraction and Encapsulation in C#</a><br />
Almir Tihak</li>
<li><a href="https://dotnettips.wordpress.com/2024/03/08/general-performance-tips-for-microsoft-net-hashing-data/">General Performance Tip: Hashing Data</a><br />
David McCarter</li>
<li><a href="https://neuecc.medium.com/r3-a-new-modern-reimplementation-of-reactive-extensions-for-c-cf29abcc5826">R3 — A New Modern Reimplementation of Reactive Extensions for C#</a><br />
Yoshifumi Kawai<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://damienbod.com/2024/03/04/multi-client-blob-storage-access-using-asp-net-core-with-entra-id-authentication-and-rbac/">Multi client blob storage access using ASP.NET Core with Entra ID authentication and RBAC</a><br />
Damien Bowden</li>
<li><a href="https://jamiemaguire.net/index.php/2024/03/03/an-intro-to-minimal-apis-with-asp-net-core-and-net8/">An Intro to Minimal APIs with ASP.NET Core and .NET 8.0</a><br />
Jamie Maguire</li>
<li><a href="https://www.roundthecode.com/dotnet-tutorials/how-to-create-add-custom-middleware-aspnet-core">Creating your own custom middleware in ASP.NET Core</a><br />
David Grace</li>
<li><a href="https://jonhilton.net/paypal-net8-ssr/">The quickest way to integrate PayPal checkout with Blazor SSR in .NET 8</a><br />
Jon Hilton</li>
<li><a href="https://www.telerik.com/blogs/blazor-basics-validating-form-data">Blazor Basics: Validating Form Data with Blazor</a><br />
Claudio Bernasconi</li>
<li><a href="https://bartwullems.blogspot.com/2024/03/performance-test-your-aspnet-core-app.html">Performance test your ASP.NET Core app using Bombardier</a><br />
Bart Wullems</li>
<li><a href="https://www.codeproject.com/Articles/5378651/ASP-NET-8-Multilingual-Application-with-Single-Res">ASP.NET 8 – Multilingual Application with Single Resx File</a><br />
Mark Pelf</li>
<li><a href="https://www.hanselman.com/blog/updating-to-net-8-updating-to-ihostbuilder-and-running-playwright-tests-within-nunit-headless-or-headed-on-any-os">Updating to .NET 8, updating to IHostBuilder, and running Playwright Tests within NUnit headless or headed on any OS</a><br />
Scott Hanselman</li>
<li><a href="https://weblog.west-wind.com/posts/2024/Mar/08/Comparing-Raw-ASPNET-Request-Throughput-across-Versions">Comparing Raw ASP.NET Request Throughput across Versions</a><br />
Rick Strahl</li>
<li><a href="https://baaijte.net/blog/microsoft-fluentui-aspnetcore.components-4.5/">What's new for the Microsoft Fluent UI Blazor libraries 3.6 and 4.5</a><br />
Vincent Baaij</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://www.tpeczek.com/2024/03/azure-functions-extensibility.html">Azure Functions Extensibility - Extensions and Isolated Worker Model</a><br />
Tomasz Pęczek</li>
<li><a href="https://pmichaels.net/application-insights-custom-alerts/">Custom Alerts in Application Insights</a><br />
Paul Michaels</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/seguridad-del-codigo-el-codigo-zombi-y-como-te-afecta.aspx">Seguridad del código: el código zombi y cómo te afecta</a><br />
CampusMVP</li>
<li><a href="https://martinfowler.com/articles/patterns-legacy-displacement/event-interception.html">Event Interception</a><br />
Ian Cartwright, Rob Horn & James Lewis</li>
<li><a href="https://codeopinion.com/event-driven-architecture-lost-its-way/">Event-Driven Architecture lost its way</a><br />
Derek Comartin</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://towardsdev.com/3-essential-sql-tricks-you-absolutely-need-to-know-1005084a8579">3 Essential SQL Tricks You Absolutely Need to Know</a><br />
Nariman Esmaiely Fard</li>
<li><a href="https://devblogs.microsoft.com/dotnet/get-started-milvus-vector-db-dotnet/">Get Started with Milvus Vector DB in .NET</a><br />
Luis Quintanilla</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://www.anthropic.com/news/claude-3-family">Introducing the next generation of Claude</a><br />
Anthropic</li>
<li><a href="https://jasonhaley.com/2024/02/27/azure-vector-search-ai-assistant/">Demo Review: Azure Vector Search AI Assistant</a><br />
Jason Haley</li>
<li><a href="https://devblogs.microsoft.com/semantic-kernel/architecting-ai-apps-with-semantic-kernel/">Architecting AI Apps with Semantic Kernel</a><br />
Sophia Lagerkran</li>
<li><a href="https://devblogs.microsoft.com/semantic-kernel/navigating-the-transition-semantic-kernel-net-v1-migration-guide/">Navigating the Transition: Semantic Kernel .NET V1 Migration Guide</a><br />
Sophia Lagerkran</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/?retry">Announcing TypeScript 5.4</a><br />
Daniel Rosenwasser</li>
<li><a href="https://dropbox.tech/frontend/how-we-reduced-the-size-of-our-javascript-bundles-by-33-percent">How we reduced the size of our JavaScript bundles by 33%</a><br />
Umair Nadeem</li>
<li><a href="https://webkit.org/blog/15063/webkit-features-in-safari-17-4/">WebKit Features in Safari 17.4</a><br />
Jen Simmons and Jon Davis</li>
<li><a href="https://voussoir.net/writing/css_for_printing">CSS for printing to paper</a><br />
Voussoir.net</li>
<li><a href="https://khalidabuhakmeh.com/how-to-integrate-htmx-and-shoelace-web-components">How to Integrate HTMX and Shoelace Web Components</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://webdesign.tutsplus.com/learn-these-viewport-relative-css-units-100vh-100dvh-100lvh-100svh--cms-108537t">Learn These Viewport-Relative CSS Units (100vh, 100dvh, 100lvh, 100svh)</a><br />
George Martsoukos</li>
<li><a href="https://www.telerik.com/blogs/internationalization-react-intl">Internationalization with React-Intl</a><br />
Hassan Djirdeh</li>
<li><a href="https://www.smashingmagazine.com/2024/03/modern-css-tooltips-speech-bubbles-part2/">Modern CSS Tooltips And Speech Bubbles (Part 2)</a><br />
Temani Afif</li>
<li><a href="https://timdeschryver.dev/blog/angular-has-your-back-when-it-comes-to-xss#angular-and-39-s-built-in-protection">Angular has your back when it comes to XSS</a><br />
Tim Deschryver</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://dev.to/mgeovany/como-configurar-prettier-y-no-morir-en-el-intento-extensiones-de-vscode-que-te-ayudaran-56o2">Como configurar Prettier y no morir en el intento, extensiones de VSCode que te ayudarán 🤯</a><br />
Geovany</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/code-coverage-features-in-visual-studio-enterprise/">Code coverage features in Visual Studio Enterprise</a><br />
Faisal Hafeez</li>
<li><a href="https://nicksnettravels.builttoroam.com/chatgpt-copilot-xaml/">Using ChatGPT and GitHub Copilot to Generate the XAML for your Windows application</a><br />
Nick Randolph</li>
<li><a href="https://github.blog/changelog/2024-03-07-github-copilot-chat-general-availability-in-jetbrains-ide/">GitHub Copilot Chat General Availability in JetBrains IDE</a><br />
GitHub</li>
<li><a href="https://build5nines.com/github-actions-run-pandoc-to-convert-markdown-to-word-document/">GitHub Actions: Run Pandoc To Convert Markdown To Word Document</a><br />
Chris Pietschmann</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://egvijayanand.in/2024/03/05/using-windows-subsystem-for-android-for-dotnet-maui-android-development/">Using WSA for .NET MAUI Android Development</a><br />
Vijay Anand</li>
<li><a href="https://www.sharpnado.com/net-maui-painfully-slow-debugging/">.NET MAUI: painfully slow debugging resolved with speedscope</a><br />
Jean-Marie Alfonsi</li>
<li><a href="https://www.syncfusion.com/succinctly-free-ebooks/dotnet-maui-community-toolkit-succinctly">Syncfusion Free Ebooks | .NET MAUI Community Toolkit Succinctly</a><br />
Alessandro Del Sole</li>
<li><a href="https://www.syncfusion.com/blogs/post/xamarins-end-of-life.aspx">Syncfusion's Response to Xamarin’s End of Life: A Comprehensive Plan</a><br />
Paul Anderson</li></ul><ul>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-20599639047099443612024-03-05T08:05:00.009+01:002024-03-05T08:32:32.404+01:00Acceder a parámetros de query string desde componentes Blazor 8 de cualquier tipo<img alt="Blazor" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBUgEtI1OgBX4GxZGmDIH5m2kDKsfmq0N_mkTa_9NE1jReSlOABaWbJtXM1L5Szkb4uCudiBdzjLebOyvg6Mxv-zMcwgfan8PveUpX5nrHirqjFzJXJQUheXB3vaIEYiXXt8FGTNSpPi_4s5LXOVIKKgcwK-FX_3aciAHC6BYyYZ6rvstXvxo/s16000/Blazor.png" title="Blazor" width="100%" />
<p>En Blazor es posible acceder a valores de parámetros de la <em>query string</em> <strong>exclusivamente desde componentes de tipo página</strong>, es decir, aquellos definidos con la directiva <code>@page</code>.</p>
<p>Para ello, bastaba con declarar una propiedad pública y decorarla con los atributos <code>[Parameter]</code> y <code>[SupplyParameterFromQuery]</code>. Por ejemplo, si desde una página quisiésemos obtener el valor del parámetro <code>term</code> de la <em>query string</em>, podríamos hacerlo de la siguiente forma:</p>
<pre><code class="language-cs">
@page "/search"
<p>Searching term: @Term</p>
@code {
[Parameter]
[SupplyParameterFromQuery]
public string Term { get; set; }
}
</code></pre>
<p>Sin embargo, como sabéis, esto <strong>no funcionaba si intentábamos acceder así a estos parámetros desde componentes que no fueran páginas</strong>, es decir, que no fueran instanciados por el sistema de <i>routing</i>.<span></span></p><a name='more'></a><p></p>
<p>Pues bien, <b>a partir de Blazor 8, el atributo <code>[SupplyParameterFromQuery]</code> puede ser utilizado sobre propiedades de componentes de cualquier tipo</b>, no sólo de aquellos decorados con la directiva <code>@page</code>. Por tanto, cualquier tipo de componente podrá acceder directamente a parámetros de la <em>query string</em>, evitando tener que pasárselos de forma manual o usando valores en cascada.</p>
<p>También es interesante destacar que si usamos <code>[SupplyParameterFromQuery]</code>, ya no será necesario añadir el atributo <code>[Parameter]</code>, como ocurría en versiones anteriores, así que nos ahorramos de paso una línea de código 😉</p>
<pre><code class="language-cs">[SupplyParameterFromQuery]
public string Term { get; set; }
...
</code></pre>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-1310514427789952442024-03-04T08:05:00.004+01:002024-03-04T08:05:00.127+01:00Enlaces interesantes 558<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/04/una-forma-mas-eficiente-de-comprobar-si.html">Una forma más eficiente de comprobar si un texto es un JSON válido</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/10/el-operador-nameof-de-c-6.html">El operador nameof de C# 6</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://dotnettips.wordpress.com/2024/02/26/string-performance-tips-for-microsoft-net-comparing-strings-with-globalization/">String Performance: Comparing Strings with Globalization</a><br />
David McCarter</li>
<li><a href="https://devblogs.microsoft.com/oldnewthing/20240226-00/?p=109451">A C# LINQ one-liner to check if exactly one of a set of conditions is met</a><br />
Raymond Chen</li>
<li><a href="https://blog.ploeh.dk/2024/02/26/testing-exceptions/">Testing exceptions</a><br />
Mark Seemann</li>
<li><a href="https://jeremybytes.blogspot.com/2024/02/parallelforeachasync-and-exceptions.html">Parallel.ForEachAsync and Exceptions</a><br />
Jeremy Clark</li>
<li><a href="https://www.code4it.dev/csharptips/iformattable-interface/">C# Tip: IFormattable interface, to define different string formats for the same object</a><br />
Davide Bellone</li>
<li><a href="https://www.devleader.ca/2024/02/26/reflection-in-c-4-code-simple-but-powerful-code-examples/">Reflection in C#: 4 Simple But Powerful Code Examples</a><br />
Nick Cosentino</li>
<li><a href="https://steven-giesel.com/blogPost/4cf6d48a-ec9d-4c68-961c-31fd8d8c1340">Lock statement patterns</a><br />
Steven Giesel</li>
<li><a href="https://www.devleader.ca/2024/02/27/async-await-in-c-3-beginner-tips-you-need-to-know/">async await in C#: 3 Beginner Tips You Need to Know</a><br />
Nick Cosentino</li>
<li><a href="https://github.com/MoaidHathot/Dumpify">MoaidHathot/Dumpify: Adding <code>.Dump()</code> extension methods to Console Applications, similar to LinqPad's.</a><br />
Moaid Hathot</li>
<li><a href="https://jeremybytes.blogspot.com/2024/02/continue-processing-with.html">Continue Processing with Parallel.ForEachAsync (even when exceptions are thrown)</a><br />
Jeremy Clark</li>
<li><a href="https://cezarypiatek.github.io/post/mocking-authorization-tokens/">Mocking authorization tokens with WireMock.NET</a><br />
Cezary Piątek</li>
<li><a href="https://www.devleader.ca/2024/02/28/activator-createinstance-in-c-a-quick-rundown/">Activator.CreateInstance in C# – A Quick Rundown</a><br />
Nick Cosentino<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/dotnet/the-fast-and-the-fluent-a-blazor-story/">The FAST and the Fluent: A Blazor story</a><br />
Vincent Baaij</li>
<li><a href="https://damienbod.com/2024/02/26/delegated-read-and-application-write-access-to-blob-storage-using-asp-net-core-with-entra-id-authentication/">Delegated read and application write access to blob storage using ASP.NET Core with Entra ID authentication</a><br />
Damien Bowden</li>
<li><a href="https://www.syncfusion.com/blogs/post/responsive-web-blazor-mediaquery.aspx">Create Responsive Web Designs Like a Pro with Blazor Media Query</a><br />
Silambarasan Ilango</li>
<li><a href="https://www.milanjovanovic.tech/blog/automatically-register-minimal-apis-in-aspnetcore">Automatically Register Minimal APIs in ASP.NET Core</a><br />
Milan Jovanović</li>
<li><a href="https://andrewlock.net/using-unix-domain-sockets-with-aspnetcore-and-httpclient/">Using Unix domain sockets with ASP.NET Core and HttpClient</a><br />
Andrew Lock</li>
<li><a href="https://khalidabuhakmeh.com/shoelace-web-components-with-aspnet-core">Shoelace Web Components with ASP.NET Core</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://www.telerik.com/blogs/fetching-sharing-data-between-components-blazor-auto-render-mode">Fetching and Sharing Data with Blazor’s Auto Render Mode</a><br />
Jon Hilton</li>
<li><a href="https://community.devexpress.com/blogs/aspnet/archive/2024/02/27/blazor-accessibility-enhancements-23-2.aspx">Blazor — Accessibility Enhancements and Options</a><br />
DevExpress Blogs</li>
<li><a href="https://code-maze.com/aspnetcore-how-to-fix-cors-error-with-anyorigin-and-allowcredentials/">How to Fix CORS Error With AnyOrigin and AllowCredentials</a><br />
Code Maze</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://nestenius.se/2024/02/22/persisting-the-asp-net-core-data-protection-key-ring-in-azure-key-vault/">Persisting the ASP.NET Core Data Protection Key Ring in Azure Key Vault</a><br />
Tore Nestenius</li>
<li><a href="https://azure.github.io/AppService/2024/03/01/Hybrid-connection-debug-utility.html">Troubleshoot your App Service Hybrid Connections with the Hybrid Connection Debug Utility</a><br />
Jordan Selig</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://codeopinion.com/app-configuration-where-does-it-go/">App Configuration: where does it go?</a><br />
Derek Comartin</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://www.codeproject.com/Tips/5378079/Challenges-in-Migrating-ASP-NET-Apps-to-Containers">Challenges in Migrating ASP.NET Apps to Containers</a><br />
Mohammad Elsheimy</li>
<li><a href="https://bartwullems.blogspot.com/2024/02/ef-core-cannot-convert-from-string-to.html">EF Core - Cannot convert from 'string' to 'System.FormattableString'</a><br />
Bart Wullems</li>
<li><a href="https://code-maze.com/efcore-single-and-split-queries/">Single and Split Queries in Entity Framework Core</a><br />
Code Maze</li>
<li><a href="https://bartwullems.blogspot.com/2024/02/ef-core-systeminvalidoperationexception.html">EF Core - System.InvalidOperationException : The required column 'Id' was not present in the results of a 'FromSql' operation.</a><br />
Bart Wullems</li>
<li><a href="https://code-maze.com/efcore-add-unique-constraints-to-a-property-code-first/">How to Add Unique Constraints to a Property in EF Core Code-First</a><br />
Ivan Gechev</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://azure.microsoft.com/en-us/blog/microsoft-and-mistral-ai-announce-new-partnership-to-accelerate-ai-innovation-and-introduce-mistral-large-first-on-azure/">Introducing Mistral-Large on Azure in partnership with Mistral AI</a><br />
Eric Boyd</li>
<li><a href="https://techcommunity.microsoft.com/t5/apps-on-azure-blog/creating-intelligent-apps-on-app-service-with-net/ba-p/4062684">Creating Intelligent Apps on App Service with .NET</a><br />
Jeff Martinez</li>
<li><a href="https://elbruno.com/2024/02/27/how-to-use-semantickernel-with-openai-and-azure-openai-in-c-1-n/">How to Use SemanticKernel with OpenAI and Azure OpenAI in C# – 1/N</a><br />
Bruno Capuano</li>
<li><a href="https://qdrant.tech/articles/rag-is-dead/">RAG is Dead. Long Live RAG!</a><br />
David Myriel</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/guia-completa-para-crear-un-proyecto-con-react-explorando-las-diferentes-opciones.aspx">Guía completa para crear un proyecto con React: explorando las diferentes opciones</a><br />
José Manuel Alarcón</li>
<li><a href="https://tonsky.me/blog/js-bloat/">JavaScript Bloat in 2024</a><br />
Nikita Prokopov</li>
<li><a href="https://hackernoon.com/mastering-type-safe-json-serialization-in-typescript">Mastering Type-Safe JSON Serialization in TypeScript</a><br />
Maksim Zemskov</li>
<li><a href="https://www.syncfusion.com/blogs/post/switch-redux-to-redux-toolkit.aspx">Should We Switch from Redux to Redux ToolKit?</a><br />
Nishani Dissanayake</li>
<li><a href="https://www.smashingmagazine.com/2024/02/reporting-core-web-vitals-performance-api/">Reporting Core Web Vitals With The Performance API</a><br />
Geoff Graham</li>
<li><a href="https://www.freecodecamp.org/news/advanced-css-selectors/">Advanced CSS Selectors – How and When to Use Them</a><br />
Ophy Boamah</li>
<li><a href="https://www.syncfusion.com/blogs/post/js-commonjs-vs-es-modules.aspx">Understanding CommonJS vs. ES Modules in JavaScript</a><br />
Poorna Theekshana</li>
<li><a href="https://www.bennadel.com/blog/4597-creating-a-css-class-name-directive-in-apline-js-3.htm">Creating A CSS Class Name Directive In Apline.js 3</a><br />
Ben Nadel</li>
<li><a href="https://www.telerik.com/blogs/rest-spread-operators-explained-javascript">Rest and Spread Operators Explained in JavaScript</a><br />
Ezekiel Lawson</li>
<li><a href="https://soamtripathy.hashnode.dev/understanding-event-propagation-in-javascript-bubbling-vs-capturing-explained">Mastering Event Propagation in JavaScript: Bubbling vs. Capturing</a><br />
Soumya Ranjan Tripathy</li>
<li><a href="https://webkit.org/blog/15054/an-html-switch-control/">An HTML Switch Control</a><br />
Anne van Kesteren & Jon Davis</li>
<li><a href="https://dev.to/fidalmathew/async-vs-defer-in-javascript-which-is-better-26gm">Async vs Defer in JavaScript: Which is Better?🤔</a><br />
Fidal Mathew</li>
<li><a href="https://www.telerik.com/blogs/4-reasons-use-angular-your-next-web-app">4 Reasons to Use Angular for Your Next Web App</a><br />
Alyssa Nicoll</li>
<li><a href="https://www.smashingmagazine.com/2024/03/modern-css-tooltips-speech-bubbles-part1/">Modern CSS Tooltips And Speech Bubbles (Part 1)</a><br />
Temani Afif</li>
<li><a href="https://www.webdevstory.com/javascript-tricks-smarter-coding/">30 JavaScript Tricky Hacks</a><br />
M Mainul Hasan</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://code.visualstudio.com/updates/v1_87">Visual Studio Code February 2024</a><br />
VS Code Team</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/02/27/critical-thinking-in-an-ai-powered-world/">Critical Thinking in an AI-Powered World</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://github.blog/2024-02-27-github-copilot-enterprise-is-now-generally-available/">GitHub Copilot Enterprise is now generally available</a><br />
Thomas Dohmke</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/02/27/resharper-2024-1-eap-6/">ReSharper 2024.1 EAP 6: The Most Feature-Rich Update Yet</a><br />
Sasha Ivanova</li>
<li><a href="https://thedatafarm.com/docker/docker-init-for-asp-net-core-compared-to-vs-or-vs-code-extensions/">Docker Init for ASP.NET Core Compared to VS or VS Code Extensions</a><br />
Julie Lerman</li>
<li><a href="https://devblogs.microsoft.com/dotnet/azure-migrate-application-and-code-assessment-march-2024-update/">GitHub Copilot Analysis, Customized Rules, and more come to the Azure Migrate application and code assessment</a><br />
Mike Rousos</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://egvijayanand.in/2024/02/29/dotnet-maui-native-embedding/">.NET MAUI – Native Embedding</a><br />
Vijay Anand</li>
<li><a href="https://devblogs.microsoft.com/dotnet/dotnet-maui-community-toolkit-2023-highlights/">.NET MAUI Community Toolkit 2023 Highlights</a><br />
Kym Phillpotts</li>
<li><a href="https://www.sharpnado.com/net-maui-disable-scrolling-on-android/">.net MAUI: Disable scrolling on Android</a><br />
Jean-Marie Alfonsi</li>
<li><a href="https://www.irisclasson.com/2024/02/27/maui-imagebutton-aspectfit-and-the-missing-image/">MAUI ImageButton AspectFit and the Missing Image</a><br />
Iris Classon</li>
<li><a href="https://www.telerik.com/blogs/beyond-basics-getting-started-media-picker-net-maui">Getting Started with the Media Picker in .NET MAUI</a><br />
Leomaris Reyes</li></ul><ul>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-27001577367804048442024-02-26T08:05:00.001+01:002024-02-26T08:05:00.130+01:00Enlaces interesantes 557<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/04/verificar-si-una-cadena-de-texto-es-un.html">Verificar si una cadena de texto es un JSON válido</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/09/uso-de-miembros-estaticos-en-c-6-una.html">Uso de miembros estáticos en C# 6, ¿una buena idea?</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://code-maze.com/csharp-check-positive-negative-number/">How to Check if a Number Is Positive or Negative in C#</a><br />
Code Maze</li>
<li><a href="https://devblogs.microsoft.com/dotnet/developing-optimized-github-actions-with-net-and-native-aot/">Developing Optimized GitHub Actions with .NET and Native AOT</a><br />
David Pine</li>
<li><a href="https://www.meziantou.net/getting-all-exceptions-thrown-from-parallel-foreachasync.htm">Getting all exceptions thrown from Parallel.ForEachAsync</a><br />
Gérald Barré</li>
<li><a href="https://dev.to/karenpayneoregon/c-systemtextjson-37m1">C# System.Text.Json</a><br />
Karen Payne</li>
<li><a href="https://code-maze.com/csharp-get-the-number-of-lines-in-a-text-file/">How to Get the Number of Lines in a Text File in C#</a><br />
Karthikeyan N. S.</li>
<li><a href="https://hackernoon.com/a-detailed-guide-to-string-concatenation-in-net">A Detailed Guide to String Concatenation in .NET</a><br />
Aleksei</li>
<li><a href="https://nblumhardt.com/2024/02/tracing-with-message-templates/">The case for an application-level tracing API in .NET</a><br />
Nicholas Blumhardt</li>
<li><a href="https://devblogs.microsoft.com/dotnet/winforms-designer-64-bit-path-forward/">WinForms in a 64-Bit world - our strategy going forward</a><br />
Klaus Loeffelmann</li>
<li><a href="https://bartwullems.blogspot.com/2024/02/addconsole-is-obsolete-this-method-is.html">AddConsole is obsolete: This method is retained only for compatibility</a><br />
Bart Wullems</li>
<li><a href="https://www.devleader.ca/2024/02/22/c-for-beginners-5-simplified-concepts-in-c/">C# for Beginners – 5 Simplified Concepts in C#</a><br />
Nick Cosentino</li>
<li><a href="https://endjin.com/blog/2024/02/dotnet-jsonelement-parse-errors">.NET JsonElement Error Handling</a><br />
Ian Griffiths<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul style="text-align: left;">
<li><a href="https://damienbod.com/2024/02/19/using-a-csp-nonce-in-blazor-web/">Using a CSP nonce in Blazor Web</a><br />
Damien Bowden</li>
<li><a href="https://ilovedotnet.org/blogs/blazor-wasm-dynamic-component/">Blazor WASM Dynamic Component</a><br />
Abdul Rahman Shabeek Mohamed</li>
<li><a href="https://code-maze.com/aspnetcore-call-signalr-from-controller/">How to Call SignalR Hub from Controller in ASP.NET Core</a><br />
Alexandra Ogubuike
</li><li><a href="https://www.milanjovanovic.tech/blog/using-scoped-services-from-singletons-in-aspnetcore">Using Scoped Services From Singletons in ASP.NET Core</a><br />
Milan Jovanović</li><ul>
</ul>
<li><a href="https://andrewlock.net/using-named-pipes-with-aspnetcore-and-httpclient/">Using named pipes with ASP.NET Core and HttpClient</a><br />
Andrew Lock</li>
<li><a href="https://weblog.west-wind.com/posts/2024/Feb/20/Reading-Raw-ASPNET-RequestBody-Multiple-Times">Reading Raw ASP.NET Request.Body Multiple Times</a><br />
Rick Strahl</li>
<li><a href="https://www.telerik.com/blogs/blazor-enhanced-navigation-fully-explained">Blazor’s Enhanced Navigation Fully Explained</a><br />
Ed Charbeneau</li>
<li><a href="https://jeremybytes.blogspot.com/2024/02/method-injection-in-aspnet-core-api.html">Method Injection in ASP.NET Core: API Controllers vs. MVC Controllers</a><br />
Jeremy Clark</li>
<li><a href="https://alexanderzeitler.com/articles/dealing-with-csharp-records-in-aspnet-core-model-binding/">Dealing with C# records in ASP.NET Core model binding</a><br />
Alexander Zeitler</li>
<li><a href="https://blog.logrocket.com/using-real-time-data-angular-signalr/">Using real-time data in Angular with SignalR</a><br />
Lewis Cianci</li>
<li><a href="https://jeffreyfritz.com/2024/02/blazor-and-net-8-how-i-build-a-fast-and-flexible-website/">Blazor and .NET 8: How I Built a Fast and Flexible Website</a><br />
Jeff Fritz</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://www.techwatching.dev/posts/azure-sdk-di">Using dependency injection with Azure .NET SDK</a><br />
Alexandre Nédélec</li>
<li><a href="https://joonasw.net/view/using-azure-key-vault-for-signing-and-encrypting-json-web-tokens">Using Azure Key Vault for signing and encrypting JSON Web Tokens</a><br />
Joonas Westlin</li>
<li><a href="https://www.tpeczek.com/2024/02/azure-functions-extensibility-runtime.html">Azure Functions Extensibility</a><br />
Tomasz Pęczek</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://steven-giesel.com/blogPost/9994b00c-8bc2-4794-ae74-80e6ee4cd5e5">Avoid multiple boolean parameters</a><br />
Steven Giesel</li>
<li><a href="https://ardalis.com/introducing-modular-monoliths-goldilocks-architecture/">Introducing Modular Monoliths: The Goldilocks Architecture</a><br />
Steve Smith</li>
<li><a href="https://blog.devgenius.io/decoding-why-0-6-0-3-0-8999999999999999-in-js-and-how-to-solve-976a0fa01640">Decoding Why 0.6 + 0.3 = 0.8999999999999999 in JS and How to Solve?</a><br />
Jeeva Ramanathan</li>
<li><a href="https://codeopinion.com/orms-can-lead-to-fat-domain-models-slim-them-down/">ORMs can lead to FAT domain models. Slim them down!</a><br />
Derek Comartin</li>
<li><a href="https://code-maze.com/dotnet-clean-architecture/">Clean Architecture in .NET</a><br />
Muhammed Saleem</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://khalidabuhakmeh.com/how-to-map-sql-results-to-any-object-using-entity-framework-core-8">How to Map SQL Results To Any Object Using Entity Framework Core 8</a><br />
Khalid Abuhakmeh</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://www.bluelabellabs.com/blog/llamaindex-response-modes-explained/">LlamaIndex Response Modes Explained</a><br />
Bobby Gill</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-4-rc/">Announcing TypeScript 5.4 RC</a><br />
Daniel Rosenwasser</li>
<li><a href="https://dev.to/this-is-learning/a11y-vanilla-javascript-aria-live-announcer-784">A11y: Vanilla javascript aria-live announcer</a><br />
Cristian-Florin Calina</li>
<li><a href="https://www.sonarsource.com/blog/union-intersection-difference-javascript-sets/">Union, intersection, difference, and more are coming to JavaScript Sets</a><br />
Phil Nash</li>
<li><a href="https://www.telerik.com/blogs/best-both-angular-worlds-standalone-modules-combined">Best of Both Angular Worlds: Standalone & Modules Combined</a><br />
Dany Paredes</li>
<li><a href="https://levelup.gitconnected.com/new-javascript-array-methods-that-every-web-developer-should-learn-4cab3d447bd6">New JavaScript Array Methods That Every Web Developer Should Learn</a><br />
Shalitha Suranga</li>
<li><a href="https://www.zachleat.com/web/throbber/">throbber Web Component</a><br />
Zach Leatherman</li>
<li><a href="https://aralroca.com/blog/html-node-streaming">HTML Streaming and DOM Diffing Algorithm</a><br />
Aral Roca</li>
<li><a href="https://whitep4nth3r.com/blog/ramblings-about-javascript-scope-weird-errors-frameworks/">Ramblings about JavaScript scope, weird errors and frameworks</a><br />
Salma Alam-Maylor</li>
<li><a href="https://frontbackgeek.com/basics-of-singly-linked-lists-in-javascript/">Understanding the Basics of Singly Linked Lists in JavaScript</a><br />
FrontBackGeek</li>
<li><a href="https://www.smashingmagazine.com/2024/02/vanilla-javascript-libraries-quest-stateful-dom-rendering/">Vanilla JavaScript, Libraries, And The Quest For Stateful DOM Rendering</a><br />
Frederik Dohr</li>
<li><a href="https://www.smashingmagazine.com/2024/02/vanilla-javascript-libraries-quest-stateful-dom-rendering/">Vanilla JavaScript, Libraries, And The Quest For Stateful DOM Rendering</a><br />
Frederik Dohr</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://blog.jetbrains.com/dotnet/2024/02/19/jetbrains-rider-and-the-net-aspire-plugin/">JetBrains Rider and the .NET Aspire Plugin</a><br />
Khalid Abuhakmeh & Rival Abdrakhmanov</li>
<li><a href="https://bartwullems.blogspot.com/2024/02/visual-studioshare-your-settings.html">Visual Studio–Share your settings</a><br />
Bart Wullems</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/visualstudio-extensibility-17-9/">VisualStudio.Extensibility: Install extensions without restarting Visual Studio!</a> & <a href="https://devblogs.microsoft.com/visualstudio/a-streamlined-extension-manager-comes-to-visual-studio-17-9/">A Streamlined Extension Manager comes to Visual Studio 17.9</a><br />
Maia Kelner</li>
<li><a href="https://ardalis.com/active-local-nuget-server/">An Active Local NuGet Server</a><br />
Steve Smith</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/02/21/jetbrains-ai-assistant-generate-test-data-for-dotnet/">How To Use AI Assistant to Generate Test Data For .NET Applications</a><br />
Khalid Abuhakmeh</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://www.telerik.com/blogs/exploring-4-behaviors-net-maui-community-toolkit">Exploring 4 Behaviors from the .NET MAUI Community Toolkit</a><br />
Leomaris Reyes</li>
<li><a href="https://www.syncfusion.com/blogs/post/manage-contact-maui-sqlite-crud.aspx">Easily Manage Contacts in Your .NET MAUI App with SQLite and Perform CRUD Actions</a><br />
Jeyasri Murugan</li>
<li><a href="https://askxammy.com/creating-an-e-book-onboarding-screen-in-net-maui/">Creating an E-Book OnBoarding screen in .NET MAUI</a><br />
Leomaris Reyes</li>
<li><a href="https://egvijayanand.in/2024/02/24/using-visual-studio-code-for-dotnet-maui-development/">Using Visual Studio Code for .NET MAUI Development</a><br />
Vijay Anand</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/apple-elimina-las-pwa-en-europa-libertad-o-seguridad.aspx">Apple elimina las PWA en Europa: ¿Libertad o seguridad?</a><br />
CampusMVP</li>
<li><a href="https://bartwullems.blogspot.com/2024/02/share-private-key-without-using.html">Share a private key without using passwords</a><br />
Bart Wullems</li>
<li><a href="https://httptoolkit.com/blog/yaml-media-type-rfc/">22 years later, YAML now has a media type</a><br />
Tim Perry</li>
<li><a href="https://www.smashingmagazine.com/2024/02/designing-for-colorblindness/">A Practical Guide To Designing For Colorblind People</a><br />
Vitaly Friedman</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-41324215185628187252024-02-20T08:05:00.014+01:002024-02-20T08:18:49.610+01:00Deserialización y serialización personalizada en .NET con System.Text.Json usando custom converters<img alt=".NET" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggPhnd9ZQ4eqBbsniTu7J4y5tTeDxIl8MoBpsy2ir_BxqkMp7TPJtVdL462DXMCI3RuS_Q716yjv2plFUbI_fA7qy_I2K1FHvgTQfBPgIq5oMRG02g5a1t5XOqXmaOwd88RH7GZO52F912aZqMDCn20DdSruzSAAshjI51TqU4ibWuPnRO2mw/s16000/net.png" title=".NET" width="100%" />
<p>Hace poco, andaba enfrascado en el proceso de modernización de una aplicación antigua que, entre otras cosas, guardaba datos en formato JSON en un repositorio de archivos. Dado que se trataba de una aplicación creada con .NET "clásico", la serialización y deserialización de estos datos se realizaba utilizando la popular biblioteca <a href="https://www.newtonsoft.com/json">Newtonsoft.Json</a>.</p>
<p>Al pasar a versiones modernas de .NET, esta biblioteca ya no es la mejor opción, pues ya el propio <em>framework</em> nos facilita las herramientas necesarias para realizar estas tareas de forma más eficiente mediante los componentes del espacio de nombres <code>System.Text.Json</code>. Y aquí es donde empiezan a explotar las cosas 😉.</p>
<p>Si habéis trabajado con este tipo de asuntos, probablemente habréis notado que, por defecto, los componentes de deserialización creados por <a href="https://twitter.com/JamesNK">James Newton-King</a> son bastante permisivos y dejan pasar cosas que <code>System.Text.Json</code> no permite. Por ejemplo, si tenemos una clase .NET con una propiedad de tipo <code>string</code> y queremos deserializar un valor JSON numérico sobre ella, <code>Newtonsoft.Json</code> lo hará sin problemas, pero <code>System.Text.Json</code> nos lanzará una excepción. Esa laxitud de <code>Newtonsoft.Json</code> es algo que en ocasiones nos puede venir bien, pero en otras puede puede hacer pasar por alto errores en nuestros datos que luego, al ser procesados por componentes de deserialización distintos, podrían ocasionar problemas.</p>
<p>Por ejemplo, observad el siguiente código:</p>
<pre><code class="language-cs">var json = """
{
"Count": "1234"
}
""";
// Deserializamos usando Newtonsoft.Json:
var nsj = Newtonsoft.Json.JsonConvert.DeserializeObject<Data>(json);
Console.WriteLine("Newtonsoft: " + nsj.Count);
// Intentamos deserializar usando System.Text.Json
// y se lanzará una excepción:
var stj = System.Text.Json.JsonSerializer.Deserialize<Data>(json);
Console.WriteLine("System.Text.Json: " + stj.Count);
Console.Read();
// La clase de datos utilizada
record Data(int Count);
</code></pre>
<p>Para casos como este, nos vendrá bien conocer <b>qué son los <em>custom converters</em> y cómo podemos utilizarlos</b>.<span></span></p><a name='more'></a><p></p>
<h2>¿Qué es un <em>custom converter</em>?</h2>
<p>Un convertidor personalizado o <em>custom converter</em> es un componente que podemos insertar en el proceso de serialización y deserialización de <code>System.Text.Json</code> para que se encargue de convertir valores JSON en objetos .NET y viceversa. Este componente nos <b>permite tener un control muy fino sobre los procesos de serializacón y deserialización</b>, lo que nos puede ser útil en situaciones en las que necesitamos adaptar el comportamiento de <code>System.Text.Json</code> a nuestras necesidades, como por ejemplo cuando nos encontramos casos como el que hemos visto antes.</p>
<p>En la práctica, los <em>custom converters</em> son clases que implementan la interfaz <code>JsonConverter<T></code>, donde <code>T</code> es el tipo de dato .NET de las propiedades cuya serialización o deserialización queremos controlar. Por ejemplo, en el caso anterior, donde nuestra propiedad era de tipo <code>int</code>, necesitaríamos implementar un <code>JsonConverter<int></code>.</p>
<p>Esta interfaz requiere la implementación de dos métodos:</p>
<pre><code class="language-cs">public class MyCustomConverter : JsonConverter<T>
{
public override T Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
}
public override void Write(Utf8JsonWriter writer, T value,
JsonSerializerOptions options)
{
}
}
</code></pre>
<ul>
<li><b>El tipo genérico <code>T</code> es el tipo de dato hacia o desde el que queremos convertir</b>, según hablemos de deserialización o serialización. Por ejemplo, si usamos un <code>int</code>, el conversor sería utilizado cuando:
<ul>
<li>Se está deserializando y <code>System.Text.Json</code> encuentra una propiedad de tipo <code>int</code> en la que debe almacenar el valor presente en el JSON.</li>
<li>Se está serializando y hay que generar la representación JSON de una propiedad de tipo <code>int</code>.</li>
</ul>
</li>
<li><code><b>Read()</b></code>: usado durante la deserialización, este método se encarga de obtener el valor JSON entrante y transformarlo en el objeto de tipo <code>T</code> que retorna.</li>
<li><code><b>Write()</b></code>: escribe sobre el <em>writer</em> JSON el valor del objeto de tipo <code>T</code> que recibe como parámetro.</li>
</ul>
<p>Vamos a ver un ejemplo práctico de cómo implementar un <em>custom converter</em> para serializar y deserializar propiedades de tipo <code>int</code>. Para ello, crearemos una clase heredando de <code>JsonConverter<int></code>, como la siguiente:</p>
<pre><code class="language-cs">public class IntConverter : System.Text.Json.Serialization.JsonConverter<int>
{
public override int Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
// Aquí implementaremos la lógica de deserialización, es decir,
// convertiremos el valor JSON que recibamos a entero
}
public override void Write(Utf8JsonWriter writer, int value,
JsonSerializerOptions options)
{
// Aquí implementaremos la lógica de serialización,
// es decir, convertiremos del valor entero a un número JSON
}
}
</code></pre>
<blockquote>
<p>No siempre tendremos que implementar ambos métodos. Si, por ejemplo, únicamente vamos a necesitar deserializar de forma personalizada, podríamos dejar el método <code>Write()</code> vacío, o viceversa.</p>
</blockquote>
<p>Veamos ahora cómo implementar cada uno de estos métodos.</p>
<h2>Deserialización personalizada con <em>custom converters</em></h2>
<p>El método <code>Read()</code> es el encargado de deserializar el valor JSON entrante y convertirlo en un objeto de tipo <code>T</code>. En el caso de nuestro ejemplo, donde estamos trabajando con un <code>int</code>, el método <code>Read()</code> podría ser algo así:</p>
<pre><code class="language-cs">public override int Read(ref Utf8JsonReader reader, Type typeToConvert,
JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case JsonTokenType.String:
return int.TryParse(reader.GetString(), out int stringValueAsInt)
? stringValueAsInt : 0;
case JsonTokenType.Number:
return reader.TryGetInt32(out int numberValueAsInt) ? numberValueAsInt : 0;
case JsonTokenType.True:
return 1;
default:
return 0;
}
}
</code></pre>
<p>Se trata de un ejemplo básico, pero creo que os valdrá para que os quedéis con la idea de que <strong>aquí podríamos implementar cualquier tipo de lógica de deserialización</strong>. En este caso, la lógica es muy simple, pues sea cual sea el valor JSON entrante, intentaremos generar un valor entero para él:</p>
<ul>
<li>Si es una cadena, la parsearemos para transformarla en un valor entero.</li>
<li>Si es un número, lo usaremos tal cual.</li>
<li>Si es un <code>true</code>, devolveremos 1 (porque nos apetece, podríamos haber elegido cualquier otro criterio)</li>
<li>En otros casos, siempre retornaremos el valor 0.</li>
</ul>
<p>Fijaos que podemos acceder al valor JSON entrante usando el objeto <code>reader</code> que nos llega como parámetro. Con él, podemos determinar el tipo de dato que estamos leyendo y actuar en consecuencia: si es un <code>JsonTokenType.String</code>, obtenemos su valor con el método <code>reader.GetString()</code> e intentamos convertir el valor obtenido a entero; en cambio, si es un <code>JsonTokenType.Number</code>, intentamos obtener el valor como entero, mientras que si es un <code>JsonTokenType.True</code>, devolveremos 1. En cualquier otro caso, devolvemos 0.</p>
<p>Para crear deserializadores personalizados robustos, es importante considerar todos los tipos de datos JSON que pueden llegarnos y realizar las acciones de conversión apropiadas para que en todos los casos el método retorne un valor que encaje con lo que necesitamos.</p>
<h2>Serialización personalizada con <em>custom converters</em></h2>
<p>La serialización es normalmente más sencilla, pues consiste únicamente en representar con JSON el valor de la propiedad, que nos llega en el parámetro <code>value</code> del método <code>Write()</code>.</p>
<p>En nuestro caso, que estamos trabajando con un entero, la implementación de este método sería algo así:</p>
<pre style="text-align: left;"><code class="language-cs">public override void Write(Utf8JsonWriter writer, int value,
JsonSerializerOptions options)
{
writer.WriteNumberValue(value);
}
</code></pre>
<div>Como podéis intuir, el objeto <code>writer</code> dispone de un buen número de métodos <span style="font-family: monospace;">WriteXXX()</span> para generar valores JSON de múltiples tipos: <code>WriteStringValue(), WriteBooleanValue(), WriteNullValue()</code>, etc., por lo que se trata simplemente de usar el o los métodos apropiados en cada caso para emitir el JSON que queramos.</div><h2>Aplicar el <em>custom converter</em> a operaciones de serialización y deserialización</h2>
<p>Seguro que en este punto os habéis dado cuenta de que falta algo, ¿verdad? Hemos implementado nuestro <em>custom converter</em>, pero en ningún sitio le hemos dicho a <code>System.Text.Json</code> que lo utilice, por lo que no tendrá ningún efecto.</p>
<p><strong>Para que se utilice nuestro <em>custom converter</em> tendremos que añadirlo a las opciones de serialización o deserialización</strong> que estemos utilizando, materializadas en un objeto de tipo <code>JsonSerializerOptions</code>. Seguro que habéis usado esta clase alguna vez para configurar opciones de <em>casing</em>, ignorar propiedades, etc. Pues bien, también podemos añadir nuestros <em>custom converters</em> a estas opciones.</p>
<pre><code class="language-cs">var options = new JsonSerializerOptions();
options.Converters.Add(new IntConverter());
// Podemos establecer otras opciones aquí, por ejemplo:
options.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
...
</code></pre>
<p>Luego, podemos usar estas opciones tanto para serializar como para deserializar:</p>
<pre><code class="language-cs">var options = new JsonSerializerOptions();
options.Converters.Add(new IntConverter());
// Se usará nuestro custom converter para deserializar las propiedades `int`:
var data = System.Text.Json.JsonSerializer.Deserialize<Data>(json, options);
// Y también para serializarlas:
var json = System.Text.Json.JsonSerializer.Serialize(data, options);
</code></pre>
<h2>¡Hasta aquí hemos llegado!</h2>
<p>Obviamente, lo que hemos visto es sólo el principio. Podemos crear <em>custom converters</em> para cualquier tipo de dato, y no sólo para tipos primitivos, sino también para tipos complejos, como por ejemplo, para deserializar fechas en un formato específico, colecciones, diccionarios, etc.. En algunos casos la cosa se puede llegar a complicar un poco, pero nada que no pueda resolverse en un ratillo de diversión 😉 De hecho, me apunto para ver la implementación de algunos de estos casos algo más complejos en un post futuro.</p>
<p>Espero que os resulte útil en proyectos en los que tengáis que lidiar con JSON, sobre todo si tenéis que ser compatibles con otros sistemas cuyos criterios de serialización o deserialización sean distintos a los proporcionados por defecto por las bibliotecas de .NET.</p>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-51653696591978840552024-02-19T08:05:00.002+01:002024-02-19T08:05:00.135+01:00Enlaces interesantes 556<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/03/como-saber-donde-se-esta-gestionando.html">Cómo saber dónde se está gestionando una petición en ASP.NET Core</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/09/inicializacion-de-propiedades-en-c-60.html">Inicialización de propiedades en C# 6.0</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://github.com/dotnet/core/discussions/9167">.NET 9 Preview 1</a><br />
Rich Lander</li>
<li><a href="https://devblogs.microsoft.com/nuget/announcing-nuget-6-9/">Announcing NuGet 6.9</a><br />
Allie Barry</li>
<li><a href="https://devblogs.microsoft.com/dotnet/our-vision-for-dotnet-9/">Our Vision for .NET 9</a><br />
.NET Team</li>
<li><a href="https://ardalis.com/hello-redis-getting-started-with-redis-dotnet/">Hello, Redis - Getting Started with Redis and dotnet 8</a><br />
Steve Smith</li>
<li><a href="https://steven-giesel.com/blogPost/2e23afb8-4dc6-461e-8110-4122c7fefee7">Garbage Collector (over)simplified</a> & <a href="https://steven-giesel.com/blogPost/e0c236dc-40dc-4100-97bc-b68a2ccb5f4f">The garbage collector in .NET - Part 2: Compacting</a><br />
Steven Giesel</li>
<li><a href="https://code-maze.com/csharp-convert-a-number-between-hexadecimal-and-decimal/">Convert Between Hexadecimal and Decimal in C#</a><br />
Martin Chege</li>
<li><a href="https://www.meziantou.net/creating-an-httpclient-that-uses-dns-over-https.htm">Creating an HttpClient that uses DNS over Https</a><br />
Gérald Barré</li>
<li><a href="https://code-maze.com/csharp-difference-between-properties-and-fields/">What Is the Difference Between Properties and Fields in C#</a><br />
Code Maze</li>
<li><a href="https://steven-giesel.com/blogPost/62049533-001a-46fb-a1da-88effc0183f1">LINQ MindMap: .NET 9 Edition</a><br />
Steven Giesel</li>
<li><a href="https://conductofcode.io/post/creating-custom-powertoys-run-plugins/">Creating custom PowerToys Run plugins</a><br />
Henrik Lau Eriksson</li>
<li><a href="https://code-maze.com/dotnet-how-to-overwrite-datetime-now-during-testing/">How to Overwrite DateTime.Now During Testing in .NET</a><br />
Ivan Gechev</li>
<li><a href="https://www.code4it.dev/blog/how-to-get-random-items/">Is Random.GetItems the best way to get random items in C# 12?</a><br />
Davide Bellone</li>
<li><a href="https://code-maze.com/csharp-new-features-in-version-12/">New Features in C# 12</a><br />
Bozo Spoljaric</li>
<li><a href="https://code-maze.com/aspnetcore-how-to-log-a-class-and-method-names-using-serilog/">How to Log a Class and Method Names Using Serilog</a><br />
Muhammad Afzal Qureshi</li>
<li><a href="https://www.tabsoverspaces.com/233932-enumerating-over-select-index">Enumerating over Select’s index</a><br />
Jiří Činčura</li>
<li><a href="https://www.devleader.ca/2024/02/14/weak-events-in-c-how-to-avoid-nasty-memory-leaks/">Weak Events in C# – How to Avoid Nasty Memory Leaks</a><br />
Nick Cosentino</li>
<li><a href="https://nodogmablog.bryanhogan.net/2024/02/polly-core-rate-limiter/">Polly Core Rate Limiter</a><br />
Bryan Hogan</li>
<li><a href="https://dev.to/dotnet/an-introduction-to-the-world-of-containers-with-net-8-4elf">An Introduction to the World of Containers with .NET 8</a><br />
James Montemagno<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/controladores-o-minimal-apis-para-crear-apis-con-net.aspx">¿Controladores o minimal APIs para crear APIs con .NET?</a><br />
CampusMVP</li>
<li><a href="https://learn.microsoft.com/es-es/dotnet/aspire/whats-new/preview-3">.NET Aspire preview 3</a><br />
Aspire Team</li>
<li><a href="https://damienbod.com/2024/02/12/using-blob-storage-from-asp-net-core-with-entra-id-authentication/">Using Blob storage from ASP.NET Core with Entra ID authentication</a><br />
Damien Bowden</li>
<li><a href="https://code-maze.com/fluxor-for-state-management-in-blazor/">Using Fluxor for State Management in Blazor</a><br />
Gergo Vandor</li>
<li><a href="https://www.devleader.ca/2024/02/09/webapplicationfactory-in-asp-net-core-practical-tips-for-c-developers/">WebApplicationFactory in ASP.NET Core: Practical Tips for C# Developers</a><br />
Nick Cosentino</li>
<li><a href="https://jonhilton.net/blazor-web-app-interactivity-choices/">Interactive what now? Deciphering Blazor's web app project template options</a><br />
Jon Hilton</li>
<li><a href="https://andrewlock.net/8-ways-to-set-the-urls-for-an-aspnetcore-app/">8 ways to set the URLs for an ASP.NET Core app</a><br />
Andrew Lock</li>
<li><a href="https://www.syncfusion.com/blogs/post/transform-blazor-wasm-to-pwa.aspx">Transforming a Blazor WebAssembly (WASM) App into a Progressive Web App</a><br />
Hari Venkatesh</li>
<li><a href="https://devblogs.microsoft.com/dotnet/introducing-aspnetcore-metrics-and-grafana-dashboards-in-dotnet-8/">Introducing ASP.NET Core metrics and Grafana dashboards in .NET 8</a><br />
James Newton-King</li>
<li><a href="https://code-maze.com/aspnetcore-conditional-required-attributes/">Creating Conditional Required Attributes for Validation in .NET Web API</a><br />
Ainea Wabwoba</li>
<li><a href="https://www.syncfusion.com/blogs/post/blazor-file-manager-virtualization.aspx">Enhancing the Blazor File Manager Performance with Virtualization</a><br />
Keerthana Rajendran</li>
<li><a href="https://www.devleader.ca/2024/02/13/xunit-in-asp-net-core-what-you-need-to-know-to-start/">xUnit in ASP.NET Core – What You Need to Know to Start</a><br />
Nick Cosentino</li>
<li><a href="https://jesseliberty.com/2024/02/15/api-part-7-swagger-comments/">API Part 7 – Swagger Comments</a><br />
Jesse Liberty</li>
<li><a href="https://www.syncfusion.com/blogs/post/state-maintenance-blazor-tabs.aspx">Mastering State Maintenance in Blazor Tabs</a><br />
Mahesh Palanisamy</li>
<li><a href="https://www.telerik.com/blogs/blazor-basics-html-forms-capturing-user-data">Blazor Basics: HTML Forms and Capturing User Data</a><br />
Claudio Bernasconi</li>
<li><a href="https://www.syncfusion.com/blogs/post/crud-blazor-datagrid-fluxor.aspx">Perform Effortless CRUD Actions in Blazor DataGrid with Fluxor</a><br />
Maithiliy K.</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/azure-sdk/azure-developer-cli-azd-february-2024-release/">Azure Developer CLI (azd)</a><br />
Grace Kulin</li>
<li><a href="https://www.rahulpnath.com/blog/lambda-lifecycle-and-net/">Why Should You Care About Lambda Lifecycle As A .NET Developer?</a><br />
Rahul Nath</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://fernandovillalba.substack.com/p/its-not-microservice-or-monolith">It's not microservice or monolith; it's cognitive load you need to understand first</a><br />
Fernando Villalba</li>
<li><a href="https://www.milanjovanovic.tech/blog/getting-the-current-user-in-clean-architecture">Getting the Current User in Clean Architecture</a><br />
Milan Jovanović</li>
<li><a href="https://seankilleen.com/2024/02/creating-and-modeling-sensible-happy-paths-for-software-team-success/">Creating and Modeling “Sensible Happy Paths” for Software Team Success</a><br />
Sean Killeen</li>
<li><a href="https://codeopinion.com/best-developer-interview-question/">Best Developer Interview Question</a><br />
Derek Comartin</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://www.codeproject.com/Articles/5377237/Understanding-vector-databases">Understanding Vector Databases</a><br />
Nicolas Descartes</li>
<li><a href="https://erikej.github.io/efcore/dacpac/2024/02/11/powertools-dacpac.html">Better together with Entity Framework Core Power Tools - use a SQL Server Database Project (.dacpac) and EF Core</a><br />
Erik Ejlskov Jensen</li>
<li><a href="https://khalidabuhakmeh.com/increase-performance-with-complex-types-in-entity-framework-core-8">Increase Performance with Complex Types in Entity Framework Core 8</a><br />
Khalid Abuhakmeh</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://blog.google/technology/ai/google-gemini-next-generation-model-february-2024/">Our next-generation model: Gemini 1.5</a><br />
Sundar Pichai & Demis Hassabis</li>
<li><a href="https://martinfowler.com/articles/engineering-practices-llm.html">Engineering Practices for LLM Application Development</a><br />
David Tan & Jessie Wang</li>
<li><a href="https://openai.com/blog/memory-and-new-controls-for-chatgpt">Memory and new controls for ChatGPT</a><br />
OpenAI</li>
<li><a href="https://visualstudiomagazine.com/articles/2024/02/16/pca-using-svd-for-ml.aspx">Principal Component Analysis from Scratch Using Singular Value Decomposition with C#</a><br />
James McCaffrey</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://blog.angular.io/angular-v17-2-is-now-available-596cbe96242d">Angular v17.2 is now available</a><br />
Minko Gechev</li>
<li><a href="https://jacobpadilla.com/articles/chrome-devtools-tips-tricks">Hidden Gems in Chrome DevTools: 9 Tips and Tricks</a><br />
Jacob Padilla</li>
<li><a href="https://www.telerik.com/blogs/through-digital-landscape-role-content-security-policy-why-csp-important">The Role of Content Security Policy—Why Is CSP So Important?</a><br />
Petar Grigorov</li>
<li><a href="https://briantree.se/how-to-use-angulars-new-control-flow-syntax/">How to Use Angular's New Control Flow Syntax</a><br />
Brian Treese</li>
<li><a href="https://www.htmhell.dev/adventcalendar/2023/14/">Getting started with Web Performance</a><br />
Alistair Shepherd</li>
<li><a href="https://css.oddbird.net/sasslike/mixins-functions/">CSS Mixins & Functions Explainer</a><br />
Miriam Suzanne</li>
<li><a href="https://web.dev/blog/array-with?hl=en">Immutable array updates with Array.prototype.with</a><br />
Jad Joubran</li>
<li><a href="https://blog.logrocket.com/exploring-interaction-next-paint-new-core-web-vital">Exploring Interaction to Next Paint, a new Core Web Vital</a><br />
Rahul Chhodde</li>
<li><a href="https://itnext.io/apple-wants-to-kill-pwas-0895be2e497b">Apple Wants To Kill PWAs</a><br />
Danny Moerkerke</li>
<li><a href="https://auth0.com/blog/webauthn-and-passkeys-for-developers/">A Passwordless Future! Passkeys for Developers</a><br />
Deepu K Sasidharan</li>
<li><a href="https://blog.angular.io/material-3-experimental-support-in-angular-17-2-8e681dde650e">Material 3 Experimental Support in Angular 17.2</a><br />
Miles Malerba</li>
<li><a href="https://michaelscodingspot.com/typescript-api-change/">Changing TypeScript library functions while keeping backwards compatibility</a><br />
Michael Shpilt</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/visualstudio/visual-studio-2022-17-9-now-available/">Visual Studio 2022 17.9 Now Available</a><br />
Maddy Montaquila</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/introducing-visual-studio-17-10-preview-1-is-here/">Introducing Visual Studio 17.10 – Preview 1 is Here!</a><br />
Mark Downie</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/a-look-back-visual-studios-profiling-tool-advancements-in-2023/">A Look Back: Visual Studio’s Profiling Tool Advancements in 2023</a><br />
Harshada Hole</li>
<li><a href="https://knowyourtoolset.com/2024/02/visual-studio-tips/">Visual Studio Tips and Tricks</a><br />
Erik Dahl</li>
<li><a href="https://anthonygiretti.com/2024/02/11/ndepend-is-the-must-have-tool-for-net-applications-discovering-the-report-feature-at-a-glance/">NDepend is the must-have tool for .NET applications. Discovering the report feature at a glance.</a><br />
Anthony Giretti</li>
<li><a href="https://www.giorgi.dev/portfolio/efcore-query-plan-visualizer/">Entity Framework Core Query Plan Visualizer | Giorgi Dalakishvili</a><br />
Giorgi Dalakishvili</li></ul><ul>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://www.genbeta.com/a-fondo/cursor-tu-raton-esta-torcido-ha-estado-asi-hace-anos-hay-buena-razon-que-explica">El cursor de tu ratón está torcido, y ha estado así desde hace años: hay una buena razón que lo explica</a><br />
Marcos Merino</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-81921990258924427992024-02-13T08:05:00.069+01:002024-02-19T08:27:06.773+01:00¡Nuevo curso de Blazor 8 en CampusMVP!<img alt="Blazor" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjYtngzSgBTz-foc4XMLM045BhCMVXMpE7MTqiZbQdcAfnyuBujfpMuXL2bt51wkx9S7Rr8RiwBmH1KOFNZinRlaNiBmiSJI6J9vVkCte1INv3UEEvD1ZNhh2KEL_mOyjYpyXlfbtAhw_fQLT2MsDx519yGaO3A4wVum60a6xmc2cOK2NOXDTzz-g/s1600/curso-blazor-net-8.png" title="Curso de Blazor 8 en CampusMVP" width="100%" />
<p>Como seguramente sabréis, <strong>Blazor es la gran apuesta de Microsoft para el desarrollo de aplicaciones web con .NET</strong>. Sólo hay que ver la cantidad de novedades que han introducido en la última versión para darse cuenta de que están poniendo toda la carne en el asador y, de alguna forma, está convirtiéndose en la opción preferida para el desarrollo de este tipo de aplicaciones.</p>
<p>Pues bien, es un placer anunciaros que, tras varios meses de preparación, <strong>hace unos días hemos puesto en marcha el nuevo curso de <a href="https://www.campusmvp.es/catalogo/Product-Desarrollo-de-aplicaciones-Web-con-Blazor-y-.NET_246.aspx">desarrollo de aplicaciones Web con Blazor en .NET 8</a></strong>, como siempre, en <a href="https://www.campusmvp.es">CampusMVP</a>.</p>
<p>Ha sido un trabajo duro, porque esta última versión ha venida cargada de novedades (sobre todo en lo relativo <strong>al nuevo modelo unificado propuesto por las Blazor Web Apps</strong>) y hemos tenido que revisar en profundidad y reescribir parte del contenido del curso, rehacer ejemplos y regrabar material audiovisual, todo <strong>con el objetivo de seguir siendo el mejor y más completo curso de Blazor del mercado</strong>.</p>
<p>En este post voy a intentar responder a las siguientes preguntas:</p>
<ul>
<li><a href="#que-es">¿Qué es Blazor?</a></li>
<li><a href="#me-interesa">¿Por qué es interesante aprender a desarrollar con Blazor?</a></li>
<li><a href="#aspnetcore">Si ya hemos trabajado con ASP.NET Core y MVC, ¿siguen valiendo estos conocimientos?</a></li>
<li><a href="#curso">¿En qué consiste el curso de desarrollo con Blazor?</a></li>
<li><a href="#contenidos">¿Cuáles son los contenidos del curso?</a></li>
<li><a href="#conocimientos">¿Qué conocimientos previos se necesitan para seguir el curso?</a></li>
<li><a href="#al-ataque">Me convence, ¿cuándo empezamos?<span><a name='more'></a></span></a></li>
</ul>
<h2>¿Qué es Blazor?<a name="que-es"></a></h2>
<p>El objetivo de partida de Blazor era bastante ambicioso: ofrecer a los desarrolladores .NET <strong>un <em>framework</em> para la construcción de aplicaciones web SPA, similar a otros como Angular, React o Vue, pero usando exclusivamente C#</strong>. Vaya, el sueño dorado de aquellos a los que JavaScript siempre les ha parecido la parte más dura de programar para la web ;)</p>
<p>Es decir, a diferencia de las soluciones tradicionales para crear aplicaciones web SPA:</p>
<ul>
<li><strong>Utilizaremos los entornos de desarrollo con los que nos sentimos cómodos</strong> los desarrolladores .NET, como Visual Studio, para crear, programar, depurar, testear y distribuir nuestras aplicaciones.</li>
<li>O, como ocurre en toda la nueva generación de tecnologías del ecosistema .NET, <strong>podremos desarrollar y ejecutar sobre cualquier sistema operativo y usar herramientas más ligeras</strong> como Visual Studio Code o la línea de comandos de .NET.</li>
<li><strong>Utilizaremos C# en lugar de JavaScript</strong> para implementar la capa de presentación, algo que hasta ahora no era posible conseguir, con las ventajas que ello conlleva.</li>
<li><strong>Aprovecharemos los conocimientos que ya tenemos de .NET</strong> para crear aplicaciones web SPA. Es decir, podremos usar los tipos y clases de .NET con las que llevamos años trabajando, pero para crear aplicaciones que corren en el navegador.</li>
<li>Será posible <strong>reutilizar código existente en todas las capas de las aplicaciones</strong>, así como compartir código entre cliente y servidor, pues ambos utilizarán las mismas tecnologías.</li>
</ul>
<blockquote>
<p>Seguro que alguno pensará que todo esto lo ha escuchado antes, pero el protagonista era el denostado Silverlight. Nada más lejos de eso; no estamos hablando de "incrustar" código .NET en un <em>browser</em> usando tecnologías propietarias como hacíamos años atrás, en la era RIA (Rich Internet Applications), sino en una <strong>tecnología respetuosa y alineada con estándares</strong> abiertos de la web.</p>
</blockquote>
<p>Sólo con lo dicho hasta ahora, las ventajas de Blazor ya podrían ser suficientes para considerarlo una opción a la hora de acometer nuevos proyectos, pero la cosa no queda ahí.</p>
<p>A la vista de la simplicidad, potencia y productividad del modelo de componentes que utiliza, el ámbito de Blazor ha ido creciendo y, en la actualidad, <strong>Blazor es mucho más que un <em>framework</em> para crear aplicaciones web SPA</strong>.</p>
<p>En la última versión, Blazor ya no sólo permite crear aplicaciones de <em>frontend</em>, sino que Blazor se ha convertido en <strong>una plataforma de desarrollo completa o <em>fullstack</em></strong>, con la que podemos crear también aplicaciones ejecutadas por completo en <em>backend</em> (como MVC o Razor Pages, por lo que, de alguna forma, puede llegar a sustituir estas tecnologías).</p>
<p>Puedes leer algo más sobre Blazor en los siguientes artículos:</p>
<ul>
<li><a href="https://www.variablenotfound.com/2020/01/que-es-blazor-eso-de-lo-que-todo-el.html">¿Qué es Blazor, eso de lo que todo el mundo habla?</a></li>
<li><a href="https://www.campusmvp.es/recursos/post/Introduccion-a-blazor-a-traves-de-7-preguntas.aspx">Introducción a Blazor a través de 7 preguntas (y sus respuestas)</a></li>
<li><a href="https://www.campusmvp.es/recursos/post/como-funciona-blazor-otras-7-preguntas-y-respuestas-para-conocerlo-mejor.aspx">Cómo funciona Blazor: otras 7 preguntas y respuestas para conocerlo mejor</a></li>
<li><a href="https://www.campusmvp.es/recursos/post/por-que-blazor.aspx">¿Por qué Blazor? - Qué me ofrece Blazor si desarrollo con .NET y C#</a></li>
<li><a href="https://www.campusmvp.es/catalogo/Product-Desarrollo-de-aplicaciones-Web-con-Blazor-y-.NET_246.aspx">Curso Online - Desarrollo de aplicaciones Web con Blazor y .NET</a></li>
</ul>
<h2>¿Por qué es interesante aprender a desarrollar con Blazor?<a name="me-interesa"></a></h2>
<p>Si trabajáis en la creación de aplicaciones web con tecnologías Microsoft, la respuesta es categórica: <strong>sin duda, deberías aprender Blazor</strong>. Dejad que os explique por qué.</p>
<p><strong>La imparable popularización de las aplicaciones web SPA ha traído de la mano algunos problemas para los desarrolladores .NET</strong>. Incluso los <em>frameworks</em> más modernos y potentes, como ASP.NET Core MVC o Web API, no ofrecen herramientas para la creación de aplicaciones SPA, por lo que nos vemos obligados a:</p>
<ul>
<li><strong>Quedar relegados al desarrollo del <em>backend</em></strong> del que normalmente hacen uso de este tipo de sistemas.</li>
<li><strong>Movernos al <em>frontend</em></strong>, aprendiendo a trabajar con <em>frameworks</em> como Angular, React, Vue o cualquiera de los muchos otros disponibles en el ecosistema Javascript.</li>
</ul>
<p>Si, como es bastante habitual, sois de los que tienen que tocar un poco de todo (aka <em>full-stack developers</em>) probablemente habréis sufrido al elegir esta última opción. Para los desarrolladores .NET, los <strong><em>frameworks</em> de <em>frontend</em> tradicionales suelen ser un territorio hostil</strong> e incómodo porque:</p>
<ul>
<li><strong>No es sencillo elegir en cuál de las cestas poner los huevos</strong>. Aunque últimamente parece haberse relajado algo la cosa y la propia selección natural ha ido haciendo su trabajo eliminando opciones que no aportaban demasiado, durante años, el mundillo de los <em>frameworks</em> SPA ha vivido constantes terremotos y no era sencillo decantarse por una u otra opción.</li>
<li><strong>Debemos utilizar <a href="https://www.campusmvp.es/catalogo/Product-Herramientas-avanzadas-para-desarrollo-Web-Front-End_243.aspx">herramientas distintas a las habituales</a></strong>, y veces no se llevan demasiado bien entre ellas, por lo que nos vemos obligados a usar distintos "cinturones de herramientas" en función de lo que vayamos a hacer en cada momento.</li>
<li>Todo esto obliga a <strong>aprender un modelo de programación completamente nuevo</strong>: sintaxis, workflows de trabajo distintos, bibliotecas de clases y componentes totalmente diferentes, herramientas diversas (y a veces poco amigables), etc.</li>
<li>Por no hablar del lenguaje... aunque tiene sus cosas buenas, la experiencia de programación con <strong>Javascript queda muy lejos de lo que supone utilizar C#</strong>, un lenguaje moderno, potente y con un sistema de tipos estricto que nos defienda de nosotros mismos y nuestros constantes errores. (Es cierto que TypeScript ha suavizado algo este asunto, pero, aún así, la experiencia no está a la altura.)</li>
</ul>
<p><strong>Con Blazor podremos desarrollar aplicaciones web (SPA y no SPA) profesionales</strong>, solventando todos los problemas anteriores de un plumazo:</p>
<ul>
<li><strong>La experiencia desde Visual Studio es exactamente como la conocemos</strong>: compilación, ejecución, depuración, testing, etc. Todo lo haremos usando las mismas herramientas de siempre, con las que ya somos productivos.</li>
<li>... aunque, si lo preferimos, podremos programar utilizando Visual Studio Code o cualquier otro editor ligero al que estemos acostumbrados y usar la línea de comandos para compilar, ejecutar, testear o distribuir.</li>
<li>En lugar de JavaScript, <strong>implementaréis la lógica de la interfaz de usuario en C#</strong>, y <strong>utilizaréis la biblioteca de clases de .NET que ya conocéis</strong> de sobra.</li>
<li>Lo anterior ya hace que la curva de aprendizaje sea suave, pero, aún hay más:
<ul>
<li>Si conocéis Razor de ASP.NET MVC, ASP.NET Core o Razor Pages, os sentiréis muy cómodos porque es la misma sintaxis usada para crear componentes Blazor.</li>
<li>También encontraréis que una de las formas en las que podemos ejecutar aplicaciones Blazor, llamada Blazor Server, es conceptualmente similar a ASP.NET Web Forms (aunque por supuesto sin sus conocidos problemas), por lo que no os costará mucho trabajo entenderlo si partís desde ese punto.</li>
</ul>
</li>
</ul>
<p>Obviamente tendréis que aprender a trabajar con Blazor, pero al menos no deberéis dedicar tiempo a conocer a fondo el entorno, las herramientas, las bibliotecas base o el lenguaje para sacarle partido: esa lección ya la traéis aprendida de casa ;)</p>
<p>Pero no sólo eso. Una vez conocemos Blazor, nos damos cuenta de que está construido sobre elementos muy sencillos, pensados disparar nuestra productividad desde el minuto uno. Una vez conocéis algunos fundamentos básicos, veréis que se pueden crear componentes, o elementos visuales reutilizables, con una facilidad y velocidad pasmosas.</p>
<blockquote>
<p>Con Blazor, <strong>los desarrolladores .NET podemos crear espectaculares aplicaciones web sin abandonar las herramientas ni el lenguaje que ya utilizamos a diario</strong>.</p>
</blockquote>
<h2>Si ya hemos trabajado con ASP.NET Core y MVC, ¿siguen valiendo estos conocimientos?<a name="aspnetcore"></a></h2>
<p>Totalmente. De hecho, <strong>si conocéis ASP.NET Core estaréis mejor posicionados para exprimir Blazor al máximo</strong>, porque hay conocimientos que podréis aprovechar directamente.</p>
<p>Por ejemplo, las Blazor Web Apps, que es el nuevo modelo de proyecto unificado utilizado por defecto para las aplicaciones web con Blazor, <strong>son en la práctica aplicaciones ASP.NET Core</strong>. Esto significa que heredan de la plataforma muchas funcionalidades de forma directa: inicialización, inyección de dependencias, <em>logging</em>, <em>settings</em>, <em>middlewares</em>, <em>routing</em>, etc. y, por tanto, vuestros conocimientos previos os serán de utilidad.</p>
<p>En caso de optar por el modelo de ejecución puro en el lado cliente, denominado Blazor WebAssembly, los conocimientos de ASP.NET Core os vendrán también de perlas para la implementación del <em>backend</em>, imprescindible en cualquier aplicación SPA. Además, en este caso, podréis disfrutar de las ventajas de utilizar .NET en ambos extremos: <strong>¡compartir código C# entre <em>frontend</em> y <em>backend</em> de forma directa!</strong></p>
<p>Inicialmente, la ideal de Blazor no era sustituir a MVC ni Razor Pages, simplemente cubría un hueco que anteriormente no estaba resuelto en el <em>stack</em> de tecnologías .NET: la implementación de aplicaciones SPA en el <em>frontend</em>. Por tanto, no se trataba de un reemplazo, sino de una opción adicional que simplificaba el acceso al mundo de las aplicaciones SPA.</p>
<p>Sin embargo, la última versión de Blazor aparecida con ASP.NET Core 8, ha traído consigo un nuevo modelo de proyecto unificado que incluye capacidades de renderización completa en servidor, por lo que, ya <strong>podríamos implementar en Blazor lo que hasta ahora hacíamos mediante vistas MVC o páginas Razor</strong>.</p>
<p>Lo importante, como siempre, <strong>es disponer de varias alternativas para poder elegir la más apropiada en cada escenario</strong>.</p>
<h2>¿En qué consiste el curso de desarrollo con Blazor?<a name="curso"></a></h2>
<p>Este curso se imparte <strong>completamente online</strong> utilizando <a href="https://www.plataformaself.com/">la potentísima plataforma de eLearning SELF</a> (de los mismos que están detrás de <a href="https://www.campusmvp.com">CampusMVP</a>), y siguiendo su contrastada metodología para asegurar tu éxito a lo largo el proceso de formación.</p>
<p style="float: right; margin: 0px 0px 20px 20px;"><a href="https://www.campusmvp.es/catalogo/Product-Desarrollo-de-aplicaciones-Web-con-Blazor-y-.NET_246.aspx?utm_source=variablenotfound&utm_medium=post&utm_content=post_curso_blazor&utm_campaign=blazor"><img alt="Curso de Blazor en CampusMVP" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhW6kjJqBpa5Mw9aVZIO3L-5nC2vM9NblrCc3za1y62OQJC8Nx8n143wuxL0v4r9DpQbmW3jG8xUuBJNrGkEzwKQqWQZrtfb8cBm7pgML7DjrT5h_NXZ5c328EJNOJoRYRBL1elJg/s220/banner-VNF-blazor.gif" /></a></p>
<p><strong>Sin horarios y a vuestro propio ritmo</strong>, pero no en solitario: contaréis con todo el soporte del equipo de CampusMVP y, <strong>dado que soy el tutor</strong>, me tendréis a vuestra disposición para la resolución de dudas y ayudaros durante aprendizaje.</p>
<p>La dedicación estimada ronda las 6 u 8 horas semanales, durante un total de 12 semanas. A lo largo de ellas realizaremos un <strong>profundo recorrido en la última versión Blazor, partiendo desde cero</strong>, a través de las más de 200 lecciones que componen el temario. Éste, además, lo podréis descargar en formato PDF (¡600 páginas!) al finalizar el curso, para que lo tengáis como referencia.</p>
<p>Para afianzar los conocimientos, incluimos también <b>más de 50 vídeos</b>, sin paja ni rellenos, directos al grano y llevados a cabo de forma magistral por el gran <a href="https://twitter.com/jm_alarcon">José Manuel Alarcón</a>, donde podréis ver en vivo el funcionamiento de muchas de las características que vamos estudiando.</p>
<p>Pero el curso no sólo consiste en contenido teórico: a lo largo del mismo <strong>encontraréis numerosas prácticas</strong> que os ayudarán a conseguir una mejor asimilación de los conceptos, así como proyectos descargables, consejos, trucos e ideas que seguro os resultarán de utilidad cuando vayáis a aplicar vuestros nuevos conocimientos en el mundo real.</p>
<p>¿Y cómo saber vuestro nivel de aprovechamiento? Sencillo. Conforme vayáis avanzando os propondremos autoevaluaciones que os permitirán conocer vuestro grado de conocimiento sobre los contenidos. Al finalizar el curso <b>podréis acreditar su realización mediante un diploma</b>, así como incluirlo en <a href="https://www.campusmvp.es/perfiles-certificados">vuestro perfil certificado de CampusMVP</a>, un perfil online verificable por terceros donde podéis demostrar qué habéis aprendido con nosotros.</p>
<h2>¿Cuáles son los contenidos del curso?<a name="contenidos"></a></h2>
<p>En este curso hacemos un <strong>completo recorrido de Blazor, comenzando desde cero</strong>.</p>
<p>Tras una breve introducción para ponernos en contexto, inmediatamente comenzamos describiendo los distintos modelos de <em>hosting</em> disponibles para el desarrollo web: <strong>Blazor SSR, Blazor Server y Blazor WebAssembly</strong>. Veremos cómo funcionan, sus elementos arquitecturales y las ventajas e inconvenientes de cada uno, para que podáis elegir cuál es el que más conviene en cada caso.</p>
<blockquote>
<p>A lo largo del curso <strong>estudiaremos los distintos modelos de <em>hosting</em> en paralelo</strong>, por lo que al finalizar estaréis en disposición de crear aplicaciones utilizando cualquiera de ellos.</p>
</blockquote>
<p>Seguidamente, entraremos en faena creando nuestros primeros proyectos Blazor, echando un vistazo a <strong>la forma de organizarlos</strong> y los <strong>tipos de componentes</strong> con los que estructuraremos nuestras aplicaciones.</p>
<p>Estudiaremos también en la <strong>sintaxis Razor</strong>, fundamental a la hora de escribir componentes, detallando sus particularidades y diferencias respecto al Razor que usamos en MVC o Razor Pages, directivas, construcciones y técnicas para organizar y simplificar el código.</p>
<p>Aprenderemos las distintas fórmulas para <strong>comunicar componentes</strong>, y a sacar provecho de los eventos del <strong>ciclo de vida</strong> de los mismos, así como a controlar aspectos como la <strong>liberación de recursos</strong> o la <strong>renderización de componentes</strong>.</p>
<p>Empezaremos creando componentes simples, pero iremos profundizando sucesivamente hasta llegar a <strong>componentes complejos</strong> que usan toda la potencia de Blazor para crear elementos altamente reutilizables gracias a la <strong>parametrización, uso de fragmentos o tipado genérico</strong>. Veremos cómo <strong>consumir y producir eventos</strong> del sistema o personalizados para facilitar la comunicación bidireccional entre componentes.</p>
<p>Haremos también una parada en la <strong>inyección de dependencias</strong> y aprenderemos a utilizarla para crear componentes más sencillos, limpios y reutilizables.</p>
<p>Dedicaremos un módulo al sistema de <strong>navegación y <em>routing</em></strong> de Blazor, aprendiendo a construir sitios navegables y controlar la navegación del usuario.</p>
<p>También pondremos el foco en el potente <strong>sistema de <em>binding</em></strong>, ese mecanismo que enlaza la UI con nuestras clases .NET de forma casi mágica. Seguidamente, nos centraremos en estudiar las herramientas que ofrece Blazor para ayudarnos a crear <strong>formularios de datos y validar</strong> la información suministrada.</p>
<p>La <strong>interoperación con Javascript</strong> también toma su protagonismo en el curso. Las fórmulas para comunicar nuestro código Blazor con este lenguaje abre la puerta al aprovechamiento del enorme ecosistema del mismo, consiguiendo que en muchas ocasiones no tengamos que partir de cero a la hora de crear interfaces espectaculares.</p>
<p>Para la creación de aplicaciones renderizadas por completo en el servidor, iremos viendo en distintos puntos las mejoras progresivas o <em>progressive enhancements</em> que nos ofrece <strong>Blazor SSR para conseguir una experiencia de usuario similar a la obtenida con una SPA</strong>.</p>
<p>Ya casi finalizando, nos detendremos en estudiar los <strong>mecanismos de autenticación y autorización</strong> que nos permitirán construir aplicaciones seguras y adaptadas a distintos perfiles de usuario. Veremos también cómo crear aplicaciones internacionalizadas, crear y distribuir componentes reutilizables o algunas técnicas para <em>testear</em> nuestros componentes.</p>
<p>De forma trasversal, al final de cada módulo te demostraremos sobre <strong>una aplicación real</strong> cómo "encajan" los conceptos que hemos ido viendo en él. Esa aplicación es <strong>BlazorStore</strong>, la plataforma de comercio electrónico que desarrollaréis al finalizar el curso, y para la que hemos reservado sus últimas lecciones.</p>
<p align="center"><iframe allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen="" frameborder="0" height="315" src="https://www.youtube.com/embed/w0vcKBHZ6BM" width="560"></iframe></p>
<h2>¿Qué conocimientos previos se necesitan para seguir el curso?<a name="conocimientos"></a></h2>
<p>Si estáis leyendo esto, probablemente ya los tengáis ;)</p>
<p>En primer lugar, dado que se trata de un curso de programación de aplicaciones web, es necesario <strong>conocer los fundamentos de este tipo de sistemas, al menos a un nivel básico</strong>. Debéis saber identificar cliente y servidor, entender las responsabilidades de cada uno de estos extremos y conocer mínimamente los mecanismos de comunicación entre ellos.</p>
<p>También es importante que conozcáis <strong>algo de HTML y CSS</strong>, y muy recomendable que tener algunas <strong>nociones de Javascript</strong>, aunque no es indispensable.</p>
<p>Por último, dado que una de las premisas de Blazor es desarrollar usando C# y .NET en todos los extremos, ¡qué menos que conocerlos! En el curso asumiremos que tenéis un <strong>nivel razonable de C#</strong> y que habéis trabajado con la <strong>biblioteca de clases base de .NET</strong>. Es decir, en el curso no explicaremos qué es una expresión lambda o qué es un objeto de tipo <code>List<string></code>, se supone que debéis saberlo antes de comenzar.</p>
<p>En cambio, no es necesario conocer nada sobre tecnologías de acceso a datos, pues el curso no entraremos en ello. En algunos ejemplos usaremos Entity Framework Core, pero no es necesario que lo conozcáis para poder seguirlos sin problema.</p>
<h2>Me convence, ¿cuándo empezamos?<a name="al-ataque"></a></h2>
<p>Pues ya, <strong>en cuanto queráis</strong> :) Sólo tenéis que <a href="https://www.campusmvp.es/catalogo/Product-Desarrollo-de-aplicaciones-Web-con-Blazor-y-.NET_246.aspx?utm_source=variablenotfound&utm_medium=post&utm_content=post_curso_blazor&utm_campaign=blazor">visitar la web de CampusMVP</a>, inscribiros, y casi sobre la marcha os facilitarán las credenciales de acceso a la plataforma.</p>
<blockquote>
<p>Recordad que, si trabajáis para una empresa española, este curso podríais hacerlo prácticamente sin coste, gracias a la <a href="https://www.campusmvp.es/descuentos/formacion-bonificada">Formación Bonificada</a>.</p>
</blockquote>
<h2>¡Eso es todo! Ahora es vuestro turno...</h2>
<p>Bueno, pues creo que con esto quedarán despejadas todas vuestras dudas sobre el curso, o al menos muchas de ellas. Si no es así, no dudéis en <a href="https://www.campusmvp.es/catalogo/Product-Desarrollo-de-aplicaciones-Web-con-Blazor-y-.NET_246.aspx?utm_source=variablenotfound&utm_medium=post&utm_content=post_curso_blazor&utm_campaign=blazor">contactar con CampusMVP</a>, donde os van a atender de maravilla, o conmigo a través de un comentario, <a href="https://www.variablenotfound.com/p/el-autor.html">correo electrónico</a> o usando el <a href="https://www.variablenotfound.com/p/formulario-de-contacto.html">formulario de contacto del blog</a>.</p>
<p>¡Espero veros a muchos por allí!</p>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-50520963419037855572024-02-12T08:05:00.004+01:002024-02-12T08:05:00.264+01:00Enlaces interesantes 555<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/03/evitar-que-codigo-de-pruebas-llegue.html">Evitar que código de pruebas llegue a producción usando directivas de compilación de C#</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2014/06/ejecutar-tareas-en-segundo-plano-en.html">Ejecutar tareas en segundo plano en ASP.NET 4.5.2</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/volcados-de-memoria-en-kubernetes-para-depurar-aplicaciones-net.aspx">Volcados de memoria en Kubernetes para depurar aplicaciones .NET</a><br />
CampusMVP</li>
<li><a href="https://www.meziantou.net/enable-the-new-terminallogger-in-dotnet-8-sdk-automatically.htm">Enable the new TerminalLogger in .NET 8 SDK automatically</a><br />
Gérald Barré</li>
<li><a href="https://code-maze.com/csharp-how-to-correctly-implement-idisposable-interface/">How to Correctly Implement IDisposable Interface in C#</a><br />
Code Maze</li>
<li><a href="https://dotnettips.wordpress.com/2024/02/05/general-performance-tips-for-microsoft-net-optimizing-attributes/">General Performance Tip: Optimizing Attributes</a><br />
David McCarter</li>
<li><a href="https://minidump.net/exploring-frozen-segments/">Exploring .NET frozen segments</a><br />
Kevin Gosse</li>
<li><a href="https://andrewlock.net/using-default-interface-methods-for-performance-gains-in-iheaderdictionary/">Using default interface methods for performance gains in IHeaderDictionary</a><br />
Andrew Lock</li>
<li><a href="https://code-maze.com/xunit-how-to-pass-complex-parameters-to-theory/">How to Pass Complex Parameters to Theory in xUnit</a><br />
Code Maze</li>
<li><a href="https://code-maze.com/dotnet-appsettings-json-content-to-dictionary/">How to Get appsettings.json Content as a Dictionary in .NET Core</a><br />
Code Maze</li>
<li><a href="https://bartwullems.blogspot.com/2024/02/net-8its-time-to-get-rid-of-these-flaky.html">.NET 8–It’s time to get rid of these flaky tests!</a><br />
Bart Wullems</li>
<li><a href="https://devblogs.microsoft.com/dotnet/resilience-and-chaos-engineering/">Resilience and chaos engineering</a><br />
Martin Tomka<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://damienbod.com/2024/02/05/secure-an-asp-net-core-blazor-web-app-using-microsoft-entra-id/">Secure an ASP.NET Core Blazor Web app using Microsoft Entra ID</a><br />
Damien Bowden</li>
<li><a href="https://www.devleader.ca/2024/02/01/ultimate-starter-guide-to-middleware-in-asp-net-core-everything-you-need-to-know/">Ultimate Starter Guide to Middleware in ASP.NET Core</a><br />
Nick Cosentino</li>
<li><a href="https://www.codeproject.com/Articles/5376905/How-to-Use-Local-Storage-in-Blazor">How to Use Local Storage in Blazor</a><br />
Rikam</li>
<li><a href="https://www.syncfusion.com/blogs/post/syncfusion-blazor-playground-app.aspx">Explore the Possibilities of the Blazor Playground App</a><br />
Rajendran R.</li>
<li><a href="https://khalidabuhakmeh.com/html-web-components-with-vanilla-javascript-and-aspnet-core">HTML Web Components with Vanilla JavaScript and ASP.NET Core</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://code-maze.com/aspnetcore-mapcontrollers-vs-mapcontrollerroute-routing/">MapControllers vs MapControllerRoute Routing in ASP.NET Core</a><br />
Code Maze</li>
<li><a href="https://code-maze.com/aspnetcore-secret-management/">Tools and Best Practices for Secret Management in .NET</a><br />
Code Maze</li>
<li><a href="https://www.telerik.com/blogs/unified-blazor-web-app-project-template-fully-explained">Unified Blazor Web App Project Template Fully Explained</a><br />
Ed Charbeneau</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://johnnyreilly.com/using-bun-in-azure-pipelines">Using Bun in Azure Pipelines</a><br />
John Reilly</li>
<li><a href="https://pmichaels.net/app-insights-alerts/">Application Insights Alerts</a><br />
Paul Michaels</li>
<li><a href="https://www.devlead.se/posts/2024/2024-02-08-introducing-ari">Introducing ARI</a><br />
Mattias Karlsson</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://tonsky.me/blog/unicode/">The Absolute Minimum Every Software Developer Must Know About Unicode in 2023 (Still No Excuses!)</a><br />
Nikita Prokopov</li>
<li><a href="https://codeopinion.com/listen-to-yourself-pattern-is-it-an-alternative-to-the-outbox-pattern/">Listen to yourself pattern: Is it an alternative to the Outbox Pattern?</a><br />
Derek Comartin</li>
<li><a href="https://devblogs.microsoft.com/oldnewthing/20240209-00/?p=109379">On the virtues of the trailing comma</a><br />
Raymond Chen</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://code-maze.com/lazy-loading-and-eager-loading-in-entity-framework-core/">Lazy Loading and Eager Loading in Entity Framework Core</a><br />
Code Maze</li>
<li><a href="https://www.milanjovanovic.tech/blog/how-i-made-my-efcore-query-faster-with-batching">How I Made My EF Core Query 3.42x Faster With Batching</a><br />
Milan Jovanović</li>
<li><a href="https://build5nines.com/nosql-vs-sql-demystifying-nosql-databases/">NoSQL Vs SQL: Demystifying NoSQL Databases</a><br />
Chris Pietschmann</li>
<li><a href="https://hamedsalameh.com/full-text-search-with-elasticsearch-and-netcore/">Full Text Search With ElasticSearch And .NetCore</a><br />
Hamed Salameh</li>
<li><a href="https://dev.to/nnomier/can-redis-be-used-as-a-primary-database-5d4b">Can Redis be used as a Primary database?</a><br />
Noha N.</li>
<li><a href="https://www.freecodecamp.org/news/use-dapper-in-your-dotnet-projects/">How to Use Dapper in Your .NET Projects</a><br />
Grant Riordan</li>
<li><a href="https://dateo-software.de/blog/concurrency-entity-framework">Be optimistic about concurrency in Entity Framework</a><br />
Dennis Frühauff</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://blog.google/technology/ai/google-gemini-update-sundar-pichai-2024/">The next chapter of our Gemini era</a><br />
Sundar Pichai</li>
<li><a href="https://dev.to/cyber_holics/introduction-to-tensors-the-building-blocks-of-artificial-intelligence-3lcb">Introduction To Tensors: The Building Blocks Of Artificial Intelligence</a><br />
Victor Isaac Oshimua</li>
<li><a href="https://visualstudiomagazine.com/articles/2024/02/09/prompt-engineering-tips.aspx">'Prompt Engineering' Jokes Abound when GitHub Asks Devs for Tips</a><br />
David Ramel</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://blog.jquery.com/2024/02/06/jquery-4-0-0-beta/">jQuery 4.0.0 BETA!</a><br />
Timmy Wilison</li>
<li><a href="https://eisenbergeffect.medium.com/using-global-styles-in-shadow-dom-5b80e802e89d">Using Global Styles in Shadow DOM</a><br />
Rob Eisenberg</li>
<li><a href="https://www.telerik.com/blogs/simplify-javascript-development-lodash">Simplify JavaScript Development with Lodash</a><br />
Hassan Djirdeh</li>
<li><a href="https://www.telerik.com/blogs/understanding-utilizing-javascript-set-object">Understanding and Utilizing the JavaScript Set Object</a><br />
Hassan Djirdeh</li>
<li><a href="https://davidwalsh.name/detect-caps-lock">Detect Caps Lock with JavaScript</a><br />
David Walsh</li>
<li><a href="https://levelup.gitconnected.com/html-attributes-that-every-web-developer-should-know-8ffd4cd88288">HTML Attributes That Every Web Developer Should Know</a><br />
Shalitha Suranga</li>
<li><a href="https://www.zachleat.com/web/carouscroll/">carouscroll Web Component</a><br />
Zach Leatherman</li>
<li><a href="https://davidwalsh.name/css-override-width-height">How to Override width and height HTML attributes with CSS</a><br />
David Walsh</li>
<li><a href="https://www.telerik.com/blogs/how-upload-multiple-files-angular-app">How to Upload Multiple Files in an Angular App</a><br />
Dany Paredes</li>
<li><a href="https://www.smashingmagazine.com/2024/02/web-development-getting-too-complex/">Web Development Is Getting Too Complex, And It May Be Our Fault</a><br />
Juan Diego Rodríguez</li>
<li><a href="https://www.syncfusion.com/blogs/post/top-react-libraries-build-ui.aspx">Top 8 React Libraries for Building Beautiful and Functional UIs</a><br />
Vidura Senevirathne</li>
<li><a href="https://dev.to/nwhitmont/configuring-prettier-and-eslint-in-your-vscode-typescript-project-3fa9">Configuring Prettier and ESLint in Your VSCode TypeScript Project</a><br />
Nils Whitmont</li>
<li><a href="https://www.smashingmagazine.com/2024/02/draw-radar-charts-web/">How To Draw Radar Charts In Web</a><br />
Preethi Sam</li>
<li><a href="https://www.telerik.com/blogs/how-javascript-frameworks-share-data-across-components">How JavaScript Frameworks Share Data Across Components</a><br />
Jonathan Gamble</li>
<li><a href="https://frankforce.com/lu1ky-pinball-code-deep-dive/">How I made a 1K Pinball Game in JavaScript – Lu1ky Pinball</a><br />
Frank Force</li>
<li><a href="https://geoffgraham.me/css-is-logical/">CSS is Logical - Geoff Graham</a><br />
Geoff Graham</li>
<li><a href="https://tympanus.net/codrops/2024/02/07/on-scroll-revealing-webgl-image-explorations/">On-Scroll Revealing WebGL Images</a><br />
Yuri Artiukh</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/commandline/introducing-sudo-for-windows/">Introducing Sudo for Windows!</a><br />
Jordi Adoumie</li>
<li><a href="https://www.itprotoday.com/windows-11/getting-started-microsoft-powertoys#close-modal">Getting Started With Microsoft PowerToys</a><br />
Brien Posey</li>
<li><a href="https://devblogs.microsoft.com/dotnet/dev-tunnels-a-game-changer-for-mobile-developers/">Dev Tunnels: A Game Changer for Mobile Developers</a><br />
James Montemagno</li>
<li><a href="https://www.codeproject.com/Tips/5376943/Getting-Started-with-Playwright-using-Visual-Studi">Getting Started with Playwright using Visual Studio 2022/C# and NUnit</a><br />
Mohammed Faci</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/02/05/creating-custom-ai-prompts-with-resharper/">Creating Custom AI Prompts with ReSharper and Rider</a><br />
Rachel Appel</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/developing-with-accessibility-in-mind-at-microsoft/">Developing With Accessibility in Mind at Microsoft</a><br />
Nandita Gupta</li>
<li><a href="https://pmichaels.net/ildasm/">Using ildasm to view IL code</a><br />
Paul Michaels</li>
<li><a href="https://devblogs.microsoft.com/dotnet/my-top-10-new-visual-studio-features-of-2023-for-dotnet-developers/">My Top 10 NEW Visual Studio Features of 2023 for .NET Developers</a><br />
James Montemagno</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://www.syncfusion.com/blogs/post/waiting-list-ui-dotnet-maui.aspx">Easily Replicate a Waiting List UI in .NET MAUI</a><br />
Leomaris Reyes</li>
<li><a href="https://egvijayanand.in/2024/02/09/dotnet-maui-item-templates-made-easy-on-cli-and-visual-studio-code/">.NET MAUI – Item Templates – Made Easy on CLI and VS Code</a><br />
Vijay Anand</li></ul><ul>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-66401780006834683082024-02-06T08:05:00.023+01:002024-02-19T08:27:31.437+01:00Cómo conseguir que los parámetros de un constructor primario de C# sean de sólo lectura<img alt="C#" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6uTC5x0nlVPyLR4CwNZmbC6X_dp-XG-L7MNo4ylZBY-DaxxtWVWGVZMKZwiZqSvztUM4LVUptbWTW02XiPXFjZUm550YRQz98TL_RVgdi1x4udSL8alkcJpt5H38rMewexMwK38MI4D3ClXS6OAUB4uukNPDT0tTePgDzKDxt9lTJ_3UWCyw/s16000/csharp.png" title="C#" width="100%" />
<p>Hace unos días, veíamos por aquí los <a href="https://www.variablenotfound.com/2024/01/constructores-primarios-en-c-12.html">constructores primarios de C#</a>, una característica recientemente introducida en el lenguaje que permite omitir el constructor si en éste lo único que hacemos es asignar los valores de sus parámetros a campos de la clase.</p>
<p>Veamos un ejemplo a modo de recordatorio rápido:</p>
<pre><code class="language-cs">// Clase con constructor tradicional
public class Person
{
private readonly string _name;
public Person(string name)
{
_name = name;
}
public override string ToString() => _name;
}
// La misma clase usando el constructor primario:
public class Person(string name)
{
public override string ToString() => name;
}
</code></pre>
<p>Como comentamos en el post, los parámetros del constructor primarios eran internamente convertidos en campos privados de la clase, generados automáticamente e inaccesibles desde el código.<span></span></p><a name='more'></a><p></p>
<p>Sin embargo, <strong>los valores de los parámetros podían ser modificados desde los miembros de instancia</strong>, lo cual podría resultar bastante problemático, sobre todo porque es habitual que los parámetros suministrados a un constructor sean almacenados en campos de sólo lectura, como hemos visto en el ejemplo anterior de uso del constructor tradicional.</p>
<p>Por ejemplo, observemos el siguiente código, donde no podemos asegurar que la salida de <code>ToString()</code> sea el valor suministrado al constructor porque quizás se realizó una llamada previa a <code>Set()</code> y su valor fue modificado:</p>
<pre><code class="language-cs">public class Person(string name)
{
public override string ToString() => name;
public void Set()
{
name = "Otro nombre";
}
}
</code></pre>
<p>Podemos comprender mejor por qué se comporta de esta forma si echamos un vistazo al código que genera el compilador durante la construcción del proyecto. En él podemos ver que internamente el método <code>Set()</code> está sobrescribiendo el valor directamente sobre el campo privado autogenerado y, por tanto, cualquier modificación al valor del parámetro afectará al resto de miembros que lo utilicen:</p>
<pre><code class="language-cs">public class Person
{
[CompilerGenerated]
private string <name>P;
public Person(string name)
{
<name>P = name;
base..ctor();
}
public override string ToString()
{
return <name>P;
}
public void Set()
{
<name>P = "Otro nombre";
}
}
</code></pre>
<p>Para los que solemos capturar en miembros <code>readonly</code> los parámetros proporcionados a un constructor, esta posibilidad es realmente peligrosa porque puede dar lugar a comportamientos inesperados y fallos difíciles de cazar. Por ello, me ha alegrado descubrir que, aunque obligue a teclear algo más, <strong>hay formas sencillas de evitar las modificaciones de los parámetros del constructor primario</strong>.</p>
<h2>Cómo hacer que un parámetro del constructor primario sea de sólo lectura</h2>
<p>Una primera idea consiste en <strong>añadir a la clase un campo <code>readonly</code> con el mismo nombre que el parámetro del constructor primario, y asignarle el valor del parámetro recibido</strong>. Este escenario será detectado por el compilador, que ya no tendrá necesidad de generar un nuevo campo privado para almacenar el valor del parámetro porque usará el que estamos proporcionando.</p>
<p>Creo que se entiende mejor si lo vemos en código:</p>
<pre><code class="language-cs">public class Person(string name)
{
private readonly string name = name;
public override string ToString() => name;
}
</code></pre>
<p>Al compilarlo, el código generado será equivalente al siguiente. Observad que ya no existe el campo autogenerado <code><name>P</code> porque se utiliza directamente el campo <code>name</code> que hemos añadido:</p>
<pre><code class="language-cs">public class Person
{
private readonly string name;
public Person(string name)
{
this.name = name;
base..ctor();
}
public override string ToString()
{
return name;
}
}
</code></pre>
<p>Y obviamente, al tratarse de un campo de sólo lectura, la inserción de un método como el siguiente generará un error de compilación:</p>
<pre><code class="language-cs">public class Person(string name)
{
private readonly string name = name;
public override string ToString() => name;
public void Set()
{
name = "Otro nombre"; // Error CS0191: No se puede asignar
// un valor a un campo readonly
}
}
</code></pre>
<p>Una variante de la solución anterior, que además nos viene mejor si seguimos alguna convención específica para el nombrado de campos privados (por ejemplo, usar el guion bajo como prefijo), se basa en <b>insertar el modificador <code>in</code> en el parámetro del constructor primario</b>. Cuando se hace esto, dicho parámetro deja de estar accesible desde los miembros de la clase y, por tanto, sólo podemos usarlo durante la construcción de la instancia. Es decir, el siguiente código fallaría en compilación:</p>
<pre><code class="language-cs">public class Person(in string name)
{
public override string ToString() => name; // error CS9109: Cannot use ref, out, or in
// primary constructor parameter 'name'
// inside an instance member
}
</code></pre>
<p>De esta forma aseguramos que el valor del parámetro del constructor primario no será modificado (vaya, ni siquiera leído) desde el código de la clase. Y partiendo de esto, podríamos ahora <strong>añadir un campo privado de sólo lectura</strong>, con el nombre que nos interese, para poner el valor a disposición del miembro que lo necesite:</p>
<pre><code class="language-cs">public class Person(in string name)
{
private readonly string _name = name;
public override string ToString() => _name;
}
</code></pre>
<p>Como curiosidad, el código generado por el compilador es el equivalente al siguiente, bastante similar al que vimos al principio del post, en el ejemplo donde usábamos constructores tradicionales:</p>
<pre><code class="language-cs">public class Person
{
private readonly string _name;
public Person([In][IsReadOnly] ref string name)
{
_name = name;
base..ctor();
}
public override string ToString()
{
return _name;
}
}
</code></pre>
<p>¡Espero que os sea de ayuda!</p>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com2tag:blogger.com,1999:blog-27752126.post-54951511124693737222024-02-05T08:05:00.001+01:002024-02-05T08:05:00.136+01:00Enlaces interesantes 554<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/03/modificar-en-tiempo-de-ejecucion-el.html">Modificar en tiempo de ejecución el valor de los settings de una aplicación ASP.NET Core</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2013/05/eager-loading-en-entity-framework.html">Eager loading en Entity Framework: mejora drástica del rendimiento en acceso a datos</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/thread-sleep-vs-task-delay-en-net-como-introducir-retardos-en-tu-codigo-correctamente.aspx">Thread.Sleep vs Task.Delay en .NET: cómo introducir retardos en tu código correctamente</a><br />
José Manuel Alarcón</li>
<li><a href="https://cezarypiatek.github.io/post/generate-wiremocknet-mappings-with-proxy/">The fastest way to create WireMock.NET mappings</a><br />
Cezary Piątek</li>
<li><a href="https://code-maze.com/csharp-how-to-create-xml-documents/">How to Create XML Files in C#</a><br />
Matjaz Prtenjak</li>
<li><a href="https://bartwullems.blogspot.com/2024/01/gethashcode-in-net-core.html">GetHashCode() in .NET Core</a><br />
Bart Wullems</li>
<li><a href="https://www.mobilize.net/blog/consuming-wcf-services-in-dotnet8">Consuming WCF Services in .NET 8 (.NET Core is no more!)</a><br />
DeeDee Walsh</li>
<li><a href="https://www.jimmybogard.com/tales-from-the-net-migration-trenches-hangfire/">Tales from the .NET Migration Trenches - Hangfire</a><br />
Jimmy Bogard</li>
<li><a href="https://www.meziantou.net/checking-if-a-collection-is-empty-in-csharp.htm">Checking if a collection is empty in C#</a><br />
Gérald Barré</li>
<li><a href="https://fiseni.com/posts/the-journey-to-630x-faster-batch-job/">From Hours to Seconds: The Journey to a 630x Faster Batch Job</a><br />
Fati Iseni</li>
<li><a href="https://www.milanjovanovic.tech/blog/how-to-build-a-url-shortener-with-dotnet">How to Build a URL Shortener With .NET</a><br />
Milan Jovanović</li>
<li><a href="https://andrewlock.net/understanding-default-interface-methods/">Understanding C# 8 default interface methods</a><br />
Andrew Lock</li>
<li><a href="https://khalidabuhakmeh.com/dotnet-tasks-lists-foreach-and-problems">.NET Tasks, List’s ForEach, and Problems</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://code-maze.com/csharp-how-to-select-multiple-records-using-linq/">How to Select Multiple Records Based on a List of IDs Using LINQ</a><br />
Bozo Spoljaric</li>
<li><a href="https://code-maze.com/csharp-logging-message-templates/">How to Properly Create Message Templates for Logging in C#</a><br />
Vadzim Zylevich</li>
<li><a href="https://bartwullems.blogspot.com/2024/01/net-8refresh-memory-limit.html">.NET 8–Refresh memory limit</a><br />
Bart Wullems</li>
<li><a href="https://code-maze.com/csharp-arraysegment/">How To Use ArraySegment in C#</a><br />
Kamil Pakula</li>
<li><a href="https://dev.to/esdanielgomez/using-azure-openai-service-to-generate-images-with-dall-e-in-net-49n9">Using Azure OpenAI Service to generate images with DALL-E in .NET</a><br />
Daniel Gomez</li>
<li><a href="https://www.codeproject.com//Articles/5275388/HigLabo-Mapper-Creating-Fastest-Object-Mapper-in-t">HigLabo.Mapper, Creating Fastest Object Mapper in the world with Expression Tree in 10 Days</a><br />
Higty</li>
<li><a href="https://visualstudiomagazine.com/articles/2024/02/01/matrix-inverse-ml-tutorial.aspx">Matrix Inverse from Scratch Using SVD Decomposition with C#</a><br />
James McCaffrey</li>
<li><a href="https://steven-giesel.com/blogPost/080c8f82-f376-489f-a304-72d419978294">SearchValues object become better with .NET 9</a><br />
Steven Giesel<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://ardalis.com/log-request-headers-middleware/">Log Request Headers Middleware for ASP.NET Core</a><br />
Steve Smith</li>
<li><a href="https://code-maze.com/aspnetcore-different-ways-to-run-background-tasks/">Different Ways to Run Background Tasks in ASP.NET Core</a><br />
Code Maze</li>
<li><a href="https://ardalis.com/http-file-not-sending-auth-header/">Solved! Visual Studio .http File Not Sending Authorization Header</a><br />
Steve Smith</li>
<li><a href="https://jonhilton.net/client-or-server-project-for-components/">Should I put my Blazor components in the server project, or the client project?</a><br />
Jon Hilton</li>
<li><a href="https://ilovedotnet.org/blogs/blazor-wasm-communication-between-components/">Blazor WASM Communication Between Components</a><br />
Abdul Rahman Shabeek Mohamed</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://dev.to/isaacojeda/workflows-3goj">.NET Orquestado: Workflows con DTFx y Azure</a><br />
Isaac Ojeda</li>
<li><a href="https://devblogs.microsoft.com/dotnet/how-to-deploy-dotnet-aspire-apps-to-azure-container-apps/">How to deploy .NET Aspire apps to Azure Container Apps</a><br />
Jiachen Jiang</li>
<li><a href="https://techcommunity.microsoft.com/t5/azure-storage-blog/azure-blob-storage-events-a-event-driven-solution-for-blob/ba-p/4025612">Azure Blob Storage Events: A event-driven solution for Blob Storage changes</a><br />
Nishant Ranjan</li>
<li><a href="https://www.red-gate.com/simple-talk/homepage/c-sharp-cancellation-tokens-in-aws/">C# Cancellation Tokens in AWS</a><br />
Camilo Reyes</li>
<li><a href="https://stackify.com/how-to-use-dependency-injection-in-azure-functions/">How to Use Dependency Injection in Azure Functions</a><br />
HitSubscribe</li>
<li><a href="https://azure.github.io/AppService/2024/01/29/Harnessing-the-Power-of-Network-Trace-Analysis-in-Azure-App-Service.html">Harnessing the Power of Network Trace Analysis in Azure App Service</a><br />
Olu Shadare</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://adhithiravi.medium.com/transforming-legacy-code-a-software-consultants-perspective-943495cb6795">Transforming Legacy Code — A Software Consultant’s Perspective</a><br />
Adhithi Ravichandran</li>
<li><a href="https://www.kirupa.com/data_structures_algorithms/default_sorting_algorithms.htm">Meet the Default Sorting Algorithms!</a><br />
Kirupa Chinnathambi</li>
<li><a href="https://geekswithblogs.com/aimee/put-vs-patch-with-rest-apis/">PUT vs PATCH with REST APIs</a><br />
Aimee Writer</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://techcommunity.microsoft.com/t5/sql-server-blog/released-microsoft-data-sqlclient-5-1-5/ba-p/4044024">Released: Microsoft.Data.SqlClient 5.1.5</a><br />
David Engel</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://code-maze.com/csharp-machine-learning-probabilistic-programming-with-infer-net/">Probabilistic Programming in C# With Infer.NET</a><br />
Ivan Matec</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/typescript/announcing-typescript-5-4-beta/">Announcing TypeScript 5.4 Beta</a><br />
Daniel Rosenwasser</li>
<li><a href="https://blog.openreplay.com/vue-custom-drag-and-drop-file-uploading/">Improving Vue.js Drag-and-Drop File Uploading</a><br />
David Fagbuyiro</li>
<li><a href="https://blog.cassidoo.co/post/css-accent-color/">Use CSS accent-color to style your inputs</a><br />
Cassidy Williams</li>
<li><a href="https://dev.to/ctnkaan/typescript-secrets-part-1-as-const-57ne">TypeScript Secrets Part 1: "as const"</a><br />
Çetin Kaan Taşkıngenç</li>
<li><a href="https://www.nieknijland.nl/blog/animating-hamburger-menu-icons">Animating hamburger menu icons</a><br />
Niek Nijland</li>
<li><a href="https://olodocoder.hashnode.dev/javascript-web-apis-series-file-storage-apis">JavaScript Web APIs Series: File and Storage APIs</a><br />
Adebayo Adams</li>
<li><a href="https://ruoyusun.com/2024/01/23/cividle-optimization.html">Squeezing Last Bit Of JavaScript Performance For My Automation Game</a><br />
Ruoyu Sun</li>
<li><a href="https://httptoolkit.com/blog/what-is-x-forwarded-for/">What is X-Forwarded-For and when can you trust it?</a><br />
Phil Sturgeon</li>
<li><a href="https://levelup.gitconnected.com/html-tags-that-help-you-build-modern-frontends-a57296ccb4c1">HTML Tags That Help You Build Modern Frontends</a><br />
Shalitha Suranga</li>
<li><a href="https://webdesign.tutsplus.com/how-to-integrate-bootstrap-5-tabs-with-chartjs--cms-107864t">How to Integrate Bootstrap 5 Tabs With Chart.js</a><br />
George Martsoukos</li>
<li><a href="https://www.telerik.com/blogs/how-to-implement-scheduler-component-react-application">How to Implement the Scheduler Component in Your React App</a><br />
Hassan Djirdeh</li>
<li><a href="https://dev.to/eralpozcan/how-to-use-object-recognition-with-tensorflowjs-and-vue-3-3glb">How to Use Object Recognition with TensorFlow.js and Vue 3?</a><br />
Eralp</li>
<li><a href="https://www.codeproject.com/Articles/5376754/Custom-Bootstrap-5-Breadcrumbs">Custom Bootstrap 5 Breadcrumbs</a><br />
Mark Pelf</li>
<li><a href="https://dev.to/alexmercedcoder/understanding-javascript-promises-in-depth-5ga9">Understanding JavaScript Promises In-Depth</a><br />
Alex Merced</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://www.infoq.com/news/2024/01/vs-github-copilot-new-features/">Visual Studio GitHub Copilot Extension Introduces New Features and Enhancements</a><br />
Almir Vuk</li>
<li><a href="https://www.code4it.dev/blog/custom-snippets-visualstudio2022/">How to create custom snippets in Visual Studio 2022</a><br />
Davide Bellone</li>
<li><a href="https://blog.elmah.io/secret-elmah-io-features-1-include-source-code-in-errors/">"Secret" elmah.io features</a><br />
Thomas Ardal</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/01/29/12-debugging-techniques-in-jetbrains-rider-you-should-know-about/">12 Debugging Techniques In JetBrains Rider You Should Know About</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/in-the-debuggers-spotlight-a-year-in-review/">In the Debugger's Spotlight: A Year in Review</a><br />
Harshada Hole</li>
<li><a href="https://ardalis.com/pass-results-from-one-powershell-script-to-another/#sq_hhp5dbjy6f">Pass Results from One PowerShell Script To Another</a><br />
Steve Smith</li>
<li><a href="https://code.visualstudio.com/updates/v1_86#_accessibility">Visual Studio Code January 2024</a><br />
VS Code Team</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://www.syncfusion.com/blogs/post/maui-stackedcolumn-chart-athlete.aspx">Chart of the Week: Create a .NET MAUI Stacked Column Chart for the Top-Earning Female Athletes</a><br />
Dhanaraj Rajendran</li>
<li><a href="https://www.syncfusion.com/blogs/post/load-maui-scheduler-sqlite-crud.aspx">Easily Load Appointments in .NET MAUI Scheduler with SQLite and Perform CRUD</a><br />
Jeyasri Murugan</li>
<li><a href="https://visualstudiomagazine.com/articles/2024/02/02/maui-dos-and-donts.aspx">12 Simple .NET MAUI Do's and Don'ts</a><br />
David Ramel</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://www.specnext.com/zx-spectrum-next-assembly-developer-book/">ZX Spectrum Next Assembly Developer book</a><br />
Carlos Henrique Olifiers</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-24514506798039088092024-01-30T08:05:00.006+01:002024-01-30T08:05:00.130+01:00Constructores primarios en C# 12<img alt="C#" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6uTC5x0nlVPyLR4CwNZmbC6X_dp-XG-L7MNo4ylZBY-DaxxtWVWGVZMKZwiZqSvztUM4LVUptbWTW02XiPXFjZUm550YRQz98TL_RVgdi1x4udSL8alkcJpt5H38rMewexMwK38MI4D3ClXS6OAUB4uukNPDT0tTePgDzKDxt9lTJ_3UWCyw/s16000/csharp.png" title="C#" width="100%" />
<p>Hace ya algunos años, con la llegada de C# 9, los <em>records</em> nos mostraron otra forma de crear objetos distinta a los clásicos constructores. Ya entonces, y únicamente en aquél ámbito, se comenzó a hablar de <em>primary constructors</em>, pero no ha sido hasta C# 12 cuando se ha implementado de forma completa esta característica en el lenguaje.</p>
<p>En este post vamos a ver de qué se trata, cómo podemos utilizarlos y peculiaridades que hay que tener en cuenta.</p><p><span></span></p><a name='more'></a><p></p>
<p>Básicamente, los constructores primarios o principales (no sé cuál es la traducción más correcta, pero me me gusta más la primera 😉) proporcionan una sintaxis más concisa para definir clases o estructuras que necesitan un constructor para poder ser materializadas.</p>
<p>A diferencia de los constructores tradicionales, <b>los parámetros de entrada se definen sobre la propia clase o estructura y estarán disponibles en todo su cuerpo sin necesidad de mapearlos a campos o propiedades internas</b>.</p>
<p>Vamos a ver un ejemplo muy simple de su uso, pero partiremos de la implementación de una clase básica, que necesita 9 líneas de código si usamos la fórmula "clásica" de C#:</p>
<pre><code class="language-cs">Console.WriteLine(new Person("John")); // Muestra "John" por consola
// Clase con constructor tradicional
public class Person
{
private readonly string _name;
public Person(string name)
{
_name = name;
}
public override string ToString() => _name;
}
</code></pre>
<p>El código equivalente usando un constructor primario sería el siguiente, donde podéis ver que lo hemos reducido a sólo 4 líneas (50%, poco más, poco menos):</p>
<pre><code class="language-cs">public class Person(string name)
{
public override string ToString() => name;
}
</code></pre>
<p>Ahora, teniendo este código en mente, fijaos en varios puntos importantes.</p>
<p>Primero, <strong>los parámetros del constructor primario se definen entre paréntesis después del nombre de la clase o estructura</strong>. Es decir, no es necesario definir un método constructor ni nada parecido, todo va ahí.</p>
<p>Segundo, <strong>no ha hecho falta guardar el valor del parámetro <code>name</code></strong> en ningún sitio. Todos los miembros de la clase o estructura tienen acceso a él, como puedes comprobar en el método <code>ToString()</code>.</p>
<p>Fijaos también en que en dicho método hemos accedido de forma directa al parámetro, <strong>no hemos necesitado usar <code>this</code></strong> porque realmente se trata de un parámetro del constructor primario, no un campo o propiedad de la clase.</p>
<p>Los constructores primarios pueden convivir con otros constructores, es decir, nada impide que una clase como la anterior tenga constructores adicionales. La única pega es que estos <strong>otros constructores deberán llamar obligatoriamente al constructor primario</strong> para asegurar que los parámetros sean inicializados antes de usarlos. Podemos ver un ejemplo a continuación:</p>
<pre><code class="language-cs">public class Person(string name, int? age)
{
public Person(string name): this(name, 0) { }
public Person(int age): this("Anonymous", age) { }
public override string ToString() => name;
}
</code></pre>
<p>Y por supuesto, <strong>podemos usarlos para recibir parámetros de cualquier tipo u origen</strong>. Por ejemplo, un escenario donde serán especialmente útiles es a la hora de recibir los servicios requeridos por una clase cuando usamos inyección de dependencias, pues evitaremos mucho código de fontanería:</p>
<pre><code class="language-cs">public class InvoiceServices(IInvoice repository, IUnitOfWork uow, INotifier notifier)
{
public async Task<Invoice> CreateInvoice(Invoice invoice)
{
repository.Add(invoice);
await uow.CommitAsync();
await notifier.NotifyNewInvoiceAsync(invoice);
...
}
}
</code></pre>
<p>Obviamente, los parámetros del constructor primario no estarán disponibles desde miembros estáticos porque no hay ninguna instancia por detrás cuyo constructor recoja los valores. Por tanto, el siguiente código fallaría en compilación:</p>
<pre><code class="language-cs">public class Person(string name)
{
public override string ToString() => name;
// Error CS9105:
// Cannot use primary constructor parameter 'string name' in this context.
public static void Print() => Console.WriteLine(name);
}
</code></pre>
<p>Aunque no sean visibles, los parámetros de los constructores primarios son introducidos en campos privados, inaccesibles para el desarrollador. El compilador simplemente hace la "magia" de transformar el acceso a los parámetros del constructor en acceso a estos campos privados. Y, como tales, <b>sus valores pueden ser modificados</b> desde el código (algo que no se me antoja especialmente recomendable, pero bueno):</p>
<pre><code class="language-cs">var person = new Person("John");
person.SetName("Peter");
Console.WriteLine(person); // Muestra "Peter" por consola
public class Person(string name)
{
public void SetName(string newName) => name = newName;
public override string ToString() => name;
}
</code></pre>
<p>Estos campos privados no son visibles fuera de la clase, aunque podríamos crear propiedades de acceso a ellos, como hemos hecho siempre:</p>
<pre><code class="language-cs">public class Person(string name)
{
public string Name => name;
public override string ToString() => name;
}
</code></pre>
<p>Obviamente, estos dos últimos aspectos no aplican en <em>records</em>, que por definición son inmutables y los parámetros de sus constructores primarios son propiedades públicas:</p>
<pre><code class="language-cs">var person = new Person("John");
Console.WriteLine(person.Name); // Muestra "John" por consola
public record Person(string Name)
{
// Error CS8852: no se puede asignar Person.Name
public void SetName(string newName) => Name = newName;
}
</code></pre>
<h2>Conclusiones</h2>
<p>En definitiva, los constructores primarios son una interesante mejora que, en la línea de muchas otras novedades recientes, continúan haciendo el código C# cada vez más conciso.</p>
<p>Aunque la sintaxis pueda resultar algo rara al principio, no creo que vayamos a tardar demasiado en acostumbrarnos a ella y comenzar a introducirla en nuestros desarrollos. Que al final, cualquier cambio destinado a que nuestras manos sufran menos, bienvenido es 😉</p>
Publicado en: <a href="https://www.variablenotfound.com">www.variablenotfound.com</a>.José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com2tag:blogger.com,1999:blog-27752126.post-7207942430004642682024-01-29T08:05:00.001+01:002024-01-29T08:05:00.125+01:00Enlaces interesantes 553<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/03/usar-booleanos-si-no-veces.html">¿Usar booleanos? ¿Sí, no, a veces?</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2013/03/generar-archivos-excel-como-un-senor.html">Generar archivos Excel como un señor con ClosedXml</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://itnext.io/a-practical-guide-to-modular-monoliths-with-net-59da23c01137">A Practical Guide to Modular Monoliths with .NET</a><br />
Charles Chen</li>
<li><a href="https://code-maze.com/csharp-remove-html-tags-from-a-string/">How To Remove HTML Tags From a String in C#</a><br />
Code Maze</li>
<li><a href="https://itnext.io/fortifying-your-net-project-8b68758c3f25">Fortifying Your .NET Project</a><br />
Dick van Straaten</li>
<li><a href="https://www.mobilize.net/blog/to-upgrade-or-not-to-upgrade-is-dotnet8-worth-the-leap-from-dotnet6">To Upgrade or Not to Upgrade: Is .NET 8 Worth the Leap from .NET 6?</a><br />
DeeDee Walsh</li>
<li><a href="https://nblumhardt.com/2024/01/serilog-tracing/">SerilogTracing</a><br />
Nicholas Blumhardt</li>
<li><a href="https://www.meziantou.net/how-to-get-assembly-code-generated-by-the-jit-for-a-csharp-method.htm">How to get assembly code generated by the JIT for a C# method</a><br />
Gérald Barré</li>
<li><a href="https://code-maze.com/csharp-how-to-truncate-a-string/">How to Truncate a String in .NET</a><br />
Code Maze</li>
<li><a href="https://code-maze.com/chsarp-how-to-escape-curly-brackets-and-special-characters/">How to Escape Curly Brackets and Special Characters in C#</a><br />
Lennart Pries</li>
<li><a href="https://blog.ploeh.dk/2024/01/22/a-range-kata-implementation-in-c/">A Range kata implementation in C#</a><br />
Mark Seemann</li>
<li><a href="https://code-maze.com/csharp-selenium-maximize-browser/">How to Maximize the Browser Window With Selenium in C#</a><br />
Semir Teskeredzic</li>
<li><a href="https://andrewlock.net/creating-a-source-generator-part-10-testing-your-incremental-generator-pipeline-outputs-are-cacheable/">Testing your incremental generator pipeline outputs are cacheable: Creating a source generator</a><br />
Andrew Lock</li>
<li><a href="https://www.code4it.dev/csharptips/observablecollection/">C# Tip: ObservableCollection - a data type to intercept changes to the collection</a><br />
Davide Bellone</li>
<li><a href="https://code-maze.com/csharp-check-if-items-of-a-list-exist-in-another-list/">How to Check if Items of a List Exist in Another List in C#</a><br />
Martin Chege</li>
<li><a href="https://devblogs.microsoft.com/dotnet/office-rtc-dotnet-migration/">Microsoft Office's RTC (Real-Time Channel) migration to modern .NET</a><br />
Gilad Oren</li>
<li><a href="https://steven-giesel.com/blogPost/0594ba85-356b-47f1-89a9-70e9761c582e">Three new LINQ methods in .NET 9</a><br />
Steven Giesel</li>
<li><a href="https://code-maze.com/csharp-convert-a-jobject-to-a-dictionary/">Fastest Way to Convert a JObject to a Dictionary in C#</a><br />
Code Maze<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://nestenius.se/2024/01/22/improving-asp-net-core-security-by-putting-your-cookies-on-a-diet/">Improving ASP.NET Core Security By Putting Your Cookies On A Diet – Tore Nestenius</a><br />
Tore Nestenius</li>
<li><a href="https://khalidabuhakmeh.com/how-to-use-blazor-server-rendered-components-with-htmx">How To Use Blazor Server-Rendered Components with HTMX</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://code-maze.com/aspnetcore-using-mariadb-with-web-api/">Using MariaDB With ASP.NET Core Web API</a><br />
Januarius Njoku</li>
<li><a href="https://www.cazzulino.com/cascading-blazor.html">Auto-notifying cascading values in Blazor</a><br />
Daniel Cazzulino</li>
<li><a href="https://www.sitepoint.com/net-8-blazor-render-modes-explained/">Blazor Render Modes Explained</a><br />
Peter De Tender</li>
<li><a href="https://jonhilton.net/blazor-share-auth-state/">Share user authentication state with interactive WASM components</a><br />
Jon Hilton</li>
<li><a href="https://www.syncfusion.com/blogs/post/new-blazor-dropdown-tree.aspx">Introducing the New Blazor Dropdown Tree Component</a><br />
Keerthana Rajendran</li>
<li><a href="https://www.telerik.com/blogs/blazor-basics-component-parameters-state-management">Blazor Basics: Component Parameters and State Management</a><br />
Claudio Bernasconi</li>
<li><a href="https://kristoffer-strube.dk/post/a-holistic-comparison-of-blazor-wasm-performance-from-aspnet-core-5-to-8/">A holistic comparison of Blazor WASM performance from ASP.NET Core 5 to 8</a><br />
Kristoffer Strube</li>
<li><a href="https://www.telerik.com/blogs/adding-context-menu-telerik-ui-aspnet-core-grid">Add a Context Menu to Your Telerik UI for ASP.NET Core Grid</a><br />
Jefferson S. Motta</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://daniel.mcloughlin.cloud/hands-on-with-microsoft-copilot-for-azure">Hands-on with Microsoft Copilot for Azure</a><br />
Daniel McLoughlin</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://read.engineerscodex.com/p/how-google-takes-the-pain-out-of">How Google takes the pain out of code reviews, with 97% dev satisfaction</a><br />
Leonardo Creed</li>
<li>[Understanding Domain-Driven Design <a href="https://compiler.blog/understanding-domain-driven-design-part-1">Part 1</a> & <a href="https://compiler.blog/understanding-domain-driven-design-part-2">Part 2</a><br />
Ozan Akman</li>
<li><a href="https://ilovedotnet.org/blogs/structural-design-pattern-facade/">Structural Design Pattern</a> & <a href="https://ilovedotnet.org/blogs/creational-design-pattern-Builder">Creational Design Pattern</a><br />
Abdul Rahman Shabeek Mohamed</li>
<li><a href="https://codeopinion.com/free-your-http-api-misconceptions-are-holding-you-back/">Free your HTTP API. Misconceptions are holding you back!</a><br />
Derek Comartin</li>
<li><a href="https://www.kirupa.com/data_structures_algorithms/bogosort.htm">Bogosort</a><br />
Kirupa Chinnathambi</li></ul><ul>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://www.smashingmagazine.com/2024/01/guide-retrieval-augmented-generation-language-models/">A Simple Guide To Retrieval Augmented Generation Language Models</a><br />
Joas Pambou</li>
<li><a href="https://openai.com/blog/new-embedding-models-and-api-updates">New embedding models and API updates</a><br />
OpenAI</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://shefali.dev/javascript-tips/">18 JavaScript Tips : You Should Know for Clean and Efficient Code</a><br />
Shefali Jangid</li>
<li><a href="https://dev.to/dunia/mastering-css-custom-properties-the-senior-developers-approach-to-css-custom-properties-4088">Mastering CSS Custom Properties: The Senior Developer's Approach to CSS Custom Properties.</a><br />
Alex Dunia</li>
<li><a href="https://dev.to/diogom/using-the-view-transition-api-on-angular-framework-2ip3">Using the View Transition API on Angular Framework</a><br />
Diogo Machado</li>
<li><a href="https://dev.to/alexanderop/the-problem-with-as-in-typescript-why-its-a-shortcut-we-should-avoid-2km4">The Problem with "as" in TypeScript: Why It's a Shortcut We Should Avoid</a><br />
Alexander Opalic</li>
<li><a href="https://www.smashingmagazine.com/2023/12/marketing-changed-oop-javascript/">How Marketing Changed OOP In JavaScript</a><br />
Juan Diego Rodríguez</li>
<li><a href="https://christianheilmann.com/2024/01/19/10-print-chr205-5-rnd1goto-10-in-javascript/">10 print chr$(205.5 + rnd(1));:goto 10 in JavaScript</a><br />
Christian Heilmann</li>
<li><a href="https://tedium.co/2023/11/24/weird-html-hacks-history">10 Weird HTML Hacks That Shaped The Internet</a><br />
Ernie Smith</li>
<li><a href="https://proxiesapi.com/articles/the-complete-puppeteer-cheatsheet">The Complete Puppeteer Cheatsheet</a><br />
Mohan Ganesan</li>
<li><a href="https://www.roboleary.net/frontend/2024/01/21/lazy-load-iframes.html">Don't sleep on native lazy loading iframes</a><br />
Rob O'Leary</li>
<li><a href="https://dev.to/greenteaisgreat/the-new-css-color-format-you-didnt-know-you-needed-oklch-10hf">The New CSS Color Format You Didn't Know You Needed; OKLCH()</a><br />
Nathan G Bornstein</li>
<li><a href="https://moderncss.dev/12-modern-css-one-line-upgrades/?ref=dailydev">12 Modern CSS One-Line Upgrades</a><br />
Stephanie Eckles</li>
<li><a href="https://www.syncfusion.com/blogs/post/whats-new-angular-17-syncfusion.aspx">What’s New in Angular 17 and for Syncfusion Angular Components</a><br />
Mydeen S. N.</li>
<li><a href="https://blog.stephaniestimac.com/posts/2024/01/css-field-sizing/">Better form UX with the CSS property <code>field-sizing</code></a><br />
Stephanie Stimac</li>
<li><a href="https://confidence.sh/blog/how-to-use-the-web-bluetooth-api/">How To Use The Web Bluetooth API</a><br />
Confidence Okoghenun</li>
<li><a href="https://www.smashingmagazine.com/2024/01/css-blurry-shimmer-effect/">CSS Blurry Shimmer Effect</a><br />
Yair Even Or</li>
<li><a href="https://tympanus.net/codrops/2024/01/24/experimental-css-only-carousels-with-scroll-driven-animations/">Experimental CSS-Only Carousels with Scroll-Driven Animations</a><br />
Maxwell Barvian</li>
<li><a href="https://macarthur.me/posts/with">Let's Bring Back JavaScript's <code>with()</code> Statement</a><br />
Alex MacArthur</li>
<li><a href="https://ndeyefatoudiop.com/7-common-css-mistakes-junior-frontend-developers-make-and-how-to-fix-them">7 Common CSS Mistakes Junior Frontend Developers Make (And How to Fix Them)</a><br />
Ndeye Fatou Diop</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/visualstudio/visual-studio-productivity-features-in-2023/">Visual Studio productivity features in 2023</a><br />
Leah Tran</li>
<li><a href="https://devblogs.microsoft.com/dotnet/introducing-ms-test-runner/">Introducing the MSTest Runner - CLI, Visual Studio, & More</a><br />
Amaury Levé</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/01/19/resharper-2024-1-eap1/">Welcome to the ReSharper 2024.1 Early Access Program</a><br />
Sasha Ivanova</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/copilot-chat-slash-commands-and-context-variables/">Code Faster and Better with GitHub Copilot's New Features: Slash Commands and Context Variables</a><br />
Peter Groenewegen</li>
<li><a href="https://wizardzines.com/comics/inside-git/">inside .git</a><br />
Julia Evans</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://egvijayanand.in/2024/01/23/introducing-dotnet-maui-generic-item-templates-for-visual-studio-2022/">Introducing .NET MAUI Generic Item Templates for Visual Studio 2022</a><br />
Vijay Anand</li>
<li><a href="https://www.telerik.com/blogs/january-xaml-fest-net-maui-microsoft-linkedin-header-design">January XAML Fest for .NET MAUI—Microsoft’s LinkedIn Header Design</a><br />
Leomaris Reyes</li>
<li><a href="https://community.devexpress.com/blogs/mobile/archive/2024/01/24/creating-profile-settings-page-with-net-maui-form-items.aspx">.NET MAUI — Creating Profile Settings Page with Form Items</a><br />
Kseniya K.</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://gabrielgambetta.com/zx-raytracer.html">ZX Spectrum Raytracer</a><br />
Gabriel Gambetta</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-31917414504074788892024-01-23T08:05:00.002+01:002024-01-23T08:05:00.122+01:00Personalizar los mensajes de error de parseado en formularios Blazor<img alt="Blazor" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBUgEtI1OgBX4GxZGmDIH5m2kDKsfmq0N_mkTa_9NE1jReSlOABaWbJtXM1L5Szkb4uCudiBdzjLebOyvg6Mxv-zMcwgfan8PveUpX5nrHirqjFzJXJQUheXB3vaIEYiXXt8FGTNSpPi_4s5LXOVIKKgcwK-FX_3aciAHC6BYyYZ6rvstXvxo/s16000/Blazor.png" title="Blazor" width="100%" />
<p>Como sabemos, gran parte de las validaciones en formularios Blazor las implementamos usando anotaciones de datos, o <em>data annotations</em>. Estas anotaciones nos permiten validar los datos de entrada antes de que ejecutemos la lógica de negocio, que normalmente se encontrará en el <em>handler</em> del evento <code>OnValidSubmit</code> del formulario.</p>
<p>Vemos un ejemplo de formulario Blazor aquí, y el código C# justo debajo:</p>
<pre><code class="language-xml">@page "/friend"
<h3>FriendEditor</h3>
<EditForm Model="Friend" OnValidSubmit="Save">
<DataAnnotationsValidator />
<div class="form-group mb-2">
<label for="name">Name:</label>
<ValidationMessage For="()=>Friend.Name" />
<InputText @bind-Value="Friend.Name" class="form-control" id="name" />
</div>
<div class="form-group mb-2">
<label for="score">Score:</label>
<ValidationMessage For="()=>Friend.Score" />
<InputNumber @bind-Value="Friend.Score" class="form-control" id="score" />
</div>
<div class="form-group mb-2">
<label for="birthDate">BirthDate:</label>
<ValidationMessage For="()=>Friend.BirthDate" />
<InputDate @bind-Value="Friend.BirthDate" class="form-control" id="birthDate" />
</div>
<div class="form-group mb-2">
<button type="submit" class="btn btn-primary">Save</button>
</div>
</EditForm>
</code></pre>
<pre><code class="language-cs">@code {
private FriendViewModel Friend = new();
private async Task Save()
{
await Task.Delay(1000);
Friend = new FriendViewModel();
}
public class FriendViewModel
{
[Required(ErrorMessage = "El nombre es obligatorio")]
public string Name { get; set; }
[Range(0, 10, ErrorMessage = "La puntuación debe estar entre {1} y {2}")]
public int Score { get; set; }
public DateTime BirthDate { get; set; }
}
}
</code></pre>
<p><span></span></p><a name='more'></a>En tiempo de ejecución, cuando introducimos valores inválidos (por ejemplo, si dejamos en blanco el nombre o introducimos en <code>Score</code> un número fuera del rango 0-10 permitido), podremos ver los mensajes de error que hemos definido en las anotaciones de datos:<p></p>
<p>
<img alt="Errores de validación en el formulario" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgL6hRcgxXCUXZvXxsd5AfruRpc0Ehv0uGkGFhIm_EK_55-LUSUEkaBjlro2S3DEg2MIZwtTrjFLJevB3cHp76mXQNRmy4psLMtO1rjvsU6ZSITSzimGcuoNnGM6-3KZFLik_ZJwfdjmazFNw1nEUYxdecLS_Nrb8Ln8ioVZv43OQucyVTo9V9Mg/s1600/validation-error.png" style="max-width: 100%;" />
</p>
<p>Sin embargo, <strong>una cosa es que el usuario introduzca valores incorrectos desde el punto de vista de la lógica de nuestra aplicación, y otra cosa es que el usuario introduzca valores que ni siquiera se puedan parsear</strong> para obtener los tipos de datos que estamos esperando. En este caso, los mensajes de error no son proporcionados por las <em>Data annotations</em> sino por el propio <em>framework</em>, como vemos en la siguiente captura, donde hemos dejado en blanco los campos <code>Score</code> y <code>BirthDate</code>:</p>
<p>
<img alt="Error de parseo en el formulario" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjMxbgxoG0Hl5D5cBUy5Abq4BN2xvtXZ_ECK4MpnzIuhNw-tUK71HCcVXrGvni9Dlq-9Fm2i3tz-cevBsLlB4JO5whNTqiZDfdXUqWwjY_yVRiYg3D8AHeVnjbRnHATWMNh60N7_UZujpWF80vz2hbFXLrcnRCXY_FPsKDKdnoSriy-rpKnaOVhRw/s794/parsing-error.png" style="max-width: 100%;" />
</p>
<p>Estos textos de descripción del error, además de estar en inglés, no lo hemos definido nosotros por medio de anotaciones, por lo que no tenemos control sobre ellos. En una interfaz de usuario cuidada, <b>no deberíamos dejarlo así</b>.</p>
<p>La solución es bien sencilla. Basta con utilizar el atributo <code>ParsingErrorMessage</code> en los componentes de entrada de datos que nos interese, y suministrarle el texto que queramos que se muestre en caso de que el usuario introduzca un valor que no se pueda parsear. Por ejemplo:</p>
<pre><code class="language-xml"><InputNumber @bind-Value="Friend.Score" class="form-control" id="score"
ParsingErrorMessage="Introduzca un número válido" />
...
<InputDate @bind-Value="Friend.BirthDate" class="form-control" id="birthDate"
ParsingErrorMessage="Introduzca una fecha válida" />
</code></pre>
<p>
<img alt="Formulario con errores de parseado personalizados" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiu93su6sQkj_F85M_Cvz-5Z7I-5kc2YQsrZgmAiwQCBStCd_xtgAa_w8PI6VU0Xeos4OlxiTDcC_1UHUalNFVlHlu_ylWJDaVBHbYpJuI2aLIFkZ5gbtJo1qpikd1vwLYGfuLM_2-YKZBwZqjoh3PdZh7rEXptuIXu7OiGJdWeLEAMB6dHeKjw8Q/s794/custom-parsing-errors.png" style="max-width: 100%;" />
</p>
<p>Por supuesto, dado que el texto de este mensaje de error lo pasamos en un atributo del componente, nada impide que suministremos una expresión que podría haber sido obtenida desde los recursos localizados del proyecto, posibilitando así que estos mensajes aparezcan en el idioma del usuario.</p>
Publicado en: <a href="https://www.variablenotfound.com">www.variablenotfound.com</a>.José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-72078923481599436862024-01-22T08:05:00.004+01:002024-01-22T08:05:00.127+01:00Enlaces interesantes 552<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/02/raw-string-literals-en-c-11.html">Raw string literals en C# 11</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2013/02/desacoplando-controladores-aspnet-mvc.html">Desacoplando controladores ASP.NET MVC, paso a paso</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://andrewlock.net/creating-a-source-generator-part-9-avoiding-performance-pitfalls-in-incremental-generators/">Avoiding performance pitfalls in incremental generators: Creating a source generator, part 9</a><br />
Andrew Lock</li>
<li><a href="https://www.stevejgordon.co.uk/authenticating-a-github-app-using-a-json-web-token-in-dotnet">Authenticating a .NET GitHub App using a JSON Web Token (JWT)</a><br />
Steve Gordon</li>
<li><a href="https://steven-giesel.com/blogPost/3368bf96-648e-4fa2-9c6c-be71e40ac4cc">An alternative to AutoMapper</a><br />
Steven Giesel</li>
<li><a href="https://www.meziantou.net/difference-between-cultureinfo-get-and-new-cultureinfo.htm">Difference between CultureInfo.Get and new CultureInfo</a><br />
Gérald Barré</li>
<li><a href="https://code-maze.com/csharp-converting-string-to-byte-array/">Converting String to Byte Array in C#</a><br />
Caleb Okechukwu</li>
<li><a href="http://addressof.com/posts/going-native/">Going Native</a><br />
Cory Smith</li>
<li><a href="https://code-maze.com/csharp-how-to-save-a-list-to-a-text-file/">How to Save a List to a Text File in C#</a><br />
Code Maze</li>
<li><a href="https://www.devleader.ca/2024/01/10/what-does-yield-do-in-c-a-simplified-view-for-beginners/">What Does yield Do In C#: A Simplified View For Beginners</a><br />
Nick Cosentino</li>
<li><a href="https://mabroukmahdhi.medium.com/what-we-are-doing-wrong-with-logging-in-c-798dd7a4ec6d">What We Are Doing Wrong with Logging in C#</a><br />
Mabrouk Mahdhi</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/01/16/interceptors-using-csharp-12-in-rider-and-resharper/">Interceptors – Using C# 12 in Rider and ReSharper</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://cezarypiatek.github.io/post/mocking-graphql-with-wiremock/">Mocking GraphQL queries with WireMock.NET</a><br />
Cezary Piątek</li>
<li><a href="https://code-maze.com/csharp-how-to-ensure-a-string-is-valid-json/">How to Ensure a String Is Valid JSON in C#</a><br />
Code Maze</li>
<li><a href="https://www.syncfusion.com/blogs/post/split-excel-file-csharp.aspx">3 Simple Steps to Split an Excel File into Multiple Excel Files in C#</a><br />
Mohan Chandran</li>
<li><a href="https://code-maze.com/csharp-plugin-architecture-pattern/">Plugin Architecture Pattern in C#</a><br />
Alvaro Montoya</li>
<li><a href="https://code-maze.com/csharp-how-to-create-a-temp-file-in-temp-folder/">How to Create a Temp File in the Temp Folder in C#</a><br />
Code Maze</li>
<li><a href="https://steven-giesel.com/blogPost/4271d529-5625-4b67-bd59-d121f2d8c8f6">A replacement for BinaryFormatter in .NET 8</a><br />
Steven Giesel<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://damienbod.com/2024/01/15/migrate-asp-net-core-blazor-server-to-blazor-web/">Migrate ASP.NET Core Blazor Server to Blazor Web</a><br />
Damien Bowden</li>
<li><a href="https://jonhilton.net/blazor-auth0-net8/">Simpler auth for Blazor Web Apps with Auth0?</a><br />
Jon Hilton</li>
<li><a href="https://www.roundthecode.com/dotnet-tutorials/exception-handling-own-middleware-dotnet-8">Exception handling has its own middleware in .NET 8</a><br />
David Grace</li>
<li><a href="https://code-maze.com/dotnet-use-iexceptionhandler-to-handle-exceptions/">How to Use IExceptionHandler to Handle Exceptions in .NET</a><br />
Ainea Wabwoba</li>
<li><a href="https://ilovedotnet.org/blogs/implementing-caching-using-decorator-pattern-in-asp-net-webapi/">Implementing Caching using Decorator Pattern in ASP.NET WEB API</a><br />
Abdul Rahman Shabeek Mohamed</li>
<li><a href="https://khalidabuhakmeh.com/how-to-use-iasyncenumerable-with-blazor-stream-rendering">How to use IAsyncEnumerable with Blazor Stream Rendering</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://www.syncfusion.com/blogs/post/new-blazor-data-form.aspx">Introducing the New Blazor Data Form Component</a><br />
Saravanan G.</li>
<li><a href="https://www.jimmybogard.com/tales-from-the-net-migration-trenches-session-state/">Tales from the .NET Migration Trenches - Session State</a><br />
Jimmy Bogard</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://www.recetasdevops.dev/post/auditaazureconazqr/">Sigue las mejores prácticas y recomendaciones en Azure con Azure Quick Review</a><br />
Alejandro García</li>
<li><a href="https://dev.to/one-beyond/azure-service-bus-101-introduction-to-queues-and-messaging-4coj">Azure Service Bus 101: Introduction to Queues and Messaging</a><br />
Ignacio Ripoli</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://itnext.io/x-509-certificates-expalined-8d6ae8ed3368">X.509 Certificates Explained</a><br />
Anirban Bhattacherji</li>
<li><a href="https://codeopinion.com/want-to-build-a-good-api-here-are-5-tips-for-api-design/">Want to build a good API? Here are 5 Tips for API Design.</a><br />
Derek Comartin</li>
<li><a href="https://martinfowler.com/articles/continuousIntegration.html">Continuous Integration</a><br />
Martin Fowler</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/cosmosdb/azure-cosmos-db-design-patterns-part-5-document-versioning/">Azure Cosmos DB design patterns – Part 5: Document versioning</a><br />
Jay Gordon</li>
<li><a href="https://code-maze.com/efcore-how-to-revert-a-migration/">How to Revert a Migration in EF Core</a><br />
Code Maze</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://www.codeproject.com/Articles/5375908/Truly-Understanding-Neural-Networks-through-its">Truly Understanding Neural Networks through its Implementation in C#</a><br />
Nicolas Descartes</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://ir.relevant.space/css-trivia-masonry-grid-layout/">CSS Trivia: Masonry Grid Layout</a><br />
Dalia</li>
<li><a href="https://dev.to/tinymce/understanding-xss-its-more-than-just-a-script-4clo">Understanding XSS: It's More Than Just a Script</a><br />
Mrinalini Sugosh</li>
<li><a href="https://nolanlawson.com/2024/01/13/web-component-gotcha-constructor-vs-connectedcallback/">Web component gotcha: constructor vs connectedCallback</a><br />
Nolan Lawson</li>
<li><a href="https://blog.logrocket.com/angular-signals-vs-observables">Angular signals vs. observables: How and when to use each</a><br />
Lewis Cianci</li>
<li><a href="https://code.tutsplus.com/learn-how-to-code-a-simple-javascript-calendar-and-datepicker--cms-108322t">Learn How to Code a Simple JavaScript Calendar and Datepicker</a><br />
Esther Vaati</li>
<li><a href="https://www.smashingmagazine.com/2024/01/css-border-image-property/">The Complex But Awesome CSS border-image Property</a><br />
Temani Afif</li>
<li><a href="https://www.telerik.com/blogs/new-angular-hydration">The New Angular Hydration</a><br />
Jonathan Gamble</li>
<li><a href="https://www.kirupa.com/javascript/remap.htm">Remapping Values</a><br />
Kirupa Chinnathambi</li>
<li><a href="https://webdesign.tutsplus.com/currency-converter-with-html-css-and-vanilla-javascript--cms-108362t">Create a Currency Converter with HTML, CSS, and Vanilla JavaScript</a><br />
Esther Vaati</li>
<li><a href="https://plainenglish.io/community/sharing-a-state-between-windows-without-a-server-48b990">How to Share State Between Browser Windows</a><br />
Achraf</li>
<li><a href="https://tympanus.net/codrops/2024/01/17/a-practical-introduction-to-scroll-driven-animations-with-css-scroll-and-view/">A Practical Introduction to Scroll-Driven Animations with CSS scroll() and view()</a><br />
Adam Argyle</li>
<li><a href="https://www.telerik.com/blogs/javascript-map-object">The JavaScript Map Object</a><br />
Hassan Djirdeh</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://dev.to/devland/12-popular-but-useless-vs-code-extensions-youre-probably-using-3n28">12 Popular but Useless VS Code Extensions You're Probably Using</a><br />
Thomas Sentre</li>
<li><a href="https://devblogs.microsoft.com/nuget/introducing-nugetsolver-a-powerful-tool-for-resolving-nuget-dependency-conflicts-in-visual-studio/">Introducing NuGetSolver: A Powerful Tool for Resolving NuGet Dependency Conflicts in Visual Studio</a><br />
Erick Yondon</li>
<li><a href="https://blog.jetbrains.com/dotnet/2024/01/10/use-jetbrains-ai-assistant-to-help-you-understand-changes-in-your-code/">Use JetBrains AI Assistant To Help You Understand Changes In Your Code</a><br />
Matthias Koch</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/17-9-preview-3-brings-exciting-changes-to-code-search/">17.9 Preview 3 brings exciting changes to Code Search</a><br />
Leah Tran</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/latest-updates-for-remote-linux-development-in-visual-studio-remote-file-explorer-integrated-terminal-and-more/">Latest updates for Remote Linux Development in Visual Studio: Remote File Explorer, Integrated Terminal, and more...</a><br />
Sinem Akinci</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://egvijayanand.in/2024/01/16/introducing-dotnet-maui-generic-item-templates/">Introducing .NET MAUI Generic Item Templates</a><br />
Vijay Anand</li>
<li><a href="https://egvijayanand.in/2024/01/18/dotnet-maui-8-service-release-1/">.NET MAUI 8 SR1</a><br />
Vijay Anand</li>
<li><a href="https://askxammy.com/timeline-xamarin-apps/">Timeline Xamarin Apps</a><br />
Leomaris Reyes</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://www.code4it.dev/blog/kill-the-process-blocking-a-port-windows/">How to kill a process running on a local port in Windows</a><br />
Davide Bellone</li>
<li><a href="https://donno2048.github.io/HTML-PDF-JPEG/">An HTML page which is also a valid PDF file and JPEG image</a><br />
Elisha Hollander</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-75669916613480388882024-01-16T08:05:00.007+01:002024-01-16T08:05:00.134+01:00Enlaces interesantes 551<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/02/periodictimer-temporizadores-asincronos.html">PeriodicTimer: Temporizadores asíncronos en .NET 6</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2012/09/101-nuevas-citas-celebres-del-mundo-de.html">101 nuevas citas célebres del mundo de la informática (¡y van 404!)</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://github.com/praeclarum/1brc">GitHub - praeclarum/1brc: The One Billion Row Challenge</a><br />
Frank A. Krueger</li>
<li><a href="https://www.meziantou.net/making-primary-constructor-parameters-read-only.htm">Making primary constructor parameters read-only</a><br />
Gérald Barré</li>
<li><a href="https://code-maze.com/csharp-consistent-byte-representation-of-strings-without-encoding/">Consistent Byte Representation of Strings in C# Without Encoding</a><br />
Code Maze</li>
<li><a href="https://nodogmablog.bryanhogan.net/2024/01/throw-throwifcancellationrequested-in-a-method-that-returns-a-value-when-using-a-cancellation-token/">Throw ThrowIfCancellationRequested in a Method that Returns a Value when Using a Cancellation Token</a><br />
Bryan Hogan</li>
<li><a href="https://jonhilton.net/coravel/">Coravel - Easy task scheduling for your .NET web apps</a><br />
Jon Hilton</li>
<li><a href="https://andrewlock.net/a-brief-look-at-stringvalues/">A brief look at StringValues</a><br />
Andrew Lock</li>
<li><a href="https://steven-giesel.com/blogPost/544c33da-be2e-4d96-99c9-9313f48548bd">Const strings are not so const after all</a><br />
Steven Giesel</li>
<li><a href="https://markheath.net/post/stream-read-guidelines">Some Stream.Read Guidelines</a><br />
Mark Heath</li>
<li><a href="https://intodot.net/using-implicit-conversion-operators-in-c-to-improve-readability/">Using implicit conversion operators in C# to improve readability</a><br />
Henrique Dalcin Dalmas</li>
<li><a href="https://code-maze.com/csharp-thread-sleep-vs-task-delay/">When to Use Thread.Sleep, When to Use Task.Delay?</a><br />
Code Maze</li>
<li><a href="https://aaronstannard.com/roslyn-nuget/">How to Distribute Roslyn Analyzers via NuGet</a><br />
Aaron Stannard<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://dev.to/esdanielgomez/webcam-para-capturar-imagenes-en-dotvvm-aspnet-hd4">Webcam para capturar imágenes en DotVVM & ASP.NET</a><br />
Daniel Gomez</li>
<li><a href="https://code-maze.com/aspnetcore-swagger-ignore-properties/">How to Ignore Model Properties With Swagger in .NET</a><br />
Gergo Vandor</li>
<li><a href="https://hashset.dev/article/21_htmx_web_sockets_signal_r_and_you">HTMX, WebSockets, SignalR and you</a><br />
Kai Ito</li>
<li><a href="https://khalidabuhakmeh.com/view-transitions-api-with-aspnet-core-and-htmx">View Transitions API with ASP.NET Core and HTMX</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://code-maze.com/how-to-use-sections-in-blazor/">How to Use Sections in Blazor</a><br />
Muhammad Afzal Qureshi</li>
<li><a href="https://code-maze.com/dotnet-aspire-building-distributed-applications/">Building Distributed Applications With .NET Aspire</a><br />
Code Maze</li>
<li><a href="https://www.syncfusion.com/blogs/post/blazor-synchronized-charts.aspx">Blazor Synchronized Charts: The Perfect Tool for Trade Analysis</a><br />
Krishnan Periyasamy</li>
<li><a href="https://endjin.com/blog/2024/01/asp-dotnet-8-aot-csharp-12-interceptors">ASP.NET Core 8.0 uses C# 12.0's experimental interceptors to enable AOT</a><br />
Ian Griffiths</li>
<li><a href="https://jesseliberty.com/2024/01/08/net-apis-part-5-all-the-crud-apis/">.NET APIs Part 5 – All the CRUD APIs</a><br />
Jesse Liberty</li>
<li><a href="https://baaijte.net/blog/microsoft-fluentui-aspnetcore.components-4.3/">What's new for the Microsoft Fluent UI Blazor components version 4.3.0</a><br />
Vincent Baaij</li>
<li><a href="https://www.telerik.com/blogs/integrating-code-telerik-ui-blazor-form-component">Integrating Code with the Telerik UI for Blazor Form Component</a><br />
Peter Vogel</li>
<li><a href="https://devblogs.microsoft.com/dotnet/introducing-blazor-sortable/">Sortable Lists for Blazor using a SortableJS Component</a><br />
Burke Holland</li>
<li><a href="https://www.telerik.com/blogs/aspnet-core-basics-understanding-practicing-solid">ASP.NET Core Basics: Understanding and Practicing SOLID</a><br />
Assis Zang</li></ul><ul>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://ilovedotnet.org/blogs/structural-design-pattern-decorator/">Structural Design Pattern - Decorator</a><br />
Abdul Rahman Shabeek Mohamed</li>
<li><a href="https://abhishek-srivas.medium.com/pure-functions-302758ae55f2">Pure Functions</a><br />
Abhishek Srivas</li>
<li><a href="https://www.devleader.ca/2024/01/07/what-is-inversion-of-control-a-simplified-beginners-guide/">What is Inversion of Control – A Simplified Beginner’s Guide</a><br />
Nick Cosentino</li>
<li><a href="https://markheath.net/post/what-are-we-optimizing-for">What are we optimizing for?</a><br />
Mark Heath</li>
<li><a href="https://codeopinion.com/domain-modeling-gone-wrong-to-right/">Domain Modeling Gone Wrong to Right</a><br />
Derek Comartin</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://www.red-gate.com/simple-talk/databases/sql-server/database-administration-sql-server/optimized-locking-in-azure-sql-database/">Optimized locking in Azure SQL Database</a><br />
Aaron Bertrand</li>
<li><a href="https://techcommunity.microsoft.com/t5/sql-server-blog/released-security-updates-for-microsoft-data-sqlclient-and/ba-p/4024264">Released: Security updates for Microsoft.Data.SqlClient and System.Data.SqlClient</a><br />
David Engel</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li>“Attention is all you need”: La investigación que revolucionó la Inteligencia Artificial con los Transformers <a href="https://www.elladodelmal.com/2024/01/attention-is-all-you-need-la.html">(Parte 1)</a> & <a href="https://www.elladodelmal.com/2024/01/attention-is-all-you-need-la_01380413382.html">Parte 2</a><br />
Fran Ramírez</li>
<li><a href="https://blog.theodo.com/2024/01/anomaly-detection-llm/">Step-by-Step Guide to building an Anomaly Detector using a LLM</a><br />
Chloé Caron</li>
</ul>
<h4>Web / HTML / CSS / Javascript / WASM</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/react-por-que-se-ejecutan-dos-veces-algunas-operaciones-en-mis-componentes-jsx.aspx">React: ¿Por qué se ejecutan dos veces algunas operaciones en mis componentes JSX?</a><br />
David Charte</li>
<li><a href="https://dev.to/dhutaryan/how-to-mix-colors-in-css-316l">How to mix colors in css?</a><br />
Dzmitry Hutaryan</li>
<li><a href="https://whatpwacando.today/">What PWA Can Do Today</a><br />
Danny Moerkerke</li>
<li><a href="https://www.syncfusion.com/blogs/post/full-stack-app-angular-graphql-2.aspx">A Full-Stack Web App Using Angular and GraphQL: Data Fetching and Manipulation (Part 2)</a><br />
Ankit Sharma</li>
<li><a href="https://www.tpeczek.com/2024/01/experimenting-with-net-webassembly.html">Experimenting With .NET & WebAssembly - Running .NET Based Slight Application On WASM/WASI Node Pool in AKS</a><br />
Tomasz Pęczek</li>
<li><a href="https://www.syncfusion.com/blogs/post/angular-3d-chart.aspx">Unveiling the New Angular 3D Chart: A Step Forward in Data Visualization</a><br />
Gowrimathi S.</li>
<li><a href="https://www.freecodecamp.org/news/break-out-elements-from-containers-using-flexbox/">How to Use CSS Flexbox to Break Elements Out of Their Containers</a><br />
Kheoh Yee Wei</li>
<li><a href="https://www.smashingmagazine.com/2024/01/top-frontend-tools-2023/">Top Front-End Tools Of 2023</a><br />
Louis Lazaris</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://www.continuousimprover.com/2024/01/github-vs-azdo.html">22 reasons to ditch Azure DevOps and switch to GitHub as soon as possible</a><br />
Dennis Doomen</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/visual-studio-performance-highlights-delivered-in-2023/">Visual Studio Performance Highlights Delivered in 2023</a><br />
Nayana Srikanth</li>
<li><a href="https://weblog.west-wind.com/posts/2024/Jan/10/Sharing-Tab-Missing-in-Windows-Folder-Properties">Sharing Tab Missing in Windows Folder Properties</a><br />
Rick Strahl</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://www.sharpnado.com/materialframe-maui/">MaterialFrame MAUI: blur effect, acrylic brush, dark theme...</a><br />
Jean-Marie Alfonsi</li>
<li><a href="https://www.c-sharpcorner.com/article/lottie-animations-in-net-maui2/">Lottie Animations in .NET MAUI</a><br />
Mushtaq M A</li>
<li><a href="https://egvijayanand.in/2024/01/09/what-is-new-in-the-dotnet-maui-all-in-one-templates-pack/">What’s new in the .NET MAUI All-in-One Templates Pack</a><br />
Vijay Anand</li>
<li><a href="https://community.devexpress.com/blogs/mobile/archive/2024/01/08/net-maui-bottom-sheet-3-ways-to-optimize-mobile-screen-space.aspx">.NET MAUI Bottom Sheet — 3 Ways to Optimize Mobile Screen Space</a><br />
Anthony Sameishchev</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://daedtech.com/the-challenge-of-working-backward-from-a-post-title-to-a-keyword/">The Challenge of Working Backward From a Post Title to a Keyword</a><br />
Erik Dietrich</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-53925613380719837242024-01-15T08:05:00.001+01:002024-01-15T08:05:00.135+01:00Top posts 2023 en Variable not found<img alt="Top posts 2023 en Variable not found" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSyn3CoEwHJMfy5BDtWDYFvyTzJO1VuE8DMlM8aTLlIrnxPFLH30kEaNl-xe0NERvz243fwvJuDFiotE4NqqAs0-3z4F6WuIHqP74MhSEFRl0j8eQJQndFLVZfPHyiyrNlLRghOgkbxvdqDpXDu2nix5eWLnXQd6E-kUH26CnoyQXhKZkJA6xI4A/s1600/header.jpg" style="width: 100%;" />
<p>Primero, espero que hayáis disfrutado las fiestas y que el 2024 que acabamos de estrenar venga bien cargado de cosas buenas 🙂</p>
<p>Y para inaugurar el año, como cada primer post de enero, aprovecharemos para revisar las diez publicaciones más leídas durante los últimos 365 días.<span></span></p><a name='more'></a><p></p>
<h2>Top posts 2023 en Variable not found</h2>
<p>Comenzando por el último puesto, encontramos el post "<a href="https://www.variablenotfound.com//2023/04/binding-de-parametros-en-minimal-apis.html">Binding de parámetros en Minimal APIs con BindAsync</a>", donde presentábamos una forma algo "mágica" de implementar el <em>binding</em> personalizado de parámetros complejos en Minimal APIs.</p>
<p>Seguidamente, encontramos el post "<a href="https://www.variablenotfound.com/2023/01/el-filtro-outputcache-por-fin-de-vuelta.html">El filtro [OutputCache], por fin de vuelta en ASP.NET Core 7</a>", en el que celebrábamos la vuelta de una funcionalidad del vetusto MVC "clásico" que, por fin, volvía a estar disponible en el entonces recién aparecido ASP.NET Core 7.</p>
<p>En octava posición, tenemos el post "<a href="https://www.variablenotfound.com//2023/06/non-nullable-property-must-contain-non.html">Non-nullable property must contain a non-null value when exiting constructor: 7 formas de evitar el warning CS8618 en C#</a>". En él, veíamos cómo evitar el aviso del compilador cuando no nos estamos llevando demasiado bien con los <a href="https://www.variablenotfound.com/2019/07/tipos-referencia-anulables-en-c-8.html">tipos referencia anulables</a> en C#, y de paso repasábamos distintas opciones que tenemos para gestionarlos en las versiones más recientes del lenguaje.</p>
<p>También hablábamos de novedades en el artículo posicionado en séptimo lugar, "<a href="/2023/04/eliminaciones-y-actualizaciones-masivas.html">Eliminaciones y actualizaciones masivas (bulk deletes/updates) con EF Core 7</a>". Se trata de funcionalidades muy esperadas de Entity Framework, que despertaron el interés de los lectores del blog.</p>
<p>Las posiciones sexta, quinta y cuarta está ocupadas, curiosamente, por una lista de "DON'TS", <em>posts</em> que pretendían llamar la atención sobre formas de solucionar problemas habituales que, por decirlo de alguna forma, no son todo lo óptimas que deberían. El trío de entradas es el siguiente:</p>
<ul>
<li><a href="https://www.variablenotfound.com/2023/01/no-uses-replace-para-eliminar-los.html">¡No uses Replace() para eliminar los guiones de un GUID en .NET!</a></li>
<li><a href="https://www.variablenotfound.com/2023/03/no-uses-list-si-siempre-vas-buscar-por.html">¡No uses List<T> si siempre vas a buscar por clave en los elementos en una colección!</a></li>
<li><a href="https://www.variablenotfound.com/2023/07/no-guardes-como-cadena-el-resultado.html">¡No guardes como cadena el resultado JSON de la llamada a una API si lo único que quieres hacer es deserializarla!</a></li></ul><p>Subido ya al podio, en tercer lugar, tenemos el post <a href="https://www.variablenotfound.com/2023/02/obtener-el-valor-de-parametros-de-la.html">Obtener el valor de parámetros de la query string con JavaScript</a>, donde compartía uno de mis grandes descubrimientos del momento: el objeto <code>URLSearchParams</code>. Que sí, que ya llevaba tiempo ahí, pero cada uno descubre las cosas cuando las descubre, ¿no? ;)</p>
<p>En segunda posición, un artículo muy básico, pero a la vez creo que clarificador, sobre la sencilles de los mecanismos de interoperación entre Blazor y JavaScript: <a href="https://www.variablenotfound.com//2023/02/como-enviar-mensajes-la-consola-del.html">Cómo enviar mensajes a la consola del navegador desde Blazor</a>. Y supongo que ha despertado interés porque, al final, un buen <code>console.log()</code> es una de las mejores herramienta de depuración que existen ;)</p>
<p>Y en primera posición, a una cierta distancia de los anteriores, encontramos el post <a href="https://www.variablenotfound.com/2023/03/prueba-apis-facilmente-con-el-nuevo.html">Prueba APIs fácilmente con el nuevo cliente HTTP integrado en Visual Studio 2022</a>, donde echábamos un vistazo a una de las novedades de Visual Studio 2022 que más me han gustado últimamente: el cliente HTTP integrado en el IDE. Aunque el soporte para archivos <code>.http</code> ya existía en otros entornos de desarrollo, la integración en Visual Studio es razonablemente buena y muy cómoda de usar.</p>
<p>Una vez más, ¡feliz año 2024 a todos! ¡Seguimos viéndonos por aquí!</p>
Publicado en: <a href="https://www.variablenotfound.com">www.variablenotfound.com</a>.José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-28467449190565735912023-12-26T08:05:00.004+01:002023-12-26T08:05:00.131+01:00Enlaces interesantes 550---
<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ante todo, aprovecho para desearos felices fiestas y, como no nos veremos por aquí hasta enero, un grandioso 2024. </p><p>Y, por supuesto, ahí van los enlaces recopilados durante la semana pasada que, como siempre, espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/02/como-recibir-un-json-como-string-en-una.html">Cómo recibir un JSON como string en una acción ASP.NET Core MVC</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2012/06/por-que-separamos-los-directorios-con.html">¿Por qué separamos los directorios con la barra invertida?</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://dev.to/isaacojeda/fluentresults-simplificando-el-manejo-de-resultados-y-errores-en-aplicaciones-net-2kgl">FluentResults: Simplificando el Manejo de Resultados y Errores en Aplicaciones .NET</a><br />
Isaac Ojeda</li>
<li><a href="https://josef.codes/customize-the-httpclient-logging-dotnet-core/">Customize the HttpClient logging</a><br />
Josef Ottosson</li>
<li><a href="https://code-maze.com/dotnet-using-the-cli-to-build-and-run-net-applications/">Using the CLI to Build and Run .NET Applications</a><br />
Dusko Mirkovic</li>
<li><a href="https://www.roundthecode.com/dotnet-tutorials/validating-appsettings-faster-dotnet-8">Validating appsettings becomes much faster with .NET 8</a><br />
David Grace</li>
<li><a href="https://code-maze.com/csharp-custom-naming-policy-for-json/">Custom Naming Policy for JSON in C#</a><br />
Tomas Bak</li>
<li><a href="https://www.code4it.dev/blog/top-6-string-performance-tips/#tip-3-isnullorempty-vs-isnullorwhitespace-vs-isnullorempty--trim">Top 6 Performance Tips when dealing with strings in C# 12 and .NET 8</a><br />
Davide Bellone</li>
<li><a href="https://andrewlock.net/updates-to-the-stronglytypedid-library/">Updates to the StronglyTypedId library - simplification, templating, and CodeFixes: Using strongly-typed entity IDs to avoid primitive obsession</a><br />
Andrew Lock</li>
<li><a href="https://khalidabuhakmeh.com/memoizr-declarative-structured-concurrency-for-csharp">MemoizR - Declarative Structured Concurrency for C#</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://code-maze.com/autofac-fakeiteasy-package-basics/">Introduction to Autofac FakeItEasy Package</a><br />
Ainea Wabwoba</li>
<li><a href="https://www.claudiobernasconi.ch/2023/12/15/dotnet-user-interface-frameworks-selection/">What User Interface Framework Should You Choose for .NET Desktop Applications?</a><br />
Claudio Bernasconi</li>
<li><a href="https://ijrussell.github.io/posts/csharp-discriminated-union/">Discriminated Unions in C#</a><br />
Ian Russell</li>
<li><a href="https://code-maze.com/dotnet-debugging-and-profiling-multithreaded-applications/">Debugging and Profiling Multithreaded .NET Applications</a><br />
Code Maze</li>
<li><a href="https://www.milanjovanovic.tech/blog/5-serilog-best-practices-for-better-structured-logging">5 Serilog Best Practices For Better Structured Logging</a><br />
Milan Jovanović</li>
<li><a href="https://www.devleader.ca/2023/12/18/what-is-string-interpolation-in-c-what-you-need-to-know/">What Is String Interpolation In C# – What You Need To Know</a><br />
Nick Cosentino</li>
<li><a href="https://devblogs.microsoft.com/dotnet/whats-new-in-our-code-coverage-tooling/">What's New in Our Code Coverage Tooling?</a><br />
Jakub Chocholowicz</li>
<li><a href="https://steven-giesel.com/blogPost/5f4fef86-d251-4a47-b893-ca4c515ca314">The first possible new feature of C# 13: Params collection</a><br />
Steven Giesel</li>
<li><a href="https://code-maze.com/csharp-execute-javascript-using-selenium-webdriver/">Execute JavaScript Using Selenium WebDriver in C#</a><br />
Vadzim Zylevich</li>
<li><a href="https://weblog.west-wind.com/posts/2023/Dec/21/Integrating-OpenAI-image-generation-into-your-NET-Application">Integrating OpenAI Image Generation into a .NET Application</a><br />
Rick Strahl</li>
<li><a href="https://gist.github.com/atifaziz/8368a14c4e7b14885c92a2f76cafd72a">A Practical Tour of MoreLINQ</a><br />
Atif Aziz<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Aspire / Blazor</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/dotnet/announcing-dotnet-aspire-preview-2/">Announcing .NET Aspire Preview 2</a><br />
Damian Edwards</li>
<li><a href="https://dotnetthoughts.net/getting-started-with-dotnet-aspire/">Getting started with .NET Aspire</a><br />
Anuraj Parameswaran</li>
<li><a href="https://ilovedotnet.org/blogs/blazor-wasm-javascript-interop-and-isolation/">Blazor WASM Javascript Interop and Isolation</a><br />
Abdul Rahman Shabeek Mohamed</li>
<li><a href="https://steven-giesel.com/blogPost/76b40ab1-033b-488e-b11a-a5922fa8a4b7">bUnit Generators - Generate your stubs automatically</a><br />
Steven Giesel</li>
<li><a href="https://www.telerik.com/blogs/aspnet-core-basics-debugging-visual-studio">ASP.NET Core Basics: Debugging in Visual Studio</a><br />
Assis Zang</li>
<li><a href="https://www.techwatching.dev/posts/playing-with-dotnet8">Playing with the .NET 8 Web API template</a><br />
Alexandre Nédélec</li>
<li><a href="https://baldbeardedbuilder.com/blog/choosing-between-dotnet-controllers-and-minimal-apis/">Choosing Between Controllers and Minimal API for .NET APIs</a><br />
Michael Jolley</li>
<li><a href="https://www.telerik.com/blogs/displaying-list-data-items-made-easy-blazor-listbox">Displaying a List of Data Items is Easy with Blazor ListBox</a><br />
Rick Hellwege</li>
<li><a href="https://www.codeproject.com/Articles/5374192/ASP-NET-Interview-Questions-and-Answers-on-JWT-Tok">ASP.NET Interview Questions and Answers on JWT Token Security.</a><br />
Shivprasad koirala</li>
<li><a href="https://dotnetthoughts.net/how-to-use-identity-to-secure-a-web-api-backend-for-spas/">How to use identity to secure a Web API backend for single page apps</a><br />
Anuraj Parameswaran</li>
<li><a href="https://code-maze.com/aspnetcore-register-multiple-interface-implementations/">Register Multiple Implementations of the Same Interface in .NET</a><br />
Michal Kaminski</li>
</ul>
<h4>Azure / Cloud</h4>
<ul>
<li><a href="https://www.codeproject.com/Articles/5374576/Implementing-the-Saga-Pattern-on-Azure">Implementing the Saga Pattern on Azure</a><br />
Nicolas Descartes</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://newsletter.techworld-with-milan.com/p/what-is-the-difference-between-mvc">What is the difference between MVC, MVP, MVI, MVVM, MVVM-C, and VIPER architecture patterns?</a><br />
Milan Milanović</li>
<li><a href="https://michaelscodingspot.com/slow-development-in-big-companies/">Development slowness in big and legacy applications [and how to hurry it up]</a><br />
Michael Shpilt</li>
<li><a href="https://codeopinion.com/5-tips-for-building-resilient-architecture/">5 Tips for Building Resilient Architecture</a><br />
Derek Comartin</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://code-maze.com/querying-mongodb-objectid-csharp/">Querying MongoDB With ObjectId in C#</a><br />
Code Maze</li>
<li><a href="https://jamiemaguire.net/index.php/2023/12/16/elastic-search-cheat-sheet/">Elastic Search Cheat Sheet</a><br />
Jamie Maguire</li>
<li><a href="https://erikdarling.com/the-art-of-the-sql-server-stored-procedure-isolation-levels/">The Art Of The SQL Server Stored Procedure: Isolation Levels</a><br />
Erik Darling</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://powerautomate.microsoft.com/en-us/blog/ai-builder-gpt-prompts-are-generally-available/">AI Builder GPT Prompts are generally available</a><br />
Gwenael Bego</li>
<li><a href="https://devblogs.microsoft.com/premier-developer/how-to-enhance-your-chatbot-so-it-can-retrieve-data-from-multiple-data-sources-orchestrate-its-own-plan-with-c-semantic-kernel-planner-azure-openai-part-3-demo-app/">How to enhance your chatbot so it can retrieve data from multiple data sources & orchestrate its own plan with C# Semantic Kernel, planner & Azure OpenAI – part 3 (demo app)</a><br />
Jordan Bean</li>
<li><a href="https://visualstudiomagazine.com/articles/2023/12/18/spectral-data-clustering.aspx">Spectral Data Clustering from Scratch Using C#</a><br />
James McCaffrey</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://dev.to/tjindapitak/why-grpc-is-not-natively-supported-by-browsers-3oj5">Why gRPC is not natively supported by Browsers</a><br />
Thanapon Jindapitak</li>
<li><a href="https://dev.to/navdeepm20/dive-into-ecmascript-2023-fresh-goodies-for-javascript-developers-1dda">ECMAScript 2023: Fresh Goodies for JavaScript Developers</a><br />
Navdeep Mishra</li>
<li><a href="https://johnnyreilly.com/bun-overview">Overview of Bun, a JavaScript runtime</a><br />
John Reilly</li>
<li><a href="https://phuoc.ng/collection/mirror-a-text-area/calculate-the-coordinates-of-the-current-cursor-in-a-text-area/">Calculate the coordinates of the current cursor in a text area — Phuoc Nguyen</a><br />
Phuoc Nguyen</li>
<li><a href="https://bare-bones.dev/blog/parallax-in-email/">Parallax in Email with fallback</a><br />
Niven Ranchhod</li>
<li><a href="https://www.freecodecamp.org/news/javascript-async-await/">How to Use Async/Await in JavaScript – Explained with Code Examples</a><br />
Nathan Sebhastian</li>
<li><a href="https://davidwalsh.name/autogrow-textareas">AutoGrow Textareas with CSS</a><br />
David Walsh</li>
<li><a href="https://blog.devgenius.io/decoding-why-0-6-0-3-0-8999999999999999-in-js-and-how-to-solve-976a0fa01640">Decoding Why 0.6 + 0.3 = 0.8999999999999999 in JS and How to Solve?</a><br />
Jeeva Ramanathan</li>
<li><a href="https://wasmer.io/posts/introducing-the-wasmer-js-sdk">Introducing the new Wasmer JS SDK</a><br />
Michael Bryan</li>
<li><a href="https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-7/">Speeding up the JavaScript ecosystem</a><br />
Marvin Hagemeist</li>
<li><a href="https://www.smashingmagazine.com/2023/12/new-css-viewport-units-not-solve-classic-scrollbar-problem/">New CSS Viewport Units Do Not Solve The Classic Scrollbar Problem</a><br />
Šime Vidas</li>
<li><a href="https://blog.carlana.net/post/2023/web-component-alternative-futures/">Alternate Futures for “Web Components”</a><br />
Carlana Johnson</li>
<li><a href="https://www.builder.io/blog/structured-clone">Deep Cloning Objects in JavaScript, the Modern Way</a><br />
Steve Swell</li>
<li><a href="https://www.smashingmagazine.com/2023/12/view-transitions-api-ui-animations-part1/">The View Transitions API And Delightful UI Animations (Part 1)</a><br />
Adrian Bece</li>
<li><a href="https://firebase.blog/posts/2023/12/vuefire-nuxt-is-now-stable">VueFire is now stable</a><br />
Eduardo San Martin & David East</li>
<li><a href="https://www.sitepoint.com/vue-app-to-offline-ready-pwa/">Turn Your Vue App into an Offline-ready Progressive Web App</a><br />
Imran Alam</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://damienbod.com/2023/12/18/signing-git-commits-on-windows-and-using-with-github/">Signing git commits on Windows and using with Github</a><br />
Damien Bowden</li>
<li><a href="https://www.poppastring.com/blog/api-testing-with-http-files-in-visual-studio">API testing with .http files in Visual Studio</a><br />
Mark Downie</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://www.syncfusion.com/blogs/post/dotnet-maui-2023-volume-4.aspx">Introducing the 10th Set of .NET MAUI Controls and Features</a><br />
Paul Anderson</li>
<li><a href="https://www.syncfusion.com/blogs/post/dotnet-maui-switch-control.aspx">Introducing the New .NET MAUI Switch Control</a><br />
Anandhan Rajagopal</li>
<li><a href="https://www.syncfusion.com/blogs/post/dotnet-maui-carousel-control.aspx">Introducing the New .NET MAUI Carousel Control</a><br />
Chozarajan Pandiyarajan</li>
</ul>
<h4>Otros</h4>
<ul>
<li><a href="https://dev.to/adityapratapbh1/understanding-captcha-history-usage-and-effectiveness-4jd7">Understanding CAPTCHA: History, Usage, and Effectiveness</a><br />
Aditya Pratap</li>
<li><a href="https://ardalis.com/scaling-your-software-team-develop-vs-hiring/">Scaling Your Software Team: Development vs. Hiring</a><br />
Steve Smith</li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-29885890448819933072023-12-19T08:05:00.001+01:002023-12-19T08:05:00.135+01:00Collection expressions, la nueva sintaxis de inicialización de colecciones en C# 12<img alt="C#" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi6uTC5x0nlVPyLR4CwNZmbC6X_dp-XG-L7MNo4ylZBY-DaxxtWVWGVZMKZwiZqSvztUM4LVUptbWTW02XiPXFjZUm550YRQz98TL_RVgdi1x4udSL8alkcJpt5H38rMewexMwK38MI4D3ClXS6OAUB4uukNPDT0tTePgDzKDxt9lTJ_3UWCyw/s16000/csharp.png" title="C#" width="100%" />
<p>Poco a poco vamos haciéndonos con las novedades de C# 12, y en esta ocasión nos centraremos en una nueva sintaxis que proporciona una forma concisa y rápida para declarar los elementos de una colección.</p>
<p>Ya os adelanto que si sois de los que siempre han envidiado otros lenguajes por la facilidad con la que se declaran los elementos de un colección o array, estáis de enhorabuena ;) Porque, sin duda, hay formas de hacerlo menos verbosas que las que hemos tenido hasta ahora en C#:</p>
<pre><code class="language-console">// JavaScript:
let numbers = [1, 2, 3];
// Python:
numbers = [1, 2, 3]
// PHP:
$array = [1, 2, 3];
// Rust:
let array = [1, 2, 3];
</code></pre>
<p>En C# 11 y anteriores, la creación de un array es normalmente más farragosa, porque de alguna forma u otra requiere que especifiquemos que se trata de un nuevo <em>array</em> y, si la inferencia no lo permite, el tipo de los elementos que contendrá:</p>
<pre><code class="language-cs">// Forma verbosa y redundante:
int[] arr1 = new int[3] { 1, 2, 3 };
// Forma clásica, usando 'var' y especificando número y tipo elementos:
var arr2 = new int[3] { 1, 2, 3 };
// Dejamos que el compilador detecte el número de elementos:
var arr3 = new int[] { 1, 2, 3 };
// Dejamos que la inferencia de tipos determine el tipo de los elementos:
var arr4 = new [] { 1, 2, 3 };
// O bien, la más concisa, usando la sintaxis con llaves (sólo válida para arrays):
int[] arr5 = { 1, 2, 3 };
</code></pre>
<p><span></span></p><a name='more'></a>En C# 12, al igual que en otros lenguajes, <strong>podemos usar los corchetes <code>[]</code> en (prácticamente) cualquier lugar donde sea necesario especificar una colección de elementos</strong>.<p></p>
<p>Por ejemplo, en el siguiente código lo usamos en la inicialización de un <em>array</em>, aunque no veremos mucha ventaja respecto a la fórmula más concisa de C#:</p>
<pre><code class="language-cs">// C# 11 y anteriores:
var x = new int[] { 1, 2, 3 };
int[] y = { 1, 2, 3 };
// C# 12:
int[] z = [1, 2, 3];
</code></pre>
<p>Sin embargo, en el siguiente código veremos que esta nueva sintaxis cobra más sentido, porque el parámetro del método al que se está llamando recibe un <em>array</em> de caracteres y la inferencia de tipos puede detectarlo. Esto no había una mejor forma de especificarlo en versiones anteriores de C#:</p>
<pre><code class="language-cs">// En C# 11 y anteriores:
var index = "abcd".IndexOfAny(new[] { 'b', 'c'})
// En C# 12:
var index = "abcd".IndexOfAny(['b', 'c']));
</code></pre>
<p>Este tipo de declaración puede utilizarse también con otras colecciones, como <code>List<T></code>, <code>Span<T></code>, <code>IEnumerable<T></code>, etc. Es decir, las siguientes líneas son válidas:</p>
<pre><code class="language-cs">List<int> x = [1, 2, 3];
Collection<int> y = [1, 2, 3];
HashSet<int> z = [1, 2, 3];
IEnumerable<int> t = [1, 2, 3];
</code></pre>
<p>También es interesante saber que podemos usar esta sintaxis para insertar el contenido de otras colecciones en los datos iniciales usando <em>spreading</em>, gracias al operador doble punto "..":</p>
<pre><code class="language-cs">int[] x = [3, 4, 5];
int[] y = [1, 2, ..x, 6, 7];
Console.WriteLine(string.Join(", ", y));
// Muestra: 1, 2, 3, 4, 5, 6, 7
</code></pre>
<p>Y, por supuesto, soporta <em>arrays</em> multidimensionales:</p>
<pre><code class="language-cs">int[][] arr = [[1, 2, 3], [4, 5, 6], [7, 8, 9]];
</code></pre>
<p>Además, la nueva sintaxis permite<b> que sea el compilador el que decida la forma más eficiente de inicializar la colección</b>, lo que puede suponer una mejora en términos de CPU y memoria en algunos casos.</p>
<p>Sin duda, se trata de una mejora que simplifica el código de inicialización de <em>arrays</em> y otras colecciones, por lo que seguro empezaremos a verla en código ajeno y usarla en el nuestro propio.</p>
<p>¿Mola mucho, verdad?</p>
<p>Más información:</p>
<ul>
<li><a href="https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-12.0/collection-expressions">Collection expressions en C# 12</a></li>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com3tag:blogger.com,1999:blog-27752126.post-91919056810890781902023-12-18T08:05:00.006+01:002023-12-18T08:05:00.131+01:00Enlaces interesantes 549<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2022/02/archivos-javascript-independientes-por.html">Archivos JavaScript independientes por componente en Blazor</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2012/04/las-20-mejores-tiras-comicas-sobre.html">Las 20 mejores tiras cómicas sobre desarrollo de software</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/dotnet/dotnet-8-hardware-intrinsics/">Hardware Intrinsics in .NET 8</a><br />
Tanner Gooding</li>
<li><a href="https://code-maze.com/csharp-tuple-aliases/">Tuple Aliases in C#</a><br />
Aditi Saxena</li>
<li><a href="https://blog.nimblepros.com/blogs/where-csharp-primary-constructors-make-sense/">Where C# Primary Constructors Make Sense</a><br />
Steve Smith</li>
<li><a href="https://www.codeproject.com/Articles/5373951/A-Generic-Implementation-of-Dijkstra-s-Smoothsort">A Generic Implementation of Dijkstra’s Smoothsort in C#</a><br />
Jorge Luis Orejel</li>
<li><a href="https://www.growthaccelerationpartners.com/blog/5-things-you-need-to-know-about-aspire-and-net-8">5 Things You Need to Know About Aspire and .NET 8</a><br />
Growth Acceleration Partners</li>
<li><a href="https://andrewlock.net/redacting-sensitive-data-with-microsoft-extensions-compliance/">Redacting sensitive data in logs with Microsoft.Extensions.Compliance.Redaction</a><br />
Andrew Lock</li>
<li><a href="https://www.roundthecode.com/dotnet-tutorials/hosted-service-major-update-lifecycle-events">Hosted service has a major update to its lifecycle events</a><br />
David Grace</li>
<li><a href="https://www.code4it.dev/blog/unit-tests-without-interfaces/">4 ways to create Unit Tests without Interfaces in C#</a><br />
Davide Bellone</li>
<li><a href="https://codingsonata.com/build-performance-evaluation-workflow-with-workflowengine-in-net/">Build Performance Evaluation Workflow with WorkflowEngine in .NET</a><br />
Aram Tchekrekjian</li>
<li><a href="https://code-maze.com/how-to-decode-jwt-tokens-in-net/">How to Decode JWT Tokens in .NET</a><br />
Muhammad Afzal Qureshi</li>
<li><a href="https://btburnett.com/csharp/2023/12/12/generic-type-construction-with-static-virtual-interface-members">Generic Type Construction With Static Virtual Interface Members</a><br />
Brant Burnett</li>
<li><a href="https://code-maze.com/csharp-select-a-dropdown-option-using-selenium-webdriver/">Select a Dropdown Option Using Selenium WebDriver in C#</a><br />
Semir Teskeredzic</li>
<li><a href="https://bartwullems.blogspot.com/2023/12/c-record-types-copy-constructor.html">C#– Record types copy constructor</a><br />
Bart Wullems</li>
<li><a href="https://honestillusion.com/blog/2023/12/15/All-purpose-object-updater/">All Purpose Object Updater</a><br />
James Curran<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://dev.to/isaacojeda/mejorando-rendimiento-y-escalabilidad-guia-de-cache-distribuido-en-aspnet-core-3149">Mejorando Rendimiento y Escalabilidad: Guía de Caché Distribuido en ASP.NET Core</a><br />
Isaac Ojeda</li>
<li><a href="https://damienbod.com/2023/12/13/securing-a-mudblazor-ui-web-application-using-security-headers-and-microsoft-entra-id/">Securing a MudBlazor UI web application using security headers and Microsoft Entra ID</a><br />
Damien Bowden</li>
<li><a href="https://nestenius.se/2023/12/13/demystifying-openid-connects-state-and-nonce-parameters-in-asp-net-core/">Demystifying OpenID Connect’s State and Nonce Parameters in ASP.NET Core – Tore Nestenius</a><br />
Tore Nestenius</li>
<li><a href="https://jonhilton.net/persist-state-between-renders-net8/">.NET 8 Blazor component visibly loading twice? Check your prerendering</a><br />
Jon Hilton</li>
<li><a href="https://code-maze.com/aspnetcore-how-to-get-an-access-token-from-httpcontext/">How to Get an Access Token from HttpContext in ASP.NET Core</a><br />
Dona Pejnovic</li>
<li><a href="https://community.devexpress.com/blogs/aspnet/archive/2023/12/13/blazor-new-net-8-render-modes-v23-2.aspx">Blazor — New .NET 8 Render Modes in DevExpress Components</a><br />
Elena Peskova</li>
<li><a href="https://dotnetthoughts.net/integrate-openai-api-in-aspnet-core/">Integrate OpenAI API in ASP.NET Core</a><br />
Anuraj Parameswaran</li>
<li><a href="https://code-maze.com/how-to-publish-a-blazor-webassembly-application-on-iis/">Publishing Blazor WebAssembly App to IIS</a><br />
Gergo Vandor</li>
<li><a href="https://www.telerik.com/blogs/aspnet-core-basics-understanding-dependency-injection">ASP.NET Core Basics: Understanding Dependency Injection</a><br />
Assis Zang</li>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://codeopinion.com/path-to-event-driven-architecture-start-capturing-intent/">Path to Event-Driven Architecture. Start capturing INTENT!</a><br />
Derek Comartin</li>
<li><a href="https://andrewkchan.dev/posts/fire.html">Simulating Fluids, Fire, and Smoke in Real-Time</a><br />
Andrew Chan</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://steven-giesel.com/blogPost/5bf635cb-3533-4207-905f-81eb86512219">Entity Framework - Storing complex objects as JSON</a><br />
Steven Giesel</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://blog.google/technology/ai/google-gemini-pro-imagen-duet-ai-update/">Gemini API and more new AI tools for developers and enterprises</a><br />
Google</li>
<li><a href="https://dev.to/cwl157/named-entity-recognition-using-azure-ai-2he8">Named Entity Recognition Using Azure AI</a><br />
Carl Layton</li>
<li><a href="https://techcommunity.microsoft.com/t5/microsoft-mechanics-blog/build-your-own-copilots-with-azure-ai-studio/ba-p/4006387">Build your own copilots with Azure AI Studio</a><br />
Zachary Cavanell</li>
<li><a href="https://openai.com/research/weak-to-strong-generalization">Weak-to-strong generalization</a><br />
OpenAPI</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://www.campusmvp.es/recursos/post/html-como-incluir-separadores-y-grupos-en-selectores-desplegables.aspx">HTML: Cómo incluir separadores y grupos en selectores desplegables</a><br />
José Manuel Alarcón</li>
<li><a href="https://blog.melvinvmegen.com/posts/javascript/14_tips_to_write_better_javascript">14 tips to write better Javascript</a><br />
Melvin V. Megen</li>
<li><a href="https://codeguppy.com/blog/fantasy-cpu-emulator/">Build a fantasy CPU emulator in JavaScript</a><br />
CodeGuppy</li>
<li><a href="https://www.sonarsource.com/blog/stop-nesting-ternaries-javascript/">Stop nesting ternaries in JavaScript</a><br />
Phil Nash</li>
<li><a href="https://marvinh.dev/blog/speeding-up-javascript-ecosystem-part-6/">Speeding up the JavaScript ecosystem - Pollyfills gone rogue</a><br />
Marvin Hagemeist</li>
<li><a href="https://levelup.gitconnected.com/modern-css-features-that-every-web-developer-should-know-d601c2076406">Modern CSS Features That Every Web Developer Should Know</a><br />
Shalitha Suranga</li>
<li><a href="https://www.sitepoint.com/understanding-react-tooltip/">Quick Tip: Understanding React Tooltip</a><br />
Dianne Pena</li>
<li><a href="https://blog.logrocket.com/using-defer-angular-17-implement-lazy-loading">Using defer in Angular 17 to implement lazy loading</a><br />
Lewis Cianci</li>
<li><a href="https://shefali.dev/css-properties/">15 CSS Hidden Properties You Should Know About</a><br />
Shefali Jangid</li>
<li><a href="https://www.smashingmagazine.com/2023/12/css-scroll-snapping-aligned-global-page-layout-case-study/">CSS Scroll Snapping Aligned With Global Page Layout: A Full-Width Slider Case Study</a><br />
Brecht De Ruyte</li>
<li><a href="https://lennybacon.com/posts/viewtransitionsapi/">View Transitions API</a><br />
Lenny Bacon</li>
<li><a href="https://thenewstack.io/what-vues-creator-learned-the-hard-way-with-vue-3/">What Vue’s Creator Learned the Hard Way with Vue 3</a><br />
Loraine Lawson</li>
<li><a href="https://levelup.gitconnected.com/css-functions-that-help-you-design-modern-frontends-5ba7f4eaf018">CSS Functions That Help You Design Modern Frontends</a><br />
Shalitha Suranga</li>
<li><a href="https://blog.angular.io/check-out-angulars-support-for-the-view-transitions-api-3937376cfc19">Check out Angular’s support for the View Transitions API</a><br />
Andrew Scott</li>
<li><a href="https://freefullstack.com/fixing-the-top-10-common-javascript-errors/">Avoiding the 10 Common Javascript Errors</a><br />
Free Full Stack</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/visualstudio/visual-studio-17-9-preview-2-has-arrived/">Visual Studio 17.9 Preview 2 has arrived!</a><br />
Maddy Montaquila</li>
<li><a href="https://dev.to/wraith/time-saving-tip-2-user-snippets-in-vscode-5d54">Time Saving Tip #2 - User Snippets in VSCode</a><br />
Jake Lundberg</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/unlocking-the-secrets-of-managed-memory-dive-into-event-handler-leak-insights/">Unlocking the Secrets of Managed Memory: Dive into Event Handler Leak Insights!</a><br />
Massimo Giusti</li>
</ul>
<h4>.NET MAUI / Xamarin / Mobile</h4>
<ul>
<li><a href="https://www.syncfusion.com/blogs/post/maui-candle-chart-tesla-stock.aspx">Chart of the Week: Creating a .NET MAUI Candle Chart to Analysis Tesla’s (TSLA) Stock Prices</a><br />
Nitheeshkumar Thangaraj</li>
<li><a href="https://thoughtbot.com/blog/optimizing-performance-in-react-native-tips-and-techniques">Optimizing Performance in React-Native: Tips and Techniques</a><br />
Diego Oliveira</li></ul><ul>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-3509664342090905402023-12-12T08:05:00.001+01:002023-12-12T08:05:00.150+01:00Cómo aplicar atributos a propiedades de un record en C#<img alt=".NET" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEggPhnd9ZQ4eqBbsniTu7J4y5tTeDxIl8MoBpsy2ir_BxqkMp7TPJtVdL462DXMCI3RuS_Q716yjv2plFUbI_fA7qy_I2K1FHvgTQfBPgIq5oMRG02g5a1t5XOqXmaOwd88RH7GZO52F912aZqMDCn20DdSruzSAAshjI51TqU4ibWuPnRO2mw/s16000/net.png" title=".NET" width="100%" />
<p>Los <em>records</em> son una interesante fórmula para definir tipos en C# de forma rápida gracias a su concisa sintaxis, además de ofrecer otras ventajas, entre las que destacan la inmutabilidad o la implementación automática de métodos como <code>Equals()</code>, <code>GetHashCode()</code> o <code>ToString()</code>.</p>
<p>Por si no tenéis esto muy fresco, aquí va un ejemplo de <em>record</em> y la clase tradicional equivalente en C#:</p>
<pre><code class="language-cs">// Record:
public record Person(string FirstName, string LastName);
// Clase equivalente (generada automáticamente):
public class Person
{
public string FirstName { get; init; }
public string LastName { get; init; }
public Person(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
public override bool Equals(object obj)
{
return obj is Person person &&
FirstName == person.FirstName &&
LastName == person.LastName;
}
public override int GetHashCode()
{
return HashCode.Combine(FirstName, LastName);
}
public Person With(string FirstName = null, string LastName = null)
{
return new Person(FirstName ?? this.FirstName, LastName ?? this.LastName);
}
public void Deconstruct(out string firstName, out string lastName)
{
firstName = this.FirstName;
lastName = this.LastName;
}
}
</code></pre>
<p>Como podéis comprobar, <strong>hay pocas características de C# que ofrezcan una relación código/funcionalidad tan bárbara</strong> como los <em>records</em>. Por ello, poco a poco van ganando popularidad y comenzamos a verlos ya de forma habitual en código propio y ajeno.</p>
<p>Sin embargo, su concisa sintaxis hacen que a veces no sea fácil intuir cómo resolver algunos escenarios que, usando las clases tradicionales, serían triviales.</p>
<p>Por ejemplo, hoy vamos a centrarnos en un escenario muy concreto pero frecuente, cuya solución seguro que veis que puede ser aplicada en otros casos: <strong>ya que en los <em>records</em> no definimos propiedades de forma explícita, ¿cómo podríamos aplicarles atributos?<span></span></strong></p><a name='more'></a><p></p>
<p>Por ejemplo, en el siguiente código definimos un <em>record</em>, creamos una instancia del mismo y mostramos su serialización en JSON por consola:</p>
<pre><code class="language-cs">var p = new Person("John Smith", "jsmith@server.com");
Console.WriteLine(JsonSerializer.Serialize(p));
// Muestra: {"Name":"John Smith","Email":"jsmith@server.com"}
public record Person(string Name, string Email);
</code></pre>
<p>Pero imaginad que queremos ignorar la propiedad <code>Email</code> y que la propiedad <code>Name</code> aparezca como <code>fullName</code>. Normalmente usaríamos atributos como <code>[JsonIgnore]</code> o <code>[JsonPropertyName("fullName")]</code> sobre las propiedades para conseguirlo, pero como en este caso no las tenemos disponibles, debemos hacerlo así:</p>
<pre><code class="language-cs">public record Person([property: JsonPropertyName("fullName")] string Name,
[property: JsonIgnore] string Email);
</code></pre>
<p>Observad que no se trata de aplicar directamente los atributos <code>[JsonIgnore]</code>, porque entonces los estaríamos usando contra los parámetros del constructor del <em>record</em>. <strong>Debemos incluir el prefijo <code>property:</code> para indicar que los atributos deben ser aplicados a las propiedades</strong> generadas automáticamente a partir de ellos.</p>
<p>De esta forma, si volvemos a ejecutar el código, veremos que ahora la propiedad <code>Email</code> no aparece en la serialización y la propiedad <code>Name</code> aparece como <code>fullName</code>:</p>
<pre><code class="language-cs">var p = new Person("John Smith", "jsmith@server.com");
Console.WriteLine(JsonSerializer.Serialize(p));
// Muestra: {"fullName":"John Smith"}
public record Person([property: JsonPropertyName("fullName")] string Name,
[property: JsonIgnore] string Email);
</code></pre>
<p>Como decía más arriba, aunque el ejemplo hayamos visto cómo aplicar atributos de serialización o deserialización, en realidad podríamos hacer lo mismo con cualquier otro tipo de atributo que en condiciones normales aplicaríamos a las propiedades de una clase.</p>
<p>¡Espero que os sea de utilidad! 😊</p>
Publicado en: <a href="https://www.variablenotfound.com">www.variablenotfound.com</a>.José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0tag:blogger.com,1999:blog-27752126.post-43291335008709979252023-12-11T08:05:00.002+01:002023-12-11T08:05:00.143+01:00Enlaces interesantes 548<img alt="Enlaces interesantes" border="0" class="post-header-image" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjiESKM3E0lgr2q52QY_lVbswp7LRUgWEPZXRhcjNnQAwHyI9XNt6qPxqgUexPfWob1my4n6sMyoxf4OKlfmm7C5Ihc52fpNC5uAOEJ0tXQw6wnruwixP8upJJtRFRQ5oeK9eER9Y_M-u8FBvk9uMODFlizm8EiSvyaSZ7uXEUntyHfdtrjesA/s1600/enlaces.jpg" title="Enlaces interesantes" width="100%" />
<p>Ahí van los enlaces recopilados durante la semana pasada. Espero que os resulten interesantes. :-)</p>
<h4>Por si te lo perdiste...</h4>
<ul>
<li><a href="https://www.variablenotfound.com/2012/02/llamemos-las-cosas-por-su-nombre.html">Llamemos a las cosas por su nombre</a><br />
José María Aguilar</li>
<li><a href="https://www.variablenotfound.com/2022/01/aspnet-core-6-donde-esta-mi-middleware.html">ASP.NET Core 6, ¿dónde está mi middleware DeveloperExceptionPage?</a><br />
José María Aguilar</li>
</ul>
<h4>.NET Core / .NET</h4>
<ul>
<li><a href="https://devblogs.microsoft.com/dotnet/dotnet-8-networking-improvements/">.NET 8 Networking Improvements</a><br />
Máňa & Natalia Kondratyeva</li>
<li><a href="https://devblogs.microsoft.com/dotnet/extending-web-assembly-to-the-cloud/">Extending WebAssembly to the Cloud with .NET</a><br />
Richard Lander</li>
<li><a href="https://code-maze.com/csharp-local-functions/">Local Functions in C#</a><br />
Code Maze</li>
<li><a href="https://www.devleader.ca/2023/12/03/how-to-take-advantage-of-csharp-optional-parameters-for-cleaner-code/">How to Take Advantage of CSharp Optional Parameters for Cleaner Code</a><br />
Nick Cosentino</li>
<li><a href="https://endjin.com/blog/2023/12/how-dotnet-8-boosted-json-schema-performance-by-20-percent-for-free">How .NET 8.0 boosted JSON Schema performance by 20%</a><br />
Matthew Adams</li>
<li><a href="https://andrewlock.net/customising-the-new-telemetry-logging-source-generator/">Enriching logs with [TagProvider] and ILogEnricher</a><br />
Andrew Lock</li>
<li><a href="https://khalidabuhakmeh.com/how-to-use-regular-expressions-and-match-evaluators-in-dotnet">How to use Regular Expressions and Match Evaluators in .NET</a><br />
Khalid Abuhakmeh</li>
<li><a href="https://www.meziantou.net/inline-snapshot-testing-in-dotnet.htm">Inline Snapshot testing in .NET</a><br />
Gérald Barré</li>
<li><a href="https://www.roundthecode.com/dotnet-tutorials/data-annotations-awesome-additions-dotnet-8">Data annotations has some awesome additions in .NET 8</a><br />
David Grace</li>
<li><a href="https://www.i-programmer.info/programming/100-c/493-casting-the-escape-from-strong-typing.html">Deep C# - Casting the Escape from Strong Typing</a><br />
Mike James</li>
<li><a href="https://devblogs.microsoft.com/dotnet/learn-dotnet8-beginner-videos/">Learn .NET 8 with New Beginner Videos</a><br />
Katie Savage</li>
<li><a href="https://code-maze.com/csharp-create-better-looking-console-applications-with-spectre-console/">Create Better Looking Console Applications With Spectre.Console</a><br />
Januarius Njoku</li>
<li><a href="https://blog.codingmilitia.com/2023/12/06/byte-array-as-a-dictionary-key-trying-out-some-options/">Byte array as a dictionary key? Trying out some options</a><br />
João Antunes</li>
<li><a href="https://code-maze.com/dotnet-switch-between-sdk-versions/">How to Switch Between .NET SDK Versions</a><br />
Lennart Pries</li>
<li><a href="https://blog.ndepend.com/net-native-aot-explained/">.NET Native AOT Explained</a><br />
NDepend</li>
<li><a href="https://code-maze.com/csharp-rename-files-in-a-folder/">How to Rename Files in a Folder in C#</a><br />
Caleb Okechukwu</li>
<li><a href="https://michaelscodingspot.com/debug-linq-in-csharp/">How to Debug LINQ queries in C#</a><br />
Michael Shpilt<span><a name='more'></a></span></li></ul>
<h4>ASP.NET Core / ASP.NET / Blazor</h4>
<ul>
<li><a href="https://ilovedotnet.org/blogs/blazor-wasm-lazy-loading/">Blazor WASM Lazy Loading</a><br />
Abdul Rahman Shabeek Mohamed</li>
<li><a href="https://www.milanjovanovic.tech/blog/global-error-handling-in-aspnetcore-8">Global Error Handling in ASP.NET Core 8</a><br />
Milan Jovanović</li>
<li><a href="https://joshthecoder.com/2023/12/01/sneaky-async-void-leads-to-aspnetcore-crash.html">Sneaky async void Leads to ASP.NET Core Crash</a><br />
Josh Darnell</li>
<li><a href="https://www.cafe-encounter.net/p3521/blazor-cascading-parameters-dont-just-work-with-lambdas-or-method-callback">Blazor Cascading Parameters don’t “just work” with lambdas or method callback</a><br />
Chris F. Carroll</li>
<li><a href="https://blog.elmah.io/dependency-injection-using-keyed-services-is-finally-in-asp-net/">Dependency Injection using keyed services is finally in ASP.NET</a><br />
Thomas Ardal</li>
<li><a href="https://dotnetthoughts.net/integrate-openai-apis-in-aspnet-core/">Integrate OpenAI APIs in ASP.NET Core</a><br />
Anuraj Parameswaran</li>
<li><a href="https://code-maze.com/blazor-webassembly-ahead-of-time-compilation/">Blazor WebAssembly Ahead of Time Compilation</a><br />
Januarius Njoku</li>
<li><a href="https://www.telerik.com/blogs/let-users-know-whats-going-blazor-notification-component">Let Users Know What’s Going on—Blazor Notification Component</a><br />
Peter Vogel</li>
<li><a href="https://blog.delegate.at/2023/12/07/vertiq-introduction.html">Vertiq - Blazor Application Framework - An Introduction</a><br />
Manuel Grundner</li>
<li><a href="https://ilovedotnet.org/blogs/blazor-wasm-exception-handling-and-error-boundary/">Blazor WASM Exception Handling and Error Boundary</a><br />
Abdul Rahman Shabeek Mohamed</li></ul><ul>
</ul>
<h4>Conceptos / Patrones / Buenas prácticas</h4>
<ul>
<li><a href="https://codeopinion.com/ddd-is-just-giving-a-about-your-domain/">DDD is just giving a $h!t about your Domain</a><br />
Derek Comartin</li>
<li><a href="https://code-maze.com/csharp-hexagonal-architectural-pattern/">Hexagonal Architectural Pattern in C#</a><br />
Code Maze</li>
</ul>
<h4>Data</h4>
<ul>
<li><a href="https://en.oceanbase.com/blog/2596985600">Designing a Distributed SQL Engine: Challenges & Decisions</a><br />
Guoping Wang</li>
<li><a href="https://code-maze.com/insert-and-return-inserted-identity-with-dapper/">How to Insert and Return Inserted Identity With Dapper</a><br />
Code Maze</li>
</ul>
<h4>Machine learning / IA / Bots</h4>
<ul>
<li><a href="https://www.elladodelmal.com/2023/12/indirect-prompt-injection-dialog.html">Indirect Prompt Injection & Dialog Poissoning en ataques a LLMs Multi-Modales</a><br />
Chema Alonso</li>
<li><a href="https://blog.google/technology/ai/google-gemini-ai/#sundar-note">Introducing Gemini: our largest and most capable AI model</a><br />
Sundar Pichar & Demis Hassabis</li>
<li><a href="https://blogs.microsoft.com/blog/2023/12/05/celebrating-the-first-year-of-copilot-with-significant-new-innovations/">Celebrating the first year of Copilot with significant new innovations</a><br />
Yusuf Medhi</li>
</ul>
<h4>Web / HTML / CSS / Javascript</h4>
<ul>
<li><a href="https://nolanlawson.com/2023/12/02/lets-learn-how-modern-javascript-frameworks-work-by-building-one/">Let’s learn how modern JavaScript frameworks work by building one</a><br />
Nolan Lawson</li>
<li><a href="https://www.htmhell.dev/adventcalendar/2023/2/">You don't need JavaScript for that</a><br />
Kilian Valkhof</li>
<li><a href="https://www.smashingmagazine.com/2023/12/marketing-changed-oop-javascript/">How Marketing Changed OOP In JavaScript</a><br />
Juan Diego Rodríguez</li>
<li><a href="https://www.telerik.com/blogs/angular-basics-how-to-use-svg-icons">Angular Basics: How to Use SVG Icons in Angular</a><br />
Jonathan Gamble</li>
<li><a href="https://www.telerik.com/blogs/browser-image-conversion-using-ffmpeg.wasm">Browser Image Conversion Using FFmpeg.wasm</a><br />
Ifeoma Imoh</li>
<li><a href="https://blog.stephaniestimac.com/posts/2023/12/css-media-query-scripting/">CSS Media Query for Scripting Support</a><br />
Stephanie Stimac</li>
<li><a href="https://www.smashingmagazine.com/2023/12/preparing-interaction-next-paint-web-core-vital/">Preparing For Interaction To Next Paint, A New Web Core Vital</a><br />
Geoff Graham</li>
<li><a href="https://blog.stephaniestimac.com/posts/2023/12/css-media-video-source/">CSS Media Query Support for Video <source> Elements</a><br />
Stephanie Stimac</li>
</ul>
<h4>Visual Studio / Complementos / Herramientas</h4>
<ul>
<li><a href="https://blog.jetbrains.com/blog/2023/12/06/introducing-jetbrains-ai-and-the-in-ide-ai-assistant/">Introducing JetBrains AI and the In-IDE AI Assistant</a><br />
Aleksandra Krupskaya</li>
<li><a href="https://devblogs.microsoft.com/devops/work-items-in-visual-studio/">Work Items in Visual Studio</a><br />
Dan Hellem</li>
<li><a href="https://devblogs.microsoft.com/visualstudio/scroll-to-expand-document-tabs/">Scroll to expand document tabs</a><br />
Dominic Nahous</li>
</ul>
<h4>.NET MAUI / Xamarin</h4>
<ul>
<li><a href="https://www.telerik.com/blogs/net-maui-developer-productivity-vs-code">.NET MAUI Developer Productivity on VS Code</a><br />
Sam Basu</li>
<li><a href="https://blog.pieeatingninjas.be/2023/12/08/translate-spoken-text-with-whisper-and-gpt-with-azure-open-ai-services-and-net-maui/">Translate spoken text using Whisper and GPT with Azure OpenAI Services and .NET MAUI</a><br />
Pieter Nijs</li>
<li><a href="https://askxammy.com/text-truncation-and-wrapping-in-net-maui/">Text Truncation and Wrapping in .NET MAUI</a><br />
Leomaris Reyes</li></ul><ul>
</ul>
<p>Publicado en <a href="https://www.variablenotfound.com">Variable not found</a>.</p>
José María Aguilarhttp://www.blogger.com/profile/08255861077355617652noreply@blogger.com0