Skip to content

Commit 42fafd9

Browse files
SLVS-1563 Raise event outside lock block
1 parent d3d6e71 commit 42fafd9

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/SLCore/State/ActiveConfigScopeTracker.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1919
*/
2020

21-
using System;
2221
using System.ComponentModel.Composition;
23-
using System.Diagnostics;
2422
using SonarLint.VisualStudio.Core;
2523
using SonarLint.VisualStudio.Core.Synchronization;
2624
using SonarLint.VisualStudio.SLCore.Core;
@@ -109,26 +107,26 @@ public void SetCurrentConfigScope(string id, string connectionId = null, string
109107
{
110108
configurationScopeService.DidUpdateBinding(new DidUpdateBindingParams(id, GetBinding(connectionId, sonarProjectKey)));
111109
currentConfigScope = currentConfigScope with { ConnectionId = connectionId, SonarProjectId = sonarProjectKey };
112-
OnCurrentConfigurationScopeChanged();
113-
return;
114110
}
115-
116-
configurationScopeService.DidAddConfigurationScopes(new DidAddConfigurationScopesParams([
117-
new ConfigurationScopeDto(id, id, true, GetBinding(connectionId, sonarProjectKey))]));
118-
currentConfigScope = new ConfigurationScope(id, connectionId, sonarProjectKey);
119-
OnCurrentConfigurationScopeChanged();
111+
else
112+
{
113+
configurationScopeService.DidAddConfigurationScopes(new DidAddConfigurationScopesParams([
114+
new ConfigurationScopeDto(id, id, true, GetBinding(connectionId, sonarProjectKey))]));
115+
currentConfigScope = new ConfigurationScope(id, connectionId, sonarProjectKey);
116+
}
120117
}
118+
119+
OnCurrentConfigurationScopeChanged();
121120
}
122121

123122
public void Reset()
124123
{
125124
threadHandling.ThrowIfOnUIThread();
126-
127125
using (asyncLock.Acquire())
128126
{
129127
currentConfigScope = null;
130-
OnCurrentConfigurationScopeChanged();
131128
}
129+
OnCurrentConfigurationScopeChanged();
132130
}
133131

134132
public void RemoveCurrentConfigScope()
@@ -150,8 +148,9 @@ public void RemoveCurrentConfigScope()
150148
configurationScopeService.DidRemoveConfigurationScope(
151149
new DidRemoveConfigurationScopeParams(currentConfigScope.Id));
152150
currentConfigScope = null;
153-
OnCurrentConfigurationScopeChanged();
154151
}
152+
153+
OnCurrentConfigurationScopeChanged();
155154
}
156155

157156
public bool TryUpdateRootOnCurrentConfigScope(string id, string root)
@@ -164,9 +163,9 @@ public bool TryUpdateRootOnCurrentConfigScope(string id, string root)
164163
}
165164

166165
currentConfigScope = currentConfigScope with { RootPath = root };
167-
OnCurrentConfigurationScopeChanged();
168-
return true;
169166
}
167+
OnCurrentConfigurationScopeChanged();
168+
return true;
170169
}
171170

172171
public bool TryUpdateAnalysisReadinessOnCurrentConfigScope(string id, bool isReady)
@@ -179,9 +178,9 @@ public bool TryUpdateAnalysisReadinessOnCurrentConfigScope(string id, bool isRea
179178
}
180179

181180
currentConfigScope = currentConfigScope with { isReadyForAnalysis = isReady};
182-
OnCurrentConfigurationScopeChanged();
183-
return true;
184181
}
182+
OnCurrentConfigurationScopeChanged();
183+
return true;
185184
}
186185

187186
public event EventHandler CurrentConfigurationScopeChanged;

0 commit comments

Comments
 (0)