Skip to content

Commit 6e50f75

Browse files
authored
Merge pull request #9550 from dotnet/merges/master-to-release/dev16.7
Merge master to release/dev16.7
2 parents 403f594 + 1ecc201 commit 6e50f75

14 files changed

Lines changed: 661 additions & 149 deletions

File tree

src/fsharp/AccessibilityLogic.fs

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -249,12 +249,53 @@ let private IsILMethInfoAccessible g amap m adType ad ilminfo =
249249
let GetILAccessOfILPropInfo (ILPropInfo(tinfo, pdef)) =
250250
let tdef = tinfo.RawMetadata
251251
let ilAccess =
252-
match pdef.GetMethod with
253-
| Some mref -> (resolveILMethodRef tdef mref).Access
254-
| None ->
255-
match pdef.SetMethod with
256-
| None -> ILMemberAccess.Public
257-
| Some mref -> (resolveILMethodRef tdef mref).Access
252+
match pdef.GetMethod, pdef.SetMethod with
253+
| Some mref, None
254+
| None, Some mref -> (resolveILMethodRef tdef mref).Access
255+
256+
| Some mrefGet, Some mrefSet ->
257+
//
258+
// Dotnet properties have a getter and a setter method, each of which can have a separate visibility public, protected, private etc ...
259+
// This code computes the visibility for the property by choosing the most visible method. This approximation is usefull for cases
260+
// where the compiler needs to know the visibility of the property.
261+
// The specific ordering for choosing the most visible is:
262+
// ILMemberAccess.Public,
263+
// ILMemberAccess.FamilyOrAssembly
264+
// ILMemberAccess.Assembly
265+
// ILMemberAccess.Family
266+
// ILMemberAccess.FamilyAndAssembly
267+
// ILMemberAccess.Private
268+
// ILMemberAccess.CompilerControlled
269+
//
270+
let getA = (resolveILMethodRef tdef mrefGet).Access
271+
let setA = (resolveILMethodRef tdef mrefSet).Access
272+
273+
// Use the accessors to determine the visibility of the property.
274+
// N.B. It is critical to keep the ordering in decreasing visibility order in the following match expression
275+
match getA, setA with
276+
| ILMemberAccess.Public, _
277+
| _, ILMemberAccess.Public -> ILMemberAccess.Public
278+
279+
| ILMemberAccess.FamilyOrAssembly, _
280+
| _, ILMemberAccess.FamilyOrAssembly -> ILMemberAccess.FamilyOrAssembly
281+
282+
| ILMemberAccess.Assembly, _
283+
| _, ILMemberAccess.Assembly -> ILMemberAccess.Assembly
284+
285+
| ILMemberAccess.Family, _
286+
| _, ILMemberAccess.Family -> ILMemberAccess.Family
287+
288+
| ILMemberAccess.FamilyAndAssembly, _
289+
| _, ILMemberAccess.FamilyAndAssembly -> ILMemberAccess.FamilyAndAssembly
290+
291+
| ILMemberAccess.Private, _
292+
| _, ILMemberAccess.Private -> ILMemberAccess.Private
293+
294+
| ILMemberAccess.CompilerControlled, _
295+
| _, ILMemberAccess.CompilerControlled -> ILMemberAccess.CompilerControlled
296+
297+
| None, None -> ILMemberAccess.Public
298+
258299
ilAccess
259300

260301
let IsILPropInfoAccessible g amap m ad pinfo =
@@ -323,8 +364,11 @@ let IsMethInfoAccessible amap m ad minfo = IsTypeAndMethInfoAccessible amap m ad
323364

324365
let IsPropInfoAccessible g amap m ad = function
325366
| ILProp ilpinfo -> IsILPropInfoAccessible g amap m ad ilpinfo
326-
| FSProp (_, _, Some vref, _)
327-
| FSProp (_, _, _, Some vref) -> IsValAccessible ad vref
367+
| FSProp (_, _, Some vref, None)
368+
| FSProp (_, _, None, Some vref) -> IsValAccessible ad vref
369+
| FSProp (_, _, Some vrefGet, Some vrefSet) ->
370+
// pick most accessible
371+
IsValAccessible ad vrefGet || IsValAccessible ad vrefSet
328372
#if !NO_EXTENSIONTYPING
329373
| ProvidedProp (amap, tppi, m) as pp->
330374
let access =
@@ -343,4 +387,3 @@ let IsPropInfoAccessible g amap m ad = function
343387

344388
let IsFieldInfoAccessible ad (rfref:RecdFieldInfo) =
345389
IsAccessible ad rfref.RecdField.Accessibility
346-

src/fsharp/service/SemanticClassification.fs

Lines changed: 213 additions & 49 deletions
Large diffs are not rendered by default.

src/fsharp/service/SemanticClassification.fsi

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
namespace FSharp.Compiler.SourceCodeServices
44

5-
open FSharp.Compiler
65
open FSharp.Compiler.AccessibilityLogic
76
open FSharp.Compiler.Import
87
open FSharp.Compiler.NameResolution
@@ -16,25 +15,43 @@ type SemanticClassificationType =
1615
| ReferenceType
1716
| ValueType
1817
| UnionCase
18+
| UnionCaseField
1919
| Function
2020
| Property
2121
| MutableVar
2222
| Module
23+
| NameSpace
2324
| Printf
2425
| ComputationExpression
2526
| IntrinsicFunction
2627
| Enumeration
2728
| Interface
2829
| TypeArgument
2930
| Operator
30-
| Disposable
31+
| DisposableType
32+
| DisposableValue
33+
| Method
34+
| ExtensionMethod
35+
| ConstructorForReferenceType
36+
| ConstructorForValueType
37+
| Literal
38+
| RecordField
39+
| MutableRecordField
40+
| RecordFieldAsFunction
41+
| Exception
42+
| Field
43+
| Event
44+
| Delegate
45+
| NamedArgument
46+
| Value
47+
| LocalValue
48+
| Type
49+
| TypeDef
3150

3251
/// Extension methods for the TcResolutions type.
3352
[<AutoOpen>]
3453
module internal TcResolutionsExtensions =
35-
3654
val (|CNR|) : cnr: CapturedNameResolution -> (Item * ItemOccurence * DisplayEnv * NameResolutionEnv * AccessorDomain * range)
3755

3856
type TcResolutions with
39-
4057
member GetSemanticClassification: g: TcGlobals * amap: ImportMap * formatSpecifierLocations: (range * int) [] * range: range option -> struct(range * SemanticClassificationType) []

tests/FSharp.Test.Utilities/TestFramework.fs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ module Commands =
9696
let csc exec cscExe flags srcFiles =
9797
exec cscExe (sprintf "%s %s" flags (srcFiles |> Seq.ofList |> String.concat " "))
9898

99+
let vbc exec vbcExe flags srcFiles =
100+
exec vbcExe (sprintf "%s %s" flags (srcFiles |> Seq.ofList |> String.concat " "))
101+
99102
let fsi exec fsiExe flags sources =
100103
exec fsiExe (sprintf "%s %s" flags (sources |> Seq.ofList |> String.concat " "))
101104

@@ -123,6 +126,8 @@ type TestConfig =
123126
{ EnvironmentVariables : Map<string, string>
124127
CSC : string
125128
csc_flags : string
129+
VBC : string
130+
vbc_flags : string
126131
BUILD_CONFIG : string
127132
FSC : string
128133
fsc_flags : string
@@ -213,7 +218,8 @@ let config configurationName envVars =
213218
let artifactsPath = repoRoot ++ "artifacts"
214219
let artifactsBinPath = artifactsPath ++ "bin"
215220
let coreClrRuntimePackageVersion = "3.0.0-preview-27318-01"
216-
let csc_flags = "/nologo"
221+
let csc_flags = "/nologo"
222+
let vbc_flags = "/nologo"
217223
let fsc_flags = "-r:System.Core.dll --nowarn:20 --define:COMPILED"
218224
let fsi_flags = "-r:System.Core.dll --nowarn:20 --define:INTERACTIVE --maxerrors:1 --abortonerror"
219225
let operatingSystem = getOperatingSystem ()
@@ -223,6 +229,7 @@ let config configurationName envVars =
223229
let requirePackage = requireFile packagesDir
224230
let requireArtifact = requireFile artifactsBinPath
225231
let CSC = requirePackage ("Microsoft.Net.Compilers" ++ "2.7.0" ++ "tools" ++ "csc.exe")
232+
let VBC = requirePackage ("Microsoft.Net.Compilers" ++ "2.7.0" ++ "tools" ++ "vbc.exe")
226233
let ILDASM_EXE = if operatingSystem = "win" then "ildasm.exe" else "ildasm"
227234
let ILDASM = requirePackage (("runtime." + operatingSystem + "-" + architectureMoniker + ".Microsoft.NETCore.ILDAsm") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ (operatingSystem + "-" + architectureMoniker) ++ "native" ++ ILDASM_EXE)
228235
let ILASM_EXE = if operatingSystem = "win" then "ilasm.exe" else "ilasm"
@@ -231,6 +238,7 @@ let config configurationName envVars =
231238
let coreclrdll = requirePackage (("runtime." + operatingSystem + "-" + architectureMoniker + ".Microsoft.NETCore.Runtime.CoreCLR") ++ coreClrRuntimePackageVersion ++ "runtimes" ++ (operatingSystem + "-" + architectureMoniker) ++ "native" ++ CORECLR_DLL)
232239
let PEVERIFY_EXE = if operatingSystem = "win" then "PEVerify.exe" else "PEVerify"
233240
let PEVERIFY = requireArtifact ("PEVerify" ++ configurationName ++ peverifyArchitecture ++ PEVERIFY_EXE)
241+
// let FSI_FOR_SCRIPTS = artifactsBinPath ++ "fsi" ++ configurationName ++ fsiArchitecture ++ "fsi.exe"
234242
let FSharpBuild = requireArtifact ("FSharp.Build" ++ configurationName ++ fsharpBuildArchitecture ++ "FSharp.Build.dll")
235243
let FSharpCompilerInteractiveSettings = requireArtifact ("FSharp.Compiler.Interactive.Settings" ++ configurationName ++ fsharpCompilerInteractiveSettingsArchitecture ++ "FSharp.Compiler.Interactive.Settings.dll")
236244

@@ -266,7 +274,8 @@ let config configurationName envVars =
266274
ILDASM = ILDASM
267275
ILASM = ILASM
268276
PEVERIFY = PEVERIFY
269-
CSC = CSC
277+
VBC = VBC
278+
CSC = CSC
270279
BUILD_CONFIG = configurationName
271280
FSC = FSC
272281
FSI = FSI
@@ -277,9 +286,10 @@ let config configurationName envVars =
277286
FSharpBuild = FSharpBuild
278287
FSharpCompilerInteractiveSettings = FSharpCompilerInteractiveSettings
279288
csc_flags = csc_flags
280-
fsc_flags = fsc_flags
289+
fsc_flags = fsc_flags
281290
fsi_flags = fsi_flags
282-
Directory=""
291+
vbc_flags = vbc_flags
292+
Directory=""
283293
DotNetExe = dotNetExe
284294
DefaultPlatform = defaultPlatform }
285295

@@ -506,6 +516,7 @@ let fscBothToOut cfg out arg = Printf.ksprintf (Commands.fsc cfg.Directory (exec
506516
let fscBothToOutExpectFail cfg out arg = Printf.ksprintf (Commands.fsc cfg.Directory (execBothToOutExpectFail cfg cfg.Directory out) cfg.DotNetExe cfg.FSC) arg
507517
let fscAppendErrExpectFail cfg errPath arg = Printf.ksprintf (Commands.fsc cfg.Directory (execAppendErrExpectFail cfg errPath) cfg.DotNetExe cfg.FSC) arg
508518
let csc cfg arg = Printf.ksprintf (Commands.csc (exec cfg) cfg.CSC) arg
519+
let vbc cfg arg = Printf.ksprintf (Commands.vbc (exec cfg) cfg.VBC) arg
509520
let ildasm cfg arg = Printf.ksprintf (Commands.ildasm (exec cfg) cfg.ILDASM) arg
510521
let ilasm cfg arg = Printf.ksprintf (Commands.ilasm (exec cfg) cfg.ILASM) arg
511522
let peverify cfg = Commands.peverify (exec cfg) cfg.PEVERIFY "/nologo"

0 commit comments

Comments
 (0)