Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void Initialize()
}
}

private bool ItemTypeHasDefaultConstructor
private static bool ItemTypeHasDefaultConstructor
{
get
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class CultureInfoConverter : TypeConverter
/// <summary>
/// Retrieves the "default" name for our culture.
/// </summary>
private string DefaultCultureString => SR.CultureInfoConverterDefaultCultureString;
private static string DefaultCultureString => SR.CultureInfoConverterDefaultCultureString;

private const string DefaultInvariantCultureString = "(Default)";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal sealed class RuntimeLicenseContext : LicenseContext
/// if there is a '#' in the path, everything after this is treated as a fragment. So
/// we need to append the fragment to the end of the path.
/// </summary>
private string GetLocalPath(string fileName)
private static string GetLocalPath(string fileName)
{
Debug.Assert(fileName != null && fileName.Length > 0, "Cannot get local path, fileName is not valid");

Expand Down Expand Up @@ -150,7 +150,7 @@ private string GetLocalPath(string fileName)
* we are attempting to locate could have different casing
* depending on how the assembly was loaded.
**/
private Stream? CaseInsensitiveManifestResourceStreamLookup(Assembly satellite, string name)
private static Stream? CaseInsensitiveManifestResourceStreamLookup(Assembly satellite, string name)
{
CompareInfo comparer = CultureInfo.InvariantCulture.CompareInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ internal AttributeCollection GetAttributes()
/// <summary>
/// Retrieves the component name from the site.
/// </summary>
internal string? GetComponentName(object? instance)
internal static string? GetComponentName(object? instance)
{
IComponent? comp = instance as IComponent;
ISite? site = comp?.Site;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,9 @@ internal AttributeCollection GetAttributes([DynamicallyAccessedMembers(Dynamical
/// <summary>
/// Retrieves the component name from the site.
/// </summary>
internal string? GetComponentName([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.All)] Type type, object? instance)
internal static string? GetComponentName(object? instance)
{
ReflectedTypeData td = GetTypeData(type, true)!;
return td.GetComponentName(instance);
return ReflectedTypeData.GetComponentName(instance);
}

/// <summary>
Expand Down Expand Up @@ -464,7 +463,7 @@ internal EventDescriptorCollection GetEvents([DynamicallyAccessedMembers(Dynamic
/// Retrieves custom extender attributes. We don't support
/// extender attributes, so we always return an empty collection.
/// </summary>
internal AttributeCollection GetExtendedAttributes(object instance)
internal static AttributeCollection GetExtendedAttributes(object instance)
{
return AttributeCollection.Empty;
}
Expand All @@ -481,10 +480,9 @@ internal AttributeCollection GetExtendedAttributes(object instance)
/// <summary>
/// Retrieves the component name from the site.
/// </summary>
[RequiresUnreferencedCode("The Type of instance cannot be statically discovered.")]
internal string? GetExtendedComponentName(object instance)
internal static string? GetExtendedComponentName(object instance)
{
return GetComponentName(instance.GetType(), instance);
return GetComponentName(instance);
}

/// <summary>
Expand All @@ -502,15 +500,15 @@ internal TypeConverter GetExtendedConverter(object instance)
/// Return the default event. The default event is determined by the
/// presence of a DefaultEventAttribute on the class.
/// </summary>
internal EventDescriptor? GetExtendedDefaultEvent(object instance)
internal static EventDescriptor? GetExtendedDefaultEvent()
{
return null; // we don't support extended events.
}

/// <summary>
/// Return the default property.
/// </summary>
internal PropertyDescriptor? GetExtendedDefaultProperty(object instance)
internal static PropertyDescriptor? GetExtendedDefaultProperty(object instance)
{
return null; // extender properties are never the default.
}
Expand All @@ -527,7 +525,7 @@ internal TypeConverter GetExtendedConverter(object instance)
/// <summary>
/// Retrieves the events for this type.
/// </summary>
internal EventDescriptorCollection GetExtendedEvents(object instance)
internal static EventDescriptorCollection GetExtendedEvents(object instance)
{
return EventDescriptorCollection.Empty;
}
Expand Down Expand Up @@ -796,7 +794,7 @@ private static IExtenderProvider[] GetExtenders(ICollection components, object i
/// <summary>
/// Retrieves the owner for a property.
/// </summary>
internal object GetExtendedPropertyOwner(object instance, PropertyDescriptor? pd)
internal static object GetExtendedPropertyOwner(object instance, PropertyDescriptor? pd)
{
return GetPropertyOwner(instance.GetType(), instance, pd);
}
Expand Down Expand Up @@ -878,7 +876,7 @@ internal PropertyDescriptorCollection GetProperties([DynamicallyAccessedMembers(
/// <summary>
/// Retrieves the owner for a property.
/// </summary>
internal object GetPropertyOwner(Type type, object instance, PropertyDescriptor? pd)
internal static object GetPropertyOwner(Type type, object instance, PropertyDescriptor? pd)
{
return TypeDescriptor.GetAssociation(type, instance);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3324,9 +3324,9 @@ AttributeCollection ICustomTypeDescriptor.GetAttributes()
// custom type descriptor

TypeDescriptionProvider p = _node.Provider;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
return rp.GetExtendedAttributes(_instance);
return ReflectTypeDescriptionProvider.GetExtendedAttributes(_instance);
}

ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
Expand Down Expand Up @@ -3369,9 +3369,9 @@ AttributeCollection ICustomTypeDescriptor.GetAttributes()
// custom type descriptor

TypeDescriptionProvider p = _node.Provider;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
return rp.GetExtendedComponentName(_instance);
return ReflectTypeDescriptionProvider.GetExtendedComponentName(_instance);
}

ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
Expand Down Expand Up @@ -3413,9 +3413,9 @@ TypeConverter ICustomTypeDescriptor.GetConverter()
// custom type descriptor

TypeDescriptionProvider p = _node.Provider;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
return rp.GetExtendedDefaultEvent(_instance);
return ReflectTypeDescriptionProvider.GetExtendedDefaultEvent();
}

ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
Expand All @@ -3433,9 +3433,9 @@ TypeConverter ICustomTypeDescriptor.GetConverter()
// If so, we can call on it directly rather than creating another
// custom type descriptor
TypeDescriptionProvider p = _node.Provider;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
return rp.GetExtendedDefaultProperty(_instance);
return ReflectTypeDescriptionProvider.GetExtendedDefaultProperty(_instance);
}

ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
Expand Down Expand Up @@ -3478,9 +3478,9 @@ EventDescriptorCollection ICustomTypeDescriptor.GetEvents()
// If so, we can call on it directly rather than creating another
// custom type descriptor
TypeDescriptionProvider p = _node.Provider;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
return rp.GetExtendedEvents(_instance);
return ReflectTypeDescriptionProvider.GetExtendedEvents(_instance);
}

ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
Expand All @@ -3500,13 +3500,13 @@ EventDescriptorCollection ICustomTypeDescriptor.GetEvents(Attribute[]? attribute
// If so, we can call on it directly rather than creating another
// custom type descriptor
TypeDescriptionProvider p = _node.Provider;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
// There is no need to filter these events. For extended objects, they
// are accessed through our pipeline code, which always filters before
// returning. So any filter we do here is redundant. Note that we do
// pass a valid filter to a custom descriptor so it can optimize if it wants.
EventDescriptorCollection events = rp.GetExtendedEvents(_instance);
EventDescriptorCollection events = ReflectTypeDescriptionProvider.GetExtendedEvents(_instance);
return events;
}

Expand Down Expand Up @@ -3578,9 +3578,9 @@ object ICustomTypeDescriptor.GetPropertyOwner(PropertyDescriptor? pd)

TypeDescriptionProvider p = _node.Provider;

if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
return rp.GetExtendedPropertyOwner(_instance, pd);
return ReflectTypeDescriptionProvider.GetExtendedPropertyOwner(_instance, pd);
}

ICustomTypeDescriptor desc = p.GetExtendedTypeDescriptor(_instance);
Expand Down Expand Up @@ -3675,9 +3675,9 @@ AttributeCollection ICustomTypeDescriptor.GetAttributes()
// custom type descriptor
TypeDescriptionProvider p = _node.Provider;
string? name;
if (p is ReflectTypeDescriptionProvider rp)
if (p is ReflectTypeDescriptionProvider)
{
name = rp.GetComponentName(_objectType, _instance);
name = ReflectTypeDescriptionProvider.GetComponentName(_instance);
}
else
{
Expand Down Expand Up @@ -3924,7 +3924,7 @@ PropertyDescriptorCollection ICustomTypeDescriptor.GetProperties(Attribute[]? at
object? owner;
if (p is ReflectTypeDescriptionProvider rp)
{
owner = rp.GetPropertyOwner(_objectType, _instance!, pd);
owner = ReflectTypeDescriptionProvider.GetPropertyOwner(_objectType, _instance!, pd);
}
else
{
Expand Down