Fable: Use the WarningsAsErrors-Property of MSBuild

Created on 6 May 2018  路  9Comments  路  Source: fable-compiler/Fable

Description

The WarningsAsErrors-Property is currently ignored by Fable. @nojaf asked about that on Gitter yesterday. He wanted to make the compilation fail on incomplete pattern matches.

Repro code

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <!--
    Warning FS0025: Incomplete pattern matches on this expression.
    -->
    <WarningsAsErrors>FS0025</WarningsAsErrors>
  </PropertyGroup>
</Project>

Expected and actual results

Fable should fail on a project with this setting, just as dotnet build does. But we currently generate a warning instead of an error.

Related information

  • Fable version (dotnet fable --version): 1.3.16

Most helpful comment

See #1402.

All 9 comments

Thanks for the detailed report @inosik. It shouldn't be difficult to do this. I'd prefer to do it in dev2.0 branch because it has already diverged a lot with master and probably I will have to merge the changes manually checking the commits one by one.

Maybe you or someone else could send a PR? That'd be really helpful! I think the necessary steps are:

1 - Read WarningsAsErrors from MSBuild properties and add it as an option to FableCompiler object.
2 - When adding a warning and the tag is FSHARP (not FABLE), replace it with an error if the option is set.

I'd prefer to do it in dev2.0 branch

Sure.

Maybe you or someone else could send a PR?

I can look into that 馃憤

  1. We should already get all the properties from Dotnet.ProjInfo, but most of them seem to get lost somewhere. I'll look closer at the Project Cracker.

  2. We don't have to do anything special. If we pass the --warnaserror:FS0025 option to the FCS, it will turn the warning to an error and Fable will report it correctly. I already tried that yesterday real quick by simply appending the option to the OtherOptions array here:

    https://github.com/fable-compiler/Fable/blob/69dc66a1c62e4a02b7a85a2d933f0ddb5ed45f7f/src/dotnet/dotnet-fable/StateUtil.fs#L101

That'd be great @inosik, thank you!

It's strange that Dotnet.ProjInfo is swallowing properties, maybe @enricosada knows the reason?

The ProjectCracker.fullCrack function filters most of the options.

Ah, yeah. That's why I linked in my first comment the line where you can get the properties (the currently unused _msbuildProps variable) :)

See #1402.

We should finally add some docs about this and close this issue 馃槃

You're right! Would it be OK for you to send a quick PR? I guess an entry in the FAQ should work for now.

See #1591.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rommsen picture rommsen  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

MangelMaxime picture MangelMaxime  路  3Comments

jwosty picture jwosty  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments