|
| 1 | +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. |
| 2 | +namespace FSharp.Compiler.ComponentTests.Interop |
| 3 | + |
| 4 | +open Xunit |
| 5 | +open FSharp.Test.Compiler |
| 6 | +open FSharp.Test |
| 7 | +open System |
| 8 | + |
| 9 | +module ``Deeply nested CSharpClasses`` = |
| 10 | + |
| 11 | + let cslib = |
| 12 | + CSharp """ |
| 13 | +using System; |
| 14 | +
|
| 15 | +namespace MyNamespace |
| 16 | +{ |
| 17 | + public class OuterClass |
| 18 | + { |
| 19 | +
|
| 20 | + public class InnerClass |
| 21 | + { |
| 22 | +
|
| 23 | + public class MoreInnerClass |
| 24 | + { |
| 25 | + public static void somefunction() { } |
| 26 | + } |
| 27 | + } |
| 28 | + } |
| 29 | +}""" |
| 30 | + |
| 31 | + [<Fact>] |
| 32 | + let ``Missing type outerclass generates good message and range`` () = |
| 33 | + |
| 34 | + let fsharpSource = |
| 35 | + """ |
| 36 | +let loss2 = MyNamespace.OoterClass.InnerClass.MoreInnerClass.somefunction() //Note the miss-typed functionname we expect a good error message |
| 37 | +""" |
| 38 | + FSharp fsharpSource |
| 39 | + |> asExe |
| 40 | + |> withReferences [cslib] |
| 41 | + |> compile |
| 42 | + |> withSingleDiagnostic (Error 39, Line 2, Col 25, Line 2, Col 35, "The value, constructor, namespace or type 'OoterClass' is not defined. Maybe you want one of the following: |
| 43 | + OuterClass") |
| 44 | + |
| 45 | + [<Fact>] |
| 46 | + let ``Missing type nested type innerclass generates good message and range`` () = |
| 47 | + |
| 48 | + let fsharpSource = |
| 49 | + """ |
| 50 | +let loss2 = MyNamespace.OuterClass.InerClass.MoreInnerClass.somefunction() //Note the miss-typed InnerClass name we expect a good error message |
| 51 | +""" |
| 52 | + FSharp fsharpSource |
| 53 | + |> asExe |
| 54 | + |> withReferences [cslib] |
| 55 | + |> compile |
| 56 | + |> shouldFail |
| 57 | + |> withSingleDiagnostic (Error 39, Line 2, Col 36, Line 2, Col 45, "The type 'OuterClass' does not define the field, constructor or member 'InerClass'.") |
| 58 | + |
| 59 | + [<Fact>] |
| 60 | + let ``Missing type nested type moreinnerclass generates good message and range`` () = |
| 61 | + |
| 62 | + let fsharpSource = |
| 63 | + """ |
| 64 | +let loss2 = MyNamespace.OuterClass.InnerClass.MoareInnerClass.somefunction() //Note the miss-typed MoreInnerClass we expect a good error message |
| 65 | +""" |
| 66 | + FSharp fsharpSource |
| 67 | + |> asExe |
| 68 | + |> withReferences [cslib] |
| 69 | + |> compile |
| 70 | + |> shouldFail |
| 71 | + |> withSingleDiagnostic (Error 39, Line 2, Col 47, Line 2, Col 62, "The type 'InnerClass' does not define the field, constructor or member 'MoareInnerClass'.") |
| 72 | + |
| 73 | + [<Fact>] |
| 74 | + let ``Missing function generates good message and range`` () = |
| 75 | + |
| 76 | + let fsharpSource = |
| 77 | + """ |
| 78 | +let loss2 = MyNamespace.OuterClass.InnerClass.MoreInnerClass.somefunctoion() //Note the miss-typed somefunction we expect a good error message |
| 79 | +""" |
| 80 | + FSharp fsharpSource |
| 81 | + |> asExe |
| 82 | + |> withReferences [cslib] |
| 83 | + |> compile |
| 84 | + |> shouldFail |
| 85 | + |> withSingleDiagnostic ((Error 39, Line 2, Col 62, Line 2, Col 75, """The type 'MoreInnerClass' does not define the field, constructor or member 'somefunctoion'. Maybe you want one of the following: |
| 86 | + somefunction""")) |
0 commit comments