Skip to content

Syntax Colorizer doesn't recognise computation expressions with generic types #110

Closed
@KevinRansom

Description

@KevinRansom

Originally opened at CodePlex by ashtonkj

The default syntax highlighter will highlight a computation expression without a generic type parameter, but once a generic type parameter is provided then the syntax highlighter will not colour the computation expression. See the following code for example (In the default Visual Studio dark theme ceBoolBuilder is coloured blue, but ceBuilder<System.DateTimeKind> is not):

type TestCE<'T>() =
    member this.ReturnFrom(value) =
        if System.String.IsNullOrEmpty(value) then
            None
        else
            let typeT = typeof<'T>
            if typeT.IsEnum then
                box (System.Enum.Parse(typeT, value)) |> Some
            else if typeT = typeof<bool> then
                box (bool.Parse(value)) |> Some
            else None

let ceBuilder<'T> = TestCE<'T>()
let ceBoolBuilder = TestCE<bool>()

let exampleIncorrect = ceBuilder<System.DateTimeKind> { return! System.DateTimeKind.Local.ToString() }
let exampleCorrect = ceBoolBuilder { return! "true" }
Image

comments
coza99 wrote Sep 3, 2014 at 3:54 AM [x]
This is also true if the builder function is parameterized. Taking the case from above an example

type TextCE<'T>(name:string) = 
        ..........
let ceBuilder<'T> name = TestCE<'T>(name)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions