Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Commit 0112a54

Browse files
committed
2 parents eb57320 + 8d65d1c commit 0112a54

File tree

14 files changed

+168
-32
lines changed

14 files changed

+168
-32
lines changed

MethodCache.Attributes/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@
2222
// You can specify all the values or you can default the Build and Revision Numbers
2323
// by using the '*' as shown below:
2424
// [assembly: AssemblyVersion("1.0.*")]
25-
[assembly: AssemblyVersion("1.4.1.0")]
26-
[assembly: AssemblyFileVersion("1.4.1.0")]
25+
[assembly: AssemblyVersion("1.5.0.0")]
26+
[assembly: AssemblyFileVersion("1.5.0.0")]

MethodCache.Fody/CecilHelper.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static Instruction AppendLd(this Instruction instruction, ILProcessor pro
4848
// System.Type
4949
// An enum type, provided it has public accessibility and the types in which it is nested (if any) also have public accessibility (§17.2)
5050
// Single-dimensional arrays of the above types
51-
var argumentType = argument.Type;
51+
TypeReference argumentType = argument.Type;
5252

5353
switch (argumentType.MetadataType)
5454
{
@@ -72,7 +72,7 @@ public static Instruction AppendLd(this Instruction instruction, ILProcessor pro
7272
.AppendLdcI4(processor, values.Length)
7373
.Append(processor.Create(OpCodes.Newarr, argument.Type.GetElementType()), processor);
7474

75-
var arrayType = argument.Type.GetElementType();
75+
TypeReference arrayType = argument.Type.GetElementType();
7676

7777
for (int i = 0; i < values.Length; i++)
7878
{
@@ -330,19 +330,19 @@ public static MethodReference MakeGeneric(this MethodReference method, params Ty
330330

331331
public static MethodReference MakeHostInstanceGeneric(this MethodReference self, params TypeReference[] args)
332332
{
333-
var reference = new MethodReference(self.Name, self.ReturnType, self.DeclaringType.MakeGenericInstanceType(args))
333+
MethodReference reference = new MethodReference(self.Name, self.ReturnType, self.DeclaringType.MakeGenericInstanceType(args))
334334
{
335335
HasThis = self.HasThis,
336336
ExplicitThis = self.ExplicitThis,
337337
CallingConvention = self.CallingConvention
338338
};
339339

340-
foreach (var parameter in self.Parameters)
340+
foreach (ParameterDefinition parameter in self.Parameters)
341341
{
342342
reference.Parameters.Add(new ParameterDefinition(parameter.ParameterType));
343343
}
344344

345-
foreach (var genericParam in self.GenericParameters)
345+
foreach (GenericParameter genericParam in self.GenericParameters)
346346
{
347347
reference.GenericParameters.Add(new GenericParameter(genericParam.Name, reference));
348348
}

MethodCache.Fody/ModuleWeaver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ private MethodDefinition CacheTypeGetRetrieveMethod(TypeDefinition cacheType, st
179179
private MethodDefinition CacheTypeGetStoreMethod(TypeDefinition cacheInterface, string cacheTypeStoreMethodName)
180180
{
181181
// Prioritize Store methods with parameters Dictionary
182-
var methodDefinition = cacheInterface.GetMethod(cacheTypeStoreMethodName, ModuleDefinition.TypeSystem.Void,
182+
MethodDefinition methodDefinition = cacheInterface.GetMethod(cacheTypeStoreMethodName, ModuleDefinition.TypeSystem.Void,
183183
new[]
184184
{
185185
ModuleDefinition.TypeSystem.String, ModuleDefinition.TypeSystem.Object,
@@ -590,7 +590,7 @@ private void WeaveMethod(MethodDefinition methodDefinition, CustomAttribute attr
590590
.Append(processor.Create(OpCodes.Newobj,
591591
methodDefinition.Module.Import(References.DictionaryConstructor)), processor);
592592

593-
foreach (CustomAttributeNamedArgument property in attribute.Properties)
593+
foreach (CustomAttributeNamedArgument property in attribute.Properties.Union(attribute.Fields))
594594
{
595595
returnInstruction.Previous
596596
.AppendDup(processor)

MethodCache.Fody/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
// You can specify all the values or you can default the Build and Revision Numbers
3030
// by using the '*' as shown below:
3131
// [assembly: AssemblyVersion("1.0.*")]
32-
[assembly: AssemblyVersion("1.4.1.0")]
33-
[assembly: AssemblyFileVersion("1.4.1.0")]
32+
[assembly: AssemblyVersion("1.5.0.0")]
33+
[assembly: AssemblyFileVersion("1.5.0.0")]

MethodCache.Fody/ReferenceFinder.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public class References
3434

3535
public void LoadReferences()
3636
{
37-
var coreTypes = new List<TypeDefinition>();
37+
List<TypeDefinition> coreTypes = new List<TypeDefinition>();
3838

3939
AppendTypes("System.Runtime.Extensions", coreTypes);
4040
AppendTypes("System", coreTypes);
4141
AppendTypes("mscorlib", coreTypes);
4242
AppendTypes("System.Runtime", coreTypes);
4343
AppendTypes("System.Reflection", coreTypes);
4444

45-
var debugType = GetDebugType(coreTypes);
45+
TypeDefinition debugType = GetDebugType(coreTypes);
4646

4747
DebugWriteLineMethod =
4848
debugType.Methods.First(
@@ -90,7 +90,7 @@ public void LoadReferences()
9090

9191
private void AppendTypes(string name, List<TypeDefinition> coreTypes)
9292
{
93-
var definition = AssemblyResolver.Resolve(name);
93+
AssemblyDefinition definition = AssemblyResolver.Resolve(name);
9494
if (definition != null)
9595
{
9696
coreTypes.AddRange(definition.MainModule.Types);
@@ -99,14 +99,14 @@ private void AppendTypes(string name, List<TypeDefinition> coreTypes)
9999

100100
private TypeDefinition GetDebugType(List<TypeDefinition> coreTypes)
101101
{
102-
var debugType = coreTypes.FirstOrDefault(x => x.Name == "Debug");
102+
TypeDefinition debugType = coreTypes.FirstOrDefault(x => x.Name == "Debug");
103103

104104
if (debugType != null)
105105
{
106106
return debugType;
107107
}
108108

109-
var systemDiagnosticsDebug = AssemblyResolver.Resolve("System.Diagnostics.Debug");
109+
AssemblyDefinition systemDiagnosticsDebug = AssemblyResolver.Resolve("System.Diagnostics.Debug");
110110

111111
if (systemDiagnosticsDebug != null)
112112
{
@@ -123,7 +123,7 @@ private TypeDefinition GetDebugType(List<TypeDefinition> coreTypes)
123123

124124
private TypeDefinition GetDictionaryInterface(List<TypeDefinition> coreTypes)
125125
{
126-
var dictionaryType = coreTypes.FirstOrDefault(x => x.Name == "IDictionary`2");
126+
TypeDefinition dictionaryType = coreTypes.FirstOrDefault(x => x.Name == "IDictionary`2");
127127

128128
if (dictionaryType != null)
129129
{
@@ -135,7 +135,7 @@ private TypeDefinition GetDictionaryInterface(List<TypeDefinition> coreTypes)
135135

136136
private TypeDefinition GetDictionaryType(List<TypeDefinition> coreTypes)
137137
{
138-
var dictionaryType = coreTypes.FirstOrDefault(x => x.Name == "Dictionary`2");
138+
TypeDefinition dictionaryType = coreTypes.FirstOrDefault(x => x.Name == "Dictionary`2");
139139

140140
if (dictionaryType != null)
141141
{
@@ -147,7 +147,7 @@ private TypeDefinition GetDictionaryType(List<TypeDefinition> coreTypes)
147147

148148
private TypeDefinition GetSystemRuntimeTypeHandleType(List<TypeDefinition> coreTypes)
149149
{
150-
var runtimeTypeHandle = coreTypes.FirstOrDefault(x => x.Name == "RuntimeTypeHandle");
150+
TypeDefinition runtimeTypeHandle = coreTypes.FirstOrDefault(x => x.Name == "RuntimeTypeHandle");
151151

152152
if (runtimeTypeHandle != null)
153153
{
@@ -159,7 +159,7 @@ private TypeDefinition GetSystemRuntimeTypeHandleType(List<TypeDefinition> coreT
159159

160160
private TypeDefinition GetSystemTypeType(List<TypeDefinition> coreTypes)
161161
{
162-
var systemType = coreTypes.FirstOrDefault(x => x.Name == "Type");
162+
TypeDefinition systemType = coreTypes.FirstOrDefault(x => x.Name == "Type");
163163

164164
if (systemType != null)
165165
{

MethodCache.Nuget/MethodCache.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>MethodCache.Fody</id>
5-
<version>1.4.1</version>
5+
<version>1.5.0-alpha1</version>
66
<title>MethodCache.Fody</title>
77
<authors>Christopher Dresel</authors>
88
<owners>Christopher Dresel</owners>

MethodCache.Nuget/readme.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
Since 1.5.0.0 it is now possible to use custom CacheAttribute parameters for fine-grained cache control (see https://github.com/Dresel/MethodCache section "CacheAttribute Parameters Support" for details).
2+
13
Since 1.4.0.0 it is now possible to also cache properties (see https://github.com/Dresel/MethodCache for details).
24

35
If you want this package to behave as previous packages (let class level [Cache] attribute only cache methods), modify ModuleWeavers.xml to:

MethodCache.Tests.TestAssembly/Cache/CacheAttribute.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ public class CacheAttribute : Attribute
99
public int Parameter2 { get; set; }
1010

1111
public bool Parameter3 { get; set; }
12+
13+
public double parameter3;
1214
}
1315
}

MethodCache.Tests.TestAssembly/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
// You can specify all the values or you can default the Build and Revision Numbers
3030
// by using the '*' as shown below:
3131
// [assembly: AssemblyVersion("1.0.*")]
32-
[assembly: AssemblyVersion("1.4.1.0")]
33-
[assembly: AssemblyFileVersion("1.4.1.0")]
32+
[assembly: AssemblyVersion("1.5.0.0")]
33+
[assembly: AssemblyFileVersion("1.5.0.0")]

MethodCache.Tests.TestAssembly/TestClassWithParameterizedCacheAttribute.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ public string CacheParameterMethod(string argument1, int argument2)
2020
return argument1 + argument2;
2121
}
2222

23+
[Cache.Cache(Parameter3 = true, parameter3 = 0)]
24+
public string CacheParameterMethodWithField(string argument1, int argument2)
25+
{
26+
return argument1 + argument2;
27+
}
28+
2329
[Cache.ComplexCacheAttribute.Cache(ParameterBoolArray = new bool[] { false, true },
2430
ParameterByteArray = new byte[] { Byte.MinValue, Byte.MaxValue },
2531
ParameterCharacterArray = new char[] { Char.MinValue, Char.MaxValue },

0 commit comments

Comments
 (0)