-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Add TypeDescriptionProviders to XLinq #33082
Conversation
This adds TypeDescriptionProviders to XAttribute and XElement To do this without introducing a TypeConverter dependency in XML I had to push TypeDescriptionProviderAttribute down. This still causes TypeConverter to gain a dependency on XML, but right now that's the direction we've been heading with TypeConverter. I had to use the string overload of TypeDescriptionProviderAttribute in order to have a soft dependency on TypeConverter.
8e997a6
to
0f41193
Compare
test NETFX x86 Release Build |
|
||
namespace MS.Internal.Xml.Linq.ComponentModel | ||
{ | ||
class XTypeDescriptionProvider<T> : TypeDescriptionProvider |
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: missing explicit visiblity here and elsewhere, e.g. internal
@@ -0,0 +1,576 @@ | |||
// Licensed to the .NET Foundation under one or more agreements. |
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 assume all of this is just ported effectively as-is from netfx?
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.
Yes, as is: I kept the dotnet-bot commit to illustrate that. I'll run the codeformatter to fix up the style issues. I only ran IDE formatting which missed naming/visibility modifiers.
class XElementDescendantsPropertyDescriptor : XPropertyDescriptor<XElement, IEnumerable<XElement>> | ||
{ | ||
XDeferredAxis<XElement> value; | ||
XName changeState; |
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: missing _ prefix on fields
I decided to remove this from the reference assemblies. None of the usages I found would require presense in the reference assemblies and it would expose too much internal surface which we might want to change in the future (type name, and assembly).
b58f7ea
to
fc86570
Compare
@@ -211,6 +212,7 @@ public partial class XDocumentType : System.Xml.Linq.XNode | |||
public override System.Threading.Tasks.Task WriteToAsync(System.Xml.XmlWriter writer, System.Threading.CancellationToken cancellationToken) { throw null; } | |||
} | |||
[System.Xml.Serialization.XmlSchemaProvider(null, IsAny=true)] | |||
[System.ComponentModel.TypeDescriptionProvider("MS.Internal.Xml.Linq.ComponentModel.XTypeDescriptionProvider`1[[System.Xml.Linq.XElement, System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]],System.ComponentModel.TypeConverter")] |
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.
on github it looks like there is something wrong with indentation in here (this whole file and others) - please make sure this is correct
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.
This file is no longer part of this commit. I decided not to expose this in the reference assembly.
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'm lacking context on why this is needed but I'm fine with the changes. Please double check the indentation before the attributes as it looks slightly wrong on github
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.
Looks reasonable
@ericstj src/MS/Internal/Xml/Linq/ComponentModel/XComponentModel.cs is dead code. Any reason to keep it? |
It is not dead code at all. It's used by the following attributes:
The typedescriptor tech resolves this dependency at runtime. Have a look at the tests to see how its used. |
I didn't notice that, thanks. |
* Bring over XComponentModel code from desktop * Format code and add License. * Add TypeDescriptionProviders to XLinq This adds TypeDescriptionProviders to XAttribute and XElement To do this without introducing a TypeConverter dependency in XML I had to push TypeDescriptionProviderAttribute down. This still causes TypeConverter to gain a dependency on XML, but right now that's the direction we've been heading with TypeConverter. I had to use the string overload of TypeDescriptionProviderAttribute in order to have a soft dependency on TypeConverter. * Format XComponentModel source for access / naming * Remove TypeDescriptionProvider from reference assemblies I decided to remove this from the reference assemblies. None of the usages I found would require presense in the reference assemblies and it would expose too much internal surface which we might want to change in the future (type name, and assembly). Commit migrated from dotnet/corefx@a01c44c
This adds TypeDescriptionProviders to XAttribute and XElement
To do this without introducing a TypeConverter dependency in XML I had to push
TypeDescriptionProviderAttribute down.
This still causes TypeConverter to gain a dependency on XML, but right now that's the direction
we've been heading with TypeConverter.
I had to use the string overload of TypeDescriptionProviderAttribute in order to have a soft
dependency on TypeConverter.
Fixes #32641