From 6ebd1406ede923a642f6fb39996f48addcdc735b Mon Sep 17 00:00:00 2001 From: bd_ Date: Thu, 28 Nov 2024 16:28:39 -0800 Subject: [PATCH] Revert "feat: add Owner field to IExtensionContext (#480)" This reverts commit 2dcda1b7b539608b3cca4be8c69af85ec004c994. --- CHANGELOG.md | 1 + Editor/API/BuildContext.cs | 16 ---------------- Editor/API/IExtensionContext.cs | 10 +--------- Editor/ErrorReporting/ErrorReport.cs | 9 --------- 4 files changed, 2 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bf8976a..76defc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed ### Removed +- [#483] Removed `IExtensionContext.Owner` due to compatibility issues. ### Security diff --git a/Editor/API/BuildContext.cs b/Editor/API/BuildContext.cs index 3898dcd..8745083 100644 --- a/Editor/API/BuildContext.cs +++ b/Editor/API/BuildContext.cs @@ -272,18 +272,10 @@ public void DeactivateExtensionContext(Type t) { var ctx = _activeExtensions[t]; Profiler.BeginSample("NDMF Deactivate: " + t); - - using var scope = ErrorReport.WithContext(ctx); try { ctx.OnDeactivate(this); } - catch (Exception e) - { - // ensure we report the exception while the error report context is set - ErrorReport.ReportException(e); - return; - } finally { Profiler.EndSample(); @@ -373,18 +365,10 @@ public IExtensionContext ActivateExtensionContext(Type ty) if (!_activeExtensions.ContainsKey(ty)) { Profiler.BeginSample("NDMF Activate: " + ty); - - using var scope = ErrorReport.WithContext(ctx); try { ctx.OnActivate(this); } - catch (Exception e) - { - // ensure we report the exception while the error report context is set - ErrorReport.ReportException(e); - return null; - } finally { Profiler.EndSample(); diff --git a/Editor/API/IExtensionContext.cs b/Editor/API/IExtensionContext.cs index cbb9395..190c3ac 100644 --- a/Editor/API/IExtensionContext.cs +++ b/Editor/API/IExtensionContext.cs @@ -1,6 +1,4 @@ -#nullable enable - -using System; +using System; using System.Collections.Generic; using System.Collections.Immutable; @@ -22,12 +20,6 @@ public interface IExtensionContext /// /// void OnDeactivate(BuildContext context); - - /// - /// Return the plugin owning this extension context. Implementing this API is optional for backwards - /// compatibility, but is encouraged as it will provide better error messaging. - /// - PluginBase? Owner => null; } internal static class ExtensionContextUtil diff --git a/Editor/ErrorReporting/ErrorReport.cs b/Editor/ErrorReporting/ErrorReport.cs index 94863f1..7a94179 100644 --- a/Editor/ErrorReporting/ErrorReport.cs +++ b/Editor/ErrorReporting/ErrorReport.cs @@ -308,15 +308,6 @@ internal IDisposable WithContext(PluginBase thePlugin) CurrentContext.Plugin = thePlugin; return scope; } - - internal IDisposable WithContext(IExtensionContext theExtension) - { - var scope = new RestoreContextScope(this); - - if (theExtension.Owner != null) CurrentContext.Plugin = theExtension.Owner; - - return scope; - } internal IDisposable WithContextPassName(string name) {