SwensenSoftware / unquote

Write F# unit test assertions as quoted expressions, get step-by-step failure messages for free
http://www.swensensoftware.com/unquote
Apache License 2.0
287 stars 25 forks source link

Type.FSharpName bug: can't handle generic type definiations #6

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
For example,

> [3].GetType().GetGenericTypeDefinition().FSharpName;;
System.ArgumentNullException: Value cannot be null.
Parameter name: input
   at System.Text.RegularExpressions.Regex.Match(String input)
   at FSI_0038.Swensen.RegexUtils.|CompiledMatch|_|(String pattern, String str) in C:\Users\Stephen\Documents\Visual Studio 2010\Projects\Unquote\Unquote\RegexUtils.fs:line 28
   at FSI_0040.Swensen.Unquote.Sprint.sprintSig@169-20(Int32 context, Type t) in C:\Users\Stephen\Documents\Visual Studio 2010\Projects\Unquote\Unquote\Sprint.fs:line 172
   at FSI_0040.Swensen.Unquote.Sprint.sprintSig@169-20(Int32 context, Type t) in C:\Users\Stephen\Documents\Visual Studio 2010\Projects\Unquote\Unquote\Sprint.fs:line 186
   at <StartupCode$FSI_0058>.$FSI_0058.main@()
Stopped due to error

Original issue reported on code.google.com by stephen....@gmail.com on 17 Feb 2011 at 3:48

GoogleCodeExporter commented 9 years ago
Fixed, for example (there not always what I expected -- nested types not 
included in generic type definitions, and generic arrays are given as obj -- 
but I believe correct:

> typedefof<int -> (int * int)>.FSharpName;;
val it : string = "T -> TResult"
> typedefof<int * int>.FSharpName;;
val it : string = "T1 * T2"
> typedefof<list<_>>.FSharpName;;
val it : string = "list<T>"
> typedefof<seq<list<_>>>.FSharpName;;
val it : string = "seq<T>"
> typedefof<_[]>.FSharpName;;
val it : string = "obj[]"

Original comment by stephen....@gmail.com on 19 Feb 2011 at 5:29

GoogleCodeExporter commented 9 years ago

Original comment by stephen....@gmail.com on 17 Mar 2011 at 4:13