diff --git a/docs/release-notes/.FSharp.Compiler.Service/11.0.200.md b/docs/release-notes/.FSharp.Compiler.Service/11.0.200.md index a3dd9b5d252..1cac5c5de1c 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/11.0.200.md +++ b/docs/release-notes/.FSharp.Compiler.Service/11.0.200.md @@ -1,5 +1,6 @@ ### Added +* Completion: respect EditorBrowsableAttribute ([PR #20729](https://github.com/dotnet/fsharp/pull/20729)) * Runtime-async sequences allow awaits inside `try/with` bodies, filters and handlers, and reject overlapping `MoveNextAsync` calls. ([PR #20655](https://github.com/dotnet/fsharp/pull/20655)) * F# Interactive gains a JSON-RPC server mode, `--fsi-server-jsonrpc:`, in which a host submits interactions over a named pipe and receives structured results — diagnostics with positions, escaping exceptions, the values each interaction bound, and the session's own process id — instead of recovering them by looking for a `SERVER-PROMPT>` marker in the output text. Program output continues to flow through the redirected console streams. The pipe admits only the user running the session; `--fsi-server-client-pid:` names the host process whose exit ends the session. `FsiEvaluationSession` exposes both options as `JsonRpcServerPipeName` and `JsonRpcClientProcessId`. The mode is part of the .NET fsi only. ([PR #20396](https://github.com/dotnet/fsharp/pull/20396)) diff --git a/src/Compiler/AbstractIL/il.fs b/src/Compiler/AbstractIL/il.fs index 7107c5566b7..71f2aea096b 100644 --- a/src/Compiler/AbstractIL/il.fs +++ b/src/Compiler/AbstractIL/il.fs @@ -1309,6 +1309,8 @@ type WellKnownILAttributes = | NotNullIfNotNullAttribute = (1u <<< 25) | OverloadResolutionPriorityAttribute = (1u <<< 26) | RequireNamedArgumentsAttribute = (1u <<< 27) + | EditorBrowsableNever = (1u <<< 28) + | EditorBrowsableAdvanced = (1u <<< 29) | NotComputed = (1u <<< 31) [] diff --git a/src/Compiler/AbstractIL/il.fsi b/src/Compiler/AbstractIL/il.fsi index 4d0c43c8260..eb49519b851 100644 --- a/src/Compiler/AbstractIL/il.fsi +++ b/src/Compiler/AbstractIL/il.fsi @@ -921,6 +921,8 @@ type WellKnownILAttributes = | NotNullIfNotNullAttribute = (1u <<< 25) | OverloadResolutionPriorityAttribute = (1u <<< 26) | RequireNamedArgumentsAttribute = (1u <<< 27) + | EditorBrowsableNever = (1u <<< 28) + | EditorBrowsableAdvanced = (1u <<< 29) | NotComputed = (1u <<< 31) /// Represents the efficiency-oriented storage of ILAttributes in another item. @@ -930,6 +932,8 @@ type ILAttributesStored = member HasWellKnownAttribute: flag: WellKnownILAttributes * compute: (ILAttributes -> WellKnownILAttributes) -> bool + member GetOrComputeWellKnownFlags: compute: (ILAttributes -> WellKnownILAttributes) -> WellKnownILAttributes + static member CreateReader: idx: int32 * f: (int32 -> ILAttribute[]) -> ILAttributesStored static member CreateGiven: attrs: ILAttributes -> ILAttributesStored diff --git a/src/Compiler/Checking/AttributeChecking.fs b/src/Compiler/Checking/AttributeChecking.fs index e0847a6a8d2..c059fb50c8e 100755 --- a/src/Compiler/Checking/AttributeChecking.fs +++ b/src/Compiler/Checking/AttributeChecking.fs @@ -6,6 +6,7 @@ module internal FSharp.Compiler.AttributeChecking open System open System.Collections.Generic +open System.ComponentModel open FSharp.Compiler.Text.Range open Internal.Utilities.Library open FSharp.Compiler.AbstractIL.IL @@ -471,32 +472,47 @@ let private CheckProvidedAttributes (g: TcGlobals) m (provAttribs: Tainted reportObsoleteDiagnostic m #endif -/// Indicate if IL attributes contain 'ObsoleteAttribute'. Used to suppress the item in intellisense. -/// Uses cached well-known flags for O(1) check when ILAttributesStored is available. -/// See also: CheckILAttributesForUnseen for the non-cached variant on ILAttributes. -let CheckILAttributesForUnseenStored (g: TcGlobals) (cattrsStored: ILAttributesStored) = - if cattrsStored.HasWellKnownAttribute(g, WellKnownILAttributes.ObsoleteAttribute) then - not (cattrsStored.HasWellKnownAttribute(g, WellKnownILAttributes.IsByRefLikeAttribute)) - else - false - -/// Indicate if a list of IL attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. -/// Non-cached variant operating on ILAttributes directly. See CheckILAttributesForUnseenStored for cached version. -let CheckILAttributesForUnseen (cattrs: ILAttributes) = - cattrs.HasWellKnownAttribute(WellKnownILAttributes.ObsoleteAttribute) - && not (cattrs.HasWellKnownAttribute(WellKnownILAttributes.IsByRefLikeAttribute)) - -/// Checks the attributes for CompilerMessageAttribute, which has an IsHidden argument that allows -/// items to be suppressed from intellisense. -let CheckFSharpAttributesForHidden g attribs = - not (isNil attribs) && - (match attribs with - | EntityAttrib g WellKnownEntityAttributes.CompilerMessageAttribute (Attrib(_, _, _, ExtractAttribNamedArg "IsHidden" (AttribBoolArg v), _, _, _)) -> v - | _ -> false) - || - (match attribs with - | EntityAttrib g WellKnownEntityAttributes.EditorBrowsableAttribute (Attrib(_, _, [AttribInt32Arg state], _, _, _, _)) -> state = int System.ComponentModel.EditorBrowsableState.Never - | _ -> false) +[] +type UnseenItems = + | None = 0 + | Obsolete = 1 + | EditorBrowsableNever = 2 + | CompilerMessageHidden = 4 + | EditorBrowsableAdvanced = 8 + +module UnseenItems = + let All = ~~~UnseenItems.None + + let ofBool cond unseen = if cond then unseen else UnseenItems.None + +let IsUnseen (allowUnseen: UnseenItems) (unseen: UnseenItems) = + unseen &&& ~~~allowUnseen <> UnseenItems.None + +let private ILWellKnownFlagsUnseenItems (flags: WellKnownILAttributes) = + let has flag = flags &&& flag <> WellKnownILAttributes.None + UnseenItems.ofBool (has WellKnownILAttributes.ObsoleteAttribute && not (has WellKnownILAttributes.IsByRefLikeAttribute)) UnseenItems.Obsolete + ||| UnseenItems.ofBool (has WellKnownILAttributes.EditorBrowsableNever) UnseenItems.EditorBrowsableNever + ||| UnseenItems.ofBool (has WellKnownILAttributes.EditorBrowsableAdvanced) UnseenItems.EditorBrowsableAdvanced + +let ILAttributesStoredUnseenItems (g: TcGlobals) (cattrsStored: ILAttributesStored) = + cattrsStored.GetOrComputeWellKnownFlags(computeILWellKnownFlags g) |> ILWellKnownFlagsUnseenItems + +let ILAttributesUnseenItems (g: TcGlobals) (cattrs: ILAttributes) = + computeILWellKnownFlags g cattrs |> ILWellKnownFlagsUnseenItems + +let private FSharpAttributesEditorBrowsableUnseenItems g attribs = + match attribs with + | EntityAttribInt g WellKnownEntityAttributes.EditorBrowsableAttribute state -> + match enum state with + | EditorBrowsableState.Never -> UnseenItems.EditorBrowsableNever + | EditorBrowsableState.Advanced -> UnseenItems.EditorBrowsableAdvanced + | _ -> UnseenItems.None + | _ -> UnseenItems.None + +let private CheckFSharpAttributesForCompilerMessageHidden g attribs = + match attribs with + | EntityAttrib g WellKnownEntityAttributes.CompilerMessageAttribute (Attrib(_, _, _, ExtractAttribNamedArg "IsHidden" (AttribBoolArg v), _, _, _)) -> v + | _ -> false /// Indicate if a list of F# attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. let CheckFSharpAttributesForObsolete (g: TcGlobals) attribs = @@ -507,16 +523,30 @@ let CheckFSharpAttributesForObsolete (g: TcGlobals) attribs = // like Span and ReadOnlySpan in completion lists due to their dual attributes. not (attribsHaveEntityFlag g WellKnownEntityAttributes.IsByRefLikeAttribute attribs) -/// Indicates if a list of F# attributes contains 'ObsoleteAttribute' or CompilerMessageAttribute', which has an IsHidden argument -/// May be used to suppress items from intellisense. -let CheckFSharpAttributesForUnseen g attribs allowObsolete = - not (isNil attribs) && - (not allowObsolete && CheckFSharpAttributesForObsolete g attribs || CheckFSharpAttributesForHidden g attribs) +let FSharpAttributesUnseenItems g attribs = + if isNil attribs then + UnseenItems.None + else + let flags = computeEntityWellKnownFlags g attribs + let has flag = flags &&& flag <> WellKnownEntityAttributes.None + + UnseenItems.ofBool (has WellKnownEntityAttributes.ObsoleteAttribute && not (has WellKnownEntityAttributes.IsByRefLikeAttribute)) UnseenItems.Obsolete + ||| (if has WellKnownEntityAttributes.EditorBrowsableAttribute then FSharpAttributesEditorBrowsableUnseenItems g attribs else UnseenItems.None) + ||| UnseenItems.ofBool (has WellKnownEntityAttributes.CompilerMessageAttribute && CheckFSharpAttributesForCompilerMessageHidden g attribs) UnseenItems.CompilerMessageHidden + +let CheckFSharpAttributesForUnseen g attribs allowUnseen = + FSharpAttributesUnseenItems g attribs |> IsUnseen allowUnseen + +let CheckFSharpAttributesForHidden g attribs = + CheckFSharpAttributesForUnseen g attribs (UnseenItems.Obsolete ||| UnseenItems.EditorBrowsableAdvanced) #if !NO_TYPEPROVIDERS /// Indicate if a list of provided attributes contains 'ObsoleteAttribute'. Used to suppress the item in intellisense. -let CheckProvidedAttributesForUnseen (provAttribs: Tainted) m = - provAttribs.PUntaint((fun a -> a.GetAttributeConstructorArgs(provAttribs.TypeProvider.PUntaintNoFailure(id), !! typeof.FullName).IsSome), m) +let ProvidedAttributesUnseenItems (provAttribs: Tainted) m = + if provAttribs.PUntaint((fun a -> a.GetAttributeConstructorArgs(provAttribs.TypeProvider.PUntaintNoFailure(id), !! typeof.FullName).IsSome), m) then + UnseenItems.Obsolete + else + UnseenItems.None #endif /// Check the attributes associated with a property, returning warnings and errors as data. @@ -642,21 +672,21 @@ let TryGetMethodObsoleteInfo minfo = /// Indicate if a method has 'Obsolete', 'CompilerMessageAttribute' or 'TypeProviderEditorHideMethodsAttribute'. /// Used to suppress the item in intellisense. -let MethInfoIsUnseen g (m: range) (ty: TType) minfo allowObsolete = - let isUnseenByObsoleteAttrib () = +let MethInfoIsUnseen g (m: range) (ty: TType) minfo allowUnseen = + let isUnseenItemsObsoleteAttrib () = match BindMethInfoAttributes m minfo - (fun ilAttribs -> Some(not allowObsolete && CheckILAttributesForUnseen ilAttribs)) - (fun fsAttribs -> Some(CheckFSharpAttributesForUnseen g fsAttribs allowObsolete)) + (fun ilAttribs -> Some(ILAttributesUnseenItems g ilAttribs)) + (fun fsAttribs -> Some(FSharpAttributesUnseenItems g fsAttribs)) #if !NO_TYPEPROVIDERS - (fun provAttribs -> Some(not allowObsolete && CheckProvidedAttributesForUnseen provAttribs m)) + (fun provAttribs -> Some(ProvidedAttributesUnseenItems provAttribs m)) #else (fun _provAttribs -> None) #endif with - | Some res -> res + | Some unseen -> IsUnseen allowUnseen unseen | None -> false - let isUnseenByHidingAttribute () = + let isUnseenItemsHidingAttribute () = #if !NO_TYPEPROVIDERS not (isObjTyAnyNullness g ty) && isAppTy g ty && @@ -681,43 +711,43 @@ let MethInfoIsUnseen g (m: range) (ty: TType) minfo allowObsolete = false #endif - isUnseenByObsoleteAttrib () || isUnseenByHidingAttribute () + isUnseenItemsObsoleteAttrib () || isUnseenItemsHidingAttribute () /// Indicate if a property has 'Obsolete' or 'CompilerMessageAttribute'. /// Used to suppress the item in intellisense. -let PropInfoIsUnseen _m allowObsolete pinfo = +let PropInfoIsUnseen _m allowUnseen pinfo = match pinfo with | ILProp (ILPropInfo(_, pdef) as ilpinfo) -> // Properties on .NET tuple types are resolvable but unseen isAnyTupleTy pinfo.TcGlobals ilpinfo.ILTypeInfo.ToType || - CheckILAttributesForUnseen pdef.CustomAttrs + (ILAttributesUnseenItems pinfo.TcGlobals pdef.CustomAttrs |> IsUnseen allowUnseen) | FSProp (g, _, Some vref, _) - | FSProp (g, _, _, Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs allowObsolete + | FSProp (g, _, _, Some vref) -> CheckFSharpAttributesForUnseen g vref.Attribs allowUnseen | FSProp _ -> failwith "CheckPropInfoAttributes: unreachable" #if !NO_TYPEPROVIDERS | ProvidedProp (_amap, pi, m) -> - CheckProvidedAttributesForUnseen (pi.PApply((fun st -> (st :> IProvidedCustomAttributeProvider)), m)) m + ProvidedAttributesUnseenItems (pi.PApply((fun st -> (st :> IProvidedCustomAttributeProvider)), m)) m |> IsUnseen allowUnseen #endif /// Indicate if an ILFieldInfo has 'Obsolete' attribute. /// Used to suppress the item in intellisense. -let ILFieldInfoIsUnseen (finfo: ILFieldInfo) = +let ILFieldInfoIsUnseen allowUnseen (finfo: ILFieldInfo) = match finfo with - | ILFieldInfo(_, fdef) -> CheckILAttributesForUnseen fdef.CustomAttrs + | ILFieldInfo(_, fdef) -> ILAttributesUnseenItems finfo.TcGlobals fdef.CustomAttrs |> IsUnseen allowUnseen #if !NO_TYPEPROVIDERS | ProvidedField(_amap, fi, m) -> - CheckProvidedAttributesForUnseen (fi.PApply((fun st -> (st :> IProvidedCustomAttributeProvider)), m)) m + ProvidedAttributesUnseenItems (fi.PApply((fun st -> (st :> IProvidedCustomAttributeProvider)), m)) m |> IsUnseen allowUnseen #endif /// Indicate if an EventInfo has 'Obsolete' or 'CompilerMessageAttribute'. /// Used to suppress the item in intellisense. -let EventInfoIsUnseen allowObsolete (einfo: EventInfo) = +let EventInfoIsUnseen allowUnseen (einfo: EventInfo) = match einfo with - | ILEvent(ILEventInfo(_, ilEventDef)) -> CheckILAttributesForUnseen ilEventDef.CustomAttrs - | FSEvent(g, _, addValRef, _) -> CheckFSharpAttributesForUnseen g addValRef.Attribs allowObsolete + | ILEvent(ILEventInfo(_, ilEventDef)) -> ILAttributesUnseenItems einfo.TcGlobals ilEventDef.CustomAttrs |> IsUnseen allowUnseen + | FSEvent(g, _, addValRef, _) -> CheckFSharpAttributesForUnseen g addValRef.Attribs allowUnseen #if !NO_TYPEPROVIDERS | ProvidedEvent(_amap, ei, m) -> - CheckProvidedAttributesForUnseen (ei.PApply((fun st -> (st :> IProvidedCustomAttributeProvider)), m)) m + ProvidedAttributesUnseenItems (ei.PApply((fun st -> (st :> IProvidedCustomAttributeProvider)), m)) m |> IsUnseen allowUnseen #endif /// Check the attributes on a union case, returning errors and warnings as data. diff --git a/src/Compiler/Checking/AttributeChecking.fsi b/src/Compiler/Checking/AttributeChecking.fsi index e7b4cf1425f..41b05066975 100644 --- a/src/Compiler/Checking/AttributeChecking.fsi +++ b/src/Compiler/Checking/AttributeChecking.fsi @@ -4,6 +4,7 @@ /// on items from name resolution module internal FSharp.Compiler.AttributeChecking +open System open System.Collections.Generic open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler @@ -82,9 +83,28 @@ val MethInfoHasWellKnownAttributeSpec: val CheckFSharpAttributes: g: TcGlobals -> attribs: Attrib list -> m: range -> OperationResult -val CheckILAttributesForUnseen: cattrs: ILAttributes -> bool +/// Kinds of item that attributes hide from intellisense; also the set of them a caller still shows +[] +type UnseenItems = + | None = 0 + | Obsolete = 1 + | EditorBrowsableNever = 2 + | CompilerMessageHidden = 4 + | EditorBrowsableAdvanced = 8 -val CheckILAttributesForUnseenStored: g: TcGlobals -> cattrsStored: ILAttributesStored -> bool +module UnseenItems = + /// For a path segment the user has already written + val All: UnseenItems + + val ofBool: cond: bool -> unseen: UnseenItems -> UnseenItems + +val IsUnseen: allowUnseen: UnseenItems -> unseen: UnseenItems -> bool + +val ILAttributesStoredUnseenItems: g: TcGlobals -> cattrsStored: ILAttributesStored -> UnseenItems + +val ILAttributesUnseenItems: g: TcGlobals -> cattrs: ILAttributes -> UnseenItems + +val FSharpAttributesUnseenItems: g: TcGlobals -> attribs: Attrib list -> UnseenItems val CheckFSharpAttributesForHidden: g: TcGlobals -> attribs: Attrib list -> bool @@ -92,7 +112,7 @@ val TryGetFSharpObsoleteInfo: g: TcGlobals -> attribs: Attrib list -> ObsoleteDi val CheckFSharpAttributesForObsolete: g: TcGlobals -> attribs: Attribs -> bool -val CheckFSharpAttributesForUnseen: g: TcGlobals -> attribs: Attrib list -> allowObsolete: bool -> bool +val CheckFSharpAttributesForUnseen: g: TcGlobals -> attribs: Attrib list -> allowUnseen: UnseenItems -> bool val CheckPropInfoAttributes: pinfo: PropInfo -> m: range -> OperationResult @@ -105,13 +125,13 @@ val TryGetILFieldObsoleteInfo: g: TcGlobals -> finfo: ILFieldInfo -> ObsoleteDia val CheckMethInfoAttributes: g: TcGlobals -> m: range -> tyargsOpt: 'a option -> minfo: MethInfo -> OperationResult -val MethInfoIsUnseen: g: TcGlobals -> m: range -> ty: TType -> minfo: MethInfo -> allowObsolete: bool -> bool +val MethInfoIsUnseen: g: TcGlobals -> m: range -> ty: TType -> minfo: MethInfo -> allowUnseen: UnseenItems -> bool -val PropInfoIsUnseen: _m: 'a -> allowObsolete: bool -> pinfo: PropInfo -> bool +val PropInfoIsUnseen: _m: 'a -> allowUnseen: UnseenItems -> pinfo: PropInfo -> bool -val ILFieldInfoIsUnseen: finfo: ILFieldInfo -> bool +val ILFieldInfoIsUnseen: allowUnseen: UnseenItems -> finfo: ILFieldInfo -> bool -val EventInfoIsUnseen: allowObsolete: bool -> einfo: EventInfo -> bool +val EventInfoIsUnseen: allowUnseen: UnseenItems -> einfo: EventInfo -> bool val CheckEntityAttributes: g: TcGlobals -> tcref: TyconRef -> m: range -> OperationResult diff --git a/src/Compiler/Checking/NameResolution.fs b/src/Compiler/Checking/NameResolution.fs index 556f3077da9..4e718db71d6 100644 --- a/src/Compiler/Checking/NameResolution.fs +++ b/src/Compiler/Checking/NameResolution.fs @@ -4693,33 +4693,34 @@ let FakeInstantiationGenerator (_m: range) gps = List.map mkTyparTy gps // note: using local refs is ok since it is only used by VS let ItemForModuleOrNamespaceRef v = Item.ModuleOrNamespaces [v] -let IsTyconUnseenObsoleteSpec ad g amap m (x: TyconRef) allowObsolete = +let IsTyconUnseenObsoleteSpec ad g amap m (x: TyconRef) (allowUnseen: UnseenItems) = not (IsEntityAccessible amap m ad x) || - ((not allowObsolete) && - (if x.IsILTycon then - CheckILAttributesForUnseenStored g x.ILTyconRawMetadata.CustomAttrsStored - else - CheckFSharpAttributesForUnseen g x.Attribs allowObsolete)) + (if x.IsILTycon then + ILAttributesStoredUnseenItems g x.ILTyconRawMetadata.CustomAttrsStored + else + FSharpAttributesUnseenItems g x.Attribs) + |> IsUnseen allowUnseen -let IsTyconUnseen ad g amap m allowObsolete (x: TyconRef) = IsTyconUnseenObsoleteSpec ad g amap m x allowObsolete +let IsTyconUnseen ad g amap m allowUnseen (x: TyconRef) = IsTyconUnseenObsoleteSpec ad g amap m x allowUnseen -let IsValUnseen ad g _m allowObsolete (v: ValRef) = +let IsValUnseen ad g _m allowUnseen (v: ValRef) = v.IsCompilerGenerated || v.Deref.IsClassConstructor || not (IsValAccessible ad v) || - not allowObsolete && CheckFSharpAttributesForUnseen g v.Attribs allowObsolete + CheckFSharpAttributesForUnseen g v.Attribs allowUnseen -let IsUnionCaseUnseen ad g amap m allowObsolete (ucref: UnionCaseRef) = +let IsUnionCaseUnseen ad g amap m allowUnseen (ucref: UnionCaseRef) = not (IsUnionCaseAccessible amap m ad ucref) || - not allowObsolete && (IsTyconUnseen ad g amap m allowObsolete ucref.TyconRef || CheckFSharpAttributesForUnseen g ucref.Attribs allowObsolete) + IsTyconUnseen ad g amap m allowUnseen ucref.TyconRef || + CheckFSharpAttributesForUnseen g ucref.Attribs allowUnseen -let ItemIsUnseen ad g amap m allowObsolete item = +let ItemIsUnseen ad g amap m allowUnseen item = match item with - | Item.Value x -> IsValUnseen ad g m allowObsolete x - | Item.UnionCase(x, _) -> IsUnionCaseUnseen ad g amap m allowObsolete x.UnionCaseRef - | Item.ExnCase x -> IsTyconUnseen ad g amap m allowObsolete x - | Item.ILField finfo -> not allowObsolete && ILFieldInfoIsUnseen finfo - | Item.Event einfo -> not allowObsolete && EventInfoIsUnseen allowObsolete einfo + | Item.Value x -> IsValUnseen ad g m allowUnseen x + | Item.UnionCase(x, _) -> IsUnionCaseUnseen ad g amap m allowUnseen x.UnionCaseRef + | Item.ExnCase x -> IsTyconUnseen ad g amap m allowUnseen x + | Item.ILField finfo -> ILFieldInfoIsUnseen allowUnseen finfo + | Item.Event einfo -> EventInfoIsUnseen allowUnseen einfo | _ -> false let ItemOfTyconRef ncenv m (x: TyconRef) = @@ -4770,7 +4771,7 @@ type ResolveCompletionTargets = | SettablePropertiesAndFields -> false /// Resolve a (possibly incomplete) long identifier to a set of possible resolutions, qualified by type. -let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: ResolveCompletionTargets) m ad statics ty (allowObsolete: bool) = +let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: ResolveCompletionTargets) m ad statics ty (allowUnseen: UnseenItems) = protectAssemblyExploration [] <| fun () -> let g = ncenv.g let amap = ncenv.amap @@ -4784,7 +4785,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso match tryAppTy g ty with | ValueSome (tc, tinst) -> tc.UnionCasesAsRefList - |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m allowObsolete >> not) + |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m allowUnseen >> not) |> List.map (fun ucref -> Item.UnionCase(UnionCaseInfo(tinst, ucref), false)) | _ -> [] else [] @@ -4795,7 +4796,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso |> List.filter (fun x -> IsStandardEventInfo ncenv.InfoReader m ad x && x.IsStatic = statics && - (allowObsolete || not (EventInfoIsUnseen allowObsolete x))) + not (EventInfoIsUnseen allowUnseen x)) else [] let nestedTypes = @@ -4811,7 +4812,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso not x.IsSpecialName && x.IsStatic = statics && IsILFieldInfoAccessible g amap m ad x && - (allowObsolete || not (ILFieldInfoIsUnseen x))) + not (ILFieldInfoIsUnseen allowUnseen x)) let qinfos = ncenv.InfoReader.GetTraitInfosInType None ty @@ -4846,10 +4847,8 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso else [] let pinfos = - if allowObsolete then pinfosIncludingUnseen else - pinfosIncludingUnseen - |> List.filter (fun x -> not (PropInfoIsUnseen m allowObsolete x)) + |> List.filter (fun x -> not (PropInfoIsUnseen m allowUnseen x)) let minfoFilter (suppressedMethNames: Zset<_>) (minfo: MethInfo) = let isApplicableMeth = @@ -4886,7 +4885,7 @@ let ResolveCompletionsInType (ncenv: NameResolver) nenv (completionTargets: Reso not isUnseenDueToBasicObjRules && not minfo.IsInstance = statics && IsMethInfoAccessible amap m ad minfo && - not (MethInfoIsUnseen g m ty minfo allowObsolete) && + not (MethInfoIsUnseen g m ty minfo allowUnseen) && not minfo.IsConstructor && not minfo.IsClassConstructor && (minfo.LogicalName <> ".cctor") && @@ -4999,9 +4998,9 @@ let FullTypeOfPropInfo g amap m (pinfo: PropInfo) = else ty ty -let rec ResolvePartialLongIdentInType (ncenv: NameResolver) nenv isApplicableMeth m ad statics plid ty (allowObsolete: bool) = +let rec ResolvePartialLongIdentInType (ncenv: NameResolver) nenv isApplicableMeth m ad statics plid ty (allowUnseen: UnseenItems) = match plid with - | [] -> ResolveCompletionsInType ncenv nenv isApplicableMeth m ad statics ty allowObsolete + | [] -> ResolveCompletionsInType ncenv nenv isApplicableMeth m ad statics ty allowUnseen | id :: rest -> [ let g = ncenv.g @@ -5010,33 +5009,33 @@ let rec ResolvePartialLongIdentInType (ncenv: NameResolver) nenv isApplicableMet // e.g. .. for fref in ncenv.InfoReader.GetRecordOrClassFieldsOfType(None, ad, m, ty) do if fref.LogicalName = id && IsRecdFieldAccessible ncenv.amap m ad fref.RecdFieldRef && fref.RecdField.IsStatic = statics then - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest fref.FieldType allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest fref.FieldType allowUnseen for pinfo in AllPropInfosOfTypeInScope ResultCollectionSettings.AllResults ncenv.InfoReader nenv (Some id) ad IgnoreOverrides m ty do if pinfo.IsStatic = statics && IsPropInfoAccessible g amap m ad pinfo then let pinfoTy = FullTypeOfPropInfo g amap m pinfo - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest pinfoTy allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest pinfoTy allowUnseen if not statics then match TryFindAnonRecdFieldOfType g ty id with | Some (Item.AnonRecdField(_, tys, i, _)) -> - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest tys[i] allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest tys[i] allowUnseen | _ -> () // e.g. .. for einfo in ncenv.InfoReader.GetEventInfosOfType(Some id, ad, m, ty) do let einfoTy = PropTypeOfEventInfo ncenv.InfoReader m ad einfo - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest einfoTy allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest einfoTy allowUnseen // nested types for nestedTy in GetNestedTypesOfType (ad, ncenv, Some id, TypeNameResolutionStaticArgsInfo.Indefinite, false, m) ty do - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad statics rest nestedTy allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad statics rest nestedTy allowUnseen // e.g. .. for finfo in ncenv.InfoReader.GetILFieldInfosOfType(Some id, ad, m, ty) do if not finfo.IsSpecialName && finfo.IsStatic = statics && IsILFieldInfoAccessible g amap m ad finfo then let finfoTy = finfo.FieldType(amap, m) - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest finfoTy allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest finfoTy allowUnseen ] let InfosForTyconConstructors (ncenv: NameResolver) m ad (tcref: TyconRef) = @@ -5054,7 +5053,7 @@ let InfosForTyconConstructors (ncenv: NameResolver) m ad (tcref: TyconRef) = ctorInfos |> List.filter (fun minfo -> IsMethInfoAccessible amap m ad minfo && - not (MethInfoIsUnseen g m ty minfo false)) + not (MethInfoIsUnseen g m ty minfo UnseenItems.None)) match ctors with | [] -> None | _ -> Some(Item.MakeCtorGroup(nm, ctors)) @@ -5069,7 +5068,7 @@ let inline notFakeContainerModule (tyconNames: HashSet<_>) nm = not (tyconNames.Contains nm) /// Check is a namespace or module contains something accessible -let rec private EntityRefContainsSomethingAccessible (ncenv: NameResolver) m ad allowObsolete (modref: ModuleOrNamespaceRef) = +let rec private EntityRefContainsSomethingAccessible (ncenv: NameResolver) m ad allowUnseen (modref: ModuleOrNamespaceRef) = let g = ncenv.g let mty = modref.ModuleOrNamespaceType @@ -5088,22 +5087,22 @@ let rec private EntityRefContainsSomethingAccessible (ncenv: NameResolver) m ad (fun () -> let vref = mkNestedValRef modref v not vref.IsCompilerGenerated && - not (IsValUnseen ad g m allowObsolete vref) && + not (IsValUnseen ad g m allowUnseen vref) && (vref.IsExtensionMember || not vref.IsMember)))) || // Search the types in the namespace/module for an accessible tycon (mty.AllEntities |> QueueList.exists (fun tc -> not tc.IsModuleOrNamespace && - not (IsTyconUnseen ad g ncenv.amap m allowObsolete (modref.NestedTyconRef tc)))) || + not (IsTyconUnseen ad g ncenv.amap m allowUnseen (modref.NestedTyconRef tc)))) || // Search the sub-modules of the namespace/module for something accessible (mty.ModulesAndNamespacesByDemangledName |> NameMap.exists (fun _ submod -> let submodref = modref.NestedTyconRef submod - EntityRefContainsSomethingAccessible ncenv m ad allowObsolete submodref)) + EntityRefContainsSomethingAccessible ncenv m ad allowUnseen submodref)) -let GetVisibleNamespacesAndModulesAtPoint (ncenv: NameResolver) (nenv: NameResolutionEnv) fullyQualified m ad allowObsolete = +let GetVisibleNamespacesAndModulesAtPoint (ncenv: NameResolver) (nenv: NameResolutionEnv) fullyQualified m ad allowUnseen = protectAssemblyExploration [] (fun () -> let items = nenv.ModulesAndNamespaces fullyQualified @@ -5123,10 +5122,10 @@ let GetVisibleNamespacesAndModulesAtPoint (ncenv: NameResolver) (nenv: NameResol |> List.filter (fun x -> let demangledName = x.DemangledModuleOrNamespaceName IsInterestingModuleName demangledName && notFakeContainerModule ilTyconNames demangledName - && EntityRefContainsSomethingAccessible ncenv m ad allowObsolete x - && not (IsTyconUnseen ad ncenv.g ncenv.amap m allowObsolete x))) + && EntityRefContainsSomethingAccessible ncenv m ad allowUnseen x + && not (IsTyconUnseen ad ncenv.g ncenv.amap m allowUnseen x))) -let GetAccessibleSubModules g (ncenv: NameResolver) (modref: ModuleOrNamespaceRef) m ad (allowObsolete: bool) = +let GetAccessibleSubModules g (ncenv: NameResolver) (modref: ModuleOrNamespaceRef) m ad (allowUnseen: UnseenItems) = let moduleOrNamespaces = modref.ModuleOrNamespaceType.ModulesAndNamespacesByDemangledName |> NameMap.range @@ -5147,11 +5146,11 @@ let GetAccessibleSubModules g (ncenv: NameResolver) (modref: ModuleOrNamespaceRe notFakeContainerModule ilTyconNames demangledName && IsInterestingModuleName demangledName) |> List.map modref.NestedTyconRef |> List.filter (fun tyref -> - not (IsTyconUnseen ad g ncenv.amap m allowObsolete tyref) && - EntityRefContainsSomethingAccessible ncenv m ad allowObsolete tyref) + not (IsTyconUnseen ad g ncenv.amap m allowUnseen tyref) && + EntityRefContainsSomethingAccessible ncenv m ad allowUnseen tyref) |> List.map ItemForModuleOrNamespaceRef -let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv isApplicableMeth m ad (modref: ModuleOrNamespaceRef) plid allowObsolete = +let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv isApplicableMeth m ad (modref: ModuleOrNamespaceRef) plid allowUnseen = let g = ncenv.g let mty = modref.ModuleOrNamespaceType @@ -5160,35 +5159,35 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is let tycons = mty.TypeDefinitions |> List.filter (fun tcref -> not (tcref.LogicalName.Contains ",") && - not (IsTyconUnseen ad g ncenv.amap m allowObsolete (modref.NestedTyconRef tcref))) + not (IsTyconUnseen ad g ncenv.amap m allowUnseen (modref.NestedTyconRef tcref))) // Collect up the accessible values in the module, excluding the members (mty.AllValsAndMembers |> Seq.toList |> List.choose (TryMkValRefInModRef modref) // if the assembly load set is incomplete and we get a None value here, then ignore the value - |> List.filter (fun vref -> not vref.IsMember && not (IsValUnseen ad g m allowObsolete vref)) + |> List.filter (fun vref -> not vref.IsMember && not (IsValUnseen ad g m allowUnseen vref)) |> List.map Item.Value) // Collect up the accessible discriminated union cases in the module @ (UnionCaseRefsInModuleOrNamespace modref - |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m allowObsolete >> not) + |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m allowUnseen >> not) |> List.filter (fun ucref -> not (EntityHasWellKnownAttribute g WellKnownEntityAttributes.RequireQualifiedAccessAttribute ucref.TyconRef.Deref)) |> List.map (fun x -> Item.UnionCase(GeneralizeUnionCaseRef x, false))) // Collect up the accessible active patterns in the module @ (ActivePatternElemsOfModuleOrNamespace g modref |> NameMap.range - |> List.filter (fun apref -> apref.ActivePatternVal |> IsValUnseen ad g m allowObsolete |> not) + |> List.filter (fun apref -> apref.ActivePatternVal |> IsValUnseen ad g m allowUnseen |> not) |> List.map Item.ActivePatternCase) // Collect up the accessible F# exception declarations in the module @ (mty.ExceptionDefinitionsByDemangledName |> NameMap.range |> List.map modref.NestedTyconRef - |> List.filter (IsTyconUnseen ad g ncenv.amap m allowObsolete >> not) + |> List.filter (IsTyconUnseen ad g ncenv.amap m allowUnseen >> not) |> List.map Item.ExnCase) - @ GetAccessibleSubModules g ncenv modref m ad allowObsolete + @ GetAccessibleSubModules g ncenv modref m ad allowUnseen // Get all the types and .NET constructor groups accessible from here @ (tycons @@ -5202,18 +5201,18 @@ let rec ResolvePartialLongIdentInModuleOrNamespace (ncenv: NameResolver) nenv is (match mty.ModulesAndNamespacesByDemangledName.TryGetValue id with | true, mspec -> let nested = modref.NestedTyconRef mspec - if IsTyconUnseenObsoleteSpec ad g ncenv.amap m nested allowObsolete then [] else - let allowObsolete = allowObsolete && not (isNil rest) - ResolvePartialLongIdentInModuleOrNamespace ncenv nenv isApplicableMeth m ad nested rest allowObsolete + if IsTyconUnseenObsoleteSpec ad g ncenv.amap m nested UnseenItems.All then [] else + ResolvePartialLongIdentInModuleOrNamespace ncenv nenv isApplicableMeth m ad nested rest allowUnseen | _ -> []) @ (LookupTypeNameInEntityNoArity m id modref.ModuleOrNamespaceType |> List.collect (fun tycon -> let tcref = modref.NestedTyconRef tycon - if not (IsTyconUnseenObsoleteSpec ad g ncenv.amap m tcref allowObsolete) then + if not (IsTyconUnseenObsoleteSpec ad g ncenv.amap m tcref UnseenItems.All) then let ty = generalizedTyconRef g tcref - ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty allowObsolete + // Obsolete members of a type reached through a module path have always been listed + ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty (allowUnseen ||| UnseenItems.Obsolete) else [])) @@ -5247,15 +5246,15 @@ let TryToResolveLongIdentAsType (ncenv: NameResolver) (nenv: NameResolutionEnv) FreshenTycon ncenv m tcref) | _ -> None -/// allowObsolete - specifies whether we should return obsolete types & modules +/// allowUnseen - which attribute-hidden types, modules and values to return /// as (no other obsolete items are returned) -let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionEnv) isApplicableMeth fullyQualified m ad plid (allowObsolete: bool): Item list = +let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionEnv) isApplicableMeth fullyQualified m ad plid (allowUnseen: UnseenItems): Item list = let g = ncenv.g match plid with | id :: plid when id = "global" -> // this is deliberately not the mangled name - ResolvePartialLongIdentPrim ncenv nenv isApplicableMeth FullyQualified m ad plid allowObsolete + ResolvePartialLongIdentPrim ncenv nenv isApplicableMeth FullyQualified m ad plid allowUnseen | [] -> @@ -5270,7 +5269,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE | Item.UnqualifiedType _ -> false | Item.Value v -> not v.IsMember | _ -> true) - |> Seq.filter (ItemIsUnseen ad g ncenv.amap m allowObsolete >> not) + |> Seq.filter (ItemIsUnseen ad g ncenv.amap m allowUnseen >> not) |> Seq.toList let activePatternItems = @@ -5282,21 +5281,21 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE |> List.filter (function Item.ActivePatternCase _v -> true | _ -> false) let moduleAndNamespaceItems = - GetVisibleNamespacesAndModulesAtPoint ncenv nenv fullyQualified m ad allowObsolete |> List.map ItemForModuleOrNamespaceRef + GetVisibleNamespacesAndModulesAtPoint ncenv nenv fullyQualified m ad allowUnseen |> List.map ItemForModuleOrNamespaceRef let tycons = nenv.TyconsByDemangledNameAndArity(fullyQualified).Values |> Seq.filter (fun tcref -> not (tcref.LogicalName.Contains ",") && not tcref.IsFSharpException && - not (IsTyconUnseen ad g ncenv.amap m allowObsolete tcref)) + not (IsTyconUnseen ad g ncenv.amap m allowUnseen tcref)) |> Seq.map (ItemOfTyconRef ncenv m) |> Seq.toList // Get all the constructors accessible from here let constructors = nenv.TyconsByDemangledNameAndArity(fullyQualified).Values - |> Seq.filter (IsTyconUnseen ad g ncenv.amap m allowObsolete >> not) + |> Seq.filter (IsTyconUnseen ad g ncenv.amap m allowUnseen >> not) |> Seq.choose (InfosForTyconConstructors ncenv m ad) |> Seq.toList @@ -5315,9 +5314,8 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE // Look in the namespaces 'id' let namespaces = PartialResolveLongIdentAsModuleOrNamespaceThen nenv [id] (fun modref -> - let allowObsolete = rest <> [] || allowObsolete - if EntityRefContainsSomethingAccessible ncenv m ad allowObsolete modref then - ResolvePartialLongIdentInModuleOrNamespace ncenv nenv isApplicableMeth m ad modref rest allowObsolete + if EntityRefContainsSomethingAccessible ncenv m ad (if rest <> [] then UnseenItems.All else allowUnseen) modref then + ResolvePartialLongIdentInModuleOrNamespace ncenv nenv isApplicableMeth m ad modref rest allowUnseen else []) @@ -5330,7 +5328,7 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE | Item.Value x -> let ty = x.Type let ty = if x.IsCtorThisVal && isRefCellTy g ty then destRefCellTy g ty else ty - (ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest ty allowObsolete), true + (ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad false rest ty allowUnseen), true | _ -> [], false | _ -> [], false) @@ -5340,24 +5338,24 @@ let rec ResolvePartialLongIdentPrim (ncenv: NameResolver) (nenv: NameResolutionE for tcref in LookupTypeNameInEnvNoArity OpenQualified id nenv do let tcref = ResolveNestedTypeThroughAbbreviation ncenv tcref let ty = FreshenTycon ncenv m tcref - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty allowUnseen // 'T.Ident: lookup a static something in a type parameter // ^T.Ident: lookup a static something in a type parameter match nenv.eTypars.TryGetValue id with | true, tp -> let ty = mkTyparTy tp - yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty allowObsolete + yield! ResolvePartialLongIdentInType ncenv nenv isApplicableMeth m ad true rest ty allowUnseen | _ -> () ] namespaces @ values @ staticSomethingInType /// Resolve a (possibly incomplete) long identifier to a set of possible resolutions. -let ResolvePartialLongIdent ncenv nenv isApplicableMeth m ad plid allowObsolete = - ResolvePartialLongIdentPrim ncenv nenv (ResolveCompletionTargets.All isApplicableMeth) OpenQualified m ad plid allowObsolete +let ResolvePartialLongIdent ncenv nenv isApplicableMeth m ad plid allowUnseen = + ResolvePartialLongIdentPrim ncenv nenv (ResolveCompletionTargets.All isApplicableMeth) OpenQualified m ad plid allowUnseen // REVIEW: has much in common with ResolvePartialLongIdentInModuleOrNamespace - probably they should be united -let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameResolver) nenv m ad (modref: ModuleOrNamespaceRef) plid allowObsolete = +let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameResolver) nenv m ad (modref: ModuleOrNamespaceRef) plid allowUnseen = let g = ncenv.g let mty = modref.ModuleOrNamespaceType @@ -5369,10 +5367,10 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe |> List.filter (fun tcref -> not (tcref.LogicalName.Contains ",") && tcref.IsRecordTycon && - not (IsTyconUnseen ad g ncenv.amap m allowObsolete (modref.NestedTyconRef tcref))) + not (IsTyconUnseen ad g ncenv.amap m allowUnseen (modref.NestedTyconRef tcref))) - GetAccessibleSubModules g ncenv modref m ad allowObsolete + GetAccessibleSubModules g ncenv modref m ad allowUnseen // Collect all accessible record types @ (tycons |> List.map (modref.NestedTyconRef >> ItemOfTyconRef ncenv m) ) @@ -5390,9 +5388,8 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForRecordFields (ncenv: NameRe (match mty.ModulesAndNamespacesByDemangledName.TryGetValue id with | true, mspec -> let nested = modref.NestedTyconRef mspec - if IsTyconUnseenObsoleteSpec ad g ncenv.amap m nested allowObsolete then [] else - let allowObsolete = allowObsolete && not (isNil rest) - ResolvePartialLongIdentInModuleOrNamespaceForRecordFields ncenv nenv m ad nested rest allowObsolete + if IsTyconUnseenObsoleteSpec ad g ncenv.amap m nested UnseenItems.All then [] else + ResolvePartialLongIdentInModuleOrNamespaceForRecordFields ncenv nenv m ad nested rest allowUnseen | _ -> []) @ ( match rest with @@ -5423,23 +5420,23 @@ let getRecordTyconsInScope g (ncenv: NameResolver) nenv ad m = if not (tcref.LogicalName.Contains ",") && tcref.IsRecordTycon && - not (IsTyconUnseen ad g ncenv.amap m false tcref) + not (IsTyconUnseen ad g ncenv.amap m UnseenItems.None tcref) then tcref, ItemOfTyconRef ncenv m tcref ] -/// allowObsolete - specifies whether we should return obsolete types & modules +/// allowUnseen - which attribute-hidden types, modules and values to return /// as (no other obsolete items are returned) -let rec ResolvePartialLongIdentToClassOrRecdFields (ncenv: NameResolver) (nenv: NameResolutionEnv) m ad plid (allowObsolete: bool) (fieldsOnly: bool) = - ResolvePartialLongIdentToClassOrRecdFieldsImpl ncenv nenv OpenQualified m ad plid allowObsolete fieldsOnly +let rec ResolvePartialLongIdentToClassOrRecdFields (ncenv: NameResolver) (nenv: NameResolutionEnv) m ad plid (allowUnseen: UnseenItems) (fieldsOnly: bool) = + ResolvePartialLongIdentToClassOrRecdFieldsImpl ncenv nenv OpenQualified m ad plid allowUnseen fieldsOnly -and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv: NameResolutionEnv) fullyQualified m ad plid allowObsolete fieldsOnly = +and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv: NameResolutionEnv) fullyQualified m ad plid allowUnseen fieldsOnly = let g = ncenv.g match plid with | id :: plid when id = "global" -> // this is deliberately not the mangled name // dive deeper - ResolvePartialLongIdentToClassOrRecdFieldsImpl ncenv nenv FullyQualified m ad plid allowObsolete fieldsOnly + ResolvePartialLongIdentToClassOrRecdFieldsImpl ncenv nenv FullyQualified m ad plid allowUnseen fieldsOnly | [] -> // empty plid - return namespaces\modules\record types\accessible fields @@ -5447,14 +5444,14 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv: if fieldsOnly then getRecordFieldsInScope nenv else let mods = - GetVisibleNamespacesAndModulesAtPoint ncenv nenv fullyQualified m ad allowObsolete |> List.map ItemForModuleOrNamespaceRef + GetVisibleNamespacesAndModulesAtPoint ncenv nenv fullyQualified m ad allowUnseen |> List.map ItemForModuleOrNamespaceRef let recdTyCons = nenv.TyconsByDemangledNameAndArity(fullyQualified).Values |> Seq.filter (fun tcref -> not (tcref.LogicalName.Contains ",") && tcref.IsRecordTycon && - not (IsTyconUnseen ad g ncenv.amap m allowObsolete tcref)) + not (IsTyconUnseen ad g ncenv.amap m allowUnseen tcref)) |> Seq.map (ItemOfTyconRef ncenv m) |> Seq.toList @@ -5467,9 +5464,8 @@ and ResolvePartialLongIdentToClassOrRecdFieldsImpl (ncenv: NameResolver) (nenv: // Get results let modsOrNs = PartialResolveLongIdentAsModuleOrNamespaceThen nenv [id] (fun modref -> - let allowObsolete = rest <> [] && allowObsolete - if EntityRefContainsSomethingAccessible ncenv m ad allowObsolete modref then - ResolvePartialLongIdentInModuleOrNamespaceForRecordFields ncenv nenv m ad modref rest allowObsolete + if EntityRefContainsSomethingAccessible ncenv m ad (if rest <> [] then UnseenItems.All else allowUnseen) modref then + ResolvePartialLongIdentInModuleOrNamespaceForRecordFields ncenv nenv m ad modref rest allowUnseen else []) @@ -5501,7 +5497,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty ( | ValueSome(tc, tinst) -> yield! tc.UnionCasesAsRefList - |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m false >> not) + |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m UnseenItems.None >> not) |> List.map (fun ucref -> Item.UnionCase(UnionCaseInfo(tinst, ucref), false)) | _ -> () | Item.Event _ -> @@ -5564,7 +5560,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty ( let pinfos = pinfosIncludingUnseen - |> List.filter (fun x -> not (PropInfoIsUnseen m false x)) + |> List.filter (fun x -> not (PropInfoIsUnseen m UnseenItems.None x)) let minfoFilter (suppressedMethNames: Zset<_>) (minfo: MethInfo) = // Only show the Finalize, MemberwiseClose etc. methods on System.Object for values whose static type really is @@ -5595,7 +5591,7 @@ let ResolveCompletionsInTypeForItem (ncenv: NameResolver) nenv m ad statics ty ( not isUnseenDueToBasicObjRules && not minfo.IsInstance = statics && IsMethInfoAccessible amap m ad minfo && - not (MethInfoIsUnseen g m ty minfo false) && + not (MethInfoIsUnseen g m ty minfo UnseenItems.None) && not minfo.IsConstructor && not minfo.IsClassConstructor && (minfo.LogicalName <> ".cctor") && @@ -5738,14 +5734,14 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) mty.AllValsAndMembers |> Seq.toList |> List.choose (TryMkValRefInModRef modref) // if the assembly load set is incomplete and we get a None value here, then ignore the value - |> List.filter (fun vref -> not vref.IsMember && not (IsValUnseen ad g m false vref)) + |> List.filter (fun vref -> not vref.IsMember && not (IsValUnseen ad g m UnseenItems.None vref)) |> List.map Item.Value | Item.UnionCase _ -> // Collect up the accessible discriminated union cases in the module yield! UnionCaseRefsInModuleOrNamespace modref - |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m false >> not) + |> List.filter (IsUnionCaseUnseen ad g ncenv.amap m UnseenItems.None >> not) |> List.filter (fun ucref -> not (EntityHasWellKnownAttribute g WellKnownEntityAttributes.RequireQualifiedAccessAttribute ucref.TyconRef.Deref)) |> List.map (fun x -> Item.UnionCase(GeneralizeUnionCaseRef x, false)) @@ -5754,7 +5750,7 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) yield! ActivePatternElemsOfModuleOrNamespace g modref |> NameMap.range - |> List.filter (fun apref -> apref.ActivePatternVal |> IsValUnseen ad g m false |> not) + |> List.filter (fun apref -> apref.ActivePatternVal |> IsValUnseen ad g m UnseenItems.None |> not) |> List.map Item.ActivePatternCase | Item.ExnCase _ -> @@ -5763,19 +5759,19 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) mty.ExceptionDefinitionsByDemangledName |> NameMap.range |> List.map modref.NestedTyconRef - |> List.filter (IsTyconUnseen ad g ncenv.amap m false >> not) + |> List.filter (IsTyconUnseen ad g ncenv.amap m UnseenItems.None >> not) |> List.map Item.ExnCase | _ -> // Collect up the accessible sub-modules. We must yield them even though `item` is not a module or namespace, // otherwise we would not resolve long idents which have modules and namespaces in the middle (i.e. all long idents) - yield! GetAccessibleSubModules g ncenv modref m ad false + yield! GetAccessibleSubModules g ncenv modref m ad UnseenItems.None let tycons = mty.TypeDefinitions |> List.filter (fun tcref -> not (tcref.LogicalName.Contains ",") && - not (IsTyconUnseen ad g ncenv.amap m false (modref.NestedTyconRef tcref))) + not (IsTyconUnseen ad g ncenv.amap m UnseenItems.None (modref.NestedTyconRef tcref))) // Get all the types and .NET constructor groups accessible from here let nestedTycons = tycons |> List.map modref.NestedTyconRef @@ -5787,13 +5783,13 @@ let rec ResolvePartialLongIdentInModuleOrNamespaceForItem (ncenv: NameResolver) match mty.ModulesAndNamespacesByDemangledName.TryGetValue id with | true, mspec -> let nested = modref.NestedTyconRef mspec - if not (IsTyconUnseenObsoleteSpec ad g ncenv.amap m nested true) then + if not (IsTyconUnseenObsoleteSpec ad g ncenv.amap m nested UnseenItems.All) then yield! ResolvePartialLongIdentInModuleOrNamespaceForItem ncenv nenv m ad nested rest item | _ -> () for tycon in LookupTypeNameInEntityNoArity m id modref.ModuleOrNamespaceType do let tcref = modref.NestedTyconRef tycon - if not (IsTyconUnseenObsoleteSpec ad g ncenv.amap m tcref true) then + if not (IsTyconUnseenObsoleteSpec ad g ncenv.amap m tcref UnseenItems.All) then let ty = tcref |> generalizedTyconRef g yield! ResolvePartialLongIdentInTypeForItem ncenv nenv m ad true rest item ty } @@ -5837,19 +5833,19 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a for uitem in nenv.eUnqualifiedItems.Values do match uitem with | Item.UnqualifiedType _ -> () - | _ when not (ItemIsUnseen ad g ncenv.amap m false uitem) -> + | _ when not (ItemIsUnseen ad g ncenv.amap m UnseenItems.None uitem) -> yield uitem | _ -> () match item with | Item.ModuleOrNamespaces _ -> - yield! GetVisibleNamespacesAndModulesAtPoint ncenv nenv OpenQualified m ad false |> List.map ItemForModuleOrNamespaceRef + yield! GetVisibleNamespacesAndModulesAtPoint ncenv nenv OpenQualified m ad UnseenItems.None |> List.map ItemForModuleOrNamespaceRef | Item.Types _ -> for tcref in nenv.TyconsByDemangledNameAndArity(OpenQualified).Values do if not tcref.IsFSharpException && not (tcref.LogicalName.Contains ",") - && not (IsTyconUnseen ad g ncenv.amap m false tcref) + && not (IsTyconUnseen ad g ncenv.amap m UnseenItems.None tcref) then yield ItemOfTyconRef ncenv m tcref | Item.ActivePatternCase _ -> @@ -5863,7 +5859,7 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a | Item.CtorGroup _ | Item.UnqualifiedType _ -> for tcref in nenv.TyconsByDemangledNameAndArity(OpenQualified).Values do - if not (IsTyconUnseen ad g ncenv.amap m false tcref) then + if not (IsTyconUnseen ad g ncenv.amap m UnseenItems.None tcref) then match InfosForTyconConstructors ncenv m ad tcref with | Some info -> yield info | _ -> () @@ -5874,7 +5870,7 @@ let rec GetCompletionForItem (ncenv: NameResolver) (nenv: NameResolutionEnv) m a // Look in the namespaces 'id' yield! PartialResolveLongIdentAsModuleOrNamespaceThenLazy nenv [id] (fun modref -> - if EntityRefContainsSomethingAccessible ncenv m ad false modref then + if EntityRefContainsSomethingAccessible ncenv m ad UnseenItems.None modref then ResolvePartialLongIdentInModuleOrNamespaceForItem ncenv nenv m ad modref rest item else Seq.empty) diff --git a/src/Compiler/Checking/NameResolution.fsi b/src/Compiler/Checking/NameResolution.fsi index fac10862948..81ae8d60b33 100755 --- a/src/Compiler/Checking/NameResolution.fsi +++ b/src/Compiler/Checking/NameResolution.fsi @@ -4,6 +4,7 @@ module internal FSharp.Compiler.NameResolution open Internal.Utilities.Library open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.Infos open FSharp.Compiler.Import @@ -922,7 +923,14 @@ val internal getRecordTyconsInScope: /// Resolve a (possibly incomplete) long identifier to a list of possible class or record fields val internal ResolvePartialLongIdentToClassOrRecdFields: - NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> bool -> bool -> Item list + NameResolver -> + NameResolutionEnv -> + range -> + AccessorDomain -> + string list -> + allowUnseen: UnseenItems -> + fieldsOnly: bool -> + Item list /// Return the fields for the given class or record val internal ResolveRecordOrClassFieldsOfType: NameResolver -> range -> AccessorDomain -> TType -> bool -> Item list @@ -970,7 +978,7 @@ val ResolvePartialLongIdent: m: range -> ad: AccessorDomain -> plid: string list -> - allowObsolete: bool -> + allowUnseen: UnseenItems -> Item list [] @@ -987,7 +995,7 @@ val ResolveCompletionsInType: AccessorDomain -> bool -> TType -> - allowObsolete: bool -> + allowUnseen: UnseenItems -> Item list val GetVisibleNamespacesAndModulesAtPoint: @@ -996,7 +1004,7 @@ val GetVisibleNamespacesAndModulesAtPoint: FullyQualifiedFlag -> range -> AccessorDomain -> - allowObsolete: bool -> + allowUnseen: UnseenItems -> ModuleOrNamespaceRef list val IsItemResolvable: NameResolver -> NameResolutionEnv -> range -> AccessorDomain -> string list -> Item -> bool diff --git a/src/Compiler/Interactive/fsi.fs b/src/Compiler/Interactive/fsi.fs index 7249d82b4ee..e2c34fa86ce 100644 --- a/src/Compiler/Interactive/fsi.fs +++ b/src/Compiler/Interactive/fsi.fs @@ -34,6 +34,7 @@ open FSharp.Compiler.AbstractIL.ILBinaryReader open FSharp.Compiler.AbstractIL.ILBinaryWriter open FSharp.Compiler.AbstractIL.ILDynamicAssemblyWriter open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CheckDeclarations open FSharp.Compiler.CheckExpressions open FSharp.Compiler.CodeAnalysis @@ -4593,7 +4594,7 @@ type FsiInteractionProcessor rangeStdin0 ad lid - false + UnseenItems.None let names = nItems |> List.map (fun d -> d.DisplayName) let names = names |> List.filter (fun name -> name.StartsWithOrdinal(stem)) diff --git a/src/Compiler/Service/FSharpCheckerResults.fs b/src/Compiler/Service/FSharpCheckerResults.fs index 4c5481e03e2..8f4cd790c09 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fs +++ b/src/Compiler/Service/FSharpCheckerResults.fs @@ -7,6 +7,7 @@ namespace FSharp.Compiler.CodeAnalysis open System open System.Collections.Generic +open System.ComponentModel open System.Diagnostics open System.IO open System.Threading @@ -22,6 +23,7 @@ open FSharp.Compiler open FSharp.Compiler.Syntax open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CheckExpressionsOps open FSharp.Compiler.CheckDeclarations open FSharp.Compiler.CompilerConfig @@ -335,6 +337,7 @@ type FSharpCodeCompletionOptions = { SuggestPatternNames: bool SuggestObsoleteSymbols: bool + SuggestEditorBrowsableSymbols: EditorBrowsableState SuggestGeneratedOverrides: bool SuggestOverrideBodies: bool } @@ -343,10 +346,18 @@ type FSharpCodeCompletionOptions = { SuggestPatternNames = true SuggestObsoleteSymbols = false + SuggestEditorBrowsableSymbols = EditorBrowsableState.Advanced SuggestGeneratedOverrides = true SuggestOverrideBodies = true } + member internal x.AllowUnseen = + UnseenItems.ofBool x.SuggestObsoleteSymbols UnseenItems.Obsolete + ||| (match x.SuggestEditorBrowsableSymbols with + | EditorBrowsableState.Always -> UnseenItems.None + | EditorBrowsableState.Never -> UnseenItems.EditorBrowsableAdvanced ||| UnseenItems.EditorBrowsableNever + | _ -> UnseenItems.EditorBrowsableAdvanced) + /// A TypeCheckInfo represents everything we get back from the typecheck of a file. /// It acts like an in-memory database about the file. /// It is effectively immutable and not updated: when we re-typecheck we just drop the previous @@ -496,7 +507,7 @@ type internal TypeCheckInfo /// Looks at the exact name resolutions that occurred during type checking /// If 'membersByResidue' is specified, we look for members of the item obtained /// from the name resolution and filter them by the specified residue (?) - let GetPreciseItemsFromNameResolution (line, colAtEndOfNames, membersByResidue, filterCtors, resolveOverloads, allowObsolete) = + let GetPreciseItemsFromNameResolution (line, colAtEndOfNames, membersByResidue, filterCtors, resolveOverloads, allowUnseen) = let endOfNamesPos = mkPos line colAtEndOfNames // Logic below expects the list to be in reverse order of resolution @@ -517,7 +528,7 @@ type internal TypeCheckInfo let targets = ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m) - let items = ResolveCompletionsInType ncenv nenv targets m ad true ty allowObsolete + let items = ResolveCompletionsInType ncenv nenv targets m ad true ty allowUnseen let items = List.map ItemWithNoInst items ReturnItemsOfType items g denv m filterCtors @@ -527,7 +538,7 @@ type internal TypeCheckInfo ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m) let items = - ResolveCompletionsInType ncenv nenv targets m ad true (mkTyparTy tp) allowObsolete + ResolveCompletionsInType ncenv nenv targets m ad true (mkTyparTy tp) allowUnseen let items = List.map ItemWithNoInst items ReturnItemsOfType items g denv m filterCtors @@ -564,7 +575,7 @@ type internal TypeCheckInfo let targets = ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m) - let items = ResolveCompletionsInType ncenv nenv targets m ad false ty allowObsolete + let items = ResolveCompletionsInType ncenv nenv targets m ad false ty allowUnseen let items = List.map ItemWithNoInst items ReturnItemsOfType items g denv m filterCtors @@ -677,7 +688,7 @@ type internal TypeCheckInfo | None -> None) | _ -> []) - let GetNamedParametersAndSettableFields endOfExprPos cursorLine (lineStr: string) allowObsolete = + let GetNamedParametersAndSettableFields endOfExprPos cursorLine (lineStr: string) allowUnseen = let cnrs = GetCapturedNameResolutions endOfExprPos ResolveOverloads.No |> ResizeArray.toList @@ -703,7 +714,7 @@ type internal TypeCheckInfo let props = propTys |> List.collect (fun ty -> - ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ty allowObsolete) + ResolveCompletionsInType ncenv nenv ResolveCompletionTargets.SettablePropertiesAndFields m ad false ty allowUnseen) nenv.DisplayEnv, m, props @ CollectParameters meths amap m @@ -736,7 +747,14 @@ type internal TypeCheckInfo else let (nenv, ad), m = GetBestEnvForPos endOfExprPos - ResolvePartialLongIdent ncenv nenv (ConstraintSolver.IsApplicableMethApprox g amap m) m ad plid.QualifyingIdents false + ResolvePartialLongIdent + ncenv + nenv + (ConstraintSolver.IsApplicableMethApprox g amap m) + m + ad + plid.QualifyingIdents + UnseenItems.None |> List.tryPick (function | NamedArgGroup(name, meths, isCtor) when name = lastName -> Some(buildGroup meths isCtor nenv ad m) | _ -> None) @@ -828,7 +846,9 @@ type internal TypeCheckInfo /// Looks at the exact expression types at the position to the left of the /// residue then the source when it was typechecked. - let GetPreciseCompletionListFromExprTypings (parseResults: FSharpParseFileResults, endOfExprPos, filterCtors, allowObsolete: bool) = + let GetPreciseCompletionListFromExprTypings + (parseResults: FSharpParseFileResults, endOfExprPos, filterCtors, allowUnseen: UnseenItems) + = let thereWereSomeQuals, quals = GetExprTypingForPosition(endOfExprPos) @@ -868,7 +888,7 @@ type internal TypeCheckInfo let targets = ResolveCompletionTargets.All(ConstraintSolver.IsApplicableMethApprox g amap m) - let items = ResolveCompletionsInType ncenv nenv targets m ad false ty allowObsolete + let items = ResolveCompletionsInType ncenv nenv targets m ad false ty allowUnseen let items = items |> List.map ItemWithNoInst let items = items |> RemoveDuplicateItems g let items = items |> RemoveExplicitlySuppressed g @@ -881,9 +901,9 @@ type internal TypeCheckInfo ExprTypingsResult.None /// Find items in the best naming environment. - let GetEnvironmentLookupResolutions (nenv, ad, m, plid, filterCtors, showObsolete) = + let GetEnvironmentLookupResolutions (nenv, ad, m, plid, filterCtors, allowUnseen) = let items = - ResolvePartialLongIdent ncenv nenv (ConstraintSolver.IsApplicableMethApprox g amap m) m ad plid showObsolete + ResolvePartialLongIdent ncenv nenv (ConstraintSolver.IsApplicableMethApprox g amap m) m ad plid allowUnseen let items = items |> List.map ItemWithNoInst let items = items |> RemoveDuplicateItems g @@ -892,16 +912,16 @@ type internal TypeCheckInfo (items, nenv.DisplayEnv, m) /// Find items in the best naming environment. - let GetEnvironmentLookupResolutionsAtPosition (cursorPos, plid, filterCtors, showObsolete) = + let GetEnvironmentLookupResolutionsAtPosition (cursorPos, plid, filterCtors, allowUnseen) = let (nenv, ad), m = GetBestEnvForPos cursorPos - GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, showObsolete) + GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, allowUnseen) /// Find record fields in the best naming environment. - let GetClassOrRecordFieldsEnvironmentLookupResolutions (cursorPos, plid, fieldsOnly, allowObsolete) = + let GetClassOrRecordFieldsEnvironmentLookupResolutions (cursorPos, plid, fieldsOnly, allowUnseen) = let (nenv, ad), m = GetBestEnvForPos cursorPos let items = - ResolvePartialLongIdentToClassOrRecdFields ncenv nenv m ad plid allowObsolete fieldsOnly + ResolvePartialLongIdentToClassOrRecdFields ncenv nenv m ad plid allowUnseen fieldsOnly let items = items |> List.map ItemWithNoInst let items = items |> RemoveDuplicateItems g @@ -1402,7 +1422,7 @@ type internal TypeCheckInfo None, ResolveTypeNamesToTypeRefs, ResolveOverloads.Yes, - options.SuggestObsoleteSymbols + options.AllowUnseen ) match nameResItems with @@ -1596,7 +1616,7 @@ type internal TypeCheckInfo None, filterCtors, resolveOverloads, - options.SuggestObsoleteSymbols + options.AllowUnseen ) | Some residue -> // Deals with cases when we have spaces between dot and\or identifier, like A . $ @@ -1618,7 +1638,7 @@ type internal TypeCheckInfo Some(residue), filterCtors, resolveOverloads, - options.SuggestObsoleteSymbols + options.AllowUnseen ) | None -> NameResResult.Empty | _ -> NameResResult.Empty @@ -1694,8 +1714,7 @@ type internal TypeCheckInfo match leftOfDot with | Some(pos, _) -> - GetPreciseCompletionListFromExprTypings(parseResults, pos, filterCtors, options.SuggestObsoleteSymbols), - true + GetPreciseCompletionListFromExprTypings(parseResults, pos, filterCtors, options.AllowUnseen), true | None -> // Can get here in a case like: if "f xxx yyy" is legal, and we do "f xxx y" // We have no interest in expression typings, those are only useful for dot-completion. We want to fallback @@ -1727,8 +1746,7 @@ type internal TypeCheckInfo | _ -> // Use an environment lookup as the last resort let envItems, denv, m = - let allowObsolete = options.SuggestObsoleteSymbols - GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, allowObsolete) + GetEnvironmentLookupResolutions(nenv, ad, m, plid, filterCtors, options.AllowUnseen) let envResult = match nameResItems, (envItems, denv, m), qualItems with @@ -1798,7 +1816,7 @@ type internal TypeCheckInfo let (nenv, _), m = GetBestEnvForPos cursorPos let fieldItems, _, _ = - GetClassOrRecordFieldsEnvironmentLookupResolutions(cursorPos, plid, true, options.SuggestObsoleteSymbols) + GetClassOrRecordFieldsEnvironmentLookupResolutions(cursorPos, plid, true, options.AllowUnseen) let fieldCompletionItems, _, _ as fieldsResult = (fieldItems, nenv.DisplayEnv, m) |> toCompletionItems @@ -1868,19 +1886,19 @@ type internal TypeCheckInfo // Completion at 'inherit C(...)" | Some(CompletionContext.Inherit(InheritanceContext.Class, (plid, _))) -> - GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, false) + GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, UnseenItems.None) |> FilterRelevantItemsBy getItem None (getItem >> IsInheritsCompletionCandidate) |> Option.map toCompletionItems // Completion at 'interface ..." | Some(CompletionContext.Inherit(InheritanceContext.Interface, (plid, _))) -> - GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, false) + GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, UnseenItems.None) |> FilterRelevantItemsBy getItem None (getItem >> IsInterfaceCompletionCandidate) |> Option.map toCompletionItems // Completion at 'implement ..." | Some(CompletionContext.Inherit(InheritanceContext.Unknown, (plid, _))) -> - GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, false) + GetEnvironmentLookupResolutionsAtPosition(mkPos line loc, plid, filterCtors, UnseenItems.None) |> FilterRelevantItemsBy getItem None @@ -1914,7 +1932,7 @@ type internal TypeCheckInfo else // { x. } can be either record construction or computation expression. Try to get all visible record fields first match - GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, false, options.SuggestObsoleteSymbols) + GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, false, options.AllowUnseen) |> toCompletionItems with | [], _, _ -> @@ -1963,13 +1981,13 @@ type internal TypeCheckInfo | Some(CompletionContext.RecordField(RecordContext.CopyOnUpdate(identRange, (plid, _)))) -> match GetRecdFieldsForCopyAndUpdateExpr(identRange, plid) with | None -> - Some(GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, false, options.SuggestObsoleteSymbols)) + Some(GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, plid, false, options.AllowUnseen)) |> Option.map toCompletionItems | Some(items, denv, m) -> Some(List.map ItemWithNoInst items, denv, m) |> Option.map toCompletionItems // Completion at ' { XXX = ... with ... } " | Some(CompletionContext.RecordField(RecordContext.Constructor(typeName))) -> - GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, [ typeName ], false, options.SuggestObsoleteSymbols) + GetClassOrRecordFieldsEnvironmentLookupResolutions(mkPos line loc, [ typeName ], false, options.AllowUnseen) |> toCompletionItems |> Some @@ -2017,7 +2035,7 @@ type internal TypeCheckInfo // Completion at ' SomeMethod( ... ) ' or ' [] ' with named arguments | Some(CompletionContext.ParameterList(endPos, fields)) -> let results = - GetNamedParametersAndSettableFields endPos line lineStr options.SuggestObsoleteSymbols + GetNamedParametersAndSettableFields endPos line lineStr options.AllowUnseen let declaredItems = getDeclaredItemsNotInRangeOpWithAllSymbols () @@ -2157,7 +2175,7 @@ type internal TypeCheckInfo member _.GetVisibleNamespacesAndModulesAtPosition(cursorPos: pos) : ModuleOrNamespaceRef list = let (nenv, ad), m = GetBestEnvForPos cursorPos - GetVisibleNamespacesAndModulesAtPoint ncenv nenv OpenQualified m ad false + GetVisibleNamespacesAndModulesAtPoint ncenv nenv OpenQualified m ad UnseenItems.None /// Determines if a long ident is resolvable at a specific point. member _.IsRelativeNameResolvable(cursorPos: pos, plid: string list, item: Item) : bool = diff --git a/src/Compiler/Service/FSharpCheckerResults.fsi b/src/Compiler/Service/FSharpCheckerResults.fsi index 0d71159f313..5ee2b5c1125 100644 --- a/src/Compiler/Service/FSharpCheckerResults.fsi +++ b/src/Compiler/Service/FSharpCheckerResults.fsi @@ -3,12 +3,14 @@ namespace FSharp.Compiler.CodeAnalysis open System +open System.ComponentModel open System.IO open System.Threading open Internal.Utilities.Library open FSharp.Compiler.AbstractIL.IL open FSharp.Compiler.AbstractIL.ILBinaryReader open FSharp.Compiler.AccessibilityLogic +open FSharp.Compiler.AttributeChecking open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.CheckDeclarations open FSharp.Compiler.CompilerConfig @@ -240,11 +242,14 @@ type public FSharpParsingOptions = type public FSharpCodeCompletionOptions = { SuggestPatternNames: bool SuggestObsoleteSymbols: bool + SuggestEditorBrowsableSymbols: EditorBrowsableState SuggestGeneratedOverrides: bool SuggestOverrideBodies: bool } static member Default: FSharpCodeCompletionOptions + member internal AllowUnseen: UnseenItems + /// A handle to the results of CheckFileInProject. [] type public FSharpCheckFileResults = diff --git a/src/Compiler/TypedTree/TypedTreeOps.Attributes.fs b/src/Compiler/TypedTree/TypedTreeOps.Attributes.fs index 9cf33090d8b..127cf7215fd 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.Attributes.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.Attributes.fs @@ -7,6 +7,7 @@ open System open System.CodeDom.Compiler open System.Collections.Generic open System.Collections.Immutable +open System.ComponentModel open Internal.Utilities open Internal.Utilities.Collections open Internal.Utilities.Library @@ -188,6 +189,19 @@ module internal ILExtensions = | "System.Diagnostics.CodeAnalysis.NotNullIfNotNullAttribute" -> WellKnownILAttributes.NotNullIfNotNullAttribute | "System.Diagnostics.CodeAnalysis.RequireNamedArgumentsAttribute" -> WellKnownILAttributes.RequireNamedArgumentsAttribute | "System.AttributeUsageAttribute" -> WellKnownILAttributes.AttributeUsageAttribute + | "System.ComponentModel.EditorBrowsableAttribute" -> + let state = + match attr with + | ILAttribute.Decoded(_, [ ILAttribElem.Int32 state ], _) -> state + // Read in place rather than through decodeILAttribData, which allocates: prolog, one int32, no named arguments + | ILAttribute.Encoded(_, bytes, _) when bytes.Length = 8 && bytes[0] = 1uy && bytes[1] = 0uy -> + BitConverter.ToInt32(bytes, 2) + | _ -> int EditorBrowsableState.Always + + match enum state with + | EditorBrowsableState.Never -> WellKnownILAttributes.EditorBrowsableNever + | EditorBrowsableState.Advanced -> WellKnownILAttributes.EditorBrowsableAdvanced + | _ -> WellKnownILAttributes.None | _ -> WellKnownILAttributes.None /// Compute well-known attribute flags for an ILAttributes collection. diff --git a/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs b/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs index a8d9dc97c61..5e803c18053 100644 --- a/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/CompletionTests.fs @@ -1,5 +1,6 @@ module FSharp.Compiler.Service.Tests.CompletionTests +open System.ComponentModel open FSharp.Compiler.CodeAnalysis open FSharp.Compiler.EditorServices open FSharp.Test.Assert @@ -409,6 +410,16 @@ module Options = assertItemsWithNames contains [name] info ) + let private assertCSharpInteropItemWithOptions getOption (options: FSharpCodeCompletionOptions list) name source = + let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll" + let compilerOptions = [| $"-r:{csharpAssembly}" |] + options + |> List.iter (fun options -> + let contains = getOption options + let info = Checker.getCompletionInfoWithCompilerAndCompletionOptions compilerOptions options source + assertItemsWithNames contains [name] info + ) + module AllowObsolete = let private allowObsoleteOptions = { FSharpCodeCompletionOptions.Default with SuggestObsoleteSymbols = true } let private disallowObsoleteOptions = { FSharpCodeCompletionOptions.Default with SuggestObsoleteSymbols = false } @@ -732,16 +743,8 @@ type T() = T.{caret} """ - /// Helper to assert completion with a reference to the CSharp_Analysis assembly let private assertCSharpInteropItem name source = - let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll" - let compilerOptions = [| $"-r:{csharpAssembly}" |] - [allowObsoleteOptions; disallowObsoleteOptions] - |> List.iter (fun completionOptions -> - let contains = completionOptions.SuggestObsoleteSymbols - let info = Checker.getCompletionInfoWithCompilerAndCompletionOptions compilerOptions completionOptions source - assertItemsWithNames contains [name] info - ) + assertCSharpInteropItemWithOptions _.SuggestObsoleteSymbols [allowObsoleteOptions; disallowObsoleteOptions] name source // https://github.com/dotnet/fsharp/issues/13512 [] @@ -775,22 +778,431 @@ open FSharp.Compiler.Service.Tests ObsoleteMembersClass.{caret} """ + [] + let ``Nested module 01`` () = + assertItem "x" """ +module M = + module N = + [] + let x = 1 + +M.N.{caret} +""" + + [] + let ``Nested module 02`` () = + assertItem "x" """ +module M = + [] + module N = + [] + let x = 1 + +M.N.{caret} +""" + + [] + let ``Nested type 01`` () = + Checker.getCompletionInfo """ +module M = + type T() = + [] + static member Prop = 1 + +M.T.{caret} +""" + |> assertHasItemWithNames ["Prop"] + + [] + let ``Nested module - Record field 01`` () = + assertItem "R" """ +module M = + module N = + [] + type R = { F: int } + +let r = { M.N.{caret} } +""" + + [] + let ``Nested module - Record field 02`` () = + Checker.getCompletionInfo """ +module M = + [] + module N = + type R = { F: int } + +let r = { M.N.{caret} } +""" + |> assertHasItemWithNames ["R"] + // https://github.com/dotnet/fsharp/issues/13512 [] let ``CSharp - Non-obsolete members are always shown`` () = - let csharpAssembly = PathRelativeToTestAssembly "CSharp_Analysis.dll" - let compilerOptions = [| $"-r:{csharpAssembly}" |] - let source = """ + for name in ["NonObsoleteField"; "NonObsoleteMethod"; "NonObsoleteProperty"; "NonObsoleteEvent"] do + assertCSharpInteropItemWithOptions (fun _ -> true) [allowObsoleteOptions; disallowObsoleteOptions] name """ open FSharp.Compiler.Service.Tests ObsoleteMembersClass.{caret} """ - [allowObsoleteOptions; disallowObsoleteOptions] - |> List.iter (fun completionOptions -> - let info = Checker.getCompletionInfoWithCompilerAndCompletionOptions compilerOptions completionOptions source - assertItemsWithNames true ["NonObsoleteField"; "NonObsoleteMethod"; "NonObsoleteProperty"; "NonObsoleteEvent"] info - ) + module EditorBrowsableNever = + let private allowOptions = { FSharpCodeCompletionOptions.Default with SuggestEditorBrowsableSymbols = EditorBrowsableState.Never } + let private disallowOptions = { FSharpCodeCompletionOptions.Default with SuggestEditorBrowsableSymbols = EditorBrowsableState.Advanced } + + let private suggestsNever (options: FSharpCodeCompletionOptions) = + options.SuggestEditorBrowsableSymbols = EditorBrowsableState.Never + + let private assertItemAlways (name: string) source = + assertItemWithOptions (fun _ -> true) [allowOptions; disallowOptions] name source + + let private assertItemWithOptions = + assertItemWithOptions suggestsNever + + let assertItem (name: string) source = + assertItemWithOptions [allowOptions; disallowOptions] name source + + let private assertCSharpInteropItem contains name source = + assertCSharpInteropItemWithOptions contains [allowOptions; disallowOptions] name source + + [] + let ``Prop - Instance 01`` () = + assertItem "Prop" """ +open System.ComponentModel + +type T() = + [] + member this.Prop = 1 + +T().{caret} +""" + + [] + let ``Prop - Static 01`` () = + assertItem "Prop" """ +open System.ComponentModel + +type T() = + [] + static member Prop = 1 + +T.{caret} +""" + + [] + let ``Prop - Always 01`` () = + assertItemAlways "Prop" """ +open System.ComponentModel + +type T() = + [] + static member Prop = 1 + +T.{caret} +""" + + [] + let ``Method - Static 01`` () = + assertItem "Method" """ +open System.ComponentModel + +type T() = + [] + static member Method() = 1 + +T.{caret} +""" + + [] + let ``Event - Instance 01`` () = + assertItem "Ev" """ +open System.ComponentModel + +type T() = + [] + member _.Ev = Event().Publish + +T().{caret} +""" + + [] + let ``Union 01`` () = + assertItem "A" """ +open System.ComponentModel + +type U = + | [] A + | B + +U.{caret} +""" + + [] + let ``Union 02`` () = + assertItem "A" """ +open System.ComponentModel + +type U = + | [] A + | B + +let y = 1 + +do + {caret} +""" + + [] + let ``Type 01`` () = + assertItem "T" """ +open System.ComponentModel + +[] +type T() = class end + +{caret} +""" + + [] + let ``Type 02`` () = + assertItem "T" """ +open System.ComponentModel + +module M = + [] + type T() = class end + +M.{caret} +""" + + [] + let ``Prop - Nested type 01`` () = + assertItem "Prop" """ +open System.ComponentModel + +module M = + type T() = + [] + static member Prop = 1 + +M.T.{caret} +""" + + [] + let ``Type - Members of hidden type are shown`` () = + assertItemAlways "Prop" """ +open System.ComponentModel + +module M = + [] + type T() = + static member Prop = 1 + +M.T.{caret} +""" + + [] + let ``Module 01`` () = + assertItem "M" """ +open System.ComponentModel + +[] +module M = + let x = 1 + +let y = 1 + +do + {caret} +""" + + [] + let ``Module 02`` () = + assertItem "N" """ +open System.ComponentModel + +module M = + [] + module N = + let x = 1 + +M.{caret} +""" + + [] + let ``Module - Contents of hidden module are shown`` () = + assertItemAlways "x" """ +open System.ComponentModel + +[] +module M = + let x = 1 + +M.{caret} +""" + + [] + let ``Value 01`` () = + assertItem "x" """ +open System.ComponentModel + +[] +let x = 1 + +{caret} +""" + + [] + let ``Value 02`` () = + assertItem "x" """ +open System.ComponentModel + +module M = + [] + let x = 1 + +M.{caret} +""" + + [] + let ``Exception 01`` () = + assertItem "E" """ +open System.ComponentModel + +[] +exception E + +{caret} +""" + + [] + let ``Active pattern 01`` () = + assertItem "Even" """ +open System.ComponentModel + +module M = + [] + let (|Even|Odd|) x = if x % 2 = 0 then Even else Odd + +M.{caret} +""" + + [] + let ``CSharp - Type is hidden`` () = + assertCSharpInteropItem suggestsNever "EditorBrowsableNeverClass" """ +open FSharp.Compiler.Service.Tests +EditorBrowsable{caret} +""" + + [] + let ``CSharp - Members of hidden type are shown`` () = + assertCSharpInteropItem (fun _ -> true) "Prop" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableNeverClass.{caret} +""" + + [] + let ``CSharp - Field is hidden`` () = + assertCSharpInteropItem suggestsNever "NeverField" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + + [] + let ``CSharp - Method is hidden`` () = + assertCSharpInteropItem suggestsNever "NeverMethod" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + + [] + let ``CSharp - Property is hidden`` () = + assertCSharpInteropItem suggestsNever "NeverProperty" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + + [] + let ``CSharp - Event is hidden`` () = + assertCSharpInteropItem suggestsNever "NeverEvent" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + + [] + let ``CSharp - Other states are always shown`` () = + for name in ["AdvancedProperty"; "AlwaysProperty"; "VisibleProperty"] do + assertCSharpInteropItem (fun _ -> true) name """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + + module EditorBrowsableAdvanced = + let private allowOptions = { FSharpCodeCompletionOptions.Default with SuggestEditorBrowsableSymbols = EditorBrowsableState.Advanced } + let private disallowOptions = { FSharpCodeCompletionOptions.Default with SuggestEditorBrowsableSymbols = EditorBrowsableState.Always } + + let private suggestsAdvanced (options: FSharpCodeCompletionOptions) = + options.SuggestEditorBrowsableSymbols <> EditorBrowsableState.Always + + let private assertItemNever (name: string) source = + assertItemWithOptions (fun _ -> false) [allowOptions; disallowOptions] name source + + let private assertItemWithOptions = + assertItemWithOptions suggestsAdvanced + + let assertItem (name: string) source = + assertItemWithOptions [allowOptions; disallowOptions] name source + + let private assertCSharpInteropItem contains name source = + assertCSharpInteropItemWithOptions contains [allowOptions; disallowOptions] name source + + [] + let ``Default shows advanced items`` () = + FSharpCodeCompletionOptions.Default.SuggestEditorBrowsableSymbols |> shouldEqual EditorBrowsableState.Advanced + + [] + let ``Prop - Static 01`` () = + assertItem "Prop" """ +open System.ComponentModel + +type T() = + [] + static member Prop = 1 + +T.{caret} +""" + + [] + let ``Never items are not affected`` () = + assertItemNever "Prop" """ +open System.ComponentModel + +type T() = + [] + static member Prop = 1 + +T.{caret} +""" + + [] + let ``CSharp - Advanced property`` () = + assertCSharpInteropItem suggestsAdvanced "AdvancedProperty" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + + [] + let ``CSharp - Advanced type`` () = + assertCSharpInteropItem suggestsAdvanced "EditorBrowsableAdvancedClass" """ +open FSharp.Compiler.Service.Tests +EditorBrowsable{caret} +""" + + assertCSharpInteropItem (fun _ -> false) "NeverProperty" """ +open FSharp.Compiler.Service.Tests +EditorBrowsableMembersClass.{caret} +""" + module PatternNameSuggestions = let private suggestPatternNames = { FSharpCodeCompletionOptions.Default with SuggestPatternNames = true } let private doNotSuggestPatternNames = { FSharpCodeCompletionOptions.Default with SuggestPatternNames = false } diff --git a/tests/FSharp.Compiler.Service.Tests/EditorTests.fs b/tests/FSharp.Compiler.Service.Tests/EditorTests.fs index 0f4a47c440b..b65ecfce4a6 100644 --- a/tests/FSharp.Compiler.Service.Tests/EditorTests.fs +++ b/tests/FSharp.Compiler.Service.Tests/EditorTests.fs @@ -25,9 +25,6 @@ let stringMethods = "EnumerateRunes"; #endif "Equals"; "GetEnumerator"; "GetHashCode"; -#if NETCOREAPP - "GetPinnableReference"; -#endif "GetReverseIndex"; "GetType"; "GetTypeCode"; "IndexOf"; "IndexOfAny"; "Insert"; "IsNormalized"; "LastIndexOf"; "LastIndexOfAny"; "Length"; "Normalize"; "PadLeft"; "PadRight"; "Remove"; diff --git a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl index bdc5a226bcd..6ff7fc88c36 100644 --- a/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl +++ b/tests/FSharp.Compiler.Service.Tests/FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl @@ -315,6 +315,7 @@ FSharp.Compiler.AbstractIL.IL+ILAttributesStored: ILAttributes CustomAttrs FSharp.Compiler.AbstractIL.IL+ILAttributesStored: ILAttributes get_CustomAttrs() FSharp.Compiler.AbstractIL.IL+ILAttributesStored: ILAttributesStored CreateGiven(ILAttributes) FSharp.Compiler.AbstractIL.IL+ILAttributesStored: ILAttributesStored CreateReader(Int32, Microsoft.FSharp.Core.FSharpFunc`2[System.Int32,FSharp.Compiler.AbstractIL.IL+ILAttribute[]]) +FSharp.Compiler.AbstractIL.IL+ILAttributesStored: WellKnownILAttributes GetOrComputeWellKnownFlags(Microsoft.FSharp.Core.FSharpFunc`2[FSharp.Compiler.AbstractIL.IL+ILAttributes,FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes]) FSharp.Compiler.AbstractIL.IL+ILCallingConv: Boolean Equals(ILCallingConv) FSharp.Compiler.AbstractIL.IL+ILCallingConv: Boolean Equals(ILCallingConv, System.Collections.IEqualityComparer) FSharp.Compiler.AbstractIL.IL+ILCallingConv: Boolean Equals(System.Object) @@ -1845,6 +1846,8 @@ FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes Calle FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes CallerMemberNameAttribute FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes CompilerFeatureRequiredAttribute FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes DefaultMemberAttribute +FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes EditorBrowsableAdvanced +FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes EditorBrowsableNever FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes ExperimentalAttribute FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes ExtensionAttribute FSharp.Compiler.AbstractIL.IL+WellKnownILAttributes: WellKnownILAttributes IDispatchConstantAttribute @@ -2234,8 +2237,10 @@ FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: Int32 CompareTo(System FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: Int32 CompareTo(System.Object, System.Collections.IComparer) FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: Int32 GetHashCode() FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: Int32 GetHashCode(System.Collections.IEqualityComparer) +FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: System.ComponentModel.EditorBrowsableState SuggestEditorBrowsableSymbols +FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: System.ComponentModel.EditorBrowsableState get_SuggestEditorBrowsableSymbols() FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: System.String ToString() -FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: Void .ctor(Boolean, Boolean, Boolean, Boolean) +FSharp.Compiler.CodeAnalysis.FSharpCodeCompletionOptions: Void .ctor(Boolean, Boolean, System.ComponentModel.EditorBrowsableState, Boolean, Boolean) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsBindingALambdaAtPosition(FSharp.Compiler.Text.Position) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsPosContainedInApplication(FSharp.Compiler.Text.Position) FSharp.Compiler.CodeAnalysis.FSharpParseFileResults: Boolean IsPositionContainedInACurriedParameter(FSharp.Compiler.Text.Position) diff --git a/tests/service/data/CSharp_Analysis/CSharpClass.cs b/tests/service/data/CSharp_Analysis/CSharpClass.cs index e8afc869dc2..439ad07591d 100644 --- a/tests/service/data/CSharp_Analysis/CSharpClass.cs +++ b/tests/service/data/CSharp_Analysis/CSharpClass.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Runtime.InteropServices; using System.Text; @@ -176,4 +177,32 @@ public static void NonObsoleteMethod() { } public static int NonObsoleteProperty => 2; public static event EventHandler NonObsoleteEvent; } + + [EditorBrowsable(EditorBrowsableState.Never)] + public class EditorBrowsableNeverClass + { + public static int Prop => 1; + } + + [EditorBrowsable(EditorBrowsableState.Advanced)] + public class EditorBrowsableAdvancedClass + { + } + + public class EditorBrowsableMembersClass + { + [EditorBrowsable(EditorBrowsableState.Never)] public static readonly int NeverField = 1; + + [EditorBrowsable(EditorBrowsableState.Never)] + public static void NeverMethod() + { + } + + [EditorBrowsable(EditorBrowsableState.Never)] public static int NeverProperty => 1; + [EditorBrowsable(EditorBrowsableState.Never)] public static event EventHandler NeverEvent; + + [EditorBrowsable(EditorBrowsableState.Advanced)] public static int AdvancedProperty => 2; + [EditorBrowsable] public static int AlwaysProperty => 2; + public static int VisibleProperty => 2; + } }