Header menu logo FSharp.Core

FSharpReflectionExtensions Module

Defines further accessing additional information about F# types and F# values at runtime.

Type extensions

Type extension Description

FSharpValue.GetExceptionFields(exn, ?allowAccessToPrivateRepresentation)

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

Parameters:
    exn : obj - The exception instance.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

exn : obj

The exception instance.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: objnull array

The fields from the given exception.

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

FSharpType.GetExceptionFields(exceptionType, ?allowAccessToPrivateRepresentation)

Full Usage: FSharpType.GetExceptionFields(exceptionType, ?allowAccessToPrivateRepresentation)

Parameters:
    exceptionType : Type - The exception type to read.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: PropertyInfo array An array containing the PropertyInfo of each field in the exception.

Reads all the fields from an F# exception declaration, in declaration order

Assumes exceptionType is an exception representation type. If not, ArgumentException is raised.

Extended Type: FSharpType

exceptionType : Type

The exception type to read.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: PropertyInfo array

An array containing the PropertyInfo of each field in the exception.

ArgumentException Thrown if the given type is not an exception.

FSharpValue.GetRecordFields(record, ?allowAccessToPrivateRepresentation)

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

Parameters:
    record : obj - The record object.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

record : obj

The record object.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: objnull array

The array of fields from the record.

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

FSharpType.GetRecordFields(recordType, ?allowAccessToPrivateRepresentation)

Full Usage: FSharpType.GetRecordFields(recordType, ?allowAccessToPrivateRepresentation)

Parameters:
    recordType : Type - The input record type.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: PropertyInfo array An array of descriptions of the properties of the record type.

Reads all the fields from a record value, in declaration order

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

Extended Type: FSharpType

recordType : Type

The input record type.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: PropertyInfo array

An array of descriptions of the properties of the record type.

FSharpType.GetUnionCases(unionType, ?allowAccessToPrivateRepresentation)

Full Usage: FSharpType.GetUnionCases(unionType, ?allowAccessToPrivateRepresentation)

Parameters:
    unionType : Type - The input union type.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: UnionCaseInfo array An array of descriptions of the cases of the given union type.

Gets the cases of a union type.

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

Extended Type: FSharpType

unionType : Type

The input union type.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: UnionCaseInfo array

An array of descriptions of the cases of the given union type.

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

FSharpValue.GetUnionFields(value, unionType, ?allowAccessToPrivateRepresentation)

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

Parameters:
    value : objnull - The input union case.
    unionType : Type - The union type containing the value.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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'.

Extended Type: FSharpValue

value : objnull

The input union case.

unionType : Type

The union type containing the value.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

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.

FSharpType.IsExceptionRepresentation(exceptionType, ?allowAccessToPrivateRepresentation)

Full Usage: FSharpType.IsExceptionRepresentation(exceptionType, ?allowAccessToPrivateRepresentation)

Parameters:
    exceptionType : Type - The type to check.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: bool True if the type check is an F# exception.

Returns true if the exceptionType is a representation of an F# exception declaration

Extended Type: FSharpType

exceptionType : Type

The type to check.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: bool

True if the type check is an F# exception.

FSharpType.IsRecord(typ, ?allowAccessToPrivateRepresentation)

Full Usage: FSharpType.IsRecord(typ, ?allowAccessToPrivateRepresentation)

Parameters:
    typ : Type - The type to check.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: bool True if the type check succeeds.

Return true if the typ is a representation of an F# record type

Extended Type: FSharpType

typ : Type

The type to check.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: bool

True if the type check succeeds.

FSharpType.IsUnion(typ, ?allowAccessToPrivateRepresentation)

Full Usage: FSharpType.IsUnion(typ, ?allowAccessToPrivateRepresentation)

Parameters:
    typ : Type - The type to check.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: bool True if the type check succeeds.

Returns true if the typ is a representation of an F# union type or the runtime type of a value of that type

Extended Type: FSharpType

typ : Type

The type to check.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: bool

True if the type check succeeds.

FSharpValue.MakeRecord(recordType, values, ?allowAccessToPrivateRepresentation)

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

Parameters:
    recordType : Type - The type of record to make.
    values : objnull array - The array of values to initialize the record.
    ?allowAccessToPrivateRepresentation : bool - Optional flags that denotes accessibility of the private representation.

Returns: obj The created record.

Creates an instance of a record type.

Assumes the given input is a record type.

Extended Type: FSharpValue

recordType : Type

The type of record to make.

values : objnull array

The array of values to initialize the record.

?allowAccessToPrivateRepresentation : bool

Optional flags that denotes accessibility of the private representation.

Returns: obj

The created record.

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

FSharpValue.MakeUnion(unionCase, args, ?allowAccessToPrivateRepresentation)

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

Parameters:
    unionCase : UnionCaseInfo - The description of the union case to create.
    args : objnull array - The array of arguments to construct the given case.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: objnull The constructed union case.

Create a union case value.

Extended Type: FSharpValue

unionCase : UnionCaseInfo

The description of the union case to create.

args : objnull array

The array of arguments to construct the given case.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: objnull

The constructed union case.

FSharpValue.PreComputeRecordConstructor(recordType, ?allowAccessToPrivateRepresentation)

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

Parameters:
    recordType : Type - The type of record to construct.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

recordType : Type

The type of record to construct.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

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, ?allowAccessToPrivateRepresentation)

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

Parameters:
    recordType : Type - The record type.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

Returns: ConstructorInfo A ConstructorInfo for the given record type.

Get a ConstructorInfo for a record type

Extended Type: FSharpValue

recordType : Type

The record type.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: ConstructorInfo

A ConstructorInfo for the given record type.

FSharpValue.PreComputeRecordReader(recordType, ?allowAccessToPrivateRepresentation)

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

Parameters:
    recordType : Type - The type of record to read.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

recordType : Type

The type of record to read.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: obj -> objnull array

An optimized reader for the given record type.

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

FSharpValue.PreComputeUnionConstructor(unionCase, ?allowAccessToPrivateRepresentation)

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

Parameters:
    unionCase : UnionCaseInfo - The description of the union case.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

unionCase : UnionCaseInfo

The description of the union case.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: objnull array -> objnull

A function for constructing values of the given union case.

FSharpValue.PreComputeUnionConstructorInfo(unionCase, ?allowAccessToPrivateRepresentation)

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

Parameters:
    unionCase : UnionCaseInfo - The description of the union case.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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

A method that constructs objects of the given case

Extended Type: FSharpValue

unionCase : UnionCaseInfo

The description of the union case.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: MethodInfo

The description of the constructor of the given union case.

FSharpValue.PreComputeUnionReader(unionCase, ?allowAccessToPrivateRepresentation)

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

Parameters:
    unionCase : UnionCaseInfo - The description of the union case to read.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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

Extended Type: FSharpValue

unionCase : UnionCaseInfo

The description of the union case to read.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: objnull -> objnull array

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

FSharpValue.PreComputeUnionTagMemberInfo(unionType, ?allowAccessToPrivateRepresentation)

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

Parameters:
    unionType : Type - The type of union to read.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

unionType : Type

The type of union to read.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: MemberInfo

The description of the union case reader.

FSharpValue.PreComputeUnionTagReader(unionType, ?allowAccessToPrivateRepresentation)

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

Parameters:
    unionType : Type - The type of union to optimize reading.
    ?allowAccessToPrivateRepresentation : bool - Optional flag that denotes accessibility of the private representation.

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.

Extended Type: FSharpValue

unionType : Type

The type of union to optimize reading.

?allowAccessToPrivateRepresentation : bool

Optional flag that denotes accessibility of the private representation.

Returns: objnull -> int

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

Type something to start searching.