Ejemplo n.º 1
0
        void RenameMethod(MMethodDef methodDef)
        {
            if (methodDef.IsVirtual())
            {
                throw new ApplicationException("Can't rename virtual methods here");
            }
            if (!CanRenameMethod(methodDef))
            {
                return;
            }

            var info = Method(methodDef);

            if (info.renamed)
            {
                return;
            }
            info.renamed = true;
            var checker = NameChecker;

            // PInvoke methods' EntryPoint is always valid. It has to, so always rename.
            bool isValidName     = NameChecker.IsValidMethodName(info.oldName);
            bool isExternPInvoke = methodDef.MethodDef.ImplMap != null && methodDef.MethodDef.RVA == 0;

            if (!isValidName || isExternPInvoke)
            {
                INameCreator nameCreator = null;
                string       newName     = info.suggestedName;
                string       newName2;
                if (methodDef.MethodDef.ImplMap != null && !string.IsNullOrEmpty(newName2 = GetPinvokeName(methodDef)))
                {
                    newName = newName2;
                }
                else if (methodDef.IsStatic())
                {
                    nameCreator = variableNameState.staticMethodNameCreator;
                }
                else
                {
                    nameCreator = variableNameState.instanceMethodNameCreator;
                }
                if (!string.IsNullOrEmpty(newName))
                {
                    nameCreator = new NameCreator2(newName);
                }
                RenameMethod(methodDef, variableNameState.GetNewMethodName(info.oldName, nameCreator));
            }
        }
Ejemplo n.º 2
0
        void renameMethod(MethodDef methodDef)
        {
            if (methodDef.isVirtual())
            {
                throw new ApplicationException("Can't rename virtual methods here");
            }
            if (!canRenameMethod(methodDef))
            {
                return;
            }

            var info = method(methodDef);

            if (info.renamed)
            {
                return;
            }
            info.renamed = true;
            var checker = NameChecker;

            // PInvoke methods' EntryPoint is always valid. It has to, so always rename.
            if (!NameChecker.isValidMethodName(info.oldName) || methodDef.MethodDefinition.PInvokeInfo != null)
            {
                INameCreator nameCreator = null;
                string       newName     = info.suggestedName;
                if (methodDef.MethodDefinition.PInvokeInfo != null)
                {
                    newName = getPinvokeName(methodDef);
                }
                else if (methodDef.isStatic())
                {
                    nameCreator = variableNameState.staticMethodNameCreator;
                }
                else
                {
                    nameCreator = variableNameState.instanceMethodNameCreator;
                }
                if (newName != null)
                {
                    nameCreator = new NameCreator2(newName);
                }
                renameMethod(methodDef, variableNameState.getNewMethodName(info.oldName, nameCreator));
            }
        }
Ejemplo n.º 3
0
		void RenameMethod(MMethodDef methodDef) {
			if (methodDef.IsVirtual())
				throw new ApplicationException("Can't rename virtual methods here");
			if (!CanRenameMethod(methodDef))
				return;

			var info = Method(methodDef);
			if (info.renamed)
				return;
			info.renamed = true;
			var checker = NameChecker;

			// PInvoke methods' EntryPoint is always valid. It has to, so always rename.
			bool isValidName = NameChecker.IsValidMethodName(info.oldName);
			bool isExternPInvoke = methodDef.MethodDef.ImplMap != null && methodDef.MethodDef.RVA == 0;
			if (!isValidName || isExternPInvoke) {
				INameCreator nameCreator = null;
				string newName = info.suggestedName;
				string newName2;
				if (methodDef.MethodDef.ImplMap != null && !string.IsNullOrEmpty(newName2 = GetPinvokeName(methodDef)))
					newName = newName2;
				else if (methodDef.IsStatic())
					nameCreator = variableNameState.staticMethodNameCreator;
				else
					nameCreator = variableNameState.instanceMethodNameCreator;
				if (!string.IsNullOrEmpty(newName))
					nameCreator = new NameCreator2(newName);
				RenameMethod(methodDef, variableNameState.GetNewMethodName(info.oldName, nameCreator));
			}
		}
Ejemplo n.º 4
0
        void renameMethod(MethodDef methodDef)
        {
            if (methodDef.isVirtual())
                throw new ApplicationException("Can't rename virtual methods here");
            if (!canRenameMethod(methodDef))
                return;

            var info = method(methodDef);
            if (info.renamed)
                return;
            info.renamed = true;
            var checker = NameChecker;

            // PInvoke methods' EntryPoint is always valid. It has to, so always rename.
            if (!NameChecker.isValidMethodName(info.oldName) || methodDef.MethodDefinition.PInvokeInfo != null) {
                INameCreator nameCreator = null;
                string newName = info.suggestedName;
                if (methodDef.MethodDefinition.PInvokeInfo != null)
                    newName = getPinvokeName(methodDef);
                else if (methodDef.isStatic())
                    nameCreator = variableNameState.staticMethodNameCreator;
                else
                    nameCreator = variableNameState.instanceMethodNameCreator;
                if (newName != null)
                    nameCreator = new NameCreator2(newName);
                renameMethod(methodDef, variableNameState.getNewMethodName(info.oldName, nameCreator));
            }
        }