Skip to content

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Mar 21, 2017

This adds anonymous records to the F# compiler per RFC FS-1030.

Please discuss on the RFC or below - if the discussion gets long we will move to the RFC discussion thread.

The implementation is not yet complete but I believe it to be stable and usable - there are just some corner cases to finish off and considerably more testing to add, specifically

Design:

  • Resolve issues around field ordering (currently field ordering is significant)

Implementation:

  • Equality, hash and comparison on {| X = 1; Y = 2 |} Kind B types
  • ToString on {| X = 1; Y = 2 |} Kind B types
  • sprintf "%A" on {| X = 1; Y = 2 |} Kind B types
  • Quick info
  • Auto complete
  • Highlight symbols
  • F# Interactive multiple fragments
  • Field ordering
  • Find all references
  • Go-to-definition

Testing:

  • Unit testing for language service features
  • LINQ queries
  • Test suitability of {| X = 1; Y = 2 |} types for working with known common libraries accepting C# anonymous types
  • Add tests for negative case error messages

If anyone wants to give a hand with the testing that would be great. I think it's really important that someone else besides myself do serious testing on this feature. I'd love someone to try this out and give early feedback on usability and "fit and polish".

Note: F# Interactive currently doesn't work properly:

> {|  X = 1 |};;
val it : {|X : int|} = {X = 1;}

> {|  X = 1 |};;

error FS0193: internal error: Duplicate type name within an assembly.

@et1975
Copy link

et1975 commented Mar 21, 2017

I didn't see an example of decomposition, will this be possible?

let {| x = x |} = anonymousRecord

What would the Kind B syntax be like for this?
How could one distinguish between Kind A and Kind B types of same shape?

@dsyme
Copy link
Contributor Author

dsyme commented Mar 21, 2017

@et1975 I'm not certain we need to allow decomposition for these (I'm not a big fan of pattern matching on records). But if we did, it would be

let {| x = x |} = anonymousRecordKindA

let (new {| x = x |}) = anonymousRecordKindB

@vasily-kirichenko
Copy link
Contributor

vasily-kirichenko commented Mar 21, 2017

It's fantastic. I didn't even know it's coming or even RFCed.

  1. Proper tooltip on value as a whole

image

  1. No completion:

image

  1. No tooltip/find usages/etc. on fields neither on definition nor on usage site (I guess there's no FSharpSymbol?)

  2. %A formatting is same as for tuples. Maybe it's better to adopt the one used for records?

let x = {| IntF = 1; StringF = "foo" |}
printfn "x = %A" x

> x = (1, "foo")
  1. Structs!

image

@vasily-kirichenko
Copy link
Contributor

About symbol absence, I think we just should notify the sink about fields, currently there is no ones:

image

@dsyme
Copy link
Contributor Author

dsyme commented Mar 21, 2017

@yawaramin actually please ask that one on the RFC thread

@yawaramin
Copy link

@dsyme sorry, I deleted my question after I thought about it some more--I think I understand the difference, but I will repost on the RFC thread (i.e. fsharp/fslang-design#170 ) in case the discussion brings value.

@dsyme
Copy link
Contributor Author

dsyme commented Mar 23, 2017

I've updated the PR to include code for equality, comparison, ToString and record-reflection

forki and others added 26 commits March 7, 2018 11:51
ensure build outputs always go to `$(Configuration)\$(TargetDotnetProfile)\bin`
Re-enable F5 on VisualFSharp.sln
use VS version as base for insertion packages
Add commit hashes to NuGet and Visual Studio packages
* Toggles for outlining and structured guidelines

* Cleanup

* Don't remove outlining alongside block structure lines and better names

* fix up rebase;
* fix cancellation for PostAndAsyncReply

* fix tests
consolidate Newtonsoft.Json version to match what's shipped in VS
…dotnet#4385)

* Remove dependency on FSharp.LanguageService from FSharp.ProjectSystem

* Fix bad merge
* clean option module in illib

* Update NicePrint.fs

* Update NicePrint.fs

* Update NicePrint.fs

* Update NicePrint.fs

* Update NicePrint.fs
* Create a test that shows broken comparison on float32

* fix comparison of float32
@dsyme dsyme mentioned this pull request Mar 12, 2018
24 tasks
@dsyme dsyme closed this Mar 12, 2018
@dsyme
Copy link
Contributor Author

dsyme commented Mar 12, 2018

Closed as targeted dev15.6 for some reason

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.