Repository navigation
Improve SchemaAnyAttribute code coverage - #22020
Conversation
|
@supporterPL, It will cover your contributions to all .NET Foundation-managed open source projects. |
|
@supporterPL, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request. |
| </ItemGroup> | ||
| <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" /> | ||
| </Project> | ||
| </Project> No newline at end of file |
There was a problem hiding this comment.
at the end of the file make sure to have an empty newline. See here: https://stackoverflow.com/questions/5813311/no-newline-at-end-of-file
| _output = output; | ||
| } | ||
|
|
||
| public bool bWarningCallback; |
There was a problem hiding this comment.
variables above constructor and no unnecessary newlines pls
There was a problem hiding this comment.
I know that generally variables should be above constructor, but it looks that in that project are below constructors. Look at TC_SchemaSet_EnableUpaCheck or TC_SchemaSet_Misc. So my question is what has higher priority - project code style or general correct code style?
There was a problem hiding this comment.
In this case general correct code style. If you want you can also move the others up, but you don't need to.
| </xs:schema>"; | ||
|
|
||
| XmlSchema schema = XmlSchema.Read(new StringReader(xsd), null); | ||
| return schema; |
There was a problem hiding this comment.
return and read operation in one line: return XmlSchema.Read(new StringReader(xsd), null);
| </xs:schema>"; | ||
|
|
||
| XmlSchema schema = XmlSchema.Read(new StringReader(xsd), null); | ||
| return schema; |
|
Thanks for your contribution! LGTM |
|
@ViktorHofer I've just corrected my code. |
| bWarningCallback = bErrorCallback = false; | ||
| errorCount = warningCount = 0; | ||
| WarningInnerExceptionSet = ErrorInnerExceptionSet = false; | ||
| } |
There was a problem hiding this comment.
This Initialize method is unnecessary. It's only ever called at the beginning of a test, so these fields will already have their default values. A new test class is created for individual test, e.g. each theory inline data is run on its own class instance.
There was a problem hiding this comment.
@stephentoub As i wrote earlier, i wanted to use project code style ( there are similar variables initializers in other classes). So should i change it or leave it like in other places?
There was a problem hiding this comment.
Please, remove them. I know that is a bit unclear what to do in such cases but the style is bad by the reasons pointed by Stephen and we should not add more of them.
| } | ||
|
|
||
| [Theory] | ||
| //[Variation(Desc = "basetype Any ns - ##any, derivedType Any ns - ns1, allow ns2 attribute")] |
| xss.Add(GetUnionSchema(ns1, ns2, attrNs)); | ||
| xss.Compile(); | ||
|
|
||
| Assert.Equal(errorCount, expectedError); |
There was a problem hiding this comment.
Should be Assert.Equal(expectedError, errorCount), as it's Assert.Equal(expected, actual)
| @@ -0,0 +1,202 @@ | |||
| using Xunit; | |||
| public int errorCount; | ||
| public int warningCount; | ||
| public bool WarningInnerExceptionSet = false; | ||
| public bool ErrorInnerExceptionSet = false; |
There was a problem hiding this comment.
The fields should be named consistently, e.g. without the "b" prefix and capitalized consistently. Any reason they can't be private? If they can be private, they should be prefixed with an underscore and camel case. If they need to be public, they should be pascal case.
There was a problem hiding this comment.
@justinvp the same question as above. Should i use project code style or correct code style? It will be ok if this class will be implemented in different code style than others?
There was a problem hiding this comment.
@supporterPL since this is a new source file prefer to follow the coding-style so it serves as a template for any other new file on the same project.
|
And one more quetion to you, guys. What do you think about method names like 'v1', 'v2'. In my opinion they should be more precise like 'Namespaces_intersection', 'Namespaces_union' or something like that, but i didn't want to break project style. Should i start name method more precisly or leave it ? And another question: it looks that build for Linux x64 Release Build was failed and problematic tests is: |
|
@dotnet-bot Test Linux x64 Release Build |
- remove unneeded Initialize method
|
Thanks @supporterPL ! Sorry for the delays between the reviews. |
* Add TC_SchemaSet_AnyAttribute class and initializers (#16649) * Add first test sceleton (#16649) * Add XmlSchemaAnyAttribute test cases(#16649) * return and read operation in one line * Add newline at the end * move variables above constructor * replace expected value with actual one * add license header * - changed public fields to private ones - remove unneeded Initialize method
* Add TC_SchemaSet_AnyAttribute class and initializers (dotnet/corefx#16649) * Add first test sceleton (dotnet/corefx#16649) * Add XmlSchemaAnyAttribute test cases(dotnet/corefx#16649) * return and read operation in one line * Add newline at the end * move variables above constructor * replace expected value with actual one * add license header * - changed public fields to private ones - remove unneeded Initialize method Commit migrated from dotnet/corefx@6666bf9
Improve SchemaAnyAttribute code coverage from ~36% to 74 % (Line coverage).
Testcases cover mainly Union and Intersection operation between two AnyAttributes' namespaces.
It look that created tc's improve a little code coverage for following classes:
Please, let me know how can i check if my changes don't break CI pipeline.
Contributes to #16649