Skip to content

Commit

Permalink
[Breaking] Scoping generic extension methods
Browse files Browse the repository at this point in the history
This was causing every object to have additional methods appearing in the IDE and on the documentation, which can be very confusing for new developers and irritating for experienced ones.

This means that these extension methods no longer work with IntPtr and "IReferencable" types, but this feature was unused.

Seperate extension methods for "IReferencable" types could be created without "Dispose" in the name and instead use the "Release" naming.
  • Loading branch information
Fydar committed Oct 17, 2023
1 parent f07c108 commit ec58796
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sources/core/Stride.Core/ComponentBaseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public static class ComponentBaseExtensions
/// <param name="container">The container that will keep a reference to the component.</param>
/// <returns>The same component instance</returns>
public static T DisposeBy<T>(this T thisArg, ICollectorHolder container)
where T : IDisposable
{
if (ReferenceEquals(thisArg, null))
return default(T);
Expand All @@ -31,6 +32,7 @@ public static T DisposeBy<T>(this T thisArg, ICollectorHolder container)
/// <param name="thisArg">The component to remove.</param>
/// <param name="container">The container that kept a reference to the component.</param>
public static void RemoveDisposeBy<T>(this T thisArg, ICollectorHolder container)
where T : IDisposable
{
if (ReferenceEquals(thisArg, null))
return;
Expand All @@ -44,7 +46,8 @@ public static void RemoveDisposeBy<T>(this T thisArg, ICollectorHolder container
/// <param name="thisArg">The component to add a reference to.</param>
/// <returns>This component.</returns>
/// <remarks>This method is equivalent to call <see cref="IReferencable.AddReference"/> and return this instance.</remarks>
public static T KeepReference<T>(this T thisArg) where T : IReferencable
public static T KeepReference<T>(this T thisArg)
where T : IReferencable
{
if (ReferenceEquals(thisArg, null))
return default(T);
Expand Down

0 comments on commit ec58796

Please sign in to comment.