// Token: 0x06000026 RID: 38 RVA: 0x000037A4 File Offset: 0x000019A4 public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { ModuleDef module = def as ModuleDef; if (module == null) { return; } string asmName = module.Assembly.Name.String; if (!string.IsNullOrEmpty(module.Assembly.Culture) && asmName.EndsWith(".resources")) { Regex satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture)); string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length); ModuleDef mainModule = context.Modules.SingleOrDefault((ModuleDefMD mod) => mod.Assembly.Name == nameAsmName); if (mainModule == null) { context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", new object[] { module.Assembly.FullName }); throw new ConfuserException(null); } string format = "{0}." + module.Assembly.Culture + ".resources"; using (IEnumerator <Resource> enumerator = module.Resources.GetEnumerator()) { while (enumerator.MoveNext()) { Resource res = enumerator.Current; Match match = satellitePattern.Match(res.Name); if (match.Success) { string typeName = match.Groups[1].Value; TypeDef type = mainModule.FindReflectionThrow(typeName); if (type == null) { context.Logger.WarnFormat("Could not find resource type '{0}'.", new object[] { typeName }); } else { service.ReduceRenameMode(type, RenameMode.ASCII); service.AddReference <TypeDef>(type, new ResourceReference(res, type, format)); } } } return; } } string format2 = "{0}.resources"; foreach (Resource res2 in module.Resources) { Match match2 = ResourceAnalyzer.ResourceNamePattern.Match(res2.Name); if (match2.Success && res2.ResourceType == ResourceType.Embedded) { string typeName2 = match2.Groups[1].Value; if (!typeName2.EndsWith(".g")) { TypeDef type2 = module.FindReflection(typeName2); if (type2 == null) { context.Logger.WarnFormat("Could not find resource type '{0}'.", new object[] { typeName2 }); } else { service.ReduceRenameMode(type2, RenameMode.ASCII); service.AddReference <TypeDef>(type2, new ResourceReference(res2, type2, format2)); } } } } }
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { var module = def as ModuleDef; if (module == null) { return; } string asmName = module.Assembly.Name.String; if (!string.IsNullOrEmpty(module.Assembly.Culture) && asmName.EndsWith(".resources")) { // Satellite assembly var satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture)); string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length); ModuleDef mainModule = context.Modules.SingleOrDefault(mod => mod.Assembly.Name == nameAsmName); if (mainModule == null) { context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", module.Assembly.FullName); throw new ConfuserException(null); } string format = "{0}." + module.Assembly.Culture + ".resources"; foreach (Resource res in module.Resources) { Match match = satellitePattern.Match(res.Name); if (!match.Success) { continue; } string typeName = match.Groups[1].Value; TypeDef type = mainModule.FindReflection(typeName); if (type == null) { context.Logger.WarnFormat(Resources.ResourceAnalyzer_Analyze_CouldNotFindResourceType, typeName); continue; } service.ReduceRenameMode(type, RenameMode.Reflection); service.AddReference(type, new ResourceReference(res, type, format)); } } else { string format = "{0}.resources"; foreach (Resource res in module.Resources) { Match match = ResourceNamePattern.Match(res.Name); if (!match.Success || res.ResourceType != ResourceType.Embedded) { continue; } string typeName = match.Groups[1].Value; if (typeName.EndsWith(".g")) // WPF resources, ignore { continue; } // This variable is set true in case the name of the resource doesn't match the name of the class. // That happens for the resources in Visual Basic. var mismatchingName = false; TypeDef type = module.FindReflection(typeName); if (type == null) { if (typeName.EndsWith(".Resources")) { typeName = typeName.Substring(0, typeName.Length - 10) + ".My.Resources.Resources"; type = module.FindReflection(typeName); mismatchingName = type != null; } } if (type == null) { context.Logger.WarnFormat(Resources.ResourceAnalyzer_Analyze_CouldNotFindResourceType, typeName); continue; } service.ReduceRenameMode(type, RenameMode.Reflection); service.AddReference(type, new ResourceReference(res, type, format)); if (mismatchingName) { // Add string type references in case the name didn't match. This will cause the resource to get // the same name as the class, despite that not being the case before. But that doesn't really matter. FindLdTokenResourceReferences(type, match.Groups[1].Value, service); } } } }
public void Analyze(ConfuserContext context, INameService service, ProtectionParameters parameters, IDnlibDef def) { var module = def as ModuleDef; if (module == null) { return; } string asmName = module.Assembly.Name.String; if (!string.IsNullOrEmpty(module.Assembly.Culture) && asmName.EndsWith(".resources")) { // Satellite assembly var satellitePattern = new Regex(string.Format("^(.*)\\.{0}\\.resources$", module.Assembly.Culture)); string nameAsmName = asmName.Substring(0, asmName.Length - ".resources".Length); ModuleDef mainModule = context.Modules.SingleOrDefault(mod => mod.Assembly.Name == nameAsmName); if (mainModule == null) { context.Logger.ErrorFormat("Could not find main assembly of satellite assembly '{0}'.", module.Assembly.FullName); throw new ConfuserException(null); } string format = "{0}." + module.Assembly.Culture + ".resources"; foreach (Resource res in module.Resources) { Match match = satellitePattern.Match(res.Name); if (!match.Success) { continue; } string typeName = match.Groups[1].Value; TypeDef type = mainModule.FindReflection(typeName); if (type == null) { context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName); continue; } service.ReduceRenameMode(type, RenameMode.ASCII); service.AddReference(type, new ResourceReference(res, type, format)); } } else { string format = "{0}.resources"; foreach (Resource res in module.Resources) { Match match = ResourceNamePattern.Match(res.Name); if (!match.Success || res.ResourceType != ResourceType.Embedded) { continue; } string typeName = match.Groups[1].Value; if (typeName.EndsWith(".g")) // WPF resources, ignore { continue; } TypeDef type = module.FindReflection(typeName); if (type == null) { if (typeName.EndsWith(".Resources")) { typeName = typeName.Substring(0, typeName.Length - 10) + ".My.Resources.Resources"; type = module.FindReflection(typeName); } } if (type == null) { context.Logger.WarnFormat("Could not find resource type '{0}'.", typeName); continue; } service.ReduceRenameMode(type, RenameMode.ASCII); service.AddReference(type, new ResourceReference(res, type, format)); } } }