-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
No types defined for elements in XSD schema #10983
Comments
The type of the item metadata elements cannot be just xs:string because at least the Condition attribute must be allowed, perhaps Label too. Syntax example: <Project>
<ItemGroup>
<PackageReference Include="Microsoft.Data.SqlClient">
<VersionOverride Condition="$(TargetFramework) == 'netstandard2.0'">1.2.3</VersionOverride>
</PackageReference>
</ItemGroup>
</Project> I'm not sure about whether MSBuild allows child elements in item metadata elements. It allows them in PropertyGroup/* elements; see GenericPropertyType in the schema. |
So it could be type derived from string which allows any attribute? I don't understand why one would need child elements in e.g. Name. |
Yeah, I don't think child elements are needed in Name metadata. AFAIK, these schemata are intended for Intellisense and online help in the Visual Studio IDE. If the item metadata elements were given more restrictive types, then would that help for those purposes, or would the types be overridden by some Visual Studio feature anyway? |
I don't know about VS - I used XSD to generate C# classes from Microsoft.Build.xsd and found out that Name is object instead of string. So I was curious if there's some deeper reason why one element has type="msb:boolean" while other has ur-type. |
If you want to read, modify, and write MSBuild project files programmatically in C#, the MSBuild API has classes like Microsoft.Build.Construction.ProjectRootElement; see also MSBuildLocator. On the other hand, if your program does not need to build those projects, and needs to tolerate future extensions to MSBuild project syntax even when neither the program itself nor any installed version of MSBuild supports them, then System.Xml APIs (including deserialisation) may be a better choice than the MSBuild API. |
The MSBuild XML schema files have The classes in the Microsoft.Build.Construction namespace do not have this problem. |
Thanks, I'm not using XmlSerializer. I have my own library to generate C# classes and I used .NET Framework .csproj as test files, to see if it can be round-tripped using generated classes. I needed to add support for substitution groups, it's cleverly used in the schema, it was new to me. Now it works, I was just curious why the Name element has ur-type, that's all. |
Team Triage: @KalleOlaviNiemitalo answer is correct, the types are there to feed into intellisense and extra VS functions. Let us know if you have any more questions regarding this, but closing the issue for now. |
Issue Description
In XSD there are many elements which should likely have type="xs:string", but they have no type at all, thus ur-type. Is it a bug, or a design choice?
E.g.:
msbuild/src/MSBuild/MSBuild/Microsoft.Build.CommonTypes.xsd
Line 24 in 6cd445d
<xs:element name="Name"> // Friendly display name (optional)
Steps to Reproduce
Expected Behavior
Actual Behavior
Analysis
No response
Versions & Configurations
No response
The text was updated successfully, but these errors were encountered: