Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fsharp/FSharp.Compiler.Service/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"COMPILER_SERVICE",
"COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0",
"EXTENSIBLE_DUMPER",
"EXTENSIONTYPING",
// "EXTENSIONTYPING",
"FSHARP_CORE_4_5",
"FX_ATLEAST_35",
"FX_ATLEAST_40",
Expand Down
3 changes: 1 addition & 2 deletions src/fsharp/infos.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,9 +1594,8 @@ type ILFieldInfo =
| ILFieldInfo(_, x1), ILFieldInfo(_, x2) -> (x1 === x2)
#if EXTENSIONTYPING
| ProvidedField(_,fi1,_), ProvidedField(_,fi2,_)-> ProvidedFieldInfo.TaintedEquals (fi1, fi2)
#endif
| _ -> false

#endif
/// Get an (uninstantiated) reference to the field as an Abstract IL ILFieldRef
member x.ILFieldRef = rescopeILFieldRef x.ScopeRef (mkILFieldRef(x.ILTypeRef,x.FieldName,x.ILFieldType))
override x.ToString() = x.FieldName
Expand Down
29 changes: 23 additions & 6 deletions src/fsharp/vs/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,11 @@ module Impl =
/// Convert an IL type definition accessibility into an F# accessibility
let getApproxFSharpAccessibilityOfEntity (entity: EntityRef) =
match metadataOfTycon entity.Deref with
#if EXTENSIONTYPING
| ProvidedTypeMetadata _info ->
// This is an approximation - for generative type providers some type definitions can be private.
taccessPublic

#endif
| ILTypeMetadata (_,td) ->
match td.Access with
| ILTypeDefAccess.Public
Expand Down Expand Up @@ -253,7 +254,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
member x.QualifiedName =
checkIsResolved()
let fail() = invalidOp (sprintf "the type '%s' does not have a qualified name" x.LogicalName)
#if EXTENSIONTYPING
if entity.IsTypeAbbrev || entity.IsProvidedErasedTycon || entity.IsNamespace then fail()
#else
if entity.IsTypeAbbrev || entity.IsNamespace then fail()
#endif
match entity.CompiledRepresentation with
| CompiledTypeRepr.ILAsmNamed(tref,_,_) -> tref.QualifiedName
| CompiledTypeRepr.ILAsmOpen _ -> fail()
Expand All @@ -266,7 +271,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =

member x.TryFullName =
if isUnresolved() then None
#if EXTENSIONTYPING
elif entity.IsTypeAbbrev || entity.IsProvidedErasedTycon then None
#else
elif entity.IsTypeAbbrev then None
#endif
elif entity.IsNamespace then Some entity.DemangledModuleOrNamespaceName
else
match entity.CompiledRepresentation with
Expand Down Expand Up @@ -303,7 +312,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
member __.ArrayRank =
checkIsResolved()
rankOfArrayTyconRef cenv.g entity

#if EXTENSIONTYPING
member __.IsProvided =
isResolved() &&
entity.IsProvided
Expand All @@ -319,11 +328,13 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
member __.IsProvidedAndGenerated =
isResolved() &&
entity.IsProvidedGeneratedTycon

#endif
member __.IsClass =
isResolved() &&
match metadataOfTycon entity.Deref with
match metadataOfTycon entity.Deref with
#if EXTENSIONTYPING
| ProvidedTypeMetadata info -> info.IsClass
#endif
| ILTypeMetadata (_,td) -> (td.tdKind = ILTypeDefKind.Class)
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.Deref.IsFSharpClassTycon

Expand All @@ -342,7 +353,9 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
member __.IsDelegate =
isResolved() &&
match metadataOfTycon entity.Deref with
#if EXTENSIONTYPING
| ProvidedTypeMetadata info -> info.IsDelegate ()
#endif
| ILTypeMetadata (_,td) -> (td.tdKind = ILTypeDefKind.Delegate)
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.IsFSharpDelegateTycon

Expand Down Expand Up @@ -470,12 +483,14 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =

member x.StaticParameters =
match entity.TypeReprInfo with
#if EXTENSIONTYPING
| TProvidedTypeExtensionPoint info ->
let m = x.DeclarationLocation
let typeBeforeArguments = info.ProvidedType
let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments,provider) -> typeBeforeArguments.GetStaticParameters(provider)), range=m)
let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m)
[| for p in staticParameters -> FSharpStaticParameter(cenv, p, m) |]
#endif
| _ -> [| |]
|> makeReadOnlyCollection

Expand Down Expand Up @@ -1962,7 +1977,7 @@ and FSharpAttribute(cenv: cenv, attrib: AttribInfo) =

override __.ToString() =
if entityIsUnresolved attrib.TyconRef then "attribute ???" else "attribute " + attrib.TyconRef.CompiledName + "(...)"

#if EXTENSIONTYPING
and FSharpStaticParameter(cenv, sp: Tainted< ExtensionTyping.ProvidedParameterInfo >, m) =
inherit FSharpSymbol(cenv,
(fun () ->
Expand Down Expand Up @@ -2001,7 +2016,7 @@ and FSharpStaticParameter(cenv, sp: Tainted< ExtensionTyping.ProvidedParameterI
override x.GetHashCode() = hash x.Name
override x.ToString() =
"static parameter " + x.Name

#endif
and FSharpParameter(cenv, typ:TType, topArgInfo:ArgReprInfo, mOpt, isParamArrayArg, isOutArg, isOptionalArg) =
inherit FSharpSymbol(cenv,
(fun () ->
Expand Down Expand Up @@ -2073,7 +2088,9 @@ and FSharpAssembly internal (cenv, ccu: CcuThunk) =
member __.CodeLocation = ccu.SourceCodeDirectory
member __.FileName = ccu.FileName
member __.SimpleName = ccu.AssemblyName
#if EXTENSIONTYPING
member __.IsProviderGenerated = ccu.IsProviderGenerated
#endif
member __.Contents = FSharpAssemblySignature(cenv, ccu)

override x.ToString() = x.QualifiedName
Expand Down
16 changes: 8 additions & 8 deletions src/fsharp/vs/Symbols.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,10 @@ and [<Class>] FSharpAssembly =

/// The simple name for the assembly
member SimpleName : string

#if EXTENSIONTYPING
/// Indicates if the assembly was generated by a type provider and is due for static linking
member IsProviderGenerated : bool

#endif

/// Represents an inferred signature of part of an assembly as seen by the F# language
and [<Class>] FSharpAssemblySignature =
Expand Down Expand Up @@ -170,7 +170,7 @@ and [<Class>] FSharpEntity =

/// Get the rank of an array type
member ArrayRank : int

#if EXTENSIONTYPING
/// Indicates if the entity is a 'fake' symbol related to a static instantiation of a type provider
member IsStaticInstantiation : bool

Expand All @@ -182,16 +182,16 @@ and [<Class>] FSharpEntity =

/// Indicates if the entity is a generated provided type
member IsProvidedAndGenerated : bool

#endif
/// Indicates if the entity is an F# module definition
member IsFSharpModule: bool

/// Get the generic parameters, possibly including unit-of-measure parameters
member GenericParameters: IList<FSharpGenericParameter>

#if EXTENSIONTYPING
/// Get the static parameters for a provided type
member StaticParameters: IList<FSharpStaticParameter>

#endif
/// Indicates that a module is compiled to a class with the given mangled name. The mangling is reversed during lookup
member HasFSharpModuleSuffix : bool

Expand Down Expand Up @@ -478,7 +478,7 @@ and [<Class>] FSharpGenericParameter =

/// Get the declared or inferred constraints for the type parameter
member Constraints: IList<FSharpGenericParameterConstraint>

#if EXTENSIONTYPING
/// A subtype of FSharpSymbol that represents a static parameter to an F# type provider
and [<Class>] FSharpStaticParameter =

Expand All @@ -501,7 +501,7 @@ and [<Class>] FSharpStaticParameter =

[<System.ObsoleteAttribute("This member is no longer used, use IsOptional instead")>]
member HasDefaultValue : bool

#endif

/// Represents further information about a member constraint on a generic type parameter
and [<Class; NoEquality; NoComparison>]
Expand Down
17 changes: 12 additions & 5 deletions src/fsharp/vs/service.fs
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ module internal Params =
| _ -> None
#endif

#if EXTENSIONTYPING
let StaticParamsOfItem (infoReader:InfoReader) m denv d =
let amap = infoReader.amap
let g = infoReader.g
match d with
#if EXTENSIONTYPING
| ItemIsWithStaticArguments m g staticParameters ->
staticParameters
|> Array.map (fun sp ->
Expand All @@ -219,8 +219,10 @@ module internal Params =
name = spName,
canonicalTypeTextForSorting = spKind,
display = sprintf "%s%s: %s" (if spOpt then "?" else "") spName spKind))
#endif
| _ -> [| |]
#else
let StaticParamsOfItem _infoReader _m _denv _d = [||]
#endif

let rec ParamsOfItem (infoReader:InfoReader) m denv d =
let amap = infoReader.amap
Expand Down Expand Up @@ -386,7 +388,11 @@ type FSharpMethodGroup( name: string, unsortedMethods: FSharpMethodGroupItem[] )
description = FSharpToolTipText [FormatDescriptionOfItem true infoReader m denv item],
typeText = FormatReturnTypeOfItem infoReader m denv item,
parameters = (Params.ParamsOfItem infoReader m denv item |> Array.ofList),
#if EXTENSIONTYPING
hasParameters = (match item with Params.ItemIsProvidedTypeWithStaticArguments m g _ -> false | _ -> true),
#else
hasParameters = true,
#endif
staticParameters = Params.StaticParamsOfItem infoReader m denv item
))
#if FX_ATLEAST_40
Expand Down Expand Up @@ -2646,14 +2652,15 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent

member bc.NotifyProjectCleaned(options : FSharpProjectOptions) =
match incrementalBuildersCache.TryGetAny options with
| None -> ()
| Some (builderOpt, _, _) ->
| None -> ()
#if EXTENSIONTYPING
| Some (builderOpt, _, _) ->
builderOpt |> Option.iter (fun builder ->
if builder.ThereAreLiveTypeProviders then
bc.InvalidateConfiguration(options))
#else
()
#else
| Some _ -> ()
#endif

member bc.CheckProjectInBackground(options) =
Expand Down
2 changes: 2 additions & 0 deletions tests/service/Common.fs
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,12 @@ let attribsOfSymbol (s:FSharpSymbol) =
if v.IsFSharpUnion then yield "union"
if v.IsInterface then yield "interface"
if v.IsMeasure then yield "measure"
#if EXTENSIONTYPING
if v.IsProvided then yield "provided"
if v.IsStaticInstantiation then yield "staticinst"
if v.IsProvidedAndErased then yield "erased"
if v.IsProvidedAndGenerated then yield "generated"
#endif
if v.IsUnresolved then yield "unresolved"
if v.IsValueType then yield "valuetype"

Expand Down
3 changes: 2 additions & 1 deletion tests/service/ExprTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ let bool2 = false
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)

//<@ let x = Some(3) in x.IsSome @>

#if EXTENSIONTYPING
[<Test>]
let ``Test Declarations project1`` () =
let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously
Expand Down Expand Up @@ -637,6 +637,7 @@ let ``Test Declarations project1`` () =
"let f = ((); fun a -> fun b -> Operators.op_Addition<Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (a,b)) @ (246,8--247,24)";
"let letLambdaRes = Operators.op_PipeRight<(Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int) Microsoft.FSharp.Collections.list,Microsoft.FSharp.Core.int Microsoft.FSharp.Collections.list> (Cons((1,2),Empty()),let mapping: Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int -> Microsoft.FSharp.Core.int = fun tupledArg -> let a: Microsoft.FSharp.Core.int = tupledArg.Item0 in let b: Microsoft.FSharp.Core.int = tupledArg.Item1 in (LetLambda.f () a) b in fun list -> ListModule.Map<Microsoft.FSharp.Core.int * Microsoft.FSharp.Core.int,Microsoft.FSharp.Core.int> (mapping,list)) @ (249,19--249,71)"]
()
#endif

//---------------------------------------------------------------------------------------------------------
// This big list expression was causing us trouble
Expand Down
2 changes: 1 addition & 1 deletion tests/service/FSharp.Compiler.Service.Tests.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="'$(TargetFrameworkVersion)' == 'v4.5'">$(DefineConstants);FX_ATLEAST_45</DefineConstants>
<DefineConstants>$(DefineConstants);FX_ATLEAST_40</DefineConstants>
<DefineConstants>$(DefineConstants);FX_ATLEAST_40;EXTENSIONTYPING</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
Expand Down
21 changes: 17 additions & 4 deletions tests/service/ProjectAnalysisTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ let ``Test project1 whole project errors`` () =
let ``Test Project1 should have protected FullName and TryFullName return same results`` () =
let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously
let rec getFullNameComparisons (entity: FSharpEntity) =
#if EXTENSIONTYPING
seq { if not entity.IsProvided && entity.Accessibility.IsPublic then
#else
seq { if entity.Accessibility.IsPublic then
#endif
yield (entity.TryFullName = try Some entity.FullName with _ -> None)
for e in entity.NestedEntities do
yield! getFullNameComparisons e }
Expand All @@ -121,8 +125,12 @@ let ``Test Project1 should have protected FullName and TryFullName return same r
[<Test; Ignore "FCS should not throw exceptions on FSharpEntity.BaseType">]
let ``Test project1 should not throw exceptions on entities from referenced assemblies`` () =
let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously
let rec getAllBaseTypes (entity: FSharpEntity) =
let rec getAllBaseTypes (entity: FSharpEntity) =
#if EXTENSIONTYPING
seq { if not entity.IsProvided && entity.Accessibility.IsPublic then
#else
seq{
#endif
if not entity.IsUnresolved then yield entity.BaseType
for e in entity.NestedEntities do
yield! getAllBaseTypes e }
Expand Down Expand Up @@ -520,6 +528,7 @@ let ``Test project1 all uses of all symbols`` () =
set expected - set allUsesOfAllSymbols |> shouldEqual Set.empty
(set expected = set allUsesOfAllSymbols) |> shouldEqual true

#if EXTENSIONTYPING
[<Test>]
let ``Test file explicit parse symbols`` () =

Expand Down Expand Up @@ -606,7 +615,7 @@ let ``Test file explicit parse all symbols`` () =
("C", "file1", ((9, 15), (9, 16)), ["class"]);
("CAbbrev", "file1", ((9, 5), (9, 12)), ["abbrev"]);
("M", "file1", ((1, 7), (1, 8)), ["module"])]

#endif

//-----------------------------------------------------------------------------------------

Expand Down Expand Up @@ -3937,7 +3946,7 @@ type Use() =
let fileNames = [fileName1]
let args = mkProjectCommandLineArgs (dllName, fileNames)
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)

#if EXTENSIONTYPING
[<Test>]
let ``Test project28 all symbols in signature`` () =
let wholeProjectResults = checker.ParseAndCheckProject(Project28.options) |> Async.RunSynchronously
Expand All @@ -3947,14 +3956,18 @@ let ``Test project28 all symbols in signature`` () =
|> Seq.map (fun s ->
let typeName = s.GetType().Name
match s with
#if EXTENSIONTYPING
| :? FSharpEntity as fse -> typeName, fse.DisplayName, fse.XmlDocSig
#endif
| :? FSharpField as fsf -> typeName, fsf.DisplayName, fsf.XmlDocSig
| :? FSharpMemberOrFunctionOrValue as fsm -> typeName, fsm.DisplayName, fsm.XmlDocSig
| :? FSharpUnionCase as fsu -> typeName, fsu.DisplayName, fsu.XmlDocSig
| :? FSharpActivePatternCase as ap -> typeName, ap.DisplayName, ap.XmlDocSig
| :? FSharpGenericParameter as fsg -> typeName, fsg.DisplayName, ""
| :? FSharpParameter as fsp -> typeName, fsp.DisplayName, ""
#if EXTENSIONTYPING
| :? FSharpStaticParameter as fss -> typeName, fss.DisplayName, ""
#endif
| _ -> typeName, s.DisplayName, "unknown")
|> Seq.toArray

Expand Down Expand Up @@ -3992,7 +4005,7 @@ let ``Test project28 all symbols in signature`` () =
("FSharpMemberOrFunctionOrValue", "( .ctor )", "M:M.Use.#ctor");
("FSharpMemberOrFunctionOrValue", "Test", "M:M.Use.Test``1(``0)");
("FSharpGenericParameter", "?", "")|]

#endif
module Project29 =
open System.IO

Expand Down