Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0eefd48

Browse files
authored
Merge pull request#12711 from dotnet/merges/main-to-release/dev17.2
Merge main to release/dev17.2
2 parents10c803f +2bdae35 commit0eefd48

File tree

2 files changed

+173
-11
lines changed

2 files changed

+173
-11
lines changed

‎src/fsharp/FSharp.Core/observable.fsi‎

Lines changed: 172 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,38 @@ module Observable =
2525
///
2626
/// <returns>An Observable that propagates information from both sources.</returns>
2727
///
28-
/// <example-tbd></example-tbd>
28+
/// <example>
29+
/// <code lang="fsharp">
30+
/// open System.Reactive.Linq
31+
/// open System
32+
///
33+
/// let createTimer interval =
34+
/// let timer = new Timers.Timer(interval)
35+
/// timer.AutoReset &lt;- true
36+
/// timer.Enabled &lt;- true
37+
/// Observable.Create(fun observer -> timer.Elapsed.Subscribe(observer))
38+
///
39+
/// let observableFirstTimer = createTimer 1000
40+
/// let observableSecondTimer = createTimer 3000
41+
///
42+
/// let result = Observable.merge observableFirstTimer observableSecondTimer
43+
///
44+
/// result.Subscribe(fun output -> printfn $"Output - {output.SignalTime} ")
45+
/// |> ignore
46+
///
47+
/// Console.ReadLine() |> ignore
48+
/// </code>
49+
/// The sample will merge all events at a given interval and output it to the stream: <c>
50+
/// Output - 2/5/2022 3:49:37 AM
51+
/// Output - 2/5/2022 3:49:38 AM
52+
/// Output - 2/5/2022 3:49:39 AM
53+
/// Output - 2/5/2022 3:49:39 AM
54+
/// Output - 2/5/2022 3:49:40 AM
55+
/// Output - 2/5/2022 3:49:41 AM
56+
/// Output - 2/5/2022 3:49:42 AM
57+
/// Output - 2/5/2022 3:49:42 AM
58+
/// </c>
59+
/// </example>
2960
[<CompiledName("Merge")>]
3061
valmerge:source1:IObservable<'T>->source2:IObservable<'T>->IObservable<'T>
3162

@@ -38,7 +69,19 @@ module Observable =
3869
///
3970
/// <returns>An Observable of the type specified by <c>mapping</c>.</returns>
4071
///
41-
/// <example-tbd></example-tbd>
72+
/// <example>
73+
/// <code lang="fsharp">
74+
/// open System.Reactive.Linq
75+
/// let numbers = seq { 1..5 }
76+
/// let observableNumbers = Observable.ToObservable numbers
77+
///
78+
/// let multiplyByTwo = fun number -> number * 2
79+
/// let map = Observable.map multiplyByTwo observableNumbers
80+
///
81+
/// map.Subscribe(fun x -> printf $"{x} ") |> ignore
82+
/// </code>
83+
/// The sample will output: <c>2 4 6 8 10</c>
84+
/// </example>
4285
[<CompiledName("Map")>]
4386
valmap:mapping:('T-> 'U)->source:IObservable<'T>->IObservable<'U>
4487

@@ -54,7 +97,19 @@ module Observable =
5497
///
5598
/// <returns>An Observable that filters observations based on <c>filter</c>.</returns>
5699
///
57-
/// <example-tbd></example-tbd>
100+
/// <example>
101+
/// <code lang="fsharp">
102+
/// open System.Reactive.Linq
103+
/// let numbers = seq { 1..5 }
104+
/// let observableNumbers = Observable.ToObservable numbers
105+
///
106+
/// let getEvenNumbers = fun number -> number % 2 = 0
107+
/// let map = Observable.filter multiplyByTwo observableNumbers
108+
///
109+
/// map.Subscribe(fun x -> printf $"{x} ") |> ignore
110+
/// </code>
111+
/// The sample will output: <c>2 4</c>
112+
/// </example>
58113
[<CompiledName("Filter")>]
59114
valfilter:predicate:('T-> bool)->source:IObservable<'T>->IObservable<'T>
60115

@@ -73,7 +128,24 @@ module Observable =
73128
/// <returns>A tuple of Observables. The first triggers when the predicate returns true, and
74129
/// the second triggers when the predicate returns false.</returns>
75130
///
76-
/// <example-tbd></example-tbd>
131+
/// <example>
132+
/// <code lang="fsharp">
133+
/// open System.Reactive.Linq
134+
/// let numbers = seq { 1..5 }
135+
/// let observableNumbers = Observable.ToObservable numbers
136+
///
137+
/// let isEvenNumber = fun number -> number % 2 = 0
138+
/// let initialState = 2
139+
///
140+
/// let leftPartition, rightPartition =
141+
/// Observable.partition isEvenNumber observableNumbers
142+
///
143+
/// leftPartition.Subscribe(fun x -> printfn $"Left partition: {x}") |> ignore
144+
///
145+
/// rightPartition.Subscribe(fun x -> printfn $"Right partition: {x}") |> ignore
146+
/// </code>
147+
/// The sample evaluates to: <c>Left partition: 2, 4, Right partition: 1, 3, 5</c>
148+
/// </example>
77149
[<CompiledName("Partition")>]
78150
valpartition:predicate:('T-> bool)->source:IObservable<'T>->(IObservable<'T>* IObservable<'T>)
79151

@@ -92,7 +164,36 @@ module Observable =
92164
/// <returns>A tuple of Observables. The first triggers when <c>splitter</c> returns Choice1of2
93165
/// and the second triggers when <c>splitter</c> returns Choice2of2.</returns>
94166
///
95-
/// <example-tbd></example-tbd>
167+
/// <example>
168+
/// <code lang="fsharp">
169+
/// open System.Reactive.Linq
170+
/// let numbers = seq { 1..5 }
171+
/// let observableNumbers = Observable.ToObservable numbers
172+
///
173+
/// let getEvenNumbers number =
174+
/// match number % 2 = 0 with
175+
/// | true -> Choice1Of2 number
176+
/// | false -> Choice2Of2 $"{number} is not an even number"
177+
///
178+
/// let evenSplit, printOddNumbers = Observable.split getEvenNumbers observableNumbers
179+
///
180+
/// let printOutput observable functionName =
181+
/// use subscription =
182+
/// Observable.subscribe
183+
/// (fun output -> printfn $"{functionName} - Split output: {output}. Type: {output.GetType()}")
184+
/// observable
185+
///
186+
/// subscription
187+
///
188+
/// printOutput evenSplit (nameof evenSplit) |> ignore
189+
/// printOutput printOddNumbers (nameof printOddNumbers) |> ignore
190+
/// </code>
191+
/// The sample evaluates to: <c>evenSplit - Split output: 2. Type: System.Int32
192+
/// evenSplit - Split output: 4. Type: System.Int32
193+
/// printOddNumbers - Split output: 1 is not an even number. Type: System.String
194+
/// printOddNumbers - Split output: 3 is not an even number. Type: System.String
195+
/// printOddNumbers - Split output: 5 is not an even number. Type: System.String</c>
196+
/// </example>
96197
[<CompiledName("Split")>]
97198
valsplit:splitter:('T-> Choice<'U1,'U2>)->source:IObservable<'T>->(IObservable<'U1>* IObservable<'U2>)
98199

@@ -107,7 +208,23 @@ module Observable =
107208
///
108209
/// <returns>An Observable that only propagates some of the observations from the source.</returns>
109210
///
110-
/// <example-tbd></example-tbd>
211+
/// <example>
212+
/// <code lang="fsharp">
213+
/// open System.Reactive.Linq
214+
/// let numbers = seq { 1..5 }
215+
/// let observableNumbers = Observable.ToObservable numbers
216+
///
217+
/// let getOddNumbers number =
218+
/// match number with
219+
/// | _ when number % 2 = 0 -> None
220+
/// | _ -> Some number
221+
///
222+
/// let map = Observable.choose getOddNumbers observableNumbers
223+
///
224+
/// map.Subscribe(fun x -> printf $"{x} ") |> ignore
225+
/// </code>
226+
/// The sample will output: <c>1 3 5</c>
227+
/// </example>
111228
[<CompiledName("Choose")>]
112229
valchoose:chooser:('T-> 'U option)->source:IObservable<'T>->IObservable<'U>
113230

@@ -126,7 +243,20 @@ module Observable =
126243
///
127244
/// <returns>An Observable that triggers on the updated state values.</returns>
128245
///
129-
/// <example-tbd></example-tbd>
246+
/// <example>
247+
/// <code lang="fsharp">
248+
/// open System.Reactive.Linq
249+
/// let numbers = seq { 1..5 }
250+
/// let observableNumbers = Observable.ToObservable numbers
251+
///
252+
/// let multiplyBy number = fun y -> number * y
253+
/// let initialState = 2
254+
/// let scan = Observable.scan multiplyBy initialState observableNumbers
255+
///
256+
/// scan.Subscribe(fun x -> printf "%A " x) |> ignore
257+
/// </code>
258+
/// The sample evaluates to: <c>2 4 12 48 240</c>
259+
/// </example>
130260
[<CompiledName("Scan")>]
131261
valscan:collector:('U-> 'T-> 'U)->state:'U->source:IObservable<'T>->IObservable<'U>
132262

@@ -136,7 +266,16 @@ module Observable =
136266
/// <param name="callback">The function to be called on each observation.</param>
137267
/// <param name="source">The input Observable.</param>
138268
///
139-
/// <example-tbd></example-tbd>
269+
/// <example>
270+
/// <code lang="fsharp">
271+
/// open System.Reactive.Linq
272+
/// let numbers = seq { 1..5 }
273+
/// let observableNumbers = Observable.ToObservable numbers
274+
/// let multiplyByTwo = fun number -> printf $"{number * 2} "
275+
/// Observable.add multiplyByTwo observableNumbers
276+
/// </code>
277+
/// The sample evaluates to: <c>2 4 6 8 10</c>
278+
/// </example>
140279
[<CompiledName("Add")>]
141280
valadd:callback:('T-> unit)->source:IObservable<'T>->unit
142281

@@ -148,7 +287,18 @@ module Observable =
148287
///
149288
/// <returns>An object that will remove the callback if disposed.</returns>
150289
///
151-
/// <example-tbd></example-tbd>
290+
/// <example>
291+
/// <code lang="fsharp">
292+
/// open System.Reactive.Linq
293+
/// let numbers = seq { 1..3 }
294+
/// let observableNumbers = Observable.ToObservable numbers
295+
/// let printOutput observable =
296+
/// use subscription = Observable.subscribe (fun x -> printfn "%A" x) observable
297+
/// subscription
298+
/// printOutput observableNumbers |> ignore
299+
/// </code>
300+
/// The sample evaluates to: <c>1, 2, 3</c>
301+
/// </example>
152302
[<CompiledName("Subscribe")>]
153303
valsubscribe:callback:('T-> unit)->source:IObservable<'T>->System.IDisposable
154304

@@ -164,6 +314,18 @@ module Observable =
164314
///
165315
/// <returns>An Observable that triggers on successive pairs of observations from the input Observable.</returns>
166316
///
167-
/// <example-tbd></example-tbd>
317+
/// <example>
318+
/// <code lang="fsharp">
319+
/// /// open System.Reactive.Linq
320+
/// let numbers = seq { 1..5 }
321+
/// let observableNumbers = Observable.ToObservable numbers
322+
///
323+
/// let pairWise = Observable.pairwise observableNumbers
324+
///
325+
/// pairWise.Subscribe(fun pair -> printf $"{pair} ")
326+
/// |> ignore
327+
/// </code>
328+
/// The sample evaluates to: <c>(1, 2), (2, 3), (3, 4), (4, 5)</c>
329+
/// </example>
168330
[<CompiledName("Pairwise")>]
169331
valpairwise:source:IObservable<'T>->IObservable<'T*'T>

‎src/fsharp/XmlDocFileWriter.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ module XmlDocWriter =
106106

107107
doModule generatedCcu.Contents
108108

109-
use os= FileSystem.OpenFileForWriteShim(xmlfile, FileMode.OpenOrCreate).GetWriter()
109+
use os= FileSystem.OpenFileForWriteShim(xmlfile, FileMode.Create).GetWriter()
110110

111111
fprintfn os"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
112112
fprintfn os"<doc>"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp