// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespaceFSharp.Compiler.ComponentTests.Interop
openXunit
openFSharp.Test.Compiler
openFSharp.Test
openSystem
module``Deeply nested CSharpClasses``=
letcslib=
CSharp"""
using System;
namespace MyNamespace
{
public class OuterClass
{
public class InnerClass
{
public class MoreInnerClass
{
public static void somefunction() { }
}
}
}
}"""
[<Fact>]
let``Missing type outerclass generates good message and range``()=
letfsharpSource=
"""
let loss2 = MyNamespace.OoterClass.InnerClass.MoreInnerClass.somefunction() //Note the miss-typed functionname we expect a good error message
"""
FSharpfsharpSource
|>asExe
|>withReferences[cslib]
|>compile
|>withSingleDiagnostic(Error39,Line2,Col25,Line2,Col35,"The value, constructor, namespace or type 'OoterClass' is not defined. Maybe you want one of the following:
OuterClass")
[<Fact>]
let``Missing type nested type innerclass generates good message and range``()=
letfsharpSource=
"""
let loss2 = MyNamespace.OuterClass.InerClass.MoreInnerClass.somefunction() //Note the miss-typed InnerClass name we expect a good error message
"""
FSharpfsharpSource
|>asExe
|>withReferences[cslib]
|>compile
|>shouldFail
|>withSingleDiagnostic(Error39,Line2,Col36,Line2,Col45,"The type 'OuterClass' does not define the field, constructor or member 'InerClass'.")
[<Fact>]
let``Missing type nested type moreinnerclass generates good message and range``()=
letfsharpSource=
"""
let loss2 = MyNamespace.OuterClass.InnerClass.MoareInnerClass.somefunction() //Note the miss-typed MoreInnerClass we expect a good error message
"""
FSharpfsharpSource
|>asExe
|>withReferences[cslib]
|>compile
|>shouldFail
|>withSingleDiagnostic(Error39,Line2,Col47,Line2,Col62,"The type 'InnerClass' does not define the field, constructor or member 'MoareInnerClass'.")
[<Fact>]
let``Missing function generates good message and range``()=
letfsharpSource=
"""
let loss2 = MyNamespace.OuterClass.InnerClass.MoreInnerClass.somefunctoion() //Note the miss-typed somefunction we expect a good error message
"""
FSharpfsharpSource
|>asExe
|>withReferences[cslib]
|>compile
|>shouldFail
|>withSingleDiagnostic((Error39,Line2,Col62,Line2,Col75,"""The type 'MoreInnerClass' does not define the field, constructor or member 'somefunctoion'. Maybe you want one of the following: