public void AddOptions(OptionSet options) { ArgumentUtility.CheckNotNull("options", options); options.Add( "att|attribute=", "Mark affected methods with custom attribute [None | Generated | Custom] (default = Generated)", att => _mode = (AttributeMode)Enum.Parse(typeof(AttributeMode), att)); options.Add( "attPrefix=", "The unspeakable prefix for the virtual method. (default value: '<>virtualized_')", prefix => _unspeakablePrefix = prefix); options.Add( "attFullName=", "Fullname of the attribute type (default value: 'NonVirtualAttributeNonVirtualAttribute').", at => { _attName = at.Substring(at.LastIndexOf(".") + 1, at.Length - at.LastIndexOf(".") - 1); _attNamespace = at.Substring(0, at.LastIndexOf(".")); }); options.Add( "attFile|attributeFile=", "Assembly containing the custom attribute (dll or exe). ONLY applicable in 'Custom' attribute mode!", custAtt => _attributeAssembly = custAtt); _selectionFactory = new TargetSelectorFactory(); _selectionFactory.AddOptions(options); }
public void OverrideMethods_MarksAssemblyWithMatchingMethodsModified() { _selectionFactory.AddOptions(_options); _options.Parse(new[] { "--regex=(.*)" }); MethodDefinition methodMain = _assemblyDefinition.MainModule.Types[1].Methods[0]; Assert.That(_tracker.IsModified(_assemblyDefinition), Is.False); _codeGenerator.Expect(s => s.GenerateMethodAndMoveBody(Arg <MethodDefinition> .Is.Anything)). Return(new MethodDefinition("GeneratedMethod", MethodAttributes.Public | MethodAttributes.Virtual, methodMain.ReturnType)); _codeGenerator.Expect(s => s.GenerateMethodAndMoveBody(Arg <MethodDefinition> .Is.Anything)). Return(new MethodDefinition("GeneratedMethod", MethodAttributes.Public | MethodAttributes.Virtual, methodMain.ReturnType)); _methodsVirtualizer.Transform(_tracker); Assert.That(_tracker.IsModified(_assemblyDefinition), Is.True); }
public void AddOptions(OptionSet options) { ArgumentUtility.CheckNotNull ("options", options); options.Add ( "att|attribute=", "Mark affected methods with custom attribute [None | Generated | Custom] (default = Generated)", att => _mode = (AttributeMode) Enum.Parse (typeof (AttributeMode), att)); options.Add ( "attPrefix=", "The unspeakable prefix for the virtual method. (default value: '<>virtualized_')", prefix => _unspeakablePrefix = prefix); options.Add ( "attFullName=", "Fullname of the attribute type (default value: 'NonVirtualAttributeNonVirtualAttribute').", at => { _attName = at.Substring (at.LastIndexOf (".") + 1, at.Length - at.LastIndexOf (".") - 1); _attNamespace = at.Substring (0, at.LastIndexOf (".")); } ); options.Add ( "attFile|attributeFile=", "Assembly containing the custom attribute (dll or exe). ONLY applicable in 'Custom' attribute mode!", custAtt => _attributeAssembly = custAtt); _selectionFactory = new TargetSelectorFactory (); _selectionFactory.AddOptions (options); }