diff --git a/2/index.html b/2/index.html index 9227c2a..7c4059e 100644 --- a/2/index.html +++ b/2/index.html @@ -1,6 +1,6 @@ Daily DevOps & .NET — Daily DevOps & .NET
How to Prepare for Microsoft Certification

How to Prepare for Microsoft Certification

How do I best prepare for a Microsoft certification? - this or a similar question is asked by everyone who wants to deal with the topics Microsoft, Azure, Microsoft 365, Power Platform or Dynamics 365. In this article, I would like to go into the possibilities that Microsoft offers us for preparation.

When Can I Finally Renew My Microsoft Certification

When Can I Finally Renew My Microsoft Certification

When can I finally renew my Microsoft certification? - I’m certainly not alone with this or similar questions and the associated uncertainty. Okay, a certain impatience certainly resonates as well. After all, I would also like to schedule it into my daily routine. But how?

How to Prepare for Microsoft Certification

How to Prepare for Microsoft Certification

How do I best prepare for a Microsoft certification? - this or a similar question is asked by everyone who wants to deal with the topics Microsoft, Azure, Microsoft 365, Power Platform or Dynamics 365. In this article, I would like to go into the possibilities that Microsoft offers us for preparation.

Martin Stühmer

Hello there, I’m Martin, software architect and developer from the Cologne/Bonn area. Right from the start of my professional career, I decided in favor of .NET and Microsoft technologies and tools and have always incorporated them into my work. With more than 15 years of experience in the field of software architecture and development with .NET, my focus is particularly on increasing the quality and performance of development teams, the interaction of the software solution with the target environment and the actual application down to the last byte.

In my position as Director Consulting Services @ CGI , I act as enterprise architect and developer for cloud native and .NET solutions. I am also a trainer for cloud and software architecture. In addition to my professional life, I am involved in the open source communities and currently provide them with various NuGet packages with different focuses and functionalities.

A strong willingness to learn and develop is also part of my everyday life. This was taken to a new level for me in 2021 after I successfully completed my IHK trainer and my Microsoft certified trainer this year. In addition, I was able to qualify as a trainer for CGI’s Risk and Cost Driven Architecture -program in 2022.

Published blogs

How to Prepare for Microsoft Certification

How to Prepare for Microsoft Certification

How do I best prepare for a Microsoft certification? - this or a similar question is asked by everyone who wants to deal with the topics Microsoft, Azure, Microsoft 365, Power Platform or Dynamics 365. In this article, I would like to go into the possibilities that Microsoft offers us for preparation.

Martin Stühmer

Hello there, I’m Martin, software architect and developer from the Cologne/Bonn area. Right from the start of my professional career, I decided in favor of .NET and Microsoft technologies and tools and have always incorporated them into my work. With more than 15 years of experience in the field of software architecture and development with .NET, my focus is particularly on increasing the quality and performance of development teams, the interaction of the software solution with the target environment and the actual application down to the last byte.

In my position as Director Consulting Services @ CGI , I act as enterprise architect and developer for cloud native and .NET solutions. I am also a trainer for cloud and software architecture. In addition to my professional life, I am involved in the open source communities and currently provide them with various NuGet packages with different focuses and functionalities.

A strong willingness to learn and develop is also part of my everyday life. This was taken to a new level for me in 2021 after I successfully completed my IHK trainer and my Microsoft certified trainer this year. In addition, I was able to qualify as a trainer for CGI’s Risk and Cost Driven Architecture -program in 2022.

Published blogs

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

In the ever-evolving world of .NET development, managing project configurations effectively is crucial for maintaining a clean and efficient build process. One of the less frequently discussed but highly useful properties is BuildingInsideVisualStudio. This property, when correctly utilized, can streamline your build process and ensure that your project is configured properly depending on the build environment. In this article, we’ll explore the BuildingInsideVisualStudio property with concrete examples and discuss best practices for using it effectively.

Manage Nuget Packages Centrally

Manage Nuget Packages Centrally

For over 12 years, NuGet package management has been part of the .NET ecosystem with direct integrations to various IDEs, CLIs and build systems. But a feature took 12 years before it appeared and certainly needs some more maintenance until it is mature!

Illuminate Technical Debt

Illuminate Technical Debt

Whatever our role, be it developer, IT professional or architect, we try to avoid technical debt. If this is not possible from the outset, or if we decide to accept this technical debt for a limited period of time, we usually lack the tools to do so. This is where this article may help.

When Can I Finally Renew My Microsoft Certification

When Can I Finally Renew My Microsoft Certification

When can I finally renew my Microsoft certification? - I’m certainly not alone with this or similar questions and the associated uncertainty. Okay, a certain impatience certainly resonates as well. After all, I would also like to schedule it into my daily routine. But how?

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

Mastering .NET Project Properties: The BuildingInsideVisualStudio Flag

In the ever-evolving world of .NET development, managing project configurations effectively is crucial for maintaining a clean and efficient build process. One of the less frequently discussed but highly useful properties is BuildingInsideVisualStudio. This property, when correctly utilized, can streamline your build process and ensure that your project is configured properly depending on the build environment. In this article, we’ll explore the BuildingInsideVisualStudio property with concrete examples and discuss best practices for using it effectively.

Reimagining the Microsoft Certification Exam UI Experience

Reimagining the Microsoft Certification Exam UI Experience

Embark on a journey through Microsoft’s redesigned certification exam UI. Discover streamlined navigation, enhanced accessibility, and personalized experiences, revolutionizing the exam-taking experience.
Manage Nuget Packages Centrally

Manage Nuget Packages Centrally

For over 12 years, NuGet package management has been part of the .NET ecosystem with direct integrations to various IDEs, CLIs and build systems. But a feature took 12 years before it appeared and certainly needs some more maintenance until it is mature!

Illuminate Technical Debt

Illuminate Technical Debt

Whatever our role, be it developer, IT professional or architect, we try to avoid technical debt. If this is not possible from the outset, or if we decide to accept this technical debt for a limited period of time, we usually lack the tools to do so. This is where this article may help.

When Can I Finally Renew My Microsoft Certification

When Can I Finally Renew My Microsoft Certification

When can I finally renew my Microsoft certification? - I’m certainly not alone with this or similar questions and the associated uncertainty. Okay, a certain impatience certainly resonates as well. After all, I would also like to schedule it into my daily routine. But how?

Gradually Introducing Nullability in Legacy Code: A Practical Guide for .NET and C#

Gradually Introducing Nullability in Legacy Code: A Practical Guide for .NET and C#

As developers, we’re often tasked with maintaining and modernizing legacy codebases that were written long before some of the best practices of today—such as nullability annotations—were available. While modern C# now supports nullable reference types, enabling us to avoid the dreaded NullReferenceException, introducing this feature to existing, large codebases can be a challenge.

In this article, I’ll share my step-by-step approach for introducing nullability into a legacy .NET and C# project. You’ll learn how to apply nullability in a controlled, incremental manner using project-level settings, scoped annotations, and file/method-level directives, all while maintaining the integrity of your legacy codebase. After all, modernizing your code doesn’t have to be an all-or-nothing endeavor—gradual change is key to a successful transition. Let’s get started!

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

Mastering .NET Project Properties: The BuildingInsideVisualStudio Flag

In the ever-evolving world of .NET development, managing project configurations effectively is crucial for maintaining a clean and efficient build process. One of the less frequently discussed but highly useful properties is BuildingInsideVisualStudio. This property, when correctly utilized, can streamline your build process and ensure that your project is configured properly depending on the build environment. In this article, we’ll explore the BuildingInsideVisualStudio property with concrete examples and discuss best practices for using it effectively.

Manage Nuget Packages Centrally

Manage Nuget Packages Centrally

For over 12 years, NuGet package management has been part of the .NET ecosystem with direct integrations to various IDEs, CLIs and build systems. But a feature took 12 years before it appeared and certainly needs some more maintenance until it is mature!

Illuminate Technical Debt

Illuminate Technical Debt

Whatever our role, be it developer, IT professional or architect, we try to avoid technical debt. If this is not possible from the outset, or if we decide to accept this technical debt for a limited period of time, we usually lack the tools to do so. This is where this article may help.

Article overview

How to Prepare for Microsoft Certification

How to Prepare for Microsoft Certification

How do I best prepare for a Microsoft certification? - this or a similar question is asked by everyone who wants to deal with the topics Microsoft, Azure, Microsoft 365, Power Platform or Dynamics 365. In this article, I would like to go into the possibilities that Microsoft offers us for preparation.

Article overview

When Can I Finally Renew My Microsoft Certification

When Can I Finally Renew My Microsoft Certification

When can I finally renew my Microsoft certification? - I’m certainly not alone with this or similar questions and the associated uncertainty. Okay, a certain impatience certainly resonates as well. After all, I would also like to schedule it into my daily routine. But how?

How to Prepare for Microsoft Certification

How to Prepare for Microsoft Certification

How do I best prepare for a Microsoft certification? - this or a similar question is asked by everyone who wants to deal with the topics Microsoft, Azure, Microsoft 365, Power Platform or Dynamics 365. In this article, I would like to go into the possibilities that Microsoft offers us for preparation.

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

Mastering .NET Project Properties: The BuildingInsideVisualStudio Flag

In the ever-evolving world of .NET development, managing project configurations effectively is crucial for maintaining a clean and efficient build process. One of the less frequently discussed but highly useful properties is BuildingInsideVisualStudio. This property, when correctly utilized, can streamline your build process and ensure that your project is configured properly depending on the build environment. In this article, we’ll explore the BuildingInsideVisualStudio property with concrete examples and discuss best practices for using it effectively.

Understanding the BuildingInsideVisualStudio Property

The BuildingInsideVisualStudio property is a conditional flag that can be used within your project files (.csproj) to apply certain settings or include/exclude packages and references based on whether the project is being built inside Visual Studio. This property is particularly useful when you need to differentiate between builds triggered from Visual Studio and those triggered from other environments such as command-line builds or CI/CD pipelines.

Example: Adding a Package Reference Conditionally

Let’s start with a practical example: adding a package reference only when the project is being built inside Visual Studio. This can be useful when you want to include certain tools or analyzers only in the development environment to keep the build lean for production.

Assuming you want to add a reference to SonarAnalyzer.CSharp, a popular static code analysis tool, but only when building the project within Visual Studio, you can use the BuildingInsideVisualStudio property to conditionally include this package reference in your .csproj file. Why would you want to do this? It’s already included in your CI/CD pipeline, so you don’t need it in your local development environment? The answer is simple: you want to have the same code analysis rules and hints in your local development environment as in your CI/CD pipeline. This way, you can fix issues early and avoid surprises when pushing your code to the repository, and executing maybe long-running CI/CD pipelines.

Here’s how you can do it:

<Project Sdk="Microsoft.NET.Sdk">
 
   <ItemGroup Condition="'$(BuildingInsideVisualStudio)' == 'true'">
@@ -39,7 +39,7 @@
 

Tags

VG Wort +How MSBuild builds projects - Visual Studio builds vs. MSBuild.exe builds
VG Wort

Article overview

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

Mastering .NET Project Properties: The BuildingInsideVisualStudio Flag

In the ever-evolving world of .NET development, managing project configurations effectively is crucial for maintaining a clean and efficient build process. One of the less frequently discussed but highly useful properties is BuildingInsideVisualStudio. This property, when correctly utilized, can streamline your build process and ensure that your project is configured properly depending on the build environment. In this article, we’ll explore the BuildingInsideVisualStudio property with concrete examples and discuss best practices for using it effectively.

Manage Nuget Packages Centrally

Manage Nuget Packages Centrally

For over 12 years, NuGet package management has been part of the .NET ecosystem with direct integrations to various IDEs, CLIs and build systems. But a feature took 12 years before it appeared and certainly needs some more maintenance until it is mature!

Illuminate Technical Debt

Illuminate Technical Debt

Whatever our role, be it developer, IT professional or architect, we try to avoid technical debt. If this is not possible from the outset, or if we decide to accept this technical debt for a limited period of time, we usually lack the tools to do so. This is where this article may help.

When Can I Finally Renew My Microsoft Certification

When Can I Finally Renew My Microsoft Certification

When can I finally renew my Microsoft certification? - I’m certainly not alone with this or similar questions and the associated uncertainty. Okay, a certain impatience certainly resonates as well. After all, I would also like to schedule it into my daily routine. But how?

Article overview

Gradually Introducing Nullability in Legacy Code: A Practical Guide for .NET and C#

Gradually Introducing Nullability in Legacy Code: A Practical Guide for .NET and C#

As developers, we’re often tasked with maintaining and modernizing legacy codebases that were written long before some of the best practices of today—such as nullability annotations—were available. While modern C# now supports nullable reference types, enabling us to avoid the dreaded NullReferenceException, introducing this feature to existing, large codebases can be a challenge.

In this article, I’ll share my step-by-step approach for introducing nullability into a legacy .NET and C# project. You’ll learn how to apply nullability in a controlled, incremental manner using project-level settings, scoped annotations, and file/method-level directives, all while maintaining the integrity of your legacy codebase. After all, modernizing your code doesn’t have to be an all-or-nothing endeavor—gradual change is key to a successful transition. Let’s get started!

Mastering .NET Project Properties: The `BuildingInsideVisualStudio` Flag

Mastering .NET Project Properties: The BuildingInsideVisualStudio Flag

In the ever-evolving world of .NET development, managing project configurations effectively is crucial for maintaining a clean and efficient build process. One of the less frequently discussed but highly useful properties is BuildingInsideVisualStudio. This property, when correctly utilized, can streamline your build process and ensure that your project is configured properly depending on the build environment. In this article, we’ll explore the BuildingInsideVisualStudio property with concrete examples and discuss best practices for using it effectively.

Manage Nuget Packages Centrally

Manage Nuget Packages Centrally

For over 12 years, NuGet package management has been part of the .NET ecosystem with direct integrations to various IDEs, CLIs and build systems. But a feature took 12 years before it appeared and certainly needs some more maintenance until it is mature!

Illuminate Technical Debt

Illuminate Technical Debt

Whatever our role, be it developer, IT professional or architect, we try to avoid technical debt. If this is not possible from the outset, or if we decide to accept this technical debt for a limited period of time, we usually lack the tools to do so. This is where this article may help.

Gradually Introducing Nullability in Legacy Code: A Practical Guide for .NET and C#

Gradually Introducing Nullability in Legacy Code: A Practical Guide for .NET and C#

As developers, we’re often tasked with maintaining and modernizing legacy codebases that were written long before some of the best practices of today—such as nullability annotations—were available. While modern C# now supports nullable reference types, enabling us to avoid the dreaded NullReferenceException, introducing this feature to existing, large codebases can be a challenge.

In this article, I’ll share my step-by-step approach for introducing nullability into a legacy .NET and C# project. You’ll learn how to apply nullability in a controlled, incremental manner using project-level settings, scoped annotations, and file/method-level directives, all while maintaining the integrity of your legacy codebase. After all, modernizing your code doesn’t have to be an all-or-nothing endeavor—gradual change is key to a successful transition. Let’s get started!

Why Gradually Introduce Nullability?

Nullability annotations in C# allow us to specify whether a reference type can be null or not. This feature brings more type safety and reliability to your code, reducing the chance of runtime errors caused by null values. But here’s the challenge: introducing nullability into an existing, possibly large codebase and no clear code style, where methods and properties might be riddled with potential nulls, can result in an overwhelming number of compiler warnings. In such cases, it’s easy to give up on nullability altogether, leaving your codebase vulnerable to null reference exceptions. But it doesn’t have to be that way.

To address this, you can take an incremental approach. Rather than trying to make your entire codebase null-safe in one go, you can introduce nullability step by step—starting with new code and gradually refactoring old code. This method minimizes disruption and lets your team handle the transition without being flooded with warnings.

Step 1: Understanding Nullability Annotations in C#

In modern C#, a string is assumed not nullable by default, meaning it cannot contain a null value without a compiler warning. However, you can explicitly declare a string as nullable by using the string? syntax. Here’s an example:

string nonNullableString = "Hello";   // Can't be null, compiler will warn
+string? nullableString = null;        // Can be null, no compiler warning
+

The nullable string? type indicates that the variable may contain a null value, while the non-nullable string enforces that null values are not allowed.

The beauty of nullable reference types is that they make your intent clear, and C#’s compiler will help enforce this through warnings whenever there’s a potential for null dereferencing. And there is a huge list of possible nullable warnings, see Nullable reference types warnings +.

Step 2: Enabling Nullability at the Project Level

The most straightforward way to introduce nullability across your entire project is by enabling it globally in your project’s .csproj file or your Directory.Build.props file. You can do this by adding the following property inside your <PropertyGroup> section:

<PropertyGroup>
+    <Nullable>enable</Nullable>
+</PropertyGroup>
+

This setting will enable nullable reference types for every file in the project, enforcing null-safety checks everywhere. However, this can result in a lot of warnings right away—especially in a large legacy codebase. If you’re not ready to tackle all these warnings at once, you might want to consider a more cautious approach.

A Safer Option: <Nullable>annotations</Nullable>

Instead of enabling nullability across the board from the start, you can take a more cautious approach by using the following property in your .csproj file:

<PropertyGroup>
+    <Nullable>annotations</Nullable>
+</PropertyGroup>
+

This option only enables annotations (i.e., you can specify nullable or non-nullable reference types), but it won’t trigger warnings for potential null reference issues in your code. This way, you can begin adding annotations like string? and int? to clarify nullability without worrying about fixing warnings immediately. This is particularly useful for large legacy projects where refactoring everything at once isn’t practical.

Once you feel confident with the annotations you’ve added, you can switch the property to <Nullable>enable</Nullable> and start addressing the warnings generated by the compiler for potential nullability issues. But until then, you can work on adding nullability annotations at your own pace.

Step 3: Using #nullable Directives for Scoped Control

In addition to enabling nullability project-wide, you may also want to control nullability at more granular levels. C# provides the #nullable directive, which allows you to enable or disable nullability checks at the file or method level. This gives you more control over where nullability is enforced, allowing you to gradually introduce null-safety to your codebase.

File-Level Nullability Control

If you want to enable nullability for just a specific file, you can use the #nullable enable directive at the top of the file. This should be the first line in the file, before any namespaces or other code. Here’s an example:

#nullable enable
+
+public class CustomerService
+{
+    public string? GetCustomerName(int id)
+    {
+        // Null-safety checks enabled
+        return null; // This is allowed because 'string?' is nullable
+    }
+
+    public void AddCustomer(Customer customer)
+    {
+        // Additional code
+    }
+}
+

In this case, all code within the file will now adhere to nullability rules. This is useful if you’re working on a new file or refactoring an older one.

Method-Level Nullability Control

If you only want to enable nullability for a specific method rather than an entine file, you can do so using #nullable around the method itself. This can help you focus on null-safety checks for specific methods without affecting the rest of the file. This is particularly helpful when you’re working on large files and want to incrementally refactor certain methods:

public class CustomerService
+{
+    #nullable enable
+    public string? GetCustomerName(int id)
+    {
+        // Null-safety checks enabled just for this method
+    }
+    #nullable restore
+
+    public void LegacyMethod(Customer customer)
+    {
+        // Null-safety checks are restored to project setting
+    }
+}
+

This way, you can enable null-safety in smaller, manageable chunks and refactor legacy methods over time. The #nullable restore directive resets the nullability setting to the project level, ensuring that the rest of the file adheres to the global nullability setting.

Step 4: Transitioning to Full Nullability

Once you’ve added nullability annotations throughout your code and feel confident in the accuracy of those annotations, you can switch the project setting from <Nullable>annotations</Nullable> to <Nullable>enable</Nullable>. This change will turn on full null-safety, meaning the compiler will now generate warnings for potential null reference issues.

At this point, your task will be to resolve any warnings by checking for null values, using the null-coalescing operator (??), or adjusting method signatures to ensure null-safety. Gradually fixing these warnings will make your code more robust and reduce the risk of runtime null reference exceptions.

Conclusion

Introducing nullability into a legacy codebase doesn’t have to be a daunting task. By taking an incremental approach—starting with project-level settings like <Nullable>annotations</Nullable>, using #nullable directives for scoped control, and focusing on new or refactored code—you can modernize your codebase while avoiding the flood of warnings that comes with a full-on switch to nullability.

Remember, the goal is to improve the long-term reliability of your code, and with nullability annotations, you’re well on your way to a safer, more maintainable C# project. Take it step by step, and soon, your legacy codebase will be a thing of the past. Modern, null-safe code awaits!

Comments

VG Wort + \ No newline at end of file diff --git a/posts/reimagining-the-microsoft-certification-exam-ui/index.html b/posts/reimagining-the-microsoft-certification-exam-ui/index.html index da908e5..ff18a47 100644 --- a/posts/reimagining-the-microsoft-certification-exam-ui/index.html +++ b/posts/reimagining-the-microsoft-certification-exam-ui/index.html @@ -20,7 +20,7 @@   aka.ms/ExamDemo   -aka.ms/TrainCertPoster
VG Wort +aka.ms/TrainCertPoster
VG Wort