cherry pick some attributes to remove

This commit is contained in:
wsycarlos 2026-02-06 00:23:50 +08:00
parent fc6cd81260
commit cf5f91d19f
2 changed files with 14 additions and 24 deletions

View File

@ -17,9 +17,9 @@ namespace Byway.PostProcessor
private readonly string[] RemoveAttributesNames =
{
// Just information
"System.Runtime.CompilerServices.CompilerGeneratedAttribute",
"System.Runtime.CompilerServices.ExtensionAttribute",
"System.ParamArrayAttribute",
//"System.Runtime.CompilerServices.CompilerGeneratedAttribute", // This is used for IEnumerator
//"System.Runtime.CompilerServices.ExtensionAttribute", // Extension Method
//"System.ParamArrayAttribute", // params parameter
"System.Reflection.DefaultMemberAttribute",
"System.Diagnostics.DebuggerStepThroughAttribute",
"System.Diagnostics.DebuggerHiddenAttribute",
@ -33,13 +33,13 @@ namespace Byway.PostProcessor
"System.Runtime.InteropServices.ComVisibleAttribute",
"System.Runtime.ConstrainedExecution.ReliabilityContractAttribute",
// Editor only
//"UnityEngine.AddComponentMenu",
//"UnityEditor.MenuItem",
//"UnityEngine.ContextMenu",
//"UnityEngine.ExecuteInEditMode",
//"UnityEngine.HideInInspector",
"UnityEngine.AddComponentMenu",
"UnityEditor.MenuItem",
"UnityEngine.ContextMenu",
//"UnityEngine.ExecuteInEditMode", // For some code, it needs it
//"UnityEngine.HideInInspector", // Some code use it to hide serialized fields
"UnityEngine.TooltipAttribute",
//"UnityEngine.DisallowMultipleComponent",
"UnityEngine.DisallowMultipleComponent",
"UnityEngine.Internal.ExcludeFromDocsAttribute",
};
@ -87,22 +87,12 @@ namespace Byway.PostProcessor
private bool RemoveAttributes(string ownerName, Collection<CustomAttribute> customAttributes)
{
bool wasProcessed = false;
foreach (var attrName in RemoveAttributesNames)
{
var index = -1;
for (var i = 0; i < customAttributes.Count; i++)
{
var attr = customAttributes[i];
if (attr.Constructor != null && attr.Constructor.DeclaringType.FullName == attrName)
{
index = i;
break;
}
}
if (index != -1)
for (int i = customAttributes.Count - 1; i >= 0; i--)
{
if (RemoveAttributesNames.Contains(customAttributes[i].AttributeType.FullName))
{
customAttributes.RemoveAt(index);
customAttributes.RemoveAt(i);
wasProcessed = true;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "com.bywaystudios.ilpostprocess",
"displayName": "IL Post Process",
"version": "0.1.1",
"version": "0.1.2",
"description": "Package containing code for IL Post Process"
}