Skip to content

Commit ce96c61

Browse files
committed
Merge pull request #410 from hoanhtien/NodejsPackageInstanceNullCheck
Fix #409 - Add null check for NodejsPackage.Instance.
2 parents 70ade8c + 17127a9 commit ce96c61

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Nodejs/Product/Nodejs/Logging/LiveLogger.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@ internal sealed class LiveLogger {
3232
private static volatile LiveLogger _instance;
3333
private static object _loggerLock = new object();
3434

35-
private NodejsDiagnosticsOptionsPage _diagnosticsOptions;
35+
private NodejsDiagnosticsOptionsPage _diagnosticsOptions = null;
3636

3737
private LiveLogger() {
38-
_diagnosticsOptions = NodejsPackage.Instance.DiagnosticsOptionsPage;
38+
if (NodejsPackage.Instance != null) {
39+
_diagnosticsOptions = NodejsPackage.Instance.DiagnosticsOptionsPage;
40+
}
3941
}
4042

4143
private static LiveLogger Instance {
@@ -68,7 +70,7 @@ public static void WriteLine(string format, params object[] args) {
6870
private void LogMessage(string message) {
6971
Debug.WriteLine(message);
7072

71-
if (_diagnosticsOptions.IsLiveDiagnosticsEnabled) {
73+
if (_diagnosticsOptions != null && _diagnosticsOptions.IsLiveDiagnosticsEnabled) {
7274
var pane = OutputWindowRedirector.Get(VisualStudio.Shell.ServiceProvider.GlobalProvider, LiveDiagnosticLogPaneGuid, LiveDiagnosticLogPaneName);
7375
if (pane != null) {
7476
pane.WriteLine(message);

0 commit comments

Comments
 (0)