question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building FluentValidation fails with CS0618 on CascadeMode.StopOnFirstFailure

See original GitHub issue

FluentValidation version

source

ASP.NET version

No response

Summary

When I attempt to build from source using either the build.cmd or using Visual Studio I am getting: Severity Code Description Project File Line Suppression State Error CS0618 'CascadeMode.StopOnFirstFailure' is obsolete: 'The behaviour of StopOnFirstFailure has been replaced by use of the separate validator-level properties ClassLevelCascadeMode and RuleLevelCascadeMode, and their global default equivalents. StopOnFirstFailure will be removed in a later release. For more details, see https://docs.fluentvalidation.net/en/latest/cascade.html .' FluentValidation (net5.0), FluentValidation (net6.0), FluentValidation (net7.0), FluentValidation (netstandard2.0), FluentValidation (netstandard2.1) C:\Users\kenne\source\repos\FluentValidation\src\FluentValidation\Enums.cs 39 Active

From examining the csproj file it doesn’t look like there is a property group explicitly setting TreatWarningsAsErrors or WarningsAsErrors but it appears to be defaulting to enabled in VS2022 (17.6.4) none the less. Not sure if it has always been this way, its a problem with just my machine or if there was a recent change to msbuild (I’m using 17.6.3+07e294721). In any case, I cannot build from source without either modifying the source or overriding the build properties.

This is my first attempt at building FluentValidation from source so it could just be some step I’m overlooking.

Steps to Reproduce

  1. Update Visual Studio 2022 to 17.6.4
  2. Do a fresh clone FluentValidation
  3. Attempt to run Build.cmd
  4. Attempt to build from Visual Studio

Issue Analytics

  • State:closed
  • Created 3 months ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
JeremySkinnercommented, Jun 29, 2023

@Sivatronics That isn’t the correct solution. TreatWarningsAsErrors must remain enabled and suppressions should be placed in code where needed using #pragma, not disabled globally.

1reaction
JeremySkinnercommented, Jun 26, 2023

Hi,

TreatWarningsAsErrors is enabled in src\Directory.build.props (not directly in the csproj files), to ensure it applies to all projects in the solution.

That being said, I can’t reproduce this problem - all the places that use the deprecated enum should be wrapped in warning suppressions to prevent this. Running a dotnet build from the command line or from Rider doesn’t trigger an error. I can’t test with Visual Studio as I don’t use windows.

Please check the following:

  • Confirm you’re on the latest commit of the main branch, and don’t have a different branch checked out.
  • Run a dotnet build from the command line. Does the problem still occur?
  • Can you confirm which line is triggering the error (ie which line is using the deprecated enum?) Anywhere that uses it should be wrapped in warning suppressions
Read more comments on GitHub >

github_iconTop Results From Across the Web

Setting the Cascade mode
In FluentValidation 9.0 and older, the CascadeMode.StopOnFirstFailure option was used to provide control over the default cascade mode at rule-level, but its ...
Read more >
CascadeMode.StopOnFirstFailure doesn't stop at first failure
Net Core 3.1 Describe the issue that you're having Either I misunderstand the intended behavior of CascadeMode, or there ...
Read more >
FluentValidation
A small validation library for .NET that uses a fluent interface and lambda expressions for building validation rules. Become a Bounty Hunter
Read more >
Using CascadeMode.StopOnFirstFailure on a validator level
From the FluentValidation documentation I learned that I can abort validation by setting the cascade mode. RuleFor(x => x.Surname) .Cascade( ...
Read more >
Using Fluent Validation in ASP.NET Core
Configuring FluentValidation​​ We will have to add Fluent Validation to our application. Navigate to Startup.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found