Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Improve SchemaAnyAttribute code coverage - #22020

Merged
pjanotti merged 10 commits into
dotnet:masterfrom
lukmatyja:SchemaAnyAttribute-Code-Coverage
Jul 12, 2017
Merged

pjanotti merged 10 commits into
dotnet:masterfrom
lukmatyja:SchemaAnyAttribute-Code-Coverage

Conversation

@lukmatyja

@lukmatyja lukmatyja commented Jul 9, 2017 •

Copy link
Copy Markdown

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:

  • System.Xml.Schema.Namespacelist (~20% to ~70%)
  • System.Xml.Schema.XmlSchemaAnnotated (~85% to ~92%)
  • System.Xml.Schema.XmlSchemaComplexContentExtension (~66% to ~75%)

Please, let me know how can i check if my changes don't break CI pipeline.

Contributes to #16649

@dnfclas

dnfclas commented Jul 9, 2017

Copy link
Copy Markdown

@supporterPL,
Thanks for your contribution.
To ensure that the project team has proper rights to use your work, please complete the Contribution License Agreement at https://cla2.dotnetfoundation.org.

It will cover your contributions to all .NET Foundation-managed open source projects.
Thanks,
.NET Foundation Pull Request Bot

@dnfclas

dnfclas commented Jul 9, 2017

Copy link
Copy Markdown

@supporterPL, thanks for signing the contribution license agreement. We will now validate the agreement and then the pull request.

Thanks, .NET Foundation Pull Request Bot

</ItemGroup>
<Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />
</Project>
</Project> No newline at end of file

@ViktorHofer ViktorHofer Jul 9, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: newline

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean exactly?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_output = output;
}

public bool bWarningCallback;

@ViktorHofer ViktorHofer Jul 9, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables above constructor and no unnecessary newlines pls

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

@ViktorHofer ViktorHofer Jul 9, 2017 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as above

@ViktorHofer

Copy link
Copy Markdown
Member

Thanks for your contribution! LGTM

@lukmatyja

Copy link
Copy Markdown
Author

@ViktorHofer I've just corrected my code.

bWarningCallback = bErrorCallback = false;
errorCount = warningCount = 0;
WarningInnerExceptionSet = ErrorInnerExceptionSet = false;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lukmatyja lukmatyja Jul 10, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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")]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you get rid of these?

@lukmatyja lukmatyja Jul 10, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hughbe U mean comments?

xss.Add(GetUnionSchema(ns1, ns2, attrNs));
xss.Compile();

Assert.Equal(errorCount, expectedError);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be Assert.Equal(expectedError, errorCount), as it's Assert.Equal(expected, actual)

@lukmatyja lukmatyja Jul 10, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hughbe Changed.

@@ -0,0 +1,202 @@
using Xunit;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license header

@lukmatyja lukmatyja Jul 10, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@justinvp Added

public int errorCount;
public int warningCount;
public bool WarningInnerExceptionSet = false;
public bool ErrorInnerExceptionSet = false;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lukmatyja lukmatyja Jul 10, 2017 •

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.

@lukmatyja

lukmatyja commented Jul 10, 2017 •

Copy link
Copy Markdown
Author

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:
System.Data.SqlClient.Tests.DiagnosticTest/ExecuteScalarAsyncErrorTest , but i didn't change anything in System.Data.SqlClient. What is the reason of this failure?

@lukmatyja

Copy link
Copy Markdown
Author

@dotnet-bot Test Linux x64 Release Build

@pjanotti

Copy link
Copy Markdown
Contributor

Thanks @supporterPL ! Sorry for the delays between the reviews.

@pjanotti
pjanotti merged commit 6666bf9 into dotnet:master Jul 12, 2017
@karelz karelz modified the milestone: 2.1.0 Jul 14, 2017
pjanotti pushed a commit to pjanotti/corefx that referenced this pull request Jul 20, 2017
* 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
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
* 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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants