From d78671a7e411095cc0fd210ad9e14ca9fa26e0a9 Mon Sep 17 00:00:00 2001 From: adelikat Date: Mon, 12 Dec 2016 09:00:58 -0600 Subject: [PATCH] Emulation.Common - Separate some attributes to their own file, and better document some attributes and interfaces --- .../Interfaces/IController.cs | 1 - .../Interfaces/IEmulatorService.cs | 34 ++--------------- BizHawk.Emulation.Common/ServiceAttributes.cs | 38 +++++++++++++++++++ 3 files changed, 42 insertions(+), 31 deletions(-) create mode 100644 BizHawk.Emulation.Common/ServiceAttributes.cs diff --git a/BizHawk.Emulation.Common/Interfaces/IController.cs b/BizHawk.Emulation.Common/Interfaces/IController.cs index 705fcfb3ca..05a742185d 100644 --- a/BizHawk.Emulation.Common/Interfaces/IController.cs +++ b/BizHawk.Emulation.Common/Interfaces/IController.cs @@ -1,6 +1,5 @@ namespace BizHawk.Emulation.Common { - public interface IController { ControllerDefinition Type { get; } diff --git a/BizHawk.Emulation.Common/Interfaces/IEmulatorService.cs b/BizHawk.Emulation.Common/Interfaces/IEmulatorService.cs index 2cb58f1539..e1b0758352 100644 --- a/BizHawk.Emulation.Common/Interfaces/IEmulatorService.cs +++ b/BizHawk.Emulation.Common/Interfaces/IEmulatorService.cs @@ -1,8 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -namespace BizHawk.Emulation.Common +namespace BizHawk.Emulation.Common { /// /// This interface specifies that an interface or implementation is a emulator core service, such as IDebuggable, @@ -14,34 +10,12 @@ namespace BizHawk.Emulation.Common } /// - /// Should be added to any field of an ICoreService that is not implemented. By Convention it should also throw a NotImplementedException - /// Any feature that does not have this attribute is assumed to be implemented - /// - public class FeatureNotImplemented : Attribute { } - - /// - /// This represents a service that would not apply to every core, instead it is a specialized service specific to a core or group of cores + /// This represents a service that would not apply to every core, + /// instead it is a specialized service specific to a core or group of cores /// This service is merely intended to define semantics and expectations of a service + /// Services of this type are not assumed to be "missing" from cores that fail to implement them /// public interface ISpecializedEmulatorService : IEmulatorService { } - - [AttributeUsage(AttributeTargets.Class)] - public class ServiceNotApplicable : Attribute - { - public ServiceNotApplicable(params Type[] types) - { - if (types != null) - { - NotApplicableTypes = types.ToList(); - } - else - { - NotApplicableTypes = new List(); - } - } - - public IEnumerable NotApplicableTypes { get; private set; } - } } diff --git a/BizHawk.Emulation.Common/ServiceAttributes.cs b/BizHawk.Emulation.Common/ServiceAttributes.cs new file mode 100644 index 0000000000..6516d0a29c --- /dev/null +++ b/BizHawk.Emulation.Common/ServiceAttributes.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace BizHawk.Emulation.Common +{ + /// + /// Should be added to any field of an IEmulatorService that is not implemented. + /// By Convention it should also throw a NotImplementedException + /// Any feature that does not have this attribute is assumed to be implemented + /// + public class FeatureNotImplemented : Attribute { } + + /// + /// Should be added to any implementation of IEmulator to document any + /// IEmulatorService (that is not an ISpecializedEmulatorService) that + /// by design, will not be implemented by the core + /// Any service that is unimplemented and not marked with this attribute is + /// assumed to be a "TODO" that needs to be done but hasn't been done yet + /// + [AttributeUsage(AttributeTargets.Class)] + public class ServiceNotApplicable : Attribute + { + public ServiceNotApplicable(params Type[] types) + { + if (types != null) + { + NotApplicableTypes = types.ToList(); + } + else + { + NotApplicableTypes = new List(); + } + } + + public IEnumerable NotApplicableTypes { get; private set; } + } +}