Header menu logo FSharp.Core

FSharpValue Type

Contains operations associated with constructing and analyzing values associated with F# types
 such as records, unions and tuples.

Static members

Static member Description

FSharpValue.GetExceptionFields(exn, ?bindingFlags)

Full Usage: FSharpValue.GetExceptionFields(exn, ?bindingFlags)

Parameters:
    exn : obj - The exception instance.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: objnull array The fields from the given exception.

Reads all the fields from a value built using an instance of an F# exception declaration

Assumes the given input is an F# exception value. If not, ArgumentException is raised.

exn : obj

The exception instance.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: objnull array

The fields from the given exception.

ArgumentException Thrown when the input type is not an F# exception.

FSharpValue.GetRecordField(record, info)

Full Usage: FSharpValue.GetRecordField(record, info)

Parameters:
    record : obj - The record object.
    info : PropertyInfo - The PropertyInfo describing the field to read.

Returns: objnull The field from the record.

Reads a field from a record value.

Assumes the given input is a record value. If not, ArgumentException is raised.

record : obj

The record object.

info : PropertyInfo

The PropertyInfo describing the field to read.

Returns: objnull

The field from the record.

ArgumentException Thrown when the input is not a record value.

FSharpValue.GetRecordFields(record, ?bindingFlags)

Full Usage: FSharpValue.GetRecordFields(record, ?bindingFlags)

Parameters:
    record : obj - The record object.
    ?bindingFlags : BindingFlags - Optional binding flags for the record.

Returns: objnull array The array of fields from the record.

Reads all the fields from a record value.

Assumes the given input is a record value. If not, ArgumentException is raised.

record : obj

The record object.

?bindingFlags : BindingFlags

Optional binding flags for the record.

Returns: objnull array

The array of fields from the record.

ArgumentException Thrown when the input type is not a record type.

FSharpValue.GetTupleField(tuple, index)

Full Usage: FSharpValue.GetTupleField(tuple, index)

Parameters:
    tuple : obj - The input tuple.
    index : int - The index of the field to read.

Returns: objnull The value of the field.

Reads a field from a tuple value.

Assumes the given input is a tuple value. If not, ArgumentException is raised.

tuple : obj

The input tuple.

index : int

The index of the field to read.

Returns: objnull

The value of the field.

FSharpValue.GetTupleFields(tuple)

Full Usage: FSharpValue.GetTupleFields(tuple)

Parameters:
    tuple : obj - The input tuple.

Returns: objnull array An array of the fields from the given tuple.

Reads all fields from a tuple.

Assumes the given input is a tuple value. If not, ArgumentException is raised.

tuple : obj

The input tuple.

Returns: objnull array

An array of the fields from the given tuple.

ArgumentException Thrown when the input is not a tuple value.

FSharpValue.GetUnionFields(value, unionType, ?bindingFlags)

Full Usage: FSharpValue.GetUnionFields(value, unionType, ?bindingFlags)

Parameters:
    value : objnull - The input union case.
    unionType : Type - The union type containing the value.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: UnionCaseInfo * objnull array The description of the union case and its fields.

Identify the union case and its fields for an object

Assumes the given input is a union case value. If not, ArgumentException is raised. If the type is not given, then the runtime type of the input object is used to identify the relevant union type. The type should always be given if the input object may be null. For example, option values may be represented using the 'null'.

value : objnull

The input union case.

unionType : Type

The union type containing the value.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: UnionCaseInfo * objnull array

The description of the union case and its fields.

ArgumentException Thrown when the input type is not a union case value.

FSharpValue.MakeFunction(functionType, implementation)

Full Usage: FSharpValue.MakeFunction(functionType, implementation)

Parameters:
    functionType : Type - The function type of the implementation.
    implementation : objnull -> objnull - The untyped lambda of the function implementation.

Returns: obj A typed function from the given dynamic implementation.

Builds a typed function from object from a dynamic function implementation

functionType : Type

The function type of the implementation.

implementation : objnull -> objnull

The untyped lambda of the function implementation.

Returns: obj

A typed function from the given dynamic implementation.

FSharpValue.MakeRecord(recordType, values, ?bindingFlags)

Full Usage: FSharpValue.MakeRecord(recordType, values, ?bindingFlags)

Parameters:
    recordType : Type - The type of record to make.
    values : objnull array - The array of values to initialize the record.
    ?bindingFlags : BindingFlags - Optional binding flags for the record.

Returns: obj The created record.

Creates an instance of a record type.

Assumes the given input is a record type.

recordType : Type

The type of record to make.

values : objnull array

The array of values to initialize the record.

?bindingFlags : BindingFlags

Optional binding flags for the record.

Returns: obj

The created record.

ArgumentException Thrown when the input type is not a record type.

FSharpValue.MakeTuple(tupleElements, tupleType)

Full Usage: FSharpValue.MakeTuple(tupleElements, tupleType)

Parameters:
    tupleElements : objnull array - The array of tuple fields.
    tupleType : Type - The tuple type to create.

Returns: obj An instance of the tuple type with the given elements.

Creates an instance of a tuple type

Assumes at least one element is given. If not, ArgumentException is raised.

tupleElements : objnull array

The array of tuple fields.

tupleType : Type

The tuple type to create.

Returns: obj

An instance of the tuple type with the given elements.

ArgumentException Thrown if no elements are given.

FSharpValue.MakeUnion(unionCase, args, ?bindingFlags)

Full Usage: FSharpValue.MakeUnion(unionCase, args, ?bindingFlags)

Parameters:
    unionCase : UnionCaseInfo - The description of the union case to create.
    args : objnull array - The array of arguments to construct the given case.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: objnull The constructed union case.

Create a union case value.

unionCase : UnionCaseInfo

The description of the union case to create.

args : objnull array

The array of arguments to construct the given case.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: objnull

The constructed union case.

FSharpValue.PreComputeRecordConstructor(recordType, ?bindingFlags)

Full Usage: FSharpValue.PreComputeRecordConstructor(recordType, ?bindingFlags)

Parameters:
    recordType : Type - The type of record to construct.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: objnull array -> obj A function to construct records of the given type.

Precompute a function for constructing a record value.

Assumes the given type is a RecordType. If not, ArgumentException is raised during pre-computation.

recordType : Type

The type of record to construct.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: objnull array -> obj

A function to construct records of the given type.

ArgumentException Thrown when the input type is not a record type.

FSharpValue.PreComputeRecordConstructorInfo(recordType, ?bindingFlags)

Full Usage: FSharpValue.PreComputeRecordConstructorInfo(recordType, ?bindingFlags)

Parameters:
    recordType : Type - The record type.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: ConstructorInfo A ConstructorInfo for the given record type.

Get a ConstructorInfo for a record type

recordType : Type

The record type.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: ConstructorInfo

A ConstructorInfo for the given record type.

FSharpValue.PreComputeRecordFieldReader(info)

Full Usage: FSharpValue.PreComputeRecordFieldReader(info)

Parameters:
    info : PropertyInfo - The PropertyInfo of the field to read.

Returns: obj -> objnull A function to read the specified field from the record.

Precompute a function for reading a particular field from a record. Assumes the given type is a RecordType with a field of the given name. If not, ArgumentException is raised during pre-computation.

Using the computed function will typically be faster than executing a corresponding call to Value.GetInfo because the path executed by the computed function is optimized given the knowledge that it will be used to read values of the given type.

info : PropertyInfo

The PropertyInfo of the field to read.

Returns: obj -> objnull

A function to read the specified field from the record.

ArgumentException Thrown when the input type is not a record type.

FSharpValue.PreComputeRecordReader(recordType, ?bindingFlags)

Full Usage: FSharpValue.PreComputeRecordReader(recordType, ?bindingFlags)

Parameters:
    recordType : Type - The type of record to read.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: obj -> objnull array An optimized reader for the given record type.

Precompute a function for reading all the fields from a record. The fields are returned in the same order as the fields reported by a call to Microsoft.FSharp.Reflection.Type.GetInfo for this type.

Assumes the given type is a RecordType. If not, ArgumentException is raised during pre-computation. Using the computed function will typically be faster than executing a corresponding call to Value.GetInfo because the path executed by the computed function is optimized given the knowledge that it will be used to read values of the given type.

recordType : Type

The type of record to read.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: obj -> objnull array

An optimized reader for the given record type.

ArgumentException Thrown when the input type is not a record type.

FSharpValue.PreComputeTupleConstructor(tupleType)

Full Usage: FSharpValue.PreComputeTupleConstructor(tupleType)

Parameters:
    tupleType : Type - The type of tuple to read.

Returns: objnull array -> obj A function to read a particular tuple type.

Precompute a function for reading the values of a particular tuple type

Assumes the given type is a TupleType. If not, ArgumentException is raised during pre-computation.

tupleType : Type

The type of tuple to read.

Returns: objnull array -> obj

A function to read a particular tuple type.

ArgumentException Thrown when the given type is not a tuple type.

FSharpValue.PreComputeTupleConstructorInfo(tupleType)

Full Usage: FSharpValue.PreComputeTupleConstructorInfo(tupleType)

Parameters:
    tupleType : Type - The input tuple type.

Returns: ConstructorInfo * Type option The description of the tuple type constructor and an optional extra type for large tuples.

Gets a method that constructs objects of the given tuple type. For small tuples, no additional type will be returned.

For large tuples, an additional type is returned indicating that a nested encoding has been used for the tuple type. In this case the suffix portion of the tuple type has the given type and an object of this type must be created and passed as the last argument to the ConstructorInfo. A recursive call to PreComputeTupleConstructorInfo can be used to determine the constructor for that the suffix type.

tupleType : Type

The input tuple type.

Returns: ConstructorInfo * Type option

The description of the tuple type constructor and an optional extra type for large tuples.

FSharpValue.PreComputeTuplePropertyInfo(tupleType, index)

Full Usage: FSharpValue.PreComputeTuplePropertyInfo(tupleType, index)

Parameters:
    tupleType : Type - The input tuple type.
    index : int - The index of the tuple element to describe.

Returns: PropertyInfo * (Type * int) option The description of the tuple element and an optional type and index if the tuple is big.

Gets information that indicates how to read a field of a tuple

tupleType : Type

The input tuple type.

index : int

The index of the tuple element to describe.

Returns: PropertyInfo * (Type * int) option

The description of the tuple element and an optional type and index if the tuple is big.

FSharpValue.PreComputeTupleReader(tupleType)

Full Usage: FSharpValue.PreComputeTupleReader(tupleType)

Parameters:
    tupleType : Type - The tuple type to read.

Returns: obj -> objnull array A function to read values of the given tuple type.

Precompute a function for reading the values of a particular tuple type

Assumes the given type is a TupleType. If not, ArgumentException is raised during pre-computation.

tupleType : Type

The tuple type to read.

Returns: obj -> objnull array

A function to read values of the given tuple type.

ArgumentException Thrown when the given type is not a tuple type.

FSharpValue.PreComputeUnionConstructor(unionCase, ?bindingFlags)

Full Usage: FSharpValue.PreComputeUnionConstructor(unionCase, ?bindingFlags)

Parameters:
Returns: objnull array -> objnull A function for constructing values of the given union case.

Precompute a function for constructing a discriminated union value for a particular union case.

unionCase : UnionCaseInfo

The description of the union case.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: objnull array -> objnull

A function for constructing values of the given union case.

FSharpValue.PreComputeUnionConstructorInfo(unionCase, ?bindingFlags)

Full Usage: FSharpValue.PreComputeUnionConstructorInfo(unionCase, ?bindingFlags)

Parameters:
Returns: MethodInfo The description of the constructor of the given union case.

A method that constructs objects of the given case

unionCase : UnionCaseInfo

The description of the union case.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: MethodInfo

The description of the constructor of the given union case.

FSharpValue.PreComputeUnionReader(unionCase, ?bindingFlags)

Full Usage: FSharpValue.PreComputeUnionReader(unionCase, ?bindingFlags)

Parameters:
    unionCase : UnionCaseInfo - The description of the union case to read.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: objnull -> objnull array A function to for reading the fields of the given union case.

Precompute a function for reading all the fields for a particular discriminator case of a union type

Using the computed function will typically be faster than executing a corresponding call to GetFields

unionCase : UnionCaseInfo

The description of the union case to read.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: objnull -> objnull array

A function to for reading the fields of the given union case.

FSharpValue.PreComputeUnionTagMemberInfo(unionType, ?bindingFlags)

Full Usage: FSharpValue.PreComputeUnionTagMemberInfo(unionType, ?bindingFlags)

Parameters:
    unionType : Type - The type of union to read.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: MemberInfo The description of the union case reader.

Precompute a property or static method for reading an integer representing the case tag of a union type.

unionType : Type

The type of union to read.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: MemberInfo

The description of the union case reader.

FSharpValue.PreComputeUnionTagReader(unionType, ?bindingFlags)

Full Usage: FSharpValue.PreComputeUnionTagReader(unionType, ?bindingFlags)

Parameters:
    unionType : Type - The type of union to optimize reading.
    ?bindingFlags : BindingFlags - Optional binding flags.

Returns: objnull -> int An optimized function to read the tags of the given union type.

Assumes the given type is a union type. If not, ArgumentException is raised during pre-computation.

Using the computed function is more efficient than calling GetUnionCase because the path executed by the computed function is optimized given the knowledge that it will be used to read values of the given type.

unionType : Type

The type of union to optimize reading.

?bindingFlags : BindingFlags

Optional binding flags.

Returns: objnull -> int

An optimized function to read the tags of the given union type.

Type something to start searching.