未验证 提交 be621d87 编写于 作者: P Phillip Carter 提交者: GitHub

Add nullable uint conversion function (#8780)

* Move nullable into separate files (#8801)

* Move nullable into separate files

* up

* jojo

* bagheera

* caramel

* bagheera2

* derp
上级 478288dc
......@@ -99,6 +99,9 @@ module Nullable =
[<CompiledName("ToInt")>]
let inline int (value:Nullable<_>) = if value.HasValue then Nullable(Operators.int value.Value) else Nullable()
[<CompiledName("ToUInt")>]
let inline uint (value: Nullable<_>) = if value.HasValue then Nullable(Operators.uint value.Value) else Nullable()
[<CompiledName("ToEnum")>]
let inline enum (value:Nullable< int32 >) = if value.HasValue then Nullable(Operators.enum value.Value) else Nullable()
......
......@@ -169,6 +169,14 @@ module Nullable =
[<CompiledName("ToInt")>]
val inline int : value:Nullable< ^T > -> Nullable<int> when ^T : (static member op_Explicit : ^T -> int) and default ^T : int
/// <summary>Converts the argument to an unsigned 32-bit integer. This is a direct conversion for all
/// primitive numeric types. The operation requires an appropriate
/// static conversion method on the input type.</summary>
/// <param name="value">The input value.</param>
/// <returns>The converted unsigned integer</returns>
[<CompiledName("ToUInt")>]
val inline uint: value: Nullable< ^T > -> Nullable<uint> when ^T :(static member op_Explicit: ^T -> uint) and default ^T : uint
/// <summary>Converts the argument to a particular enum type.</summary>
/// <param name="value">The input value.</param>
/// <returns>The converted enum type.</returns>
......
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Core.UnitTests.FSharp_Core.Linq.NullableOperators
open NUnit.Framework
open Microsoft.FSharp.Linq
[<TestFixture>]
type NullableOperators() =
[<Test>]
member _.CastingUint () =
let expected = Nullable(12u)
let actual = Nullable.uint (Nullable(12))
Assert.AreEqual(expected, actual)
\ No newline at end of file
......@@ -2342,6 +2342,7 @@ Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Single] ToFloat32
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Single] ToSingle[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt16] ToUInt16[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt32] ToUInt32[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt32] ToUInt[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt64] ToUInt64[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UIntPtr] ToUIntPtr[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[TResult] ToEnum[TResult](System.Nullable`1[System.Int32])
......
......@@ -2342,6 +2342,7 @@ Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Single] ToFloat32
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.Single] ToSingle[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt16] ToUInt16[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt32] ToUInt32[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt32] ToUInt[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UInt64] ToUInt64[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[System.UIntPtr] ToUIntPtr[T](System.Nullable`1[T])
Microsoft.FSharp.Linq.NullableModule: System.Nullable`1[TResult] ToEnum[TResult](System.Nullable`1[System.Int32])
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册