Integrate simplified message handling
Rob Mensching committed
Dec 19, 2017 at 12:24 UTC
46a4f1d98fdedc82c701ada198252dfd6099959f
14 files changed
+119
-19
src/WixToolset.Extensibility/BaseCompilerExtension.cs
+1
-1
@@ -15,7 +15,7 @@ namespace WixToolset.Extensibility
15
/// <summary>
16
/// Messaging for use by the extension.
17
/// </summary>
18
- protected Messaging Messaging { get; private set; }
18
+ protected IMessaging Messaging { get; private set; }
19
20
/// <summary>
21
/// ParserHelper for use by the extension.
src/WixToolset.Extensibility/IBinderFileManagerCore.cs
+1
-1
@@ -6,7 +6,7 @@ namespace WixToolset.Extensibility
6
using WixToolset.Data;
7
using WixToolset.Data.Bind;
8
9
- public interface IBinderFileManagerCore : IMessageHandler
9
+ public interface IBinderFileManagerCore
10
{
11
/// <summary>
12
/// Gets or sets the path to cabinet cache.
src/WixToolset.Extensibility/ICompileContext.cs
+2
-1
@@ -6,12 +6,13 @@ namespace WixToolset.Extensibility
6
using System.Collections.Generic;
7
using System.Xml.Linq;
8
using WixToolset.Data;
9
+ using WixToolset.Extensibility.Services;
10
11
public interface ICompileContext
12
{
13
IServiceProvider ServiceProvider { get; }
14
14
- Messaging Messaging { get; set; }
15
+ IMessaging Messaging { get; set; }
16
17
string CompilationId { get; set; }
18
src/WixToolset.Extensibility/IDecompilerCore.cs
+1
-1
@@ -6,7 +6,7 @@ namespace WixToolset.Extensibility
6
using WixToolset.Data;
7
using Wix = WixToolset.Data.Serialize;
8
9
- public interface IDecompilerCore : IMessageHandler
9
+ public interface IDecompilerCore
10
{
11
12
/// <summary>
src/WixToolset.Extensibility/IInscribeContext.cs
+3
-3
@@ -3,18 +3,18 @@
3
namespace WixToolset.Extensibility
4
{
5
using System;
6
- using WixToolset.Data;
6
+ using WixToolset.Extensibility.Services;
7
8
public interface IInscribeContext
9
{
10
IServiceProvider ServiceProvider { get; }
11
12
+ IMessaging Messaging { get; set; }
13
+
14
string InputFilePath { get; set; }
15
16
string IntermediateFolder { get; set; }
17
16
- Messaging Messaging { get; }
17
-
18
string OutputFile { get; set; }
19
20
string SignedEngineFile { get; set; }
src/WixToolset.Extensibility/IInspectorCore.cs
+1
-3
@@ -2,12 +2,10 @@
2
3
namespace WixToolset.Extensibility
4
{
5
- using WixToolset.Data;
6
-
5
/// <summary>
6
/// Core facilities for inspector extensions.
7
/// </summary>
10
- public interface IInspectorCore : IMessageHandler
8
+ public interface IInspectorCore
9
{
10
/// <summary>
11
/// Gets whether an error occured.
src/WixToolset.Extensibility/ILibraryContext.cs
+2
-1
@@ -5,12 +5,13 @@ namespace WixToolset.Extensibility
5
using System;
6
using System.Collections.Generic;
7
using WixToolset.Data;
8
+ using WixToolset.Extensibility.Services;
9
10
public interface ILibraryContext
11
{
12
IServiceProvider ServiceProvider { get; }
13
13
- Messaging Messaging { get; set; }
14
+ IMessaging Messaging { get; set; }
15
16
bool BindFiles { get; set; }
17
src/WixToolset.Extensibility/IMessageListener.cs
new
+17
@@ -0,0 +1,17 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility
4
+{
5
+ using WixToolset.Data;
6
+
7
+ public interface IMessageListener
8
+ {
9
+ string ShortAppName { get; }
10
+
11
+ string LongAppName { get; }
12
+
13
+ void Write(Message message);
14
+
15
+ void Write(string message);
16
+ }
17
+}
src/WixToolset.Extensibility/IPreprocessContext.cs
+2
-1
@@ -5,12 +5,13 @@ namespace WixToolset.Extensibility
5
using System;
6
using System.Collections.Generic;
7
using WixToolset.Data;
8
+ using WixToolset.Extensibility.Services;
9
10
public interface IPreprocessContext
11
{
12
IServiceProvider ServiceProvider { get; }
13
13
- Messaging Messaging { get; set; }
14
+ IMessaging Messaging { get; set; }
15
16
IEnumerable<IPreprocessorExtension> Extensions { get; set; }
17
src/WixToolset.Extensibility/IUnbindContext.cs
+6
-3
@@ -2,10 +2,15 @@
2
3
namespace WixToolset.Extensibility
4
{
5
- using WixToolset.Data;
5
+ using System;
6
+ using WixToolset.Extensibility.Services;
7
8
public interface IUnbindContext
9
{
10
+ IServiceProvider ServiceProvider { get; }
11
+
12
+ IMessaging Messaging { get; set; }
13
+
14
string ExportBasePath { get; set; }
15
16
string InputFilePath { get; set; }
@@ -14,8 +19,6 @@ namespace WixToolset.Extensibility
19
20
bool IsAdminImage { get; set; }
21
17
- Messaging Messaging { get; }
18
-
22
bool SuppressDemodularization { get; set; }
23
24
bool SuppressExtractCabinets { get; set; }
src/WixToolset.Extensibility/Services/IBindContext.cs
+1
-1
@@ -10,7 +10,7 @@ namespace WixToolset.Extensibility.Services
10
{
11
IServiceProvider ServiceProvider { get; }
12
13
- Messaging Messaging { get; set; }
13
+ IMessaging Messaging { get; set; }
14
15
IEnumerable<BindPath> BindPaths { get; set; }
16
src/WixToolset.Extensibility/Services/ICommandLineContext.cs
+1
-2
@@ -3,13 +3,12 @@
3
namespace WixToolset.Extensibility.Services
4
{
5
using System;
6
- using WixToolset.Data;
6
7
public interface ICommandLineContext
8
{
9
IServiceProvider ServiceProvider { get; }
10
12
- Messaging Messaging { get; set; }
11
+ IMessaging Messaging { get; set; }
12
13
IExtensionManager ExtensionManager { get; set; }
14
src/WixToolset.Extensibility/Services/ILinkContext.cs
+1
-1
@@ -10,7 +10,7 @@ namespace WixToolset.Extensibility.Services
10
{
11
IServiceProvider ServiceProvider { get; }
12
13
- Messaging Messaging { get; set; }
13
+ IMessaging Messaging { get; set; }
14
15
IEnumerable<ILinkerExtension> Extensions { get; set; }
16
src/WixToolset.Extensibility/Services/IMessaging.cs
new
+80
@@ -0,0 +1,80 @@
1
+// Copyright (c) .NET Foundation and contributors. All rights reserved. Licensed under the Microsoft Reciprocal License. See LICENSE.TXT file in the project root for full license information.
2
+
3
+namespace WixToolset.Extensibility.Services
4
+{
5
+ using WixToolset.Data;
6
+
7
+ /// <summary>
8
+ /// Interface for handling messages (error/warning/verbose).
9
+ /// </summary>
10
+ public interface IMessaging
11
+ {
12
+ /// <summary>
13
+ /// Indicates whether an error has been found.
14
+ /// </summary>
15
+ /// <value>A bool indicating whether an error has been found.</value>
16
+ bool EncounteredError { get; }
17
+
18
+ /// <summary>
19
+ /// Gets the last error code encountered during messaging.
20
+ /// </summary>
21
+ /// <value>The exit code for the process.</value>
22
+ int LastErrorNumber { get; }
23
+
24
+ /// <summary>
25
+ /// Gets or sets the option to show verbose messages.
26
+ /// </summary>
27
+ /// <value>The option to show verbose messages.</value>
28
+ bool ShowVerboseMessages { get; set; }
29
+
30
+ /// <summary>
31
+ /// Gets or sets the option to suppress all warning messages.
32
+ /// </summary>
33
+ /// <value>The option to suppress all warning messages.</value>
34
+ bool SuppressAllWarnings { get; set; }
35
+
36
+ /// <summary>
37
+ /// Gets and sets the option to treat warnings as errors.
38
+ /// </summary>
39
+ /// <value>The option to treat warnings as errors.</value>
40
+ bool WarningsAsError { get; set; }
41
+
42
+ /// <summary>
43
+ /// Sets the listener for messaging.
44
+ /// </summary>
45
+ /// <param name="listener"></param>
46
+ void SetListener(IMessageListener listener);
47
+
48
+ /// <summary>
49
+ /// Adds a warning message id to be elevated to an error message.
50
+ /// </summary>
51
+ /// <param name="warningNumber">Id of the message to elevate.</param>
52
+ void ElevateWarningMessage(int warningNumber);
53
+
54
+ /// <summary>
55
+ /// Adds a warning message id to be suppressed in message output.
56
+ /// </summary>
57
+ /// <param name="warningNumber">Id of the message to suppress.</param>
58
+ void SuppressWarningMessage(int warningNumber);
59
+
60
+ /// <summary>
61
+ /// Formats a message to standard message.
62
+ /// </summary>
63
+ /// <param name="message">Message to format.</param>
64
+ /// <returns>Formatted message</returns>
65
+ string FormatMessage(Message message);
66
+
67
+ /// <summary>
68
+ /// Sends a message with the given arguments.
69
+ /// </summary>
70
+ /// <param name="message">Message to write.</param>
71
+ void Write(Message message);
72
+
73
+ /// <summary>
74
+ /// Sends a message with the given arguments.
75
+ /// </summary>
76
+ /// <param name="message">Message to write.</param>
77
+ /// <param name="verbose">Indicates where to write a verbose message.</param>
78
+ void Write(string message, bool verbose = false);
79
+ }
80
+}