fsharp icon indicating copy to clipboard operation
fsharp copied to clipboard

C# collection expression support for F# lists & sets

Open brianrourkeboll opened this issue 1 year ago • 6 comments

Description

  • Add support for creating F# lists & sets in C# using C# 12 collection expressions.
    • [x] Language suggestion: https://github.com/fsharp/fslang-suggestions/issues/1355
    • [x] RFC: https://github.com/fsharp/fslang-design/pull/776
    • [x] RFC discussion: https://github.com/fsharp/fslang-design/discussions/777

Examples

FSharpSet<int> xs = [1, 2, 3];
FSharpList<int> ys = [1, 2, 3];

Checklist

  • [x] Test cases added.
  • [x] Release notes entry updated.

brianrourkeboll avatar Jun 27 '24 17:06 brianrourkeboll

:heavy_exclamation_mark: Release notes required


:white_check_mark: Found changes and release notes in following paths:

Change path Release notes path Description
src/FSharp.Core docs/release-notes/.FSharp.Core/9.0.100.md

github-actions[bot] avatar Jun 27 '24 17:06 github-actions[bot]

Does anyone know what needs to be done with the new C# test project I added to make the CI happy? Something about the test results needing to be in a certain place, and/or packaging/PDBs?

  • https://github.com/dotnet/fsharp/pull/17359/checks?check_run_id=26811754428
  • https://dev.azure.com/dnceng-public/public/_build/results?buildId=724144&view=results
*Edit*: Maybe I can figure it out

image

brianrourkeboll avatar Jun 28 '24 13:06 brianrourkeboll

Forgive me if I'm being obtuse, but I don't think I understand the cause of this error in the CI:

PDB0021: Document name doesn't match any pattern in Source Link: '/_1/microsoft.net.test.sdk/17.4.0/build/netcoreapp3.1/Microsoft.NET.Test.Sdk.Program.cs'

The only results on Google are https://github.com/dotnet/runtime/issues/62892 and https://github.com/dotnet/machinelearning/issues/4400, which don't help me much, since I don't understand the underlying problem.

I can see that it comes from here, but... I do not understand why this PR is triggering that.

Is there something obvious I'm missing?

brianrourkeboll avatar Jun 28 '24 21:06 brianrourkeboll

Failed to run : https://github.com/dotnet/fsharp/actions/runs/9718927879

github-actions[bot] avatar Jun 28 '24 21:06 github-actions[bot]

Do they need to be part of new project? We successfully test interop in component tests.

vzarytovskii avatar Jun 29 '24 19:06 vzarytovskii

Do they need to be part of new project? We successfully test interop in component tests.

Hmm, I guess they could technically go there, although these are specifically meant to test the C# compiler's handling of types from FSharp.Core and have nothing to do with the F# compiler per se.

brianrourkeboll avatar Jun 29 '24 19:06 brianrourkeboll

@vzarytovskii

Do they need to be part of new project? We successfully test interop in component tests.

If we want to put these tests in FSharp.Compiler.ComponentTests/Interop (or, perhaps better, FSharp.Core.UnitTests/Interop), we need to update $(RoslynVersion) to a version that includes C# 12 support:

https://github.com/dotnet/fsharp/blob/5c6d8e705a4152ca2711ba57e58850fc561eafea/eng/Versions.props#L92

The version in main (4.6.0-3.23329.3) is a year old. What are the other implications of updating it?

Separately, while it would be nicer from the test writer's perspective to test the consumption of FSharp.Core constructs in C# in an actual C# project, I guess it would have the downside of making it harder to run specific tests against specific versions of C#.

brianrourkeboll avatar Jul 03 '24 18:07 brianrourkeboll

@/vzarytovskii

Do they need to be part of new project? We successfully test interop in component tests.

If we want to put these tests in FSharp.Compiler.ComponentTests/Interop (or, perhaps better, FSharp.Core.UnitTests/Interop), we need to update $(RoslynVersion) to a version that includes C# 12 support:

https://github.com/dotnet/fsharp/blob/5c6d8e705a4152ca2711ba57e58850fc561eafea/eng/Versions.props#L92

The version in main (4.6.0-3.23329.3) is a year old. What are the other implications of updating it?

Separately, while it would be nicer from the test writer's perspective to test the consumption of FSharp.Core constructs in C# in an actual C# project, I guess it would have the downside of making it harder to run specific tests against specific versions of C#.

The Roslyn deps were updated in #17144, merged to main today in #17380. I'll try to get these tests to work now.

brianrourkeboll avatar Jul 08 '24 15:07 brianrourkeboll

[!CAUTION] Repository is on lockdown for maintenance, all merges are on hold.

github-actions[bot] avatar Jul 08 '24 16:07 github-actions[bot]