MoiraeSoftware / myriad

Myriad is a code generator for F#
https://moiraesoftware.github.io/myriad/
Apache License 2.0
344 stars 43 forks source link

warning in fields generator #176

Open joprice opened 3 months ago

joprice commented 3 months ago

When running with optional warnings enabled such as <WarnOn>FS3560;..., the following warning shows up in the code generated by the fields generator:

This copy-and-update record expression changes all fields of record type 'Example.Test1'. Consider using the record construction syntax instead. [3560]

When combined with <TreatWarningsAsErrors>true</TreatWarningsAsErrors>, it causes the build to fail, requiring setting <WarningsNotAsErrors>FS3560</WarningsNotAsErrors> or to disable the warning altogether.

Since all fields are updated, is there any reason to use the with syntax, and just provide all fields instead?

If that's tricky for whatever reason, could a nowarn be added to the generated file to silence the warning?

I'm not sure how valuable this warning is, and might disable it altogether, but perhaps other generators would have the same issue, and providing a parameter to disable warnings would make sense as well.

7sharp9 commented 3 months ago

Happy to accept a PR if you want to change the AST or add the nowarn. Not sure which is easier. The idea is the generated code doesnt matter how you style it so formating etc doesnt really matter.