Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 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
3 changes: 2 additions & 1 deletion src/FSharp.Core/prim-types.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7299,11 +7299,12 @@ namespace Microsoft.FSharp.Core
namespace Microsoft.FSharp.Control

open System
open System.Diagnostics.CodeAnalysis
open Microsoft.FSharp.Core
open Microsoft.FSharp.Core.Operators

module LazyExtensions =
type Lazy<'T> with
type Lazy<[<DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)>]'T> with
[<CompiledName("Create")>] // give the extension member a 'nice', unmangled compiled name, unique within this module
static member Create(creator : unit -> 'T) : Lazy<'T> =
let creator = Func<'T>(creator)
Expand Down
3 changes: 2 additions & 1 deletion src/FSharp.Core/prim-types.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -6144,6 +6144,7 @@ namespace Microsoft.FSharp.Core

namespace Microsoft.FSharp.Control

open System.Diagnostics.CodeAnalysis
open Microsoft.FSharp.Core

/// <summary>Extensions related to Lazy values.</summary>
Expand All @@ -6152,7 +6153,7 @@ namespace Microsoft.FSharp.Control
[<AutoOpen>]
module LazyExtensions =

type System.Lazy<'T> with
type System.Lazy<[<DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicParameterlessConstructor)>]'T> with

/// <summary>Creates a lazy computation that evaluates to the result of the given function when forced.</summary>
///
Expand Down
16 changes: 16 additions & 0 deletions tests/AheadOfTime/Trimming/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -9365,6 +9365,20 @@ module NonStructuralComparisonOverTimeSpanDirect =
do check "test9407" (NonStructuralComparison.hash 11L) (Operators.hash 11L)
do check "test9408" (NonStructuralComparison.hash 11UL) (Operators.hash 11UL)

let testLazySimple () =
let f23 () = let z = lazy (12345) in z.Force()
check "lazy_simple" 12345 (f23())

let testSeqWithTryFinally () =
let result =
seq {
try
yield 1
yield 2
with
| ex -> ()
} |> Seq.toList
check "seq_try_with" [1; 2] result

[<EntryPoint>]
let main _ =
Expand All @@ -9385,6 +9399,8 @@ let main _ =
PercentAPublicTests.tests ()
PercentAInternalTests.tests ()
ClassWithEvents.testWithEventClass ()
testLazySimple ()
testSeqWithTryFinally ()

match !failures with
| [] ->
Expand Down
2 changes: 1 addition & 1 deletion tests/AheadOfTime/Trimming/check.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function CheckTrim($root, $tfm, $outputfile, $expected_len) {
# error NETSDK1124: Trimming assemblies requires .NET Core 3.0 or higher.

# Check net9.0 trimmed assemblies
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net9.0" -outputfile "FSharp.Core.dll" -expected_len 300032
CheckTrim -root "SelfContained_Trimming_Test" -tfm "net9.0" -outputfile "FSharp.Core.dll" -expected_len 311296

# Check net9.0 trimmed assemblies with static linked FSharpCore
CheckTrim -root "StaticLinkedFSharpCore_Trimming_Test" -tfm "net9.0" -outputfile "StaticLinkedFSharpCore_Trimming_Test.dll" -expected_len 9154048
Expand Down
Loading