Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile errors in an F# project when setting NBGV_EmitThisAssemblyClass to false #1022

Closed
Numpsy opened this issue Jan 16, 2024 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@Numpsy
Copy link
Contributor

Numpsy commented Jan 16, 2024

Hi,
I've been using GitVersioning in some F# projects, and it's all been working.

However, I tried setting the NBGV_EmitThisAssemblyClass property to false, and then started getting a build error from the generated Version.fs file:

error FS0010: Incomplete structured construct at or before this point in definition

Looking at the code, the version file with the default options is

namespace xxx
[<assembly: System.Reflection.AssemblyVersionAttribute("0.7.0.0")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute("0.7.59.18254")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.7.59-prerelease+474e680183")>]
do()
#if NETSTANDARD || NETFRAMEWORK || NETCOREAPP
[<System.CodeDom.Compiler.GeneratedCode("Nerdbank.GitVersioning.Tasks","3.6.133.12845")>]
#endif
#if NET40_OR_GREATER || NETCOREAPP2_0_OR_GREATER || NETSTANDARD2_0_OR_GREATER
[<System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage>]
#endif
type internal ThisAssembly() =
   ...

But with NBGV_EmitThisAssemblyClass = false it's

namespace xxx
[<assembly: System.Reflection.AssemblyVersionAttribute("0.7.0.0")>]
[<assembly: System.Reflection.AssemblyFileVersionAttribute("0.7.59.18254")>]
[<assembly: System.Reflection.AssemblyInformationalVersionAttribute("0.7.59-prerelease+474e680183")>]

without the trailing do(), which seems to be the problem.

Just from a quick look at the GitVersioning code, it looks like the do() gets added by the StartThisAssemblyClass at https://github.com/dotnet/Nerdbank.GitVersioning/blob/2b5ba90c74dc5d3e9300e8079d6ed511536000a9/src/Nerdbank.GitVersioning.Tasks/AssemblyVersionInfo.cs#L741C21-L741C21 and then that isn't called when ThisAssembly is diabled?

This is with version 3.6.133, though the 3.7.48-alpha seems the same.

@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 16, 2024

Would it be reasonable to have an EndAssemblyAttributes function or similar in the code generator to add the trailing do() ?

@AArnott
Copy link
Collaborator

AArnott commented Jan 16, 2024

Sure, that sounds good. I don't use F# myself. Could you send a PR to fix this?

@AArnott
Copy link
Collaborator

AArnott commented Jan 16, 2024

You may want to target the v3.6 branch instead of main so that we can get it out faster.

@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 16, 2024

I'll try to have a look at it later

@Numpsy
Copy link
Contributor Author

Numpsy commented Jan 17, 2024

You may want to target the v3.6 branch instead of main so that we can get it out faster.

Do you want a PR against main as well, or will it get merged later?

@AArnott
Copy link
Collaborator

AArnott commented Jan 17, 2024

It will get merged later.

@AArnott AArnott closed this as completed Jan 17, 2024
@AArnott AArnott added this to the v3.6 milestone Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants