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

[Bug]: WriteCodeFragment - assembly attribute doesn't work for F# #9724

Closed
Evangelink opened this issue Feb 9, 2024 · 3 comments
Closed
Labels
bug needs-triage Have yet to determine what bucket this goes in.

Comments

@Evangelink
Copy link
Member

Issue Description

Not sure if that's by-design and the doc is only missing some sections or if that's a bug.

As part of maintenance on test-templates, I am trying to enable parallelize assembly attribute by default using the <AssemblyAttribute.../> syntax in the project. I have been able to successfully provide the implementation for C# and VB.NET but F# is failing with Unable to parse '1_IsLiteral' as an index.

Steps to Reproduce

  • Create a new F# MSTest project: dotnet new mstest --language F#

  • Edit the fsproj by adding:

<AssemblyAttribute Include="Microsoft.VisualStudio.TestTools.UnitTesting.Parallelize">
  <_Parameter1>Workers = 0</_Parameter1>
  <_Parameter1_IsLiteral>true</_Parameter1_IsLiteral>
  <_Parameter2>Scope = Microsoft.VisualStudio.TestTools.UnitTesting.ExecutionScope.MethodLevel</_Parameter2>
  <_Parameter2_IsLiteral>true</_Parameter2_IsLiteral>
</AssemblyAttribute>
  • Build: dotnet build

Error:

<redacted>\FSharp\Microsoft.FSharp.Overrides.NetSdk.targets(30,5): error : Unable to parse '1_IsLiteral' as an index [<redacted>\
project.fsproj]

Expected Behavior

Feature is supported or doc and error is improved to specify this is not supported.

Actual Behavior

<AssemblyAttribute.../> syntax in the project. I have been able to successfully provide the implementation for C# and VB.NET but F# is failing with Unable to parse '1_IsLiteral' as an index.

Analysis

No response

Versions & Configurations

No response

@Evangelink Evangelink added bug needs-triage Have yet to determine what bucket this goes in. labels Feb 9, 2024
@KalleOlaviNiemitalo
Copy link

F# has its own WriteCodeFragment task implementation that does not support the "_TypeName" and "_IsLiteral" suffixes. https://github.com/dotnet/fsharp/blob/v12.8.0/src/FSharp.Build/WriteCodeFragment.fs

@KalleOlaviNiemitalo
Copy link

KalleOlaviNiemitalo commented Feb 9, 2024

Also noted in #6285 (comment).

I think it would be best to document at WriteCodeFragment task that "_TypeName" and "_IsLiteral" are only implemented for CodeDom supported languages, i.e. C# and VB. If the F# implementation of WriteCodeFragment is ever changed to support these too, then the documentation can be updated at that time, and it can state the version of F# in which this support is added.

@Evangelink
Copy link
Member Author

Thanks for the pointers @KalleOlaviNiemitalo! I am closing this issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Have yet to determine what bucket this goes in.
Projects
None yet
Development

No branches or pull requests

2 participants