-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing CopyFrom method in OdataMessageReader and OdataMessageWriter to include Arraypool #1595
Fixing CopyFrom method in OdataMessageReader and OdataMessageWriter to include Arraypool #1595
Conversation
@@ -132,7 +132,7 @@ public void ODataMessageReaderCopyConstructorTest() | |||
// Compare original and settings created from copy constructor after setting some values | |||
settings.BaseUri = new Uri("http://www.odata.org"); | |||
settings.EnableCharactersCheck = true; | |||
copyOfSettings = settings.Clone(); | |||
copyOfSettings = settings.Clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unintended change.
|
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line.
if (element1 == null || element2 == null) | ||
{ | ||
diff.Add(string.Format("Value of items in Collection {0} does not match.", prop.Name)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra line.
{ | ||
EvaluateDifferences(element1, element2, diff); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line.
<ItemGroup> | ||
<Folder Include="References\" /> | ||
</ItemGroup> | ||
|
||
</Project> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this have any change? If it is a change that you did not intend then please revert this.
|
||
var differences = ValidationHelper.GetDifferences<ODataMessageWriterSettings>(this.settings, newSetting); | ||
Assert.True(differences.Count == 0, String.Join(",", differences)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra line.
@@ -357,7 +400,7 @@ public void PropertyGettersAndSettersTest() | |||
MaxNestingDepth = maxNestingDepth, | |||
}, | |||
Version = version, | |||
LibraryCompatibility = library, | |||
LibraryCompatibility = library, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert whitespace.
|
||
namespace Microsoft.OData.Tests | ||
{ | ||
public class TestCharArrayPool : ICharArrayPool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember I had a default implementation for ICharArrayPool. Don't I?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kept the Testchararraypool as such to be reused later as the the testarraypool implementation was inside another class file.
@@ -281,6 +281,9 @@ | |||
<Compile Include="..\ScenarioTests\UriParser\TopAndSkipFunctionalTests.cs" /> | |||
<Compile Include="..\ScenarioTests\UriParser\VerificationHelpers.cs" /> | |||
<Compile Include="..\ScenarioTests\Writer\JsonLight\WriteFeedWithoutNavigationSourceTests.cs" /> | |||
<Compile Include="..\TestCharArrayPool.cs"> | |||
<Link>TestCharArrayPool.cs</Link> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we add the for the Compile element?
@@ -450,6 +453,9 @@ | |||
<Compile Include="..\UriParser\Visitors\IsCollectionTranslatorTests.cs" /> | |||
<Compile Include="..\UriParser\Visitors\QueryNodeVisitorTests.cs" /> | |||
<Compile Include="..\UriParser\Visitors\SyntacticTreeVisitorTests.cs" /> | |||
<Compile Include="..\ValidationHelper.cs"> | |||
<Link>ValidationHelper.cs</Link> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shall we add the for the Compile element?
@@ -1,147 +1,147 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change this file?
Fixes based on Review Comments
…/odata.net into UpdateCopyFromMethod
Reverting Microsoft.Test.OData.Tests.Client.NetCore
reverted stylecop buildnumber as its already committed
@@ -0,0 +1,27 @@ | |||
using Microsoft.OData.Buffers; | |||
using System; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -0,0 +1,27 @@ | |||
using Microsoft.OData.Buffers; | |||
using System; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REsolved
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
copyright
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
REsolved
|
||
namespace Microsoft.OData.Tests | ||
{ | ||
public class ValidationHelper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ValidationHelper [](start = 11, length = 22)
make it as "static class"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
/// </summary> | ||
/// <typeparam name="T"></typeparam> | ||
/// <param name="obj"></param> | ||
/// <param name="copy"></param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add the comments, finish the comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
/// <typeparam name="T"></typeparam> | ||
/// <param name="obj"></param> | ||
/// <param name="copy"></param> | ||
/// <param name="diff"></param> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
private static void EvaluateDifferences<T>(T obj, T copy, List<string> diff) | ||
{ | ||
|
||
foreach (var prop in obj.GetType().GetProperties().Where(x => x.CanRead)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verify the input and remove unused the line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
else | ||
{ | ||
EvaluateDifferences(element1, element2, diff); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems you can replace all by calling EvaluateDifferences again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text for this contains collection, eg: "Values of Collection {0} does not match.". So to keep that text and any further modificatioins needed for collection did like this. Pls let me know if thats fine. Let me try anyway to make it more generic at a single place
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved
@@ -205,6 +205,9 @@ private void CompareMessageReaderSettings(ODataMessageReaderSettings expected, O | |||
Assert.True(expected.MessageQuotas.MaxOperationsPerChangeset == actual.MessageQuotas.MaxOperationsPerChangeset, "MaxOperationsPerChangeset does not match"); | |||
Assert.True(expected.MessageQuotas.MaxNestingDepth == actual.MessageQuotas.MaxNestingDepth, "MaxNestingDepth does not match"); | |||
Assert.True(expected.MessageQuotas.MaxReceivedMessageSize == actual.MessageQuotas.MaxReceivedMessageSize, "MaxMessageSize does not match"); | |||
|
|||
var differences = ValidationHelper.GetDifferences<ODataMessageReaderSettings>(expected, actual); | |||
Assert.True(differences.Count == 0, String.Join(",", differences)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you add the "GetDifferences" function call, how about the codes from Line 191 to Line 207?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't want to change the existing code. Existing lines will function as such
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's my concern. It seems we verify the same twice.
In reply to: 348177998 [](ancestors = 348177998)
Added copyright, sorted usings etc
Restructured EvaluateDifferences
/// <param name="diff">List Of Differences</param> | ||
/// <param name="objName">Optional parameter for objectname, to be used in differences string, default empty string</param> | ||
/// <param name="isCollection">Optional parameter to see if its a collection, default false</param> | ||
private static void EvaluateDifferences<T>(T obj, T copy, List<string> diff,string objName ="", bool isCollection =false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
,string objName ="" [](start = 83, length = 19)
add the whitespace correctly. for example:
add whitespace between the parameter, add the whitespace before and after "="?
Assert.True(expected.MessageQuotas.MaxReceivedMessageSize == actual.MessageQuotas.MaxReceivedMessageSize, "MaxMessageSize does not match"); | ||
|
||
var differences = ValidationHelper.GetDifferences<ODataMessageReaderSettings>(expected, actual); | ||
Assert.True(differences.Count == 0, String.Join(",", differences)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[](start = 79, length = 6)
remove the unused whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…o include Arraypool (OData#1595) * Changes and test * Fixing the build error * Fixes based on Review Comments Fixes based on Review Comments * Update Microsoft.Test.OData.Tests.Client.NetCore.csproj * Revert "Merge branch 'master' into UpdateCopyFromMethod" This reverts commit 1345914, reversing changes made to 9a786ed. * Update Microsoft.Test.OData.Tests.Client.NetCore.csproj Reverting Microsoft.Test.OData.Tests.Client.NetCore * reverted stylecop buildnumber reverted stylecop buildnumber as its already committed * Fixed as per review comments Added copyright, sorted usings etc * Restructured EvaluateDifferences Restructured EvaluateDifferences * Update ValidationHelper.cs
…o include Arraypool (#1595) * Changes and test * Fixing the build error * Fixes based on Review Comments Fixes based on Review Comments * Update Microsoft.Test.OData.Tests.Client.NetCore.csproj * Revert "Merge branch 'master' into UpdateCopyFromMethod" This reverts commit 1345914, reversing changes made to 9a786ed. * Update Microsoft.Test.OData.Tests.Client.NetCore.csproj Reverting Microsoft.Test.OData.Tests.Client.NetCore * reverted stylecop buildnumber reverted stylecop buildnumber as its already committed * Fixed as per review comments Added copyright, sorted usings etc * Restructured EvaluateDifferences Restructured EvaluateDifferences * Update ValidationHelper.cs
Issues
There was an issue that OData.Core ICharArrayPool is not hooked up properly, which was causing lot of Large Object Heap allocations taking up lot of memory
Description
Checklist (Uncheck if it is not completed)
Additional work necessary
N/A