Skip to content

Commit 9dfed2c

Browse files
committed
#134 Use optional and default attributes for all optional arguments for C# interop
1 parent 3391399 commit 9dfed2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2271
-2227
lines changed

Diff for: src/Plotly.NET/CommonAbstractions/Font.fs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Plotly.NET
2+
open System.Runtime.InteropServices
23

34
open DynamicObj
45

@@ -9,9 +10,9 @@ type Font () =
910
/// Init Font()
1011
static member init
1112
(
12-
?Family ,
13-
?Size ,
14-
?Color
13+
[<Optional;DefaultParameterValue(null)>] ?Family : StyleParam.FontFamily,
14+
[<Optional;DefaultParameterValue(null)>] ?Size : float,
15+
[<Optional;DefaultParameterValue(null)>] ?Color : string
1516
) =
1617
Font()
1718
|> Font.style
@@ -25,9 +26,9 @@ type Font () =
2526
// Applies the styles to Font()
2627
static member style
2728
(
28-
?Family: StyleParam.FontFamily,
29-
?Size: float,
30-
?Color: string
29+
[<Optional;DefaultParameterValue(null)>] ?Family: StyleParam.FontFamily,
30+
[<Optional;DefaultParameterValue(null)>] ?Size: float,
31+
[<Optional;DefaultParameterValue(null)>] ?Color: string
3132
) =
3233
(fun (font:Font) ->
3334

Diff for: src/Plotly.NET/CommonAbstractions/Line.fs

+17-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
namespace Plotly.NET
22

3+
open System.Runtime.InteropServices
34
open DynamicObj
45
open System
56

@@ -10,14 +11,14 @@ type Line () =
1011
/// Initialized Line object
1112
static member init
1213
(
13-
?Width:float,
14-
?Color:string,
15-
?Shape:StyleParam.Shape,
16-
?Dash:StyleParam.DrawingStyle,
17-
?Smoothing:float,
18-
?Colorscale:StyleParam.Colorscale,
19-
?OutlierColor:string,
20-
?OutlierWidth:float
14+
[<Optional;DefaultParameterValue(null)>] ?Width:float,
15+
[<Optional;DefaultParameterValue(null)>] ?Color:string,
16+
[<Optional;DefaultParameterValue(null)>] ?Shape:StyleParam.Shape,
17+
[<Optional;DefaultParameterValue(null)>] ?Dash:StyleParam.DrawingStyle,
18+
[<Optional;DefaultParameterValue(null)>] ?Smoothing:float,
19+
[<Optional;DefaultParameterValue(null)>] ?Colorscale:StyleParam.Colorscale,
20+
[<Optional;DefaultParameterValue(null)>] ?OutlierColor:string,
21+
[<Optional;DefaultParameterValue(null)>] ?OutlierWidth:float
2122

2223
) =
2324
Line ()
@@ -37,14 +38,14 @@ type Line () =
3738
// Applies the styles to Line()
3839
static member style
3940
(
40-
?Width:float,
41-
?Color:string,
42-
?Shape:StyleParam.Shape,
43-
?Dash:StyleParam.DrawingStyle,
44-
?Smoothing:float,
45-
?Colorscale:StyleParam.Colorscale,
46-
?OutlierColor:string,
47-
?OutlierWidth:float
41+
[<Optional;DefaultParameterValue(null)>] ?Width:float,
42+
[<Optional;DefaultParameterValue(null)>] ?Color:string,
43+
[<Optional;DefaultParameterValue(null)>] ?Shape:StyleParam.Shape,
44+
[<Optional;DefaultParameterValue(null)>] ?Dash:StyleParam.DrawingStyle,
45+
[<Optional;DefaultParameterValue(null)>] ?Smoothing:float,
46+
[<Optional;DefaultParameterValue(null)>] ?Colorscale:StyleParam.Colorscale,
47+
[<Optional;DefaultParameterValue(null)>] ?OutlierColor:string,
48+
[<Optional;DefaultParameterValue(null)>] ?OutlierWidth:float
4849

4950
) =
5051
(fun (line:Line) ->

Diff for: src/Plotly.NET/CommonAbstractions/Title.fs

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
namespace Plotly.NET
2+
open System.Runtime.InteropServices
23

34
open DynamicObj
45

@@ -7,10 +8,10 @@ type Title() =
78

89
static member init
910
(
10-
?Text : string,
11-
?Font : Font,
12-
?Standoff : int,
13-
?Side : StyleParam.Side
11+
[<Optional;DefaultParameterValue(null)>] ?Text : string,
12+
[<Optional;DefaultParameterValue(null)>] ?Font : Font,
13+
[<Optional;DefaultParameterValue(null)>] ?Standoff : int,
14+
[<Optional;DefaultParameterValue(null)>] ?Side : StyleParam.Side
1415
) =
1516
Title()
1617
|> Title.style
@@ -23,10 +24,10 @@ type Title() =
2324

2425
static member style
2526
(
26-
?Text : string,
27-
?Font : Font,
28-
?Standoff : int,
29-
?Side : StyleParam.Side
27+
[<Optional;DefaultParameterValue(null)>] ?Text : string,
28+
[<Optional;DefaultParameterValue(null)>] ?Font : Font,
29+
[<Optional;DefaultParameterValue(null)>] ?Standoff : int,
30+
[<Optional;DefaultParameterValue(null)>] ?Side : StyleParam.Side
3031
) =
3132
(fun (title:Title) ->
3233

Diff for: src/Plotly.NET/Config/Config.fs

+25-24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Plotly.NET
22

33
open DynamicObj
4+
open System.Runtime.InteropServices
45

56
// missing config props:
67

@@ -323,11 +324,11 @@ type ToImageButtonOptions() =
323324
inherit DynamicObj()
324325
static member init
325326
(
326-
?Format : StyleParam.ImageFormat,
327-
?Filename : string,
328-
?Width : float,
329-
?Height : float,
330-
?Scale : float
327+
[<Optional;DefaultParameterValue(null)>] ?Format : StyleParam.ImageFormat,
328+
[<Optional;DefaultParameterValue(null)>] ?Filename : string,
329+
[<Optional;DefaultParameterValue(null)>] ?Width : float,
330+
[<Optional;DefaultParameterValue(null)>] ?Height : float,
331+
[<Optional;DefaultParameterValue(null)>] ?Scale : float
331332
) =
332333
ToImageButtonOptions()
333334
|> ToImageButtonOptions.style
@@ -341,11 +342,11 @@ type ToImageButtonOptions() =
341342

342343
static member style
343344
(
344-
?Format,
345-
?Filename,
346-
?Width,
347-
?Height,
348-
?Scale
345+
[<Optional;DefaultParameterValue(null)>] ?Format,
346+
[<Optional;DefaultParameterValue(null)>] ?Filename,
347+
[<Optional;DefaultParameterValue(null)>] ?Width,
348+
[<Optional;DefaultParameterValue(null)>] ?Height,
349+
[<Optional;DefaultParameterValue(null)>] ?Scale
349350
) =
350351
fun (btnConf:ToImageButtonOptions) ->
351352
Format |> Option.map StyleParam.ImageFormat.toString |> DynObj.setValueOpt btnConf "format"
@@ -361,13 +362,13 @@ type Config() =
361362
/// Init Legend type
362363
static member init
363364
(
364-
?StaticPlot : bool,
365-
?Autosizable : bool,
366-
?Responsive : bool,
367-
?ShowEditInChartStudio : bool,
368-
?ToImageButtonOptions : ToImageButtonOptions,
369-
?Editable : bool,
370-
?EditableAnnotations : seq<StyleParam.AnnotationEditOptions>
365+
[<Optional;DefaultParameterValue(null)>] ?StaticPlot : bool,
366+
[<Optional;DefaultParameterValue(null)>] ?Autosizable : bool,
367+
[<Optional;DefaultParameterValue(null)>] ?Responsive : bool,
368+
[<Optional;DefaultParameterValue(null)>] ?ShowEditInChartStudio : bool,
369+
[<Optional;DefaultParameterValue(null)>] ?ToImageButtonOptions : ToImageButtonOptions,
370+
[<Optional;DefaultParameterValue(null)>] ?Editable : bool,
371+
[<Optional;DefaultParameterValue(null)>] ?EditableAnnotations : seq<StyleParam.AnnotationEditOptions>
371372
) =
372373
Config()
373374
|> Config.style
@@ -387,13 +388,13 @@ type Config() =
387388
(
388389
// 'Statically override options for toImage modebar button',
389390
// 'allowed keys are format, filename, width, height, scale',
390-
?StaticPlot : bool,
391-
?Autosizable : bool,
392-
?Responsive : bool,
393-
?ToImageButtonOptions : ToImageButtonOptions,
394-
?ShowEditInChartStudio : bool,
395-
?Editable : bool,
396-
?EditableAnnotations : seq<StyleParam.AnnotationEditOptions>
391+
[<Optional;DefaultParameterValue(null)>] ?StaticPlot : bool,
392+
[<Optional;DefaultParameterValue(null)>] ?Autosizable : bool,
393+
[<Optional;DefaultParameterValue(null)>] ?Responsive : bool,
394+
[<Optional;DefaultParameterValue(null)>] ?ToImageButtonOptions : ToImageButtonOptions,
395+
[<Optional;DefaultParameterValue(null)>] ?ShowEditInChartStudio : bool,
396+
[<Optional;DefaultParameterValue(null)>] ?Editable : bool,
397+
[<Optional;DefaultParameterValue(null)>] ?EditableAnnotations : seq<StyleParam.AnnotationEditOptions>
397398

398399
) =
399400
fun (config:Config) ->

Diff for: src/Plotly.NET/DisplayOptions/DisplayOptions.fs

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
namespace Plotly.NET
22

33
open DynamicObj
4+
open System.Runtime.InteropServices
45

56
type ChartDescription =
67
{
@@ -32,8 +33,8 @@ type DisplayOptions() =
3233

3334
static member init
3435
(
35-
?AdditionalHeadTags:seq<string>,
36-
?Description:ChartDescription
36+
[<Optional;DefaultParameterValue(null)>] ?AdditionalHeadTags:seq<string>,
37+
[<Optional;DefaultParameterValue(null)>] ?Description:ChartDescription
3738
) =
3839
DisplayOptions()
3940
|> DisplayOptions.style
@@ -46,8 +47,8 @@ type DisplayOptions() =
4647
// Applies the styles to Font()
4748
static member style
4849
(
49-
?AdditionalHeadTags:seq<string>,
50-
?Description:ChartDescription
50+
[<Optional;DefaultParameterValue(null)>] ?AdditionalHeadTags:seq<string>,
51+
[<Optional;DefaultParameterValue(null)>] ?Description:ChartDescription
5152
) =
5253
(fun (displayOptions:DisplayOptions) ->
5354

0 commit comments

Comments
 (0)