Skip to content

Commit e1c7b85

Browse files
authored
Merge pull request #680 from cloudRoutine/dotnetcore
enable netcore build with #EXTENSIONTYPNG
2 parents 7e18b8a + fcb9bc4 commit e1c7b85

File tree

9 files changed

+67
-28
lines changed

9 files changed

+67
-28
lines changed

src/fsharp/FSharp.Compiler.Service/project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@
190190
"COMPILER_SERVICE",
191191
"COMPILER_SERVICE_ASSUMES_FSHARP_CORE_4_4_0_0",
192192
"EXTENSIBLE_DUMPER",
193-
"EXTENSIONTYPING",
193+
// "EXTENSIONTYPING",
194194
"FSHARP_CORE_4_5",
195195
"FX_ATLEAST_35",
196196
"FX_ATLEAST_40",

src/fsharp/infos.fs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,9 +1594,8 @@ type ILFieldInfo =
15941594
| ILFieldInfo(_, x1), ILFieldInfo(_, x2) -> (x1 === x2)
15951595
#if EXTENSIONTYPING
15961596
| ProvidedField(_,fi1,_), ProvidedField(_,fi2,_)-> ProvidedFieldInfo.TaintedEquals (fi1, fi2)
1597-
#endif
15981597
| _ -> false
1599-
1598+
#endif
16001599
/// Get an (uninstantiated) reference to the field as an Abstract IL ILFieldRef
16011600
member x.ILFieldRef = rescopeILFieldRef x.ScopeRef (mkILFieldRef(x.ILTypeRef,x.FieldName,x.ILFieldType))
16021601
override x.ToString() = x.FieldName

src/fsharp/vs/Symbols.fs

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ module Impl =
102102
/// Convert an IL type definition accessibility into an F# accessibility
103103
let getApproxFSharpAccessibilityOfEntity (entity: EntityRef) =
104104
match metadataOfTycon entity.Deref with
105+
#if EXTENSIONTYPING
105106
| ProvidedTypeMetadata _info ->
106107
// This is an approximation - for generative type providers some type definitions can be private.
107108
taccessPublic
108-
109+
#endif
109110
| ILTypeMetadata (_,td) ->
110111
match td.Access with
111112
| ILTypeDefAccess.Public
@@ -253,7 +254,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
253254
member x.QualifiedName =
254255
checkIsResolved()
255256
let fail() = invalidOp (sprintf "the type '%s' does not have a qualified name" x.LogicalName)
257+
#if EXTENSIONTYPING
256258
if entity.IsTypeAbbrev || entity.IsProvidedErasedTycon || entity.IsNamespace then fail()
259+
#else
260+
if entity.IsTypeAbbrev || entity.IsNamespace then fail()
261+
#endif
257262
match entity.CompiledRepresentation with
258263
| CompiledTypeRepr.ILAsmNamed(tref,_,_) -> tref.QualifiedName
259264
| CompiledTypeRepr.ILAsmOpen _ -> fail()
@@ -266,7 +271,11 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
266271

267272
member x.TryFullName =
268273
if isUnresolved() then None
274+
#if EXTENSIONTYPING
269275
elif entity.IsTypeAbbrev || entity.IsProvidedErasedTycon then None
276+
#else
277+
elif entity.IsTypeAbbrev then None
278+
#endif
270279
elif entity.IsNamespace then Some entity.DemangledModuleOrNamespaceName
271280
else
272281
match entity.CompiledRepresentation with
@@ -303,7 +312,7 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
303312
member __.ArrayRank =
304313
checkIsResolved()
305314
rankOfArrayTyconRef cenv.g entity
306-
315+
#if EXTENSIONTYPING
307316
member __.IsProvided =
308317
isResolved() &&
309318
entity.IsProvided
@@ -319,11 +328,13 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
319328
member __.IsProvidedAndGenerated =
320329
isResolved() &&
321330
entity.IsProvidedGeneratedTycon
322-
331+
#endif
323332
member __.IsClass =
324333
isResolved() &&
325-
match metadataOfTycon entity.Deref with
334+
match metadataOfTycon entity.Deref with
335+
#if EXTENSIONTYPING
326336
| ProvidedTypeMetadata info -> info.IsClass
337+
#endif
327338
| ILTypeMetadata (_,td) -> (td.tdKind = ILTypeDefKind.Class)
328339
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.Deref.IsFSharpClassTycon
329340

@@ -342,7 +353,9 @@ and FSharpEntity(cenv:cenv, entity:EntityRef) =
342353
member __.IsDelegate =
343354
isResolved() &&
344355
match metadataOfTycon entity.Deref with
356+
#if EXTENSIONTYPING
345357
| ProvidedTypeMetadata info -> info.IsDelegate ()
358+
#endif
346359
| ILTypeMetadata (_,td) -> (td.tdKind = ILTypeDefKind.Delegate)
347360
| FSharpOrArrayOrByrefOrTupleOrExnTypeMetadata -> entity.IsFSharpDelegateTycon
348361

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

471484
member x.StaticParameters =
472485
match entity.TypeReprInfo with
486+
#if EXTENSIONTYPING
473487
| TProvidedTypeExtensionPoint info ->
474488
let m = x.DeclarationLocation
475489
let typeBeforeArguments = info.ProvidedType
476490
let staticParameters = typeBeforeArguments.PApplyWithProvider((fun (typeBeforeArguments,provider) -> typeBeforeArguments.GetStaticParameters(provider)), range=m)
477491
let staticParameters = staticParameters.PApplyArray(id, "GetStaticParameters", m)
478492
[| for p in staticParameters -> FSharpStaticParameter(cenv, p, m) |]
493+
#endif
479494
| _ -> [| |]
480495
|> makeReadOnlyCollection
481496

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

19631978
override __.ToString() =
19641979
if entityIsUnresolved attrib.TyconRef then "attribute ???" else "attribute " + attrib.TyconRef.CompiledName + "(...)"
1965-
1980+
#if EXTENSIONTYPING
19661981
and FSharpStaticParameter(cenv, sp: Tainted< ExtensionTyping.ProvidedParameterInfo >, m) =
19671982
inherit FSharpSymbol(cenv,
19681983
(fun () ->
@@ -2001,7 +2016,7 @@ and FSharpStaticParameter(cenv, sp: Tainted< ExtensionTyping.ProvidedParameterI
20012016
override x.GetHashCode() = hash x.Name
20022017
override x.ToString() =
20032018
"static parameter " + x.Name
2004-
2019+
#endif
20052020
and FSharpParameter(cenv, typ:TType, topArgInfo:ArgReprInfo, mOpt, isParamArrayArg, isOutArg, isOptionalArg) =
20062021
inherit FSharpSymbol(cenv,
20072022
(fun () ->
@@ -2073,7 +2088,9 @@ and FSharpAssembly internal (cenv, ccu: CcuThunk) =
20732088
member __.CodeLocation = ccu.SourceCodeDirectory
20742089
member __.FileName = ccu.FileName
20752090
member __.SimpleName = ccu.AssemblyName
2091+
#if EXTENSIONTYPING
20762092
member __.IsProviderGenerated = ccu.IsProviderGenerated
2093+
#endif
20772094
member __.Contents = FSharpAssemblySignature(cenv, ccu)
20782095

20792096
override x.ToString() = x.QualifiedName

src/fsharp/vs/Symbols.fsi

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ and [<Class>] FSharpAssembly =
9797

9898
/// The simple name for the assembly
9999
member SimpleName : string
100-
100+
#if EXTENSIONTYPING
101101
/// Indicates if the assembly was generated by a type provider and is due for static linking
102102
member IsProviderGenerated : bool
103-
103+
#endif
104104

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

171171
/// Get the rank of an array type
172172
member ArrayRank : int
173-
173+
#if EXTENSIONTYPING
174174
/// Indicates if the entity is a 'fake' symbol related to a static instantiation of a type provider
175175
member IsStaticInstantiation : bool
176176

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

183183
/// Indicates if the entity is a generated provided type
184184
member IsProvidedAndGenerated : bool
185-
185+
#endif
186186
/// Indicates if the entity is an F# module definition
187187
member IsFSharpModule: bool
188188

189189
/// Get the generic parameters, possibly including unit-of-measure parameters
190190
member GenericParameters: IList<FSharpGenericParameter>
191-
191+
#if EXTENSIONTYPING
192192
/// Get the static parameters for a provided type
193193
member StaticParameters: IList<FSharpStaticParameter>
194-
194+
#endif
195195
/// Indicates that a module is compiled to a class with the given mangled name. The mangling is reversed during lookup
196196
member HasFSharpModuleSuffix : bool
197197

@@ -478,7 +478,7 @@ and [<Class>] FSharpGenericParameter =
478478

479479
/// Get the declared or inferred constraints for the type parameter
480480
member Constraints: IList<FSharpGenericParameterConstraint>
481-
481+
#if EXTENSIONTYPING
482482
/// A subtype of FSharpSymbol that represents a static parameter to an F# type provider
483483
and [<Class>] FSharpStaticParameter =
484484

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

502502
[<System.ObsoleteAttribute("This member is no longer used, use IsOptional instead")>]
503503
member HasDefaultValue : bool
504-
504+
#endif
505505

506506
/// Represents further information about a member constraint on a generic type parameter
507507
and [<Class; NoEquality; NoComparison>]

src/fsharp/vs/service.fs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ module internal Params =
203203
| _ -> None
204204
#endif
205205

206+
#if EXTENSIONTYPING
206207
let StaticParamsOfItem (infoReader:InfoReader) m denv d =
207208
let amap = infoReader.amap
208209
let g = infoReader.g
209210
match d with
210-
#if EXTENSIONTYPING
211211
| ItemIsWithStaticArguments m g staticParameters ->
212212
staticParameters
213213
|> Array.map (fun sp ->
@@ -219,8 +219,10 @@ module internal Params =
219219
name = spName,
220220
canonicalTypeTextForSorting = spKind,
221221
display = sprintf "%s%s: %s" (if spOpt then "?" else "") spName spKind))
222-
#endif
223222
| _ -> [| |]
223+
#else
224+
let StaticParamsOfItem _infoReader _m _denv _d = [||]
225+
#endif
224226

225227
let rec ParamsOfItem (infoReader:InfoReader) m denv d =
226228
let amap = infoReader.amap
@@ -386,7 +388,11 @@ type FSharpMethodGroup( name: string, unsortedMethods: FSharpMethodGroupItem[] )
386388
description = FSharpToolTipText [FormatDescriptionOfItem true infoReader m denv item],
387389
typeText = FormatReturnTypeOfItem infoReader m denv item,
388390
parameters = (Params.ParamsOfItem infoReader m denv item |> Array.ofList),
391+
#if EXTENSIONTYPING
389392
hasParameters = (match item with Params.ItemIsProvidedTypeWithStaticArguments m g _ -> false | _ -> true),
393+
#else
394+
hasParameters = true,
395+
#endif
390396
staticParameters = Params.StaticParamsOfItem infoReader m denv item
391397
))
392398
#if FX_ATLEAST_40
@@ -2646,14 +2652,15 @@ type BackgroundCompiler(referenceResolver, projectCacheSize, keepAssemblyContent
26462652

26472653
member bc.NotifyProjectCleaned(options : FSharpProjectOptions) =
26482654
match incrementalBuildersCache.TryGetAny options with
2649-
| None -> ()
2650-
| Some (builderOpt, _, _) ->
2655+
| None -> ()
26512656
#if EXTENSIONTYPING
2657+
| Some (builderOpt, _, _) ->
26522658
builderOpt |> Option.iter (fun builder ->
26532659
if builder.ThereAreLiveTypeProviders then
26542660
bc.InvalidateConfiguration(options))
2655-
#else
26562661
()
2662+
#else
2663+
| Some _ -> ()
26572664
#endif
26582665

26592666
member bc.CheckProjectInBackground(options) =

tests/service/Common.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,12 @@ let attribsOfSymbol (s:FSharpSymbol) =
203203
if v.IsFSharpUnion then yield "union"
204204
if v.IsInterface then yield "interface"
205205
if v.IsMeasure then yield "measure"
206+
#if EXTENSIONTYPING
206207
if v.IsProvided then yield "provided"
207208
if v.IsStaticInstantiation then yield "staticinst"
208209
if v.IsProvidedAndErased then yield "erased"
209210
if v.IsProvidedAndGenerated then yield "generated"
211+
#endif
210212
if v.IsUnresolved then yield "unresolved"
211213
if v.IsValueType then yield "valuetype"
212214

tests/service/ExprTests.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ let bool2 = false
529529
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)
530530

531531
//<@ let x = Some(3) in x.IsSome @>
532-
532+
#if EXTENSIONTYPING
533533
[<Test>]
534534
let ``Test Declarations project1`` () =
535535
let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously
@@ -637,6 +637,7 @@ let ``Test Declarations project1`` () =
637637
"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)";
638638
"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)"]
639639
()
640+
#endif
640641

641642
//---------------------------------------------------------------------------------------------------------
642643
// This big list expression was causing us trouble

tests/service/FSharp.Compiler.Service.Tests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</PropertyGroup>
3939
<PropertyGroup>
4040
<DefineConstants Condition="'$(TargetFrameworkVersion)' == 'v4.5'">$(DefineConstants);FX_ATLEAST_45</DefineConstants>
41-
<DefineConstants>$(DefineConstants);FX_ATLEAST_40</DefineConstants>
41+
<DefineConstants>$(DefineConstants);FX_ATLEAST_40;EXTENSIONTYPING</DefineConstants>
4242
</PropertyGroup>
4343
<PropertyGroup>
4444
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>

tests/service/ProjectAnalysisTests.fs

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ let ``Test project1 whole project errors`` () =
108108
let ``Test Project1 should have protected FullName and TryFullName return same results`` () =
109109
let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously
110110
let rec getFullNameComparisons (entity: FSharpEntity) =
111+
#if EXTENSIONTYPING
111112
seq { if not entity.IsProvided && entity.Accessibility.IsPublic then
113+
#else
114+
seq { if entity.Accessibility.IsPublic then
115+
#endif
112116
yield (entity.TryFullName = try Some entity.FullName with _ -> None)
113117
for e in entity.NestedEntities do
114118
yield! getFullNameComparisons e }
@@ -121,8 +125,12 @@ let ``Test Project1 should have protected FullName and TryFullName return same r
121125
[<Test; Ignore "FCS should not throw exceptions on FSharpEntity.BaseType">]
122126
let ``Test project1 should not throw exceptions on entities from referenced assemblies`` () =
123127
let wholeProjectResults = checker.ParseAndCheckProject(Project1.options) |> Async.RunSynchronously
124-
let rec getAllBaseTypes (entity: FSharpEntity) =
128+
let rec getAllBaseTypes (entity: FSharpEntity) =
129+
#if EXTENSIONTYPING
125130
seq { if not entity.IsProvided && entity.Accessibility.IsPublic then
131+
#else
132+
seq{
133+
#endif
126134
if not entity.IsUnresolved then yield entity.BaseType
127135
for e in entity.NestedEntities do
128136
yield! getAllBaseTypes e }
@@ -520,6 +528,7 @@ let ``Test project1 all uses of all symbols`` () =
520528
set expected - set allUsesOfAllSymbols |> shouldEqual Set.empty
521529
(set expected = set allUsesOfAllSymbols) |> shouldEqual true
522530

531+
#if EXTENSIONTYPING
523532
[<Test>]
524533
let ``Test file explicit parse symbols`` () =
525534

@@ -606,7 +615,7 @@ let ``Test file explicit parse all symbols`` () =
606615
("C", "file1", ((9, 15), (9, 16)), ["class"]);
607616
("CAbbrev", "file1", ((9, 5), (9, 12)), ["abbrev"]);
608617
("M", "file1", ((1, 7), (1, 8)), ["module"])]
609-
618+
#endif
610619

611620
//-----------------------------------------------------------------------------------------
612621

@@ -3937,7 +3946,7 @@ type Use() =
39373946
let fileNames = [fileName1]
39383947
let args = mkProjectCommandLineArgs (dllName, fileNames)
39393948
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)
3940-
3949+
#if EXTENSIONTYPING
39413950
[<Test>]
39423951
let ``Test project28 all symbols in signature`` () =
39433952
let wholeProjectResults = checker.ParseAndCheckProject(Project28.options) |> Async.RunSynchronously
@@ -3947,14 +3956,18 @@ let ``Test project28 all symbols in signature`` () =
39473956
|> Seq.map (fun s ->
39483957
let typeName = s.GetType().Name
39493958
match s with
3959+
#if EXTENSIONTYPING
39503960
| :? FSharpEntity as fse -> typeName, fse.DisplayName, fse.XmlDocSig
3961+
#endif
39513962
| :? FSharpField as fsf -> typeName, fsf.DisplayName, fsf.XmlDocSig
39523963
| :? FSharpMemberOrFunctionOrValue as fsm -> typeName, fsm.DisplayName, fsm.XmlDocSig
39533964
| :? FSharpUnionCase as fsu -> typeName, fsu.DisplayName, fsu.XmlDocSig
39543965
| :? FSharpActivePatternCase as ap -> typeName, ap.DisplayName, ap.XmlDocSig
39553966
| :? FSharpGenericParameter as fsg -> typeName, fsg.DisplayName, ""
39563967
| :? FSharpParameter as fsp -> typeName, fsp.DisplayName, ""
3968+
#if EXTENSIONTYPING
39573969
| :? FSharpStaticParameter as fss -> typeName, fss.DisplayName, ""
3970+
#endif
39583971
| _ -> typeName, s.DisplayName, "unknown")
39593972
|> Seq.toArray
39603973

@@ -3992,7 +4005,7 @@ let ``Test project28 all symbols in signature`` () =
39924005
("FSharpMemberOrFunctionOrValue", "( .ctor )", "M:M.Use.#ctor");
39934006
("FSharpMemberOrFunctionOrValue", "Test", "M:M.Use.Test``1(``0)");
39944007
("FSharpGenericParameter", "?", "")|]
3995-
4008+
#endif
39964009
module Project29 =
39974010
open System.IO
39984011

0 commit comments

Comments
 (0)