Skip to content

Commit 3afcf41

Browse files
committed
Follow attribute class best practices, cleanup docs on attributes
1 parent 0ff2539 commit 3afcf41

File tree

50 files changed

+127
-130
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+127
-130
lines changed

BizHawk.BizInvoke/BizExvoker.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -122,23 +122,15 @@ public static IImportResolver GetExvoker(object o, ICallingConventionAdapter a)
122122
}
123123
}
124124

125-
/// <summary>
126-
/// mark an instance method to be exported by BizExvoker
127-
/// </summary>
125+
/// <summary>Indicates that a method is to be exported by BizExvoker.</summary>
128126
[AttributeUsage(AttributeTargets.Method)]
129-
public class BizExportAttribute : Attribute
127+
public sealed class BizExportAttribute : Attribute
130128
{
131129
public CallingConvention CallingConvention { get; }
132130

133-
/// <summary>
134-
/// Gets or sets the name of entry point; if not given, the method's name is used
135-
/// </summary>
131+
/// <remarks>The annotated method's name is used iff <see langword="null"/>.</remarks>
136132
public string EntryPoint { get; set; }
137133

138-
/// <summary>
139-
/// Initializes a new instance of the <see cref="BizImportAttribute"/> class.
140-
/// </summary>
141-
/// <param name="c">unmanaged calling convention</param>
142134
public BizExportAttribute(CallingConvention c)
143135
{
144136
CallingConvention = c;

BizHawk.BizInvoke/BizInvoker.cs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -537,28 +537,18 @@ private static Type EmitParamterLoad(ILGenerator il, int idx, Type type, FieldIn
537537
}
538538
}
539539

540-
/// <summary>
541-
/// mark an abstract method to be proxied by BizInvoker
542-
/// </summary>
540+
/// <summary>Indicates that an abstract method is to be proxied by BizInvoker.</summary>
543541
[AttributeUsage(AttributeTargets.Method)]
544-
public class BizImportAttribute : Attribute
542+
public sealed class BizImportAttribute : Attribute
545543
{
546544
public CallingConvention CallingConvention { get; }
547545

548-
/// <summary>
549-
/// Gets or sets the name of entry point; if not given, the method's name is used
550-
/// </summary>
546+
/// <remarks>The annotated method's name is used iff <see langword="null"/>.</remarks>
551547
public string EntryPoint { get; set; }
552548

553-
/// <summary>
554-
/// Gets or sets a value indicating whether or not to use a slower interop that supports more argument types
555-
/// </summary>
549+
/// <summary><see langword="true"/> iff a compatibility interop should be used, which is slower but supports more argument types.</summary>
556550
public bool Compatibility { get; set; }
557551

558-
/// <summary>
559-
/// Initializes a new instance of the <see cref="BizImportAttribute"/> class.
560-
/// </summary>
561-
/// <param name="c">unmanaged calling convention</param>
562552
public BizImportAttribute(CallingConvention c)
563553
{
564554
CallingConvention = c;

BizHawk.Client.ApiHawk/Classes/ApiInjector.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,12 @@ public static bool IsAvailable(IExternalApiProvider source, Type targetType)
6868
}
6969

7070
[AttributeUsage(AttributeTargets.Property)]
71-
public class RequiredApiAttribute : Attribute
71+
public sealed class RequiredApiAttribute : Attribute
7272
{
7373
}
7474

7575
[AttributeUsage(AttributeTargets.Property)]
76-
public class OptionalApiAttribute : Attribute
76+
public sealed class OptionalApiAttribute : Attribute
7777
{
7878
}
7979
}

BizHawk.Client.Common/Api/ExternalToolAttributes.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,12 @@ public class DuplicateException : Exception {}
9696
[AttributeUsage(AttributeTargets.Class)]
9797
public sealed class ExternalToolAttribute : Attribute
9898
{
99-
public readonly string Description;
99+
public string Description { get; set; }
100100

101101
public readonly string Name;
102102

103-
public ExternalToolAttribute(string name, string description = null)
103+
public ExternalToolAttribute(string name)
104104
{
105-
Description = description;
106105
Name = string.IsNullOrWhiteSpace(name) ? Guid.NewGuid().ToString() : name;
107106
}
108107

BizHawk.Client.Common/BinarySaveStates.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class BinaryStateLump
6969
public static BinaryStateLump BranchUserText { get; private set; }
7070

7171
[AttributeUsage(AttributeTargets.Property)]
72-
private class NameAttribute : Attribute
72+
private sealed class NameAttribute : Attribute
7373
{
7474
public string Name { get; }
7575
public string Ext { get; }

BizHawk.Client.Common/config/ConfigPersistAttribute.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@
22

33
namespace BizHawk.Client.Common
44
{
5-
/// <summary>
6-
/// Define if the property has to be persisted in config
7-
/// </summary>
5+
/// <summary>Indicates that a property is to be saved to config for persistence.</summary>
86
[AttributeUsage(AttributeTargets.Property)]
9-
public class ConfigPersistAttribute : Attribute
7+
public sealed class ConfigPersistAttribute : Attribute
108
{
119
}
1210
}

BizHawk.Client.Common/config/RestoreDefaultsAttribute.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
namespace BizHawk.Client.Common
44
{
5-
/// <summary>
6-
/// Defines a method to be called when a tool dialog's Restore Defaults method is called
7-
/// </summary>
5+
/// <summary>Indicates which method of an <see cref="IToolFormAutoConfig"/> is to be called when the generated <c>Restore Defaults</c> menu item is clicked.</summary>
6+
/// <remarks>If not present on any instance method, the menu item will do nothing. If present on multiple, the first will be called.</remarks>
87
[AttributeUsage(AttributeTargets.Method)]
9-
public class RestoreDefaultsAttribute : Attribute
8+
public sealed class RestoreDefaultsAttribute : Attribute
109
{
1110
}
1211
}

BizHawk.Client.Common/lua/LuaAttributes.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace BizHawk.Client.Common
44
{
55
[AttributeUsage(AttributeTargets.Method)]
6-
public class LuaMethodAttribute : Attribute
6+
public sealed class LuaMethodAttribute : Attribute
77
{
88
public LuaMethodAttribute(string name, string description)
99
{
@@ -16,7 +16,7 @@ public LuaMethodAttribute(string name, string description)
1616
}
1717

1818
[AttributeUsage(AttributeTargets.Method)]
19-
public class LuaMethodExampleAttribute : Attribute
19+
public sealed class LuaMethodExampleAttribute : Attribute
2020
{
2121
public LuaMethodExampleAttribute(string example)
2222
{
@@ -27,7 +27,7 @@ public LuaMethodExampleAttribute(string example)
2727
}
2828

2929
[AttributeUsage(AttributeTargets.Class)]
30-
public class LuaLibraryAttribute : Attribute
30+
public sealed class LuaLibraryAttribute : Attribute
3131
{
3232
public LuaLibraryAttribute(bool released)
3333
{

BizHawk.Client.Common/movie/import/IMovieImport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public static ImportResult Error(string errorMsg)
101101
}
102102

103103
[AttributeUsage(AttributeTargets.Class)]
104-
public class ImporterForAttribute : Attribute
104+
public sealed class ImporterForAttribute : Attribute
105105
{
106106
public ImporterForAttribute(string emulator, string extension)
107107
{

BizHawk.Client.EmuHawk/AVOut/IVideoWriter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ public interface IVideoWriter : IDisposable
9999
}
100100

101101
[AttributeUsage(AttributeTargets.Class)]
102-
public class VideoWriterAttribute : Attribute
102+
public sealed class VideoWriterAttribute : Attribute
103103
{
104104
public string ShortName { get; }
105105
public string Name { get; }
@@ -114,7 +114,7 @@ public VideoWriterAttribute(string shortName, string name, string description)
114114
}
115115

116116
[AttributeUsage(AttributeTargets.Class)]
117-
public class VideoWriterIgnoreAttribute : Attribute
117+
public sealed class VideoWriterIgnoreAttribute : Attribute
118118
{
119119
}
120120

0 commit comments

Comments
 (0)