Menu
Microsoft .NET 5 adds safe warnings for C#

Microsoft .NET 5 adds safe warnings for C#

New AnalysisLevel in the C# compiler introduces warnings for common coding mistakes and other latent bugs in a safe way

Credit: Dreamstime

Microsoft’s planned .NET 5 software development platform produces safe warnings for the C# compiler and automatically finds latent bugs.

With .NET 5, a new capability called AnalysisLevel introduces warnings in a way that alerts developers that something is wrong. The default AnalysisLevel for all projects targeting .NET 5 will be set to 5, which provides new compiler language analysis. This means that more warnings and suggestions to fix them will be introduced.

Microsoft has had many instances over the years where it wanted to provide warnings that something was wrong with a C# coding project, ranging from common coding mistakes to API misuse patterns.

But the company has been reluctant to do so because of the breaking change issue. With AnalysisLevel, warnings are introduced for patterns in a safe way.

.NET 5 currently is in a preview stage, with the production version due in November. The company detailed its C# compiler warnings plan in a bulletin posted on August 27. The bulletin noted that all new .NET projects will be opted into AnalysisLevel 5. Here are some new level 5 warnings and suggestions for .NET 5:

  • CA1416, an interoperability warning to warn when code does not work across all platforms
  • CA2247, a usage warning rethrow to preserve stack details
  • CSO185, a correctness error to not allow locks on non-reference types

Previously, .NET required the installation of NuGet packages or other standalone tools to enable deeper code analysis. The .NET 5 SDK provides this automatically. Future plans call for a new AnalysisLevel for every release of .NET. This is intended to ensure that a given analysis level always represents the same set of analysis defaults — the rules and their severities.

Turning on an existing rule by default would be done in an upcoming AnalysisLevel instead of changing the existing level. This ensures that a given project produces the same warning regardless of the SDK version, unless the project uses preview or latest.


Follow Us

Join the newsletter!

Or

Sign up to gain exclusive access to email subscriptions, event invitations, competitions, giveaways, and much more.

Membership is free, and your security and privacy remain protected. View our privacy policy before signing up.

Error: Please check your email address.

Tags Microsoft

Events

Featured

Slideshows

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners

This year’s Reseller News 30 Under 30 Tech Awards were held as an integral part of the first entirely virtual Emerging Leaders​ forum, an annual event dedicated to identifying, educating and showcasing the New Zealand technology market’s rising stars. The 30 Under 30 Tech Awards 2020 recognised the outstanding achievements and business excellence of 30 talented individuals​, across both young leaders and those just starting out. In this slideshow, Reseller News honours this year's winners and captures their thoughts about how their ideas of leadership have changed over time.​

Meet the Reseller News 30 Under 30 Tech Awards 2020 winners
Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security

Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security

This exclusive Reseller News Exchange event in Auckland explored the challenges facing the partner community on the cloud security frontier, as well as market trends, customer priorities and how the channel can capitalise on the opportunities available. In association with Arrow, Bitdefender, Exclusive Networks, Fortinet and Palo Alto Networks. Photos by Gino Demeer.

Reseller News Exchange Auckland: Beyond the myths — how partners can master cloud security
Reseller News welcomes industry figures at 2020 Hall of Fame lunch

Reseller News welcomes industry figures at 2020 Hall of Fame lunch

Reseller News welcomed 2019 inductees - Leanne Buer, Ross Jenkins and Terry Dunn - to the fourth running of the Reseller News Hall of Fame lunch, held at the French Cafe in Auckland. The inductees discussed the changing face of the IT channel ecosystem in New Zealand and what it means to be a Reseller News Hall of Fame inductee. Photos by Gino Demeer.

Reseller News welcomes industry figures at 2020 Hall of Fame lunch
Show Comments