Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitae66aaf

Browse files
dsymelatkin
authored andcommitted
add Checked.int8/uint8 and Nullable.int8/uint8
closesdotnet#19commit5869de4Author: Don Syme <dsyme@microsoft.com>Date: Thu Jan 22 12:58:32 2015 +0000 update surface area testscommitefbba0aAuthor: Don Syme <dsyme@microsoft.com>Date: Thu Jan 22 12:00:02 2015 +0000 revert renaming to minimize diffcommit00011fbAuthor: Don Syme <dsyme@microsoft.com>Date: Fri Jan 16 13:55:42 2015 +0000 Add tests and fixes for Nullable opscommit34d720bAuthor: Don Syme <dsyme@microsoft.com>Date: Thu Jan 15 16:45:05 2015 +0000 add Checked.int8/uint8 and Nullable.int8/uint8
1 parentc52b4dd commitae66aaf

File tree

9 files changed

+185
-40
lines changed

9 files changed

+185
-40
lines changed

‎src/fsharp/FSharp.Core.Unittests/SurfaceArea.4.0.fs‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,13 +1164,20 @@ Microsoft.FSharp.Core.ExperimentalAttribute: System.String ToString()
11641164
Microsoft.FSharp.Core.ExperimentalAttribute: System.String get_Message()
11651165
Microsoft.FSharp.Core.ExperimentalAttribute: System.Type GetType()
11661166
Microsoft.FSharp.Core.ExperimentalAttribute: Void .ctor(System.String)
1167+
Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked: Boolean Equals(System.Object)
1168+
Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked: Byte ToByte[T](T)
1169+
Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked: Int32 GetHashCode()
1170+
Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked: SByte ToSByte[T](T)
1171+
Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked: System.String ToString()
1172+
Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked: System.Type GetType()
11671173
Microsoft.FSharp.Core.ExtraTopLevelOperators: Boolean Equals(System.Object)
11681174
Microsoft.FSharp.Core.ExtraTopLevelOperators: Byte ToByte[T](T)
11691175
Microsoft.FSharp.Core.ExtraTopLevelOperators: Double ToDouble[T](T)
11701176
Microsoft.FSharp.Core.ExtraTopLevelOperators: Int32 GetHashCode()
11711177
Microsoft.FSharp.Core.ExtraTopLevelOperators: Microsoft.FSharp.Collections.FSharpSet`1[T] CreateSet[T](System.Collections.Generic.IEnumerable`1[T])
11721178
Microsoft.FSharp.Core.ExtraTopLevelOperators: Microsoft.FSharp.Control.FSharpAsyncBuilder DefaultAsyncBuilder
11731179
Microsoft.FSharp.Core.ExtraTopLevelOperators: Microsoft.FSharp.Control.FSharpAsyncBuilder get_DefaultAsyncBuilder()
1180+
Microsoft.FSharp.Core.ExtraTopLevelOperators: Microsoft.FSharp.Core.ExtraTopLevelOperators+Checked
11741181
Microsoft.FSharp.Core.ExtraTopLevelOperators: Microsoft.FSharp.Linq.QueryBuilder get_query()
11751182
Microsoft.FSharp.Core.ExtraTopLevelOperators: Microsoft.FSharp.Linq.QueryBuilder query
11761183
Microsoft.FSharp.Core.ExtraTopLevelOperators: SByte ToSByte[T](T)
@@ -2956,15 +2963,19 @@ Microsoft.FSharp.Data.UnitSystems.SI.UnitNames.second: System.Type GetType()
29562963
Microsoft.FSharp.Linq.NullableModule: Boolean Equals(System.Object)
29572964
Microsoft.FSharp.Linq.NullableModule: Int32 GetHashCode()
29582965
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Byte] ToByte[T](System.Nullable`1[T])
2966+
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Byte] ToUInt8[T](System.Nullable`1[T])
29592967
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Char] ToChar[T](System.Nullable`1[T])
29602968
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Decimal] ToDecimal[T](System.Nullable`1[T])
29612969
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Double] ToDouble[T](System.Nullable`1[T])
2970+
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Double] ToFloat[T](System.Nullable`1[T])
29622971
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Int16] ToInt16[T](System.Nullable`1[T])
29632972
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Int32] ToInt32[T](System.Nullable`1[T])
29642973
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Int32] ToInt[T](System.Nullable`1[T])
29652974
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Int64] ToInt64[T](System.Nullable`1[T])
29662975
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.IntPtr] ToIntPtr[T](System.Nullable`1[T])
2976+
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.SByte] ToInt8[T](System.Nullable`1[T])
29672977
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.SByte] ToSByte[T](System.Nullable`1[T])
2978+
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Single] ToFloat32[T](System.Nullable`1[T])
29682979
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Single] ToSingle[T](System.Nullable`1[T])
29692980
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt16] ToUInt16[T](System.Nullable`1[T])
29702981
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt32] ToUInt32[T](System.Nullable`1[T])

‎src/fsharp/FSharp.Core/Linq.fs‎

Lines changed: 73 additions & 33 deletions
Large diffs are not rendered by default.

‎src/fsharp/FSharp.Core/Linq.fsi‎

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,14 @@ namespace Microsoft.FSharp.Linq
101101
[<CompiledName("ToByte")>]
102102
val inline byte:value:Nullable< ^T >->Nullable<byte> when ^T:(static member op_Explicit:^T->byte)and default ^T:int
103103

104+
///<summary>Converts the argument to byte. This is a direct conversion for all
105+
///primitive numeric types. The operation requires an appropriate
106+
///static conversion method on the input type.</summary>
107+
///<param name="value">The input value.</param>
108+
///<returns>The converted byte</returns>
109+
[<CompiledName("ToUInt8")>]
110+
val inline uint8:value:Nullable< ^T >->Nullable<uint8> when ^T:(static member op_Explicit:^T->uint8)and default ^T:int
111+
104112
///<summary>Converts the argument to signed byte. This is a direct conversion for all
105113
///primitive numeric types. The operation requires an appropriate
106114
///static conversion method on the input type.</summary>
@@ -109,6 +117,15 @@ namespace Microsoft.FSharp.Linq
109117
[<CompiledName("ToSByte")>]
110118
val inline sbyte:value:Nullable< ^T >->Nullable<sbyte> when ^T:(static member op_Explicit:^T->sbyte)and default ^T:int
111119

120+
121+
///<summary>Converts the argument to signed byte. This is a direct conversion for all
122+
///primitive numeric types. The operation requires an appropriate
123+
///static conversion method on the input type.</summary>
124+
///<param name="value">The input value.</param>
125+
///<returns>The converted sbyte</returns>
126+
[<CompiledName("ToInt8")>]
127+
val inline int8:value:Nullable< ^T >->Nullable<int8> when ^T:(static member op_Explicit:^T->int8)and default ^T:int
128+
112129
///<summary>Converts the argument to signed 16-bit integer. This is a direct conversion for all
113130
///primitive numeric types. The operation requires an appropriate
114131
///static conversion method on the input type.</summary>
@@ -176,17 +193,33 @@ namespace Microsoft.FSharp.Linq
176193
///static conversion method on the input type.</summary>
177194
///<param name="value">The input value.</param>
178195
///<returns>The converted float32</returns>
179-
[<CompiledName("ToSingle")>]
196+
[<CompiledName("ToFloat32")>]
180197
val inline float32:value:Nullable< ^T >->Nullable<float32> when ^T:(static member op_Explicit:^T->float32)and default ^T:int
181198

182199
///<summary>Converts the argument to 64-bit float. This is a direct conversion for all
183200
///primitive numeric types. The operation requires an appropriate
184201
///static conversion method on the input type.</summary>
185202
///<param name="value">The input value.</param>
186203
///<returns>The converted float</returns>
187-
[<CompiledName("ToDouble")>]
204+
[<CompiledName("ToFloat")>]
188205
val inline float:value:Nullable< ^T >->Nullable<float> when ^T:(static member op_Explicit:^T->float)and default ^T:int
189206

207+
///<summary>Converts the argument to 32-bit float. This is a direct conversion for all
208+
///primitive numeric types. The operation requires an appropriate
209+
///static conversion method on the input type.</summary>
210+
///<param name="value">The input value.</param>
211+
///<returns>The converted float32</returns>
212+
[<CompiledName("ToSingle")>]
213+
val inline single:value:Nullable< ^T >->Nullable<single> when ^T:(static member op_Explicit:^T->single)and default ^T:int
214+
215+
///<summary>Converts the argument to 64-bit float. This is a direct conversion for all
216+
///primitive numeric types. The operation requires an appropriate
217+
///static conversion method on the input type.</summary>
218+
///<param name="value">The input value.</param>
219+
///<returns>The converted float</returns>
220+
[<CompiledName("ToDouble")>]
221+
val inline double:value:Nullable< ^T >->Nullable<double> when ^T:(static member op_Explicit:^T->double)and default ^T:int
222+
190223
///<summary>Converts the argument to signed native integer. This is a direct conversion for all
191224
///primitive numeric types. Otherwise the operation requires an appropriate
192225
///static conversion method on the input type.</summary>

‎src/fsharp/FSharp.Core/Query.fs‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -994,9 +994,7 @@ module Query =
994994
|_-> None)
995995

996996
let(|CallQueryBuilderRunQueryable|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b:QueryBuilder,v)-> b.Run(v)))
997-
// (typeof<QueryBuilder>.Assembly.GetType("Microsoft.FSharp.Linq.QueryRunExtensions.LowPriority").GetMethod("RunQueryAsValue").MethodHandle)
998997
let(|CallQueryBuilderRunValue|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b: QueryBuilder, v:Expr<'a>)-> b.Run(v)): 'a)// type annotations here help overload resolution
999-
// (typeof<QueryBuilder>.Assembly.GetType("Microsoft.FSharp.Linq.QueryRunExtensions.HighPriority").GetMethod("RunQueryAsEnumerable").MethodHandle)
1000998
let(|CallQueryBuilderRunEnumerable|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b: QueryBuilder, v:Expr<QuerySource<_, IEnumerable>>)-> b.Run(v)))// type annotations here help overload resolution
1001999
let(|CallQueryBuilderFor|_|):Quotations.Expr->_=(|SpecificCallToMethod|_|)(methodhandleof(fun(b:QueryBuilder,source:QuerySource<int,_>,body)-> b.For(source,body)))
10021000
let(|CallQueryBuilderYield|_|):Quotations.Expr->_=(|SpecificCall1|_|)(methodhandleof(fun(b:QueryBuilder,value)-> b.Yield value))

‎src/fsharp/FSharp.Core/fslib-extra-pervasives.fs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,14 @@ module ExtraTopLevelOperators =
166166
[<CompiledName("ToSByte")>]
167167
let inlineint8 x= sbyte x
168168

169+
moduleChecked=
170+
171+
[<CompiledName("ToByte")>]
172+
let inlineuint8 x= Checked.byte x
173+
174+
[<CompiledName("ToSByte")>]
175+
let inlineint8 x= Checked.sbyte x
176+
169177

170178
#if FX_MINIMAL_REFLECTION// not on Compact Framework
171179
#else

‎src/fsharp/FSharp.Core/fslib-extra-pervasives.fsi‎

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,36 @@ module ExtraTopLevelOperators =
8787
///<remarks>This is a direct conversion for all
8888
///primitive numeric types. For strings,the input is converted using <c>Double.Parse()</c> with InvariantCulture settings. Otherwise the operation requires and invokes a <c>ToDouble</c> method on the input type.</remarks>
8989
[<CompiledName("ToDouble")>]
90-
val inline double:value:^T->float when ^T:(static member op_Explicit:^T->double)and default ^T:int
90+
val inline double:value:^T->double when ^T:(static member op_Explicit:^T->double)and default ^T:int
9191

9292
///<summary>Converts the argument to byte.</summary>
9393
///<remarks>This is a direct conversion for all
9494
///primitive numeric types. For strings,the input is converted using <c>Byte.Parse()</c> on strings and otherwise requires a <c>ToByte</c> method on the input type.</remarks>
9595
[<CompiledName("ToByte")>]
96-
val inline uint8:value:^T->byte when ^T:(static member op_Explicit:^T->byte)and default ^T:int
96+
val inline uint8:value:^T->uint8 when ^T:(static member op_Explicit:^T->uint8)and default ^T:int
9797

9898
///<summary>Converts the argument to signed byte.</summary>
9999
///<remarks>This is a direct conversion for all
100100
///primitive numeric types. For strings,the input is converted using <c>SByte.Parse()</c> with InvariantCulture settings.
101101
///Otherwise the operation requires and invokes a <c>ToSByte</c> method on the input type.</remarks>
102102
[<CompiledName("ToSByte")>]
103-
val inline int8:value:^T->sbyte when ^T:(static member op_Explicit:^T->sbyte)and default ^T:int
103+
val inline int8:value:^T->int8 when ^T:(static member op_Explicit:^T->int8)and default ^T:int
104+
105+
106+
module Checked=
107+
108+
///<summary>Converts the argument to byte.</summary>
109+
///<remarks>This is a direct,checked conversion for all
110+
///primitive numeric types. For strings,the input is converted using <c>Byte.Parse()</c> on strings and otherwise requires a <c>ToByte</c> method on the input type.</remarks>
111+
[<CompiledName("ToByte")>]
112+
val inline uint8:value:^T->byte when ^T:(static member op_Explicit:^T->uint8)and default ^T:int
113+
114+
///<summary>Converts the argument to signed byte.</summary>
115+
///<remarks>This is a direct,checked conversion for all
116+
///primitive numeric types. For strings,the input is converted using <c>SByte.Parse()</c> with InvariantCulture settings.
117+
///Otherwise the operation requires and invokes a <c>ToSByte</c> method on the input type.</remarks>
118+
[<CompiledName("ToSByte")>]
119+
val inline int8:value:^T->sbyte when ^T:(static member op_Explicit:^T->int8)and default ^T:int
104120

105121

106122
///<summary>Builds a read-only lookup table from a sequence of key/value pairs. The key objects are indexed using generic hashing and equality.</summary>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp