Skip to content

Conversation

@dsyme
Copy link
Contributor

@dsyme dsyme commented Mar 12, 2019

Brings #2290 up-to-date with master

Implementation of RFC FS-1003

Testing verified:

  • handle cases where nameof already resolves to something user-defined, to avoid being a breaking change
  • works in quotations
  • works with method parameters
  • works with local variables
  • works with local (nested) functions
  • works with local curried functions
  • works with local tupled functions
  • can get name from inside a local function (needs to be let rec)
  • can get member names
  • can get static member names
  • can get static property names
  • can get names that quoted in ``
  • can be used in pattern matching
  • can be used with generic functions/types
  • when used like a function, let f = nameof ;; f x
  • when used with pipe operator, x |> nameof
  • can get names of operators like +, |>, typeof, nameof, ...
  • works in attributes
  • works with namespaces, nameof System.Diagnostics
  • works with types, nameof System.String
  • works with modules, nameof List

Not necessary to test (it will work:

  • works with provided symbol names, i.e. generated by type providers

Feature limitation:

  • the feature will not work with type arguments, let f<'t> (x : 't) = nameof 't

Vasily Kirichenko and others added 30 commits January 18, 2017 16:24
Conflicts:
	src/fsharp/FSComp.txt
	src/fsharp/FSharp.Core.Unittests/SurfaceArea.Silverlight.2.0.fs
	src/fsharp/FSharp.Core.Unittests/SurfaceArea.net20.fs
	src/fsharp/PostInferenceChecks.fs
	src/fsharp/TastOps.fs
	src/fsharp/TcGlobals.fs
This reverts commit 529cc6f.
This reverts commit 223d313.

Conflicts:
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAdditionExpr.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAppliedFunction.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfAsAFunction.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfDictLookup.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntConst.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfIntegerAppliedFunction.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfParameterAppliedFunction.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfPartiallyAppliedFunction.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfStringConst.fs
	tests/fsharpqa/Source/Conformance/Expressions/DataExpressions/NameOf/E_NameOfWithPipe.fs
it raises a proper error if applicated to non (Long)Ident arg
remove `typenameof and its tests
@jwosty
Copy link
Contributor

jwosty commented Apr 8, 2019

I am very much looking forward to having this. I just want to thank everyone who has put work into this!

@dsyme
Copy link
Contributor Author

dsyme commented May 22, 2019

Closing in favour of #6809 from feature branch

@The-Futurist
Copy link

@cartermp

Could someone please let us know if or when the new nameof capability will become available?

VS 2019 tells me I have this:

Visual F# Tools 10.4 for F# 4.6 16.3.0-beta.19455.1+0422ff293bb2cc722fe5021b85ef50378a9af823
Microsoft Visual F# Tools 10.4 for F# 4.6

Thanks

@KevinRansom
Copy link
Contributor

@Korporal,

It is currently available as a language preview.

So in a dotnetsdk .fsproj project file use:

<LangVersion>Preview</LangVersion>

for fsi
use

fsi /LangVersion:Preview

or
dotnet fsi --langversion:preview

Hope this helps

Kevin

@The-Futurist
Copy link

This is helpful, much appreciated.

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.

9 participants