Categories
.NET .NET 10 C# CLI Code Desktop Developer File Apps Mobile Tips Visual Studio VS Code VS2022 VS2026 Windows

Run C# Source Files Directly in .NET 10

The file app is a new feature in .NET 10 that lets you run a C# source file directly without requiring a project file, like dotnet App.cs. While the build system is tightly integrated with the project file, it operates virtually within the file-based app execution.

Project components like SDK, properties, references, and packages are now defined directly within the C# source file. This is done with the help of C# Ignored Directives. This ensures seamless integration with the virtual project file.

Categories
.NET .NET 10 ASP.NET Core Aspire Automation Azure Blazor C# CLI Code Desktop Developer Getting Started Linux macOS Mobile Visual Studio VS Code Web What's New Windows

Using C# Ignored Directives: A Guide for Programmers

C# – Preprocessor Directives are highly useful for writing code that can be compiled conditionally, depending on factors like the target framework, target platform, or build configuration.

For example:

#if NET9_0_OR_GREATER
// The code within this block will execute only on .NET 9 or higher
#endif

#if ANDROID
// The code within this block will execute only on the Android OS
#endif

#if DEBUG
// The code within this block will execute only in Debug mode
#endif

C# – Ignored Directives have a similar syntax but are ignored by the compiler because they are for tooling.

The real purpose of this feature is to execute a C# source file directly from the CLI. It doesn’t need a project file. Now, even the plain console app requires a project file, despite the much-simplified top-level statements feature.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Desktop Developer Getting Started Hybrid iOS macOS Mobile MVVM Windows Xamarin Xamarin.Forms XAML

XAML Basics: Building UI with .NET MAUI and More – Part 2

This article represents the second installment of the XAML for Beginners series, which elucidates the concept of declarative markup in the context of defining UI in .NET applications. All articles within this series are accessible from here.

The initial article focused mainly on introducing XAML and its building blocks.

In this article, the focus will be on the following:

  • Attached Properties
  • Generics
  • Passing Arguments
Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Desktop Developer General Hybrid iOS macOS Mobile Shell Tips Visual Studio VS Code Web Windows Xamarin Xamarin.Forms

.NET MAUI: Managing Query Parameters with Shell Navigation

This is an article in the Developer Tips series, which offers concise hints to enhance productivity. You can access all the articles in this series here.

The Shell feature in .NET MAUI is extensive, offering numerous capabilities. This article will focus on managing query parameters within shell navigation in .NET MAUI.

Incorporating query parameters during navigation is paramount in real-world apps, as they enable the transfer of data in scenarios such as transitioning from a list page to a details page, thereby preserving the contextual relevance.

The GoToAsync() method serves as the comprehensive solution for all your navigation needs in Shell and is overloaded to cater various requirements.

Categories
.NET .NET 8 .NET 9 .NET MAUI Android Blazor C# Code Desktop Developer General Hybrid iOS macOS Mobile Web What's New Windows Xamarin Xamarin.Forms

Transitioning from Application’s MainPage to Window’s Page in .NET MAUI 9

This article analyzes a significant change introduced in .NET MAUI 9, specifically the deprecation of the Application’s MainPage property, which has been replaced by the Window’s Page property.

An article has already been published detailing the comprehensive features of .NET MAUI 9.

The MainPage has existed since the inception of Xamarin.Forms, at which time it functioned as a single-window UI framework.

Nevertheless, the design of .NET MAUI incorporates the concept of a Window to effectively support Desktop form factors, including WinUI and Mac Catalyst.