RichardSoeteman.NET

Quick tip Treating Warnings as Errors

Published 22 November 2023

Currently I am upgrading CMSImport to Umbraco V13. I could have been done by now if I didn't broke my old rule to treat Warnings as Errors.

The problem

Umbraco releases a major release every 6 months. And in a major release it is allowed to have breaking changes. Nice thing about Umbraco is that it will not simply remove the old code but marks the old code as obsolete first. In a next release they will remove the code and your code that uses the obsolete items will break. Until then it will generate a warning and because I ignored them last time it's quite a list now

 

Help your future self

By adding <TreatWarningsAsErrors>True</TreatWarningsAsErrors> to your .CSProj file your solution will log errors instead of warnings and you need to fix those warnings before you can continue. Doing this in an early stage will probably give you a small list of things to fix instead of the 60+ I now have to fix.

<PropertyGroup>
  <AssemblyName>CMSImport.Core</AssemblyName>
  <RootNamespace>CMSImport.Core</RootNamespace>
  <TargetFramework>net8.0</TargetFramework>
  <version>0.0.7-developermode</version>
  <Authors>Soeteman Software</Authors>
  <Description></Description>
  <Copyright>Soeteman Software</Copyright>
  <Configurations>Debug;Release</Configurations>
  <TreatWarningsAsErrors>True</TreatWarningsAsErrors>
</PropertyGroup>