From 5094e0f03fff3481a3d520082b2e39bb46ef7bc4 Mon Sep 17 00:00:00 2001 From: lice Date: Fri, 1 Apr 2022 09:42:12 +0200 Subject: [PATCH 1/3] Add rider idea folder to gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b32bd32fb..cec4815ac 100644 --- a/.gitignore +++ b/.gitignore @@ -190,3 +190,4 @@ UpgradeLog*.htm # Microsoft Fakes FakesAssemblies/ +src/.idea From 585cbaed4b622106225843588459e55b50e32d56 Mon Sep 17 00:00:00 2001 From: lice Date: Fri, 1 Apr 2022 16:17:53 +0200 Subject: [PATCH 2/3] drain console.log calls between requests --- src/React.Core/Resources/shims.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/React.Core/Resources/shims.js b/src/React.Core/Resources/shims.js index f99e4f264..b578e20b9 100644 --- a/src/React.Core/Resources/shims.js +++ b/src/React.Core/Resources/shims.js @@ -31,8 +31,10 @@ MockConsole.prototype = { _formatCall: function(call) { return 'console.' + call.method + '("[.NET]", ' + call.args.join(', ') + ', ' + JSON.stringify(call.stack) + ');'; }, - getCalls: function() { - return this._calls.map(this._formatCall).join('\n'); + drainCalls: function() { + var calls = this._calls.map(this._formatCall).join('\n'); + this._calls = []; + return calls; } }; var console = new MockConsole(); From c4b840ce7524dffc91d93e4298937ee703d87503 Mon Sep 17 00:00:00 2001 From: lice Date: Fri, 1 Apr 2022 16:22:50 +0200 Subject: [PATCH 3/3] Updated calls to use the new method --- src/React.Core/ReactEnvironment.cs | 2 +- tests/React.Tests/Core/ReactEnvironmentTest.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/React.Core/ReactEnvironment.cs b/src/React.Core/ReactEnvironment.cs index 9ec081d40..d7421846b 100644 --- a/src/React.Core/ReactEnvironment.cs +++ b/src/React.Core/ReactEnvironment.cs @@ -340,7 +340,7 @@ public virtual void GetInitJavaScript(TextWriter writer, bool clientOnly = false // Propagate any server-side console.log calls to corresponding client-side calls. if (!clientOnly && _components.Count != 0) { - var consoleCalls = Execute("console.getCalls()"); + var consoleCalls = Execute("console.drainCalls()"); writer.Write(consoleCalls); } diff --git a/tests/React.Tests/Core/ReactEnvironmentTest.cs b/tests/React.Tests/Core/ReactEnvironmentTest.cs index 69ffb234d..371503166 100644 --- a/tests/React.Tests/Core/ReactEnvironmentTest.cs +++ b/tests/React.Tests/Core/ReactEnvironmentTest.cs @@ -187,7 +187,7 @@ public void SSRInitSkippedIfNoComponents(bool renderComponent, int ssrTimes) environment.GetInitJavaScript(); - mocks.Engine.Verify(x => x.Evaluate("console.getCalls()"), Times.Exactly(ssrTimes)); + mocks.Engine.Verify(x => x.Evaluate("console.drainCalls()"), Times.Exactly(ssrTimes)); } [Fact]