diff --git a/Cpp2IL.Core/Utils/AttributeInjectionUtils.cs b/Cpp2IL.Core/Utils/AttributeInjectionUtils.cs index c6148382..77cdcb22 100644 --- a/Cpp2IL.Core/Utils/AttributeInjectionUtils.cs +++ b/Cpp2IL.Core/Utils/AttributeInjectionUtils.cs @@ -10,20 +10,20 @@ namespace Cpp2IL.Core.Utils; -internal static class AttributeInjectionUtils +public static class AttributeInjectionUtils { /// /// Inject an attribute with no fields nor properties into the . /// /// A dictionary of assembly contexts to their inject attribute constructors. - internal static Dictionary InjectZeroParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple) + public static Dictionary InjectZeroParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple) { var multiInjectType = appContext.InjectTypeIntoAllAssemblies(ns, name, appContext.SystemTypes.SystemAttributeType); ApplyAttributeUsageAttribute(appContext, multiInjectType, attributeTargets, allowMultiple); return multiInjectType.InjectConstructor(false); } - internal static Dictionary InjectOneParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, TypeAnalysisContext fieldType, string fieldName) + public static Dictionary InjectOneParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, TypeAnalysisContext fieldType, string fieldName) { var multiInjectType = appContext.InjectTypeIntoAllAssemblies(ns, name, appContext.SystemTypes.SystemAttributeType); ApplyAttributeUsageAttribute(appContext, multiInjectType, attributeTargets, allowMultiple); @@ -35,7 +35,7 @@ internal static Dictionary t.DeclaringAssembly, t => (constructors[t.DeclaringAssembly], fields[t.DeclaringAssembly])); } - internal static Dictionary InjectTwoParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, TypeAnalysisContext fieldType1, string fieldName1, TypeAnalysisContext fieldType2, string fieldName2) + public static Dictionary InjectTwoParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, TypeAnalysisContext fieldType1, string fieldName1, TypeAnalysisContext fieldType2, string fieldName2) { var multiInjectType = appContext.InjectTypeIntoAllAssemblies(ns, name, appContext.SystemTypes.SystemAttributeType); ApplyAttributeUsageAttribute(appContext, multiInjectType, attributeTargets, allowMultiple); @@ -52,7 +52,7 @@ internal static Dictionary InjectThreeParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, TypeAnalysisContext fieldType1, string fieldName1, TypeAnalysisContext fieldType2, string fieldName2, TypeAnalysisContext fieldType3, string fieldName3) + public static Dictionary InjectThreeParameterAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, TypeAnalysisContext fieldType1, string fieldName1, TypeAnalysisContext fieldType2, string fieldName2, TypeAnalysisContext fieldType3, string fieldName3) { var multiInjectType = appContext.InjectTypeIntoAllAssemblies(ns, name, appContext.SystemTypes.SystemAttributeType); ApplyAttributeUsageAttribute(appContext, multiInjectType, attributeTargets, allowMultiple); @@ -71,7 +71,7 @@ internal static Dictionary InjectAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, params (TypeAnalysisContext, string)[] fields) + public static Dictionary InjectAttribute(ApplicationAnalysisContext appContext, string ns, string name, AttributeTargets attributeTargets, bool allowMultiple, params (TypeAnalysisContext, string)[] fields) { var multiInjectType = appContext.InjectTypeIntoAllAssemblies(ns, name, appContext.SystemTypes.SystemAttributeType); ApplyAttributeUsageAttribute(appContext, multiInjectType, attributeTargets, allowMultiple); @@ -109,30 +109,30 @@ private static void ApplyAttributeUsageAttribute(ApplicationAnalysisContext appC } } - internal static void AddZeroParameterAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor) + public static void AddZeroParameterAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor) { var newAttribute = new AnalyzedCustomAttribute(constructor); customAttributeHolder.CustomAttributes!.Add(newAttribute);//Nullability checked elsewhere } - internal static void AddOneParameterAttribute(HasCustomAttributes customAttributeHolder, (MethodAnalysisContext, FieldAnalysisContext) attributeInfo, object fieldValue) + public static void AddOneParameterAttribute(HasCustomAttributes customAttributeHolder, (MethodAnalysisContext, FieldAnalysisContext) attributeInfo, object fieldValue) { AddOneParameterAttribute(customAttributeHolder, attributeInfo.Item1, attributeInfo.Item2, fieldValue); } - internal static void AddOneParameterAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, FieldAnalysisContext field, object fieldValue) + public static void AddOneParameterAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, FieldAnalysisContext field, object fieldValue) { var newAttribute = new AnalyzedCustomAttribute(constructor); newAttribute.Fields.Add(new(field, MakeFieldParameter(fieldValue, newAttribute, 0))); customAttributeHolder.CustomAttributes!.Add(newAttribute);//Nullability checked elsewhere } - internal static void AddTwoParameterAttribute(HasCustomAttributes customAttributeHolder, (MethodAnalysisContext, FieldAnalysisContext, FieldAnalysisContext) attributeInfo, object fieldValue1, object fieldValue2) + public static void AddTwoParameterAttribute(HasCustomAttributes customAttributeHolder, (MethodAnalysisContext, FieldAnalysisContext, FieldAnalysisContext) attributeInfo, object fieldValue1, object fieldValue2) { AddTwoParameterAttribute(customAttributeHolder, attributeInfo.Item1, attributeInfo.Item2, fieldValue1, attributeInfo.Item3, fieldValue2); } - internal static void AddTwoParameterAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, FieldAnalysisContext field1, object fieldValue1, FieldAnalysisContext field2, object fieldValue2) + public static void AddTwoParameterAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, FieldAnalysisContext field1, object fieldValue1, FieldAnalysisContext field2, object fieldValue2) { var newAttribute = new AnalyzedCustomAttribute(constructor); newAttribute.Fields.Add(new(field1, MakeFieldParameter(fieldValue1, newAttribute, 0))); @@ -140,12 +140,12 @@ internal static void AddTwoParameterAttribute(HasCustomAttributes customAttribut customAttributeHolder.CustomAttributes!.Add(newAttribute);//Nullability checked elsewhere } - internal static void AddAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, params (FieldAnalysisContext, object)[] fields) + public static void AddAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, params (FieldAnalysisContext, object)[] fields) { AddAttribute(customAttributeHolder, constructor, fields.AsEnumerable()); } - internal static void AddAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, IEnumerable<(FieldAnalysisContext, object)> fields) + public static void AddAttribute(HasCustomAttributes customAttributeHolder, MethodAnalysisContext constructor, IEnumerable<(FieldAnalysisContext, object)> fields) { var newAttribute = new AnalyzedCustomAttribute(constructor); var i = 0;