Skip to content

Commit eeb4800

Browse files
committed
Fixed compiler error with DialogWindow
xbuild cannot compile function overload properly when the functions have optional parameter. Change remove the 1 option and 2 options variation and makes option1 and option2 optional. Change-Id: If68dc2783488847937ea030f8189f09f0446a708
1 parent 950379f commit eeb4800

File tree

3 files changed

+6
-61
lines changed

3 files changed

+6
-61
lines changed

source/VersionHandlerImpl/src/DialogWindow.cs

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ private class DialogContext {
121121
/// is created and before it is displayed.</param>
122122
public delegate void DisplayDelegate(
123123
string title, string message, Option defaultOption,
124-
string option0, string option1, string option2,
124+
string option0, string option1 = null, string option2 = null,
125125
float windowWidth = DEFAULT_WINDOWS_WIDTH, Option windowCloseOption = Option.SelectedNone,
126126
Action<Option> complete = null,
127127
Action<DialogWindow> renderContent = null,
@@ -257,7 +257,7 @@ internal static void DisplayDefault(string title, string message, Option default
257257
/// <param name="init">(Optional) Callback for additional initialization after the dialog
258258
/// is created and before it is displayed.</param>
259259
public static void Display(string title, string message, Option defaultOption,
260-
string option0, string option1, string option2,
260+
string option0, string option1 = null, string option2 = null,
261261
float windowWidth = DEFAULT_WINDOWS_WIDTH,
262262
Option windowCloseOption = Option.SelectedNone,
263263
Action<Option> complete = null, Action<DialogWindow> renderContent = null,
@@ -266,60 +266,6 @@ public static void Display(string title, string message, Option defaultOption,
266266
windowCloseOption, complete, renderContent, renderButtons, init);
267267
}
268268

269-
/// <summary>
270-
/// Displays a non-blocking modal dialog with up to 2 options.
271-
/// </summary>
272-
/// <param name="title">Title of the dialog.</param>
273-
/// <param name="message">Message to display in the dialog.</param>
274-
/// <param name="defaultOption">Option selected if interactivity is disabled.</param>
275-
/// <param name="option0">Text for the first option.</param>
276-
/// <param name="option1">Text for the second option or null to disable.</param>
277-
/// <param name="windowWidth">(Optional) Width of the dialog window.</param>
278-
/// <param name="windowCloseOption">(Optional) Option selected if the dialog is closed.</param>
279-
/// <param name="complete">(Optional) Callback to trigger once a selection is made.</param>
280-
/// <param name="renderContent">(Optional) Callback to render additional content after
281-
/// dialog message.</param>
282-
/// <param name="renderButtons">(Optional) Callback to render additional content before option
283-
/// buttons in the same row.</param>
284-
/// <param name="init">(Optional) Callback for additional initialization after the dialog
285-
/// is created and before it is displayed.</param>
286-
public static void Display(string title, string message, Option defaultOption,
287-
string option0, string option1,
288-
float windowWidth = DEFAULT_WINDOWS_WIDTH,
289-
Option windowCloseOption = Option.SelectedNone,
290-
Action<Option> complete = null, Action<DialogWindow> renderContent = null,
291-
Action<DialogWindow> renderButtons = null, Action<DialogWindow> init = null) {
292-
displayDialogMethod(title, message, defaultOption, option0, option1, null, windowWidth,
293-
windowCloseOption, complete, renderContent, renderButtons, init);
294-
}
295-
296-
/// <summary>
297-
/// Displays a non-blocking modal dialog with up to 1 options.
298-
/// </summary>
299-
/// <param name="title">Title of the dialog.</param>
300-
/// <param name="message">Message to display in the dialog.</param>
301-
/// <param name="defaultOption">Option selected if interactivity is disabled.</param>
302-
/// <param name="option0">Text for the first option.</param>
303-
/// <param name="option1">Text for the second option or null to disable.</param>
304-
/// <param name="windowWidth">(Optional) Width of the dialog window.</param>
305-
/// <param name="windowCloseOption">(Optional) Option selected if the dialog is closed.</param>
306-
/// <param name="complete">(Optional) Callback to trigger once a selection is made.</param>
307-
/// <param name="renderContent">(Optional) Callback to render additional content after
308-
/// dialog message.</param>
309-
/// <param name="renderButtons">(Optional) Callback to render additional content before option
310-
/// buttons in the same row.</param>
311-
/// <param name="init">(Optional) Callback for additional initialization after the dialog
312-
/// is created and before it is displayed.</param>
313-
public static void Display(string title, string message, Option defaultOption,
314-
string option0,
315-
float windowWidth = DEFAULT_WINDOWS_WIDTH,
316-
Option windowCloseOption = Option.SelectedNone,
317-
Action<Option> complete = null, Action<DialogWindow> renderContent = null,
318-
Action<DialogWindow> renderButtons = null, Action<DialogWindow> init = null) {
319-
displayDialogMethod(title, message, defaultOption, option0, null, null, windowWidth,
320-
windowCloseOption, complete, renderContent, renderButtons, init);
321-
}
322-
323269
/// <summary>
324270
/// Render the dialog according to the context.
325271
/// </summary>

source/VersionHandlerImpl/src/EditorMeasurement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ public void PromptToEnable(Action complete) {
362362
displayDialog(
363363
String.Format(EnableAnalytics, PluginName),
364364
String.Format(RequestConsentMessage, PluginName),
365-
DialogWindow.Option.Selected1, Yes, No, "",
365+
DialogWindow.Option.Selected1, Yes, No,
366366
windowWidth: 500.0f,
367367
complete: option => {
368368
switch (option) {

source/VersionHandlerImpl/unit_tests/src/EditorMeasurementTest.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private EditorMeasurement CreateEditorMeasurement() {
136136
SETTINGS_NAMESPACE, PLUGIN_NAME,
137137
DATA_COLLECTION_DESCRIPTION, PRIVACY_POLICY);
138138
analytics.displayDialog = (title, message, defaultOption, option0, option1,
139-
option2, windowWidth, windowCloseOption,
139+
windowWidth, windowCloseOption,
140140
complete, renderContent, renderButtons, init) => {
141141
throw new Exception("Unexpected dialog displayed");
142142
};
@@ -184,10 +184,10 @@ public void Construct() {
184184
/// </summary>
185185
/// <param name="selectedOption">0..2</param>
186186
/// <returns>Display dialog delegate.</returns>
187-
private DialogWindow.DisplayDelegate CreateDisplayDialogDelegate(
187+
private DialogWindow.Display2OptionsDelegate CreateDisplayDialogDelegate(
188188
List<DialogWindow.Option> selectedOptions) {
189189
return (string title, string message, DialogWindow.Option defaultOption,
190-
string option0, string option1, string option2,
190+
string option0, string option1,
191191
float windowWidth, DialogWindow.Option windowCloseOption,
192192
Action<DialogWindow.Option> complete,
193193
Action<DialogWindow> renderContent,
@@ -198,7 +198,6 @@ private DialogWindow.DisplayDelegate CreateDisplayDialogDelegate(
198198
Assert.That(defaultOption, Is.EqualTo(DialogWindow.Option.Selected0));
199199
Assert.That(option0, Is.Not.Empty);
200200
Assert.That(option1, Is.Not.Empty);
201-
Assert.That(option2, Is.Empty);
202201
Assert.That(windowCloseOption, Is.EqualTo(DialogWindow.Option.Selected0));
203202
Assert.That(complete, Is.Not.Null);
204203
Assert.That(renderContent, Is.Not.Null);

0 commit comments

Comments
 (0)