Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always emit conditional attributes in FCS #6004

Merged
merged 6 commits into from
Jan 16, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10829,8 +10829,10 @@ and TcAttribute canFail cenv (env: TcEnv) attrTgt (synAttr: SynAttribute) =
let conditionalCallDefineOpt = TryFindTyconRefStringAttribute cenv.g mAttr cenv.g.attrib_ConditionalAttribute tcref

match conditionalCallDefineOpt with
#if !COMPILER_SERVICE_AS_DLL
| Some d when not (List.contains d cenv.conditionalDefines) ->
[], false
#endif
| _ ->

// REVIEW: take notice of inherited?
Expand Down
25 changes: 24 additions & 1 deletion tests/service/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,27 @@ module Mod2 =
mod1val1.XmlDocSig |> shouldEqual "P:Mod1.val1"
mod2func2.XmlDocSig |> shouldEqual "M:Mod1.Mod2.func2"



module Attributes =
[<Test>]
let ``Emit conditional attributes`` () =
let source = """
open System
open System.Diagnostics

[<Conditional("Bar")>]
type FooAttribute() =
inherit Attribute()

[<Foo>]
let x = 123
"""
let fileName, options = mkTestFileAndOptions source [| |]
let _, checkResults = parseAndCheckFile fileName source options

checkResults.GetAllUsesOfAllSymbolsInFile()
|> Async.RunSynchronously
|> Array.tryFind (fun su -> su.Symbol.DisplayName = "x")
|> Option.orElseWith (fun _ -> failwith "Could not get symbol")
|> Option.map (fun su -> su.Symbol :?> FSharpMemberOrFunctionOrValue)
|> Option.iter (fun symbol -> symbol.Attributes.Count |> shouldEqual 1)