public Process ( MethodDefinition method ) : void | ||
method | MethodDefinition | |
Результат | void |
public override void Execute() { var initializeMethodFinder = new HandleMethodFinder { ModuleDefinition = ModuleDefinition, AssemblyResolver = AssemblyResolver }; initializeMethodFinder.Execute(); var stateMachineFinder = new StateMachineTypesFinder { ModuleDefinition = ModuleDefinition, }; stateMachineFinder.Execute(); var methodProcessor = new MethodProcessor { HandleMethodFinder = initializeMethodFinder, }; foreach (var stateMachine in stateMachineFinder.AllTypes) { try { var moveNext = stateMachine.Methods.First(x => x.Name == "MoveNext"); methodProcessor.Process(moveNext); } catch (Exception exception) { throw new Exception($"Failed to process '{stateMachine.FullName}'.", exception); } } }
void ProcessAssembly(List <TypeDefinition> types) { var isDebug = IncludeDebugAssert && DefineConstants.Any(c => c == "DEBUG") && ReferenceFinder.DebugAssertMethod != null; var methodProcessor = new MethodProcessor(ValidationFlags, isDebug); var propertyProcessor = new PropertyProcessor(ValidationFlags, isDebug); foreach (var type in types) { if (type.IsInterface || type.ContainsAllowNullAttribute() || type.IsGeneratedCode() || type.HasInterface("Windows.UI.Xaml.Markup.IXamlMetadataProvider")) { continue; } foreach (var method in type.MethodsWithBody()) { methodProcessor.Process(method); } foreach (var property in type.ConcreteProperties()) { propertyProcessor.Process(property); } } }
public void Execute() { var initializeMethodFinder = new HandleMethodFinder { ModuleDefinition = ModuleDefinition, }; initializeMethodFinder.Execute(); var stateMachineFinder = new StateMachineTypesFinder { ModuleDefinition = ModuleDefinition, }; stateMachineFinder.Execute(); var methodProcessor = new MethodProcessor { HandleMethodFinder = initializeMethodFinder, }; foreach (var stateMachine in stateMachineFinder.AllTypes) { var moveNext = stateMachine.Methods.First(x => x.Name == "MoveNext"); methodProcessor.Process(moveNext); } }
void ProcessMethod(MethodDefinition method) { var asyncAttribute = method.CustomAttributes.FirstOrDefault(_ => _.AttributeType.Name == "AsyncStateMachineAttribute"); if (asyncAttribute == null) { var methodProcessor = new MethodProcessor { ModuleWeaver = this, TypeSystem = ModuleDefinition.TypeSystem, Method = method, }; methodProcessor.Process(); return; } LogError(string.Format("Could not process '{0}'. async methods are not currently supported. Feel free to submit a pull request if you want this feature.", method.FullName)); //var fullName = method.FullName; //var customAttributeArgument = asyncAttribute.ConstructorArguments.First(); //var typeReference = (TypeReference) customAttributeArgument.Value; //var asyncTypeDefinition = typeReference.Resolve(); //var methodProcessorAsync = new MethodProcessorAsync // { // ModuleWeaver = this, // TypeSystem = ModuleDefinition.TypeSystem, // AsyncTypeReference = asyncTypeDefinition, // OriginalMethod = method // }; //methodProcessorAsync.Process(); }
public void Execute() { var initializeMethodFinder = new HandleMethodFinder { ModuleDefinition = ModuleDefinition, AssemblyResolver = AssemblyResolver }; initializeMethodFinder.Execute(); var stateMachineFinder = new StateMachineTypesFinder { ModuleDefinition = ModuleDefinition, }; stateMachineFinder.Execute(); var methodProcessor = new MethodProcessor { HandleMethodFinder = initializeMethodFinder, }; foreach (var stateMachine in stateMachineFinder.AllTypes) { var moveNext = stateMachine.Methods.First(x => x.Name == "MoveNext"); methodProcessor.Process(moveNext); } }
public void Execute() { var initializeMethodFinder = new HandleMethodFinder { ModuleDefinition = ModuleDefinition, AssemblyResolver = AssemblyResolver }; initializeMethodFinder.Execute(); var stateMachineFinder = new StateMachineTypesFinder { ModuleDefinition = ModuleDefinition, }; stateMachineFinder.Execute(); var methodProcessor = new MethodProcessor { HandleMethodFinder = initializeMethodFinder, }; foreach (var stateMachine in stateMachineFinder.AllTypes) { try { var moveNext = stateMachine.Methods.First(x => x.Name == "MoveNext"); methodProcessor.Process(moveNext); } catch (Exception exception) { throw new Exception($"Failed to process '{stateMachine.FullName}'.", exception); } } }
void ProcessMethod(MethodDefinition method) { if (method.IsYield()) { if (method.ContainsTimeAttribute()) { LogError("Could not process '" + method.FullName + "' since methods that yield are currently not supported. Please remove the [Time] attribute from that method."); return; } LogInfo("Skipping '" + method.FullName + "' since methods that yield are not supported."); return; } if (method.IsAsync()) { var asyncProcessor = new AsyncMethodProcessor { ModuleWeaver = this, Method = method, }; asyncProcessor.Process(); return; } var methodProcessor = new MethodProcessor { ModuleWeaver = this, Method = method, }; methodProcessor.Process(); }
public void Execute() { var msCoreReferenceFinder = new ReferenceFinder { ModuleDefinition = ModuleDefinition, AssemblyResolver = AssemblyResolver }; msCoreReferenceFinder.Execute(); var interceptorFinder = new InterceptorFinder { ModuleDefinition = ModuleDefinition }; interceptorFinder.Execute(); var methodProcessor = new MethodProcessor { referenceFinder = msCoreReferenceFinder, typeSystem = ModuleDefinition.TypeSystem, InterceptorFinder = interceptorFinder, }; foreach (var typeDefinition in ModuleDefinition.GetTypes()) { if (typeDefinition.ContainsTimeAttribute()) { methodProcessor.Process(typeDefinition.Methods.Where(x => !x.IsAbstract)); continue; } foreach (var method in typeDefinition.Methods) { if (method.IsAbstract) { continue; } if (!method.ContainsTimeAttribute()) { continue; } methodProcessor.Process(method); } } }
void ProcessAssembly(List<TypeDefinition> types) { var isDebug = IncludeDebugAssert && DefineConstants.Any(c => c == "DEBUG") && ReferenceFinder.DebugAssertMethod != null; var methodProcessor = new MethodProcessor(ValidationFlags, isDebug); var propertyProcessor = new PropertyProcessor(ValidationFlags, isDebug); foreach (var type in types) { if (type.IsInterface || type.ContainsAllowNullAttribute() || type.IsGeneratedCode() || type.HasInterface("Windows.UI.Xaml.Markup.IXamlMetadataProvider")) continue; foreach (var method in type.MethodsWithBody()) methodProcessor.Process(method); foreach (var property in type.ConcreteProperties()) propertyProcessor.Process(property); } }
void ProcessMethod(MethodDefinition method) { if (method.IsYield()) { if (method.ContainsTimeAttribute()) { WriteError("Could not process '" + method.FullName + "' since methods that yield are currently not supported. Please remove the [Time] attribute from that method."); return; } WriteInfo("Skipping '" + method.FullName + "' since methods that yield are not supported."); return; } var timeAttribute = method.GetTimeAttribute(); if (timeAttribute != null) { var format = timeAttribute.ConstructorArguments.FirstOrDefault().Value as string; if (!string.IsNullOrWhiteSpace(format)) { var hasErrors = false; var logWithMessageMethodUsingLong = LogWithMessageMethodUsingLong; var logWithMessageMethodUsingTimeSpan = LogWithMessageMethodUsingTimeSpan; if (logWithMessageMethodUsingLong is null && logWithMessageMethodUsingTimeSpan is null) { hasErrors = true; WriteError("Feature with parameter formatting is being used, but no useable log method can be found. Either disable the feature usage or update the logger signature to 'public static void Log(MethodBase methodBase, long milliseconds, string message)' or 'public static void Log(MethodBase methodBase, TimeSpan elapsed, string message)'"); } var info = parameterFormattingProcessor.ParseParameterFormatting(format); for (var i = 0; i < info.ParameterNames.Count; i++) { var parameterName = info.ParameterNames[i]; if (string.Equals(parameterName, "this")) { if (method.IsStatic) { hasErrors = true; WriteError($"Could not process '{method.FullName}' because the format uses 'this' in a static context."); } } else { var containsParameter = method.Parameters.Any(x => x.Name.Equals(parameterName)); if (!containsParameter) { hasErrors = true; WriteError($"Could not process '{method.FullName}' because the format uses '{parameterName}' which is not available as method parameter."); } } } if (hasErrors) { return; } } } if (method.IsAsync()) { var asyncProcessor = new AsyncMethodProcessor { ModuleWeaver = this, Method = method, }; asyncProcessor.Process(); return; } var methodProcessor = new MethodProcessor { ModuleWeaver = this, Method = method, }; methodProcessor.Process(); }
void ProcessMethod(MethodDefinition method) { if (method.IsYield()) { if (method.ContainsTimeAttribute()) { LogError("Could not process '" + method.FullName + "' since methods that yield are currently not supported. Please remove the [Time] attribute from that method."); return; } LogInfo("Skipping '" + method.FullName + "' since methods that yield are not supported."); return; } if (method.IsAsync()) { var asyncProcessor = new AsyncMethodProcessor { ModuleWeaver = this, Method = method, }; asyncProcessor.Process(); return; } var methodProcessor = new MethodProcessor { ModuleWeaver = this, Method = method, }; methodProcessor.Process(); }