Skip to content

Problem: Unlike C#, the F# compiler allows multiple entries of assembly attributes #3548

Open
@BentTranberg

Description

@BentTranberg

The C# compiler will not allow multiple entries of an assembly attribute within a project. If a duplicate exists, then CS0579 is emitted.

error CS0579: Duplicate 'AssemblyVersion' attribute

Unfortunately the F# compiler will allow multiple entries. This is a nuisance.

Why is this a problem?

I want to stamp every exe and dll in my solution with a version number and some other information, such as company name, title, description, trademark, copyright, etc.

Some of the information is individual for each project. I want that information to stay in AssemblyInfo.cs and AssemblyInfo.fs, which are the files initially generated when you create a project in VS. I edit this information manually in VS if needed.

Some of the information is shared among all projects of the solution. This is things like the version number, copyright information, company name, trademark, etc. I will create two files SharedAssemblyInfo.cs and SharedAssemblyInfo.fs on the solution level. Then every C# project will include SharedAssemblyInfo.cs by link, and every F# project will include SharedAssemblyInfo.fs by link. The build scripts will only have to modify these two files with updated version information before compilation, and restore them as was, after compilation. (To avoid any VCS seeing modifications, and committing them.)

Now comes the troublesome part.

If I create a new C# project, and include the SharedAssemblyInfo.cs by link, then the compiler will alert me of the duplicate assembly entries, and then I can remove the ones that are duplicate. This is quick to do, and I can't miss doing it. Good.

If I create a new F# project, and include the SharedAssemblyInfo.fs by link, then the compiler will not warn me of any duplicates. I have to remember that this needs doing. I also have to study the two files in order to determine which entries are duplicates. This is tedious and risky.

Expected behavior

The F# compiler should behave like the C# compiler in this regard, and not allow duplicate assembly attributes.

Actual behavior

The F# compiler allows duplicates of assembly attributes. This can cause problems to go unnoticed.

Known workarounds

A build script can use unit tests to analyze the build output for any inconsistencies in assembly attributes. This is however a rather time consuming solution to put in place in order to work around this problem.

Related information

VS 2017 and older.
Severity: Minimal.

Metadata

Metadata

Assignees

Labels

Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Low(Internal MS Team use only) Describes an issue with limited impact on existing code.

Type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions