Skip to content

Commit dd4f98d

Browse files
committed
Fix exposing assembly-level attributes
Previously only declarations in the last code file was visible
1 parent 35d4270 commit dd4f98d

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/fsharp/vs/IncrementalBuild.fs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1532,7 +1532,11 @@ module internal IncrementalFSharpBuild =
15321532
errorRecoveryNoRange e
15331533
mkSimpleAssRef assemblyName, None, None
15341534

1535-
let finalAccWithErrors = { finalAcc with tcErrors = finalAcc.tcErrors @ errorLogger.GetErrors() }
1535+
let finalAccWithErrors =
1536+
{ finalAcc with
1537+
tcErrors = finalAcc.tcErrors @ errorLogger.GetErrors()
1538+
topAttribs = Some topAttrs
1539+
}
15361540
ilAssemRef, tcAssemblyDataOpt, tcAssemblyExprOpt, finalAccWithErrors
15371541

15381542
// END OF BUILD TASK FUNCTIONS

tests/service/ProjectAnalysisTests.fs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,17 +4502,24 @@ module Project37 =
45024502

45034503
let fileName1 = Path.ChangeExtension(Path.GetTempFileName(), ".fs")
45044504
let base2 = Path.GetTempFileName()
4505+
let fileName2 = Path.ChangeExtension(base2, ".fs")
45054506
let dllName = Path.ChangeExtension(base2, ".dll")
45064507
let projFileName = Path.ChangeExtension(base2, ".fsproj")
45074508
let fileSource1 = """
4508-
[<System.AttributeUsage(System.AttributeTargets.Method ||| System.AttributeTargets.Assembly)>]
4509+
namespace AttrTests
4510+
4511+
[<System.AttributeUsage(System.AttributeTargets.Method ||| System.AttributeTargets.Assembly) >]
45094512
type AttrTestAttribute() =
45104513
inherit System.Attribute()
45114514
45124515
new (t: System.Type) = AttrTestAttribute()
45134516
new (t: System.Type[]) = AttrTestAttribute()
45144517
new (t: int[]) = AttrTestAttribute()
45154518
4519+
[<System.AttributeUsage(System.AttributeTargets.Assembly) >]
4520+
type AttrTest2Attribute() =
4521+
inherit System.Attribute()
4522+
45164523
type TestUnion = | A of string
45174524
type TestRecord = { B : int }
45184525
@@ -4534,7 +4541,14 @@ module Test =
45344541
do ()
45354542
"""
45364543
File.WriteAllText(fileName1, fileSource1)
4537-
let fileNames = [fileName1]
4544+
let fileSource2 = """
4545+
namespace AttrTests
4546+
4547+
[<assembly: AttrTest2()>]
4548+
do ()
4549+
"""
4550+
File.WriteAllText(fileName2, fileSource2)
4551+
let fileNames = [fileName1; fileName2]
45384552
let args = mkProjectCommandLineArgs (dllName, fileNames)
45394553
let options = checker.GetProjectOptionsFromCommandLineArgs (projFileName, args)
45404554
let wholeProjectResults =
@@ -4581,4 +4595,4 @@ let ``Test project37 typeof and arrays in attribute constructor arguments`` () =
45814595
| _ -> ()
45824596
Project37.wholeProjectResults.AssemblySignature.Attributes
45834597
|> Seq.map (fun a -> a.AttributeType.CompiledName)
4584-
|> Array.ofSeq |> shouldEqual [| "AttrTestAttribute" |]
4598+
|> Array.ofSeq |> shouldEqual [| "AttrTestAttribute"; "AttrTest2Attribute" |]

0 commit comments

Comments
 (0)