Skip to content

Commit 50ecb36

Browse files
committed
a bit of rework
1 parent f514c85 commit 50ecb36

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

src/Xamarin.Android.Build.Tasks/Linker/MonoDroid.Tuner/RemoveResourceDesignerStep.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ protected override void Process ()
4040

4141
protected override void EndProcess ()
4242
{
43-
Context.LogMessage ($" End Process Called.");
4443
if (mainDesigner != null) {
4544
Context.LogMessage ($" Setting Action on {mainAssembly.Name} to Save.");
4645
Annotations.SetAction (mainAssembly, AssemblyAction.Save);
@@ -63,7 +62,7 @@ bool FindResourceDesigner (AssemblyDefinition assembly, bool mainApplication, ou
6362
{
6463
if (p.Name == "IsApplication" && (bool)p.Argument.Value == (mainApplication ? mainApplication : (bool)p.Argument.Value))
6564
{
66-
designerFullName = attribute.ConstructorArguments[0].Value.ToString();
65+
designerFullName = attribute.ConstructorArguments[0].Value.ToString ();
6766
break;
6867
}
6968
}
@@ -89,7 +88,7 @@ bool FindResourceDesigner (AssemblyDefinition assembly, bool mainApplication, ou
8988
return false;
9089
}
9190

92-
Dictionary<string, int> BuildResourceDesignerFieldLookup(TypeDefinition type)
91+
Dictionary<string, int> BuildResourceDesignerFieldLookup (TypeDefinition type)
9392
{
9493
var output = new Dictionary<string, int> ();
9594
foreach (TypeDefinition definition in type.NestedTypes)
@@ -104,7 +103,7 @@ Dictionary<string, int> BuildResourceDesignerFieldLookup(TypeDefinition type)
104103
return output;
105104
}
106105

107-
void RemoveDesigner(TypeDefinition designer)
106+
void ClearDesignerClass (TypeDefinition designer)
108107
{
109108
Context.LogMessage ($" TryRemoving {designer.FullName}");
110109
designer.NestedTypes.Clear ();
@@ -120,7 +119,7 @@ void RemoveDesigner(TypeDefinition designer)
120119
void FixBody (MethodBody body, TypeDefinition localDesigner)
121120
{
122121
Dictionary<Instruction, int> instructions = new Dictionary<Instruction, int>();
123-
var processor = body.GetILProcessor();
122+
var processor = body.GetILProcessor ();
124123
string designerFullName = $"{localDesigner.FullName}/";
125124
foreach (var i in body.Instructions)
126125
{
@@ -131,7 +130,7 @@ void FixBody (MethodBody body, TypeDefinition localDesigner)
131130
if (match.Success && match.Groups.Count == 5) {
132131
string key = match.Groups[4].Value.Replace (designerFullName, string.Empty);
133132
if (designerConstants.ContainsKey (key) && !instructions.ContainsKey (i))
134-
instructions.Add(i, designerConstants[key]);
133+
instructions.Add(i, designerConstants [key]);
135134
}
136135
}
137136
}
@@ -146,28 +145,28 @@ void FixBody (MethodBody body, TypeDefinition localDesigner)
146145
}
147146
}
148147

149-
void ProcessTypeR (TypeDefinition type, TypeDefinition localDesigner)
148+
void FixType (TypeDefinition type, TypeDefinition localDesigner)
150149
{
151150
foreach (MethodDefinition method in type.Methods)
152151
{
153152
if (!method.HasBody)
154153
continue;
155-
FixBody(method.Body, localDesigner);
154+
FixBody (method.Body, localDesigner);
156155
}
157156
foreach (PropertyDefinition property in type.Properties)
158157
{
159158
if (property.GetMethod != null && property.GetMethod.HasBody)
160159
{
161-
FixBody(property.GetMethod.Body, localDesigner);
160+
FixBody (property.GetMethod.Body, localDesigner);
162161
}
163162
if (property.SetMethod != null && property.SetMethod.HasBody)
164163
{
165-
FixBody(property.SetMethod.Body, localDesigner);
164+
FixBody (property.SetMethod.Body, localDesigner);
166165
}
167166
}
168167
foreach (TypeDefinition nestedType in type.NestedTypes)
169168
{
170-
ProcessTypeR(nestedType, localDesigner);
169+
FixType (nestedType, localDesigner);
171170
}
172171
}
173172

@@ -200,10 +199,10 @@ protected override void ProcessAssembly (AssemblyDefinition assembly)
200199
foreach (var type in mod.Types) {
201200
if (type == localDesigner)
202201
continue;
203-
ProcessTypeR (type, localDesigner);
202+
FixType (type, localDesigner);
204203
}
205204
}
206-
RemoveDesigner (localDesigner);
205+
ClearDesignerClass (localDesigner);
207206
if (designerAttribute != null) {
208207
assembly.CustomAttributes.Remove (designerAttribute);
209208
}

0 commit comments

Comments
 (0)