π Challenge: Create a compact Maze Game in C# under 2KB without .NET Runtime, Small enough to fit in a QR Code π€
π¨βπ» Process:
β’ Self-Contained: Includes all necessary components to run on any OS.βοΈ
β’ Game Type: A graphical maze, utilizing Win32 APIs, avoiding WinForms.βοΈ
β’ Size Reduction Steps:
1- Initial Size: 64MB (with CoreCLR)
2- Post-Compression: 35.2MB
3- IL Trimming Applied: 10MB
4- Native AOT Compilation: 1.13MB
5- Removing Unused Features: 923KB
6- Using bflat Compiler: 882KB
7- bflat with Zerolib: 9KB
8- Direct PInvoke: 8KB
9- Eliminating Debugging and Relocations: 7KB
10- Targeting x86 Architecture: 6.5KB
11- Final Step with Crinkler Linker: 1,936 Bytes
π Outcome: Achieved a C# game small enough to fit in a QR code!
[ Full Article π ] : https://migeel.sk/blog/2024/01/02/building-a-self-contained-game-in-csharp-under-2-kilobytes
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#CSharp #DotNet #Optimization #LowLevel
@ProgrammingTip
β’ Self-Contained: Includes all necessary components to run on any OS.
β’ Game Type: A graphical maze, utilizing Win32 APIs, avoiding WinForms.
β’ Size Reduction Steps:
1- Initial Size: 64MB (with CoreCLR)
2- Post-Compression: 35.2MB
3- IL Trimming Applied: 10MB
4- Native AOT Compilation: 1.13MB
5- Removing Unused Features: 923KB
6- Using bflat Compiler: 882KB
7- bflat with Zerolib: 9KB
8- Direct PInvoke: 8KB
9- Eliminating Debugging and Relocations: 7KB
10- Targeting x86 Architecture: 6.5KB
11- Final Step with Crinkler Linker: 1,936 Bytes
π Outcome: Achieved a C# game small enough to fit in a QR code!
[ Full Article π ] : https://migeel.sk/blog/2024/01/02/building-a-self-contained-game-in-csharp-under-2-kilobytes
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#CSharp #DotNet #Optimization #LowLevel
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
5 Rules for Writing Better and Cleaner DTOs π§Ή
Crafting clean and maintainable DTOs is essential for keeping your codebase healthy and scalable. But let's face it, sometimes DTOs can morph into these complex beasts that leave you scratching your head. β
Fear not, fellow developers!
This article (or the accompanying video!) dives into 5 key principles to help you write simpler, more understandable DTOs.
You'll learn about:
β’ Keeping things clear and concise
β’ Utilizing properties effectively β¨
β’ Crafting descriptive names that make sense
And also other tips to transform your DTOs from chaotic to crystal clear! By following these principles, you'll be well on your way to writing cleaner, more maintainable DTOs that make your code easier to understand for you and your team.
Ready to up your DTO game? Check out the full article or watch the video for examples and take your codebase to the next level!
[ Article ] : https://ardalis.com/5-rules-dtos
[ YouTube ] : https://www.youtube.com/watch?v=W4n9x_qGpT4
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#Dto #Dotnet #csharp #programming
@ProgrammingTip
Crafting clean and maintainable DTOs is essential for keeping your codebase healthy and scalable. But let's face it, sometimes DTOs can morph into these complex beasts that leave you scratching your head. β
Fear not, fellow developers!
This article (or the accompanying video!) dives into 5 key principles to help you write simpler, more understandable DTOs.
You'll learn about:
β’ Keeping things clear and concise
β’ Utilizing properties effectively β¨
β’ Crafting descriptive names that make sense
And also other tips to transform your DTOs from chaotic to crystal clear! By following these principles, you'll be well on your way to writing cleaner, more maintainable DTOs that make your code easier to understand for you and your team.
Ready to up your DTO game? Check out the full article or watch the video for examples and take your codebase to the next level!
[ Article ] : https://ardalis.com/5-rules-dtos
[ YouTube ] : https://www.youtube.com/watch?v=W4n9x_qGpT4
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#Dto #Dotnet #csharp #programming
@ProgrammingTip
https://ardalis.com
5 Rules for DTOs
These are 5 rules for writing better DTOs.
OpenAI .NET πΎ
The OpenAI .NET library provides convenient access to the OpenAI REST API from .NET applications.βοΈ
The full API of this library can be found in the api.md file, and there are many code examples to help. For instance, the following snippet illustrates the basic use of the chat completions API:
The library is organized into several namespaces corresponding to OpenAI feature areas. Each namespace contains a corresponding client class:
β’ AssistantClient
β’ AudioClient
β’ BatchClient
β’ ChatClient
β’ EmbeddingClient
β’ FineTuningClient
β’ FileClient
β’ ImageClient
β’ ModelClient
β’ ModerationClient
β’ VectorStoreClient
[ GitHub ] : https://github.com/openai/openai-dotnet
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#AI #OpenAI #DotNet #CSharp
@ProgrammingTip
The OpenAI .NET library provides convenient access to the OpenAI REST API from .NET applications.
The full API of this library can be found in the api.md file, and there are many code examples to help. For instance, the following snippet illustrates the basic use of the chat completions API:
ChatClient client = new(model: "gpt-4o", "OPENAI_API_KEY");
ChatCompletion completion = client.CompleteChat("Say 'this is a test.'");
Console.WriteLine($"[ASSISTANT]: {completion}");
The library is organized into several namespaces corresponding to OpenAI feature areas. Each namespace contains a corresponding client class:
β’ AssistantClient
β’ AudioClient
β’ BatchClient
β’ ChatClient
β’ EmbeddingClient
β’ FineTuningClient
β’ FileClient
β’ ImageClient
β’ ModelClient
β’ ModerationClient
β’ VectorStoreClient
[ GitHub ] : https://github.com/openai/openai-dotnet
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#AI #OpenAI #DotNet #CSharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
NetPad π₯
A cross-platform C# editor and playground.
NetPad is a C# playground that lets you run C# code instantly, without the hassle of creating and managing projects. Open NetPad, start coding, hit Run, and see your output immediately. It's that simple.βοΈ
β’ Prototyping and Testing: Quickly prototype and test code snippets before incorporating them into your projects.
β’ Data Visualization: Visualize data interactively for better insights and analysis.
β’ Database Queries: Query databases using LINQ or SQL effortlessly.
β’ Learn and Experiment: Experiment with new C# features or start learning C# in an intuitive and accessible environment.
β’ Utility Scripts: Create and save your own utility or administration scripts for repeated use.
[ GitHub ] : https://github.com/tareqimbasher/NetPad
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#NetPad #Linqpad #CSharp #DotNet
@ProgrammingTip
A cross-platform C# editor and playground.
NetPad is a C# playground that lets you run C# code instantly, without the hassle of creating and managing projects. Open NetPad, start coding, hit Run, and see your output immediately. It's that simple.
β’ Prototyping and Testing: Quickly prototype and test code snippets before incorporating them into your projects.
β’ Data Visualization: Visualize data interactively for better insights and analysis.
β’ Database Queries: Query databases using LINQ or SQL effortlessly.
β’ Learn and Experiment: Experiment with new C# features or start learning C# in an intuitive and accessible environment.
β’ Utility Scripts: Create and save your own utility or administration scripts for repeated use.
[ GitHub ] : https://github.com/tareqimbasher/NetPad
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#NetPad #Linqpad #CSharp #DotNet
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
I Built a .NET App Using AI (with Cursor) - This Is Amazing β
Discover how Cursor AI can transform your .NET development workflow!π
In this video, you will see how this AI-powered code editor can help you write better code faster, understand complex codebases, and automate repetitive tasks. Whether you're a seasoned developer or just getting started with .NET, Cursor's AI capabilities will change how you think about coding.
[ YouTube ] : https://youtu.be/5hyRBuW560c
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#AI #Cursor #DotNET #CSharp
@ProgrammingTip
Discover how Cursor AI can transform your .NET development workflow!
In this video, you will see how this AI-powered code editor can help you write better code faster, understand complex codebases, and automate repetitive tasks. Whether you're a seasoned developer or just getting started with .NET, Cursor's AI capabilities will change how you think about coding.
[ YouTube ] : https://youtu.be/5hyRBuW560c
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#AI #Cursor #DotNET #CSharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
Build a Model Context Protocol (MCP) Server in C# π§
Learn how to create an MCP server using .NET 8 and ASP.NET Core!β‘οΈ
This guide walks you through building a server that can interact with AI models via the Model Context Protocol β a standard for managing model prompts, memory, and tools. Great for AI agent developers!π€ π§
[ Blog ] : https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#AI #MCP #dotnet #csharp
@ProgrammingTip
Learn how to create an MCP server using .NET 8 and ASP.NET Core!
This guide walks you through building a server that can interact with AI models via the Model Context Protocol β a standard for managing model prompts, memory, and tools. Great for AI agent developers!
[ Blog ] : https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#AI #MCP #dotnet #csharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Microsoft News
Build a Model Context Protocol (MCP) server in C#
Learn how to build a Model Context Protocol (MCP) server using the C# SDK to enable seamless communication between AI models and applications.
C# 14 - Extension Members π
C# 14 adds new syntax to define extension members. The new syntax enables you to declare extension properties in addition to extension methods.βοΈ
You can also declare extension members that extend the type, rather than an instance of the type. In other words, these new extension members can appear as static members of the type you extend.
The following code example shows an example of the different kinds of extension members you can declare:
The members in the first extension block are called as though they're instance members of
[ Blog ] : https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#csharp #dotnet
@ProgrammingTip
C# 14 adds new syntax to define extension members. The new syntax enables you to declare extension properties in addition to extension methods.
You can also declare extension members that extend the type, rather than an instance of the type. In other words, these new extension members can appear as static members of the type you extend.
The following code example shows an example of the different kinds of extension members you can declare:
public static class Enumerable
{
// Extension block
extension<TSource>(IEnumerable<TSource> source) // extension members for IEnumerable<TSource>
{
// Extension property:
public bool IsEmpty => !source.Any();
// Extension indexer:
public TSource this[int index] => source.Skip(index).First();
// Extension method:
public IEnumerable<TSource> Where(Func<TSource, bool> predicate) { ... }
}
// extension block, with a receiver type only
extension<TSource>(IEnumerable<TSource>) // static extension members for IEnumerable<Source>
{
// static extension method:
public static IEnumerable<TSource> Combine(IEnumerable<TSource> first, IEnumerable<TSource> second) { ... }
// static extension property:
public static IEnumerable<TSource> Identity => yield return default;
}
}
The members in the first extension block are called as though they're instance members of
IEnumerable<TSource>, for example sequence.IsEmpty. The members in the second extension block are called as though they're static members of IEnumerable<TSource>, for example IEnumerable<int>.Identity.[ Blog ] : https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/extension-methods
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#csharp #dotnet
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources
The Hidden Cost of DateTime.Now in .NET π°
You're Using DateTime.Nowβββand It's Breaking Your Code β¦β
Let's be honest: We've all written this:
It works⦠until it doesn't.
In production, this little line can wreck your logic due to clock drift, time zone shifts, or mocking nightmares. π
[ Article ] : https://freedium.cfd/https://medium.com/@yaseer.arafat/the-hidden-cost-of-datetime-now-and-what-every-net-developer-should-use-instead-8859863257a1
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#dotnet #csharp
@ProgrammingTip
You're Using DateTime.Nowβββand It's Breaking Your Code β¦
Let's be honest: We've all written this:
if (DateTime.Now > token.Expiry)
{
return Unauthorized();
}
It works⦠until it doesn't.
In production, this little line can wreck your logic due to clock drift, time zone shifts, or mocking nightmares. π
[ Article ] : https://freedium.cfd/https://medium.com/@yaseer.arafat/the-hidden-cost-of-datetime-now-and-what-every-net-developer-should-use-instead-8859863257a1
γ°οΈγ°οΈγ°οΈγ°οΈγ°οΈγ°οΈ
#dotnet #csharp
@ProgrammingTip
Please open Telegram to view this post
VIEW IN TELEGRAM
Telegram
Programming Tips Resources