<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Victor Sanchez</title>
    <description>The latest articles on Forem by Victor Sanchez (@vhsv90).</description>
    <link>https://forem.com/vhsv90</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1280255%2F148f0116-b7b0-488c-b376-ed872ec41594.jpeg</url>
      <title>Forem: Victor Sanchez</title>
      <link>https://forem.com/vhsv90</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/vhsv90"/>
    <language>en</language>
    <item>
      <title>Understanding .NET Compilation: .NET Standard vs .NET Core, Roslyn vs csc.exe, and Dynamic Compilation</title>
      <dc:creator>Victor Sanchez</dc:creator>
      <pubDate>Fri, 09 May 2025 23:42:55 +0000</pubDate>
      <link>https://forem.com/vhsv90/understanding-net-compilation-net-standard-vs-net-core-roslyn-vs-cscexe-and-dynamic-85e</link>
      <guid>https://forem.com/vhsv90/understanding-net-compilation-net-standard-vs-net-core-roslyn-vs-cscexe-and-dynamic-85e</guid>
      <description>&lt;p&gt;When working with .NET, it's crucial to understand how code is compiled and what tools are responsible for transforming your C# into executable binaries. This blog explores the differences between compilers used in .NET Standard and .NET Core and explains the role of Roslyn, csc.exe, and dynamic compilation in modern .NET development.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 .NET Standard vs .NET Core Compilation
&lt;/h2&gt;

&lt;p&gt;.NET Standard&lt;br&gt;
What it is: A formal specification of .NET APIs that all .NET implementations (like .NET Framework, .NET Core, Xamarin) must implement.&lt;br&gt;
Usage: Used to build libraries that are portable across all .NET platforms.&lt;br&gt;
Compilation: Uses netstandard.dll as a reference library. The actual runtime compilation is handled by the consuming runtime (.NET Core, Mono, etc.).&lt;br&gt;
.NET Core&lt;br&gt;
What it is: A cross-platform runtime implementation of .NET.&lt;br&gt;
Usage: Can build and run both applications and libraries.&lt;br&gt;
Compilation: Uses Roslyn compiler directly or via dotnet build. Relies on System.Private.CoreLib, System.Console, and other runtime assemblies.&lt;/p&gt;
&lt;h2&gt;
  
  
  ⚙️ Roslyn and csc.exe Explained
&lt;/h2&gt;

&lt;p&gt;csc.exe – The Classic Compiler&lt;br&gt;
What it is: Command-line compiler executable for C#.&lt;br&gt;
Usage: Used in traditional build pipelines or directly via CLI.&lt;br&gt;
Limitations: Not embeddable, harder to use programmatically.&lt;br&gt;
Implementation: Originally implemented in C++ as part of the .NET Framework SDK.&lt;/p&gt;

&lt;p&gt;Roslyn – Compiler as a Service&lt;br&gt;
What it is: .NET compiler platform as a set of APIs (Microsoft.CodeAnalysis).&lt;br&gt;
Usage: Used by modern tools like Visual Studio, OmniSharp, analyzers.&lt;br&gt;
Benefits: Fully programmable, supports syntax trees, diagnostics, in-memory emit.&lt;br&gt;
Implementation: Written in C#, and bootstrapped using Roslyn itself.&lt;br&gt;
📝 Note: csc.exe is built on top of Roslyn. It's essentially a thin command-line wrapper around the Roslyn API.&lt;/p&gt;
&lt;h2&gt;
  
  
  🔄 Dynamic Compilation
&lt;/h2&gt;

&lt;p&gt;Dynamic compilation refers to compiling code at runtime, allowing for runtime behaviors such as scripting, code evaluation, or plugin execution.&lt;/p&gt;

&lt;p&gt;In Roslyn, dynamic compilation is achieved by using the Roslyn APIs to compile and execute code in memory, without writing to disk. This is useful for scenarios like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Online code editors&lt;/li&gt;
&lt;li&gt;Plugin systems&lt;/li&gt;
&lt;li&gt;Educational tools&lt;/li&gt;
&lt;li&gt;Runtime extensibility in applications&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Example: Dynamic Compilation in Action
&lt;/h2&gt;

&lt;p&gt;Here's a simple example using the Roslyn API for dynamic compilation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using System;
using System.IO;
using System.Reflection;

class Program
{
    static void Main()
    {
        var code = @"
            using System;
            public static class Example
            {
                public static void Main()
                {
                    var tuple = (Part1: \"hello\", Part2: \"world\");
                    Console.WriteLine($\"{tuple.Part1} {tuple.Part2}\");
                }
            }
";

        // Resolve paths to needed assemblies
        string coreDir = Path.GetDirectoryName(typeof(object).Assembly.Location)!;

        var references = new[]
        {
            MetadataReference.CreateFromFile(typeof(object).Assembly.Location),                     // System.Private.CoreLib.dll
            MetadataReference.CreateFromFile(typeof(Console).Assembly.Location),                   // System.Console.dll
            MetadataReference.CreateFromFile(Assembly.Load("System.Runtime").Location),            // System.Runtime.dll
            MetadataReference.CreateFromFile(Assembly.Load("netstandard").Location),               // netstandard.dll
            MetadataReference.CreateFromFile(Assembly.Load("System.Console").Location),            // System.Console.dll again, to be sure
        };

        var syntaxTree = CSharpSyntaxTree.ParseText(code);
        Console.WriteLine(syntaxTree.ToString());

        var compilation = CSharpCompilation.Create(
            "HelloWorld",
            new[] { syntaxTree },
            references,
            new CSharpCompilationOptions(OutputKind.ConsoleApplication)
        );

        using var ms = new MemoryStream();
        var result = compilation.Emit(ms);

        if (!result.Success)
        {
            Console.WriteLine("Compilation failed:");
            foreach (var diag in result.Diagnostics)
                Console.WriteLine(diag.ToString());
            return;
        }

        ms.Seek(0, SeekOrigin.Begin);
        var assembly = Assembly.Load(ms.ToArray());

        var type = assembly.GetType("Example");
        var method = type?.GetMethod("Main", BindingFlags.Public | BindingFlags.Static);
        method?.Invoke(null, null); // Output: hello world
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ✅ Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding the .NET compilation process is key to mastering modern .NET development. Whether you're writing cross-platform libraries with .NET Standard or building apps with .NET Core, knowing how your code turns into binaries helps you troubleshoot, optimize, and innovate with confidence.&lt;br&gt;
Roslyn has redefined what a compiler can do—turning it from a black box into a programmable service. It powers not only Visual Studio and analyzers but also enables powerful scenarios like dynamic compilation, custom tooling, and interactive scripting.&lt;br&gt;
Whether you're using csc.exe for straightforward builds or Roslyn APIs for advanced scenarios, understanding these tools gives you the flexibility and insight to choose the right approach for your project.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>programming</category>
      <category>netcore</category>
      <category>roslyn</category>
    </item>
    <item>
      <title>Reinstalling Required Software Using Winget</title>
      <dc:creator>Victor Sanchez</dc:creator>
      <pubDate>Wed, 21 Aug 2024 15:57:56 +0000</pubDate>
      <link>https://forem.com/vhsv90/reinstalling-required-software-using-winget-1h3i</link>
      <guid>https://forem.com/vhsv90/reinstalling-required-software-using-winget-1h3i</guid>
      <description>&lt;p&gt;&lt;strong&gt;Overview&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Winget&lt;/strong&gt; (&lt;em&gt;Windows Package Manager&lt;/em&gt;) simplifies the management of software installations. This guide will walk you through exporting a list of installed applications to a JSON file and using that file to install the same applications on another machine or after a clean installation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prerequisites&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Windows Package Manager (winget):&lt;/strong&gt; Ensure winget is installed on your Windows machine. It comes with Windows 10 and Windows 11 as part of the App Installer package. Verify its installation by running &lt;strong&gt;&lt;em&gt;winget --version&lt;/em&gt;&lt;/strong&gt; in Command Prompt or PowerShell.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Administrative Rights:&lt;/strong&gt; Some operations may require administrative privileges. Ensure you have the necessary permissions to run these commands.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;&lt;strong&gt;Exporting Installed Applications&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To create a JSON file containing a list of your installed applications, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Open Command Prompt or PowerShell:&lt;/strong&gt; Press Win + X and select either Windows Terminal, Command Prompt, or PowerShell.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the Export Command:&lt;/strong&gt; Use the following command to export your installed applications to a JSON file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;winget export -o 'C:\Users\YourUsername\Desktop\apps.json' --ignore-warnings
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command generates a file named apps.json on your Desktop with a list of all installed applications.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Replace YourUsername with your actual Windows username.&lt;/li&gt;
&lt;li&gt;The -o flag specifies the output file path.&lt;/li&gt;
&lt;li&gt;The --ignore-warnings flag is optional and suppresses warnings during export.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Importing Applications&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To install applications on a new machine or after a fresh installation using the previously exported JSON file, follow these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Open Command Prompt or PowerShell:&lt;/strong&gt; Open Windows Terminal, Command Prompt, or PowerShell as before.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Run the Import Command:&lt;/strong&gt; Use the following command to import the list of applications from your JSON file:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;winget import -i 'C:\Users\YourUsername\Desktop\apps.json'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command reads the apps.json file and installs all the applications listed in it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Again, replace YourUsername with your actual Windows username.&lt;/li&gt;
&lt;li&gt;The -i flag specifies the input file path.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Tips&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Backup:&lt;/strong&gt; Ensure the JSON file is up-to-date and includes all the applications you want to install before importing.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Compatibility:&lt;/strong&gt; Applications listed in the JSON file must be available in the winget repository. If an application is not found, the import process will skip it.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Troubleshooting&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;File Not Found:&lt;/strong&gt; Verify that the file paths are correct and that the apps.json file exists at the specified location.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Permission Issues:&lt;/strong&gt; Run Command Prompt or PowerShell as an administrator if you encounter permission errors.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Application Not Found:&lt;/strong&gt; Some applications might not be available in the winget repository. Check the application's availability or update the JSON file accordingly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By following these steps, you can efficiently manage and replicate your application setup across different machines or after a system reset.&lt;/p&gt;

</description>
      <category>development</category>
      <category>tooling</category>
      <category>microsoft</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Exploring .NET Math Libraries: An Introduction to the NMLs Research Project</title>
      <dc:creator>Victor Sanchez</dc:creator>
      <pubDate>Mon, 19 Aug 2024 23:45:43 +0000</pubDate>
      <link>https://forem.com/vhsv90/exploring-net-math-libraries-an-introduction-to-the-nmls-research-project-4fi7</link>
      <guid>https://forem.com/vhsv90/exploring-net-math-libraries-an-introduction-to-the-nmls-research-project-4fi7</guid>
      <description>&lt;p&gt;Welcome to our exploration of .NET math libraries! In this blog post, we’ll dive into the NMLs (Math Libraries) research project—a solution built using .NET Core 8.0.X designed to evaluate and benchmark various math libraries. &lt;/p&gt;

&lt;p&gt;Whether you're a developer interested in mathematical computations or a performance enthusiast, this project offers valuable insights into the capabilities and performance of different libraries.&lt;/p&gt;

&lt;p&gt;You could find the code in this &lt;a href="https://github.com/vhsv90/NMLs" rel="noopener noreferrer"&gt;repository &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5kbi8ztzozei2zax268x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5kbi8ztzozei2zax268x.png" alt="Application Directory" width="800" height="382"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;The NMLs solution aims to provide a robust environment for exploring and benchmarking various .NET math libraries. Built on .NET Core 8.0.X, it facilitates the execution and evaluation of mathematical expressions while offering tools to compare performance across different libraries. Here’s a look at what the project entails:&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution Structure
&lt;/h2&gt;

&lt;p&gt;The Visual Studio solution for NMLs is organized into three main projects, each serving a specific purpose:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;MathLibsLogic&lt;/strong&gt;&lt;br&gt;
Purpose: This project contains implementations for various math libraries.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Each library is encapsulated in a class named My[LibraryName], allowing for easy extension and customization.&lt;/li&gt;
&lt;li&gt;Manages all NuGet package dependencies necessary for the math libraries, ensuring that all components are up-to-date and properly configured.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;NMLs&lt;/strong&gt;&lt;br&gt;
Purpose: A console application that allows users to test mathematical expressions and library implementations.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Users can input mathematical expressions and select different library implementations to test.&lt;/li&gt;
&lt;li&gt;Utilizes a loop with a property flag to keep the application running, accepting input until the user decides to exit.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Benchmarking&lt;/strong&gt;&lt;br&gt;
Purpose: To compare the performance of different math libraries.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses the BenchmarkDotNet package to provide detailed performance metrics.&lt;/li&gt;
&lt;li&gt;Allows for updating and running benchmark tests with various mathematical expressions to evaluate and compare library performance.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  External Projects
&lt;/h2&gt;

&lt;p&gt;Our research includes evaluating the following external projects:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ExpressionEvaluator&lt;/strong&gt; &lt;em&gt;1.4.40&lt;/em&gt;&lt;br&gt;
A versatile library for evaluating expressions. Explore it &lt;a href="https://github.com/codingseb/ExpressionEvaluator" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;ExpresiveParser&lt;/strong&gt; &lt;em&gt;3.0.1&lt;/em&gt;&lt;br&gt;
A powerful parser for evaluating expressions. Check out the project &lt;a href="https://github.com/bijington/expressive" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Microsoft.ClearScript&lt;/strong&gt; &lt;em&gt;7.4.5&lt;/em&gt;&lt;br&gt;
A library for integrating and executing scripts in .NET applications. Learn more &lt;a href="https://github.com/Microsoft/ClearScript" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;


&lt;h2&gt;
  
  
  How to Run
&lt;/h2&gt;
&lt;h3&gt;
  
  
  Using Visual Studio
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Open the NMLs solution in Visual Studio.&lt;/li&gt;
&lt;li&gt;In the Solution Explorer, right-click on either the Benchmarking or NMLs project.&lt;/li&gt;
&lt;li&gt;Select "&lt;strong&gt;Set as Startup Project&lt;/strong&gt;".&lt;/li&gt;
&lt;li&gt;Press &lt;strong&gt;F5 *&lt;em&gt;or click the *&lt;/em&gt;"Start"&lt;/strong&gt; button to run the project.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Using Terminal
&lt;/h3&gt;

&lt;p&gt;Navigate to the root directory of the cloned repository.&lt;br&gt;
Build the projects with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet build ./NMLs/NMLs.csproj
dotnet build ./Benchmarking/Benchmarking.csproj
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run the desired project with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet run --project ./NMLs/NMLs.csproj
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyazdkgu9aw84f5d7rmaq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyazdkgu9aw84f5d7rmaq.png" alt="Console App Running" width="800" height="836"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet build --configuration Release
dotnet run --project ./Benchmarking/Benchmarking.csproj --configuration Release
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Keep in mind that BenckmarkingDotNet needs to us the build project using Release configuration.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5s91ozvxgeovwydm2l5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5s91ozvxgeovwydm2l5.png" alt="BenchmarkDotNet Results" width="800" height="438"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Contribution
&lt;/h2&gt;

&lt;p&gt;We welcome contributions to this project! If you have suggestions, improvements, or find any issues, feel free to submit issues or pull requests. Your contributions help enhance the project and benefit the community.&lt;/p&gt;

</description>
      <category>netcore</category>
      <category>benchmarkdotnet</category>
      <category>csharp</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
