Skip to content

Commit fd59a1d

Browse files
committed
Merge pull request #525 from mousetraps/i467
fix #467 VS hangs after closing NTVS project
2 parents c8f1cb1 + f97e61c commit fd59a1d

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

Nodejs/Product/Analysis/Analysis/AnalysisLimits.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public AnalysisLimits() {
3434
MaxObjectLiteralProperties = 50;
3535
MaxObjectKeysTypes = 5;
3636
MaxMergeTypes = 5;
37+
MaxEvents = 5;
3738

3839
// There no practical reasons to go deeper in dependencies analysis.
3940
// Number 4 is very practical. Here the examples which hightlight idea.
@@ -147,7 +148,12 @@ public static AnalysisLimits MakeLowAnalysisLimits() {
147148
/// <summary>
148149
/// Gets the maximum number of types which can be merged at once.
149150
/// </summary>
150-
public int MaxMergeTypes { get; set; }
151+
public int MaxMergeTypes { get; set; }
152+
153+
/// <summary>
154+
/// Gets the maximum number of events which can be emitted at once.
155+
/// </summary>
156+
public int MaxEvents { get; set; }
151157

152158
/// <summary>
153159
/// Gets the maximum level of dependency modules which could be analyzed.

Nodejs/Product/Analysis/Analysis/GlobalBuilder.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ private static IAnalysisSet DefineProperty(FunctionValue func, Node node, Analys
13101310

13111311
private static IAnalysisSet DefineProperties(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) {
13121312
// object, {propName: {desc}, ...}
1313-
if (args.Length >= 2) {
1313+
if (args.Length >= 2 && args[0].Count < unit.Analyzer.Limits.MaxMergeTypes) {
13141314
foreach (var obj in args[0]) {
13151315
ExpandoValue target = obj.Value as ExpandoValue;
13161316
if (target != null) {
@@ -1342,8 +1342,14 @@ private static IAnalysisSet DefineProperties(FunctionValue func, Node node, Anal
13421342
}
13431343

13441344
private static IAnalysisSet Require(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) {
1345-
CallNode call = (CallNode)node;
1346-
IAnalysisSet res = AnalysisSet.Empty;
1345+
IAnalysisSet res = AnalysisSet.Empty;
1346+
1347+
if (node.GetType() != typeof(CallNode)) {
1348+
return res;
1349+
}
1350+
1351+
var call = (CallNode)node;
1352+
13471353
// we care a lot about require analysis and people do some pretty
13481354
// crazy dynamic things for require calls. If we let our normal
13491355
// analysis and specialized function handle it we won't get things

Nodejs/Product/Analysis/Analysis/NodejsModuleBuilder.Specializations.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ private static IAnalysisSet EventEmitterEmit(FunctionValue func, Node node, Anal
451451
if (@this != null) {
452452
foreach (var thisArg in @this) {
453453
ExpandoValue expando = @thisArg.Value as ExpandoValue;
454-
if (expando != null) {
454+
if (expando != null && args[0].Count < unit.Analyzer.Limits.MaxEvents) {
455455
foreach (var arg in args[0]) {
456456
var strValue = arg.Value.GetStringValue();
457457
if (strValue != null) {

0 commit comments

Comments
 (0)