Skip to content

Commit fda8281

Browse files
Jeffrey Schultzlahma
Jeffrey Schultz
authored andcommitted
change to support compilation under .NET Core
1 parent 3bdc793 commit fda8281

File tree

12 files changed

+110
-267
lines changed

12 files changed

+110
-267
lines changed

src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/CompositionAopProxyTypeBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public override Type BuildProxyType()
114114
}
115115

116116
Type proxyType;
117-
proxyType = typeBuilder.CreateType();
117+
proxyType = typeBuilder.CreateTypeInfo();
118118

119119
// set target method references
120120
foreach (DictionaryEntry entry in targetMethods)

src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/DecoratorAopProxyTypeBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public override Type BuildProxyType()
149149
ImplementIAopProxy(typeBuilder);
150150

151151
Type proxyType;
152-
proxyType = typeBuilder.CreateType();
152+
proxyType = typeBuilder.CreateTypeInfo();
153153

154154
// set target method references
155155
foreach (DictionaryEntry entry in targetMethods)

src/Spring/Spring.Aop/Aop/Framework/DynamicProxy/InheritanceAopProxyTypeBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public override Type BuildProxyType()
168168
ImplementIAopProxy(typeBuilder);
169169

170170
Type proxyType;
171-
proxyType = typeBuilder.CreateType();
171+
proxyType = typeBuilder.CreateTypeInfo();
172172

173173
// set target method references
174174
foreach (DictionaryEntry entry in targetMethods)

src/Spring/Spring.Aop/Aop/IThrowsAdvice.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ namespace Spring.Aop
4444
/// examples would include the ubiquitous logging of any such exceptions,
4545
/// monitoring the number and type of exceptions and sending emails to
4646
/// a support desk once certain criteria have been met, wrapping generic
47-
/// exceptions such as <see cref="System.Data.SqlClient.SqlException"/> in
47+
/// exceptions such as System.Data.SqlClient.SqlException in
4848
/// exceptions that are more meaningful to your business logic, etc.
4949
/// </p>
5050
/// </remarks>

src/Spring/Spring.Core/ContextClassDiagram.cd

-153
This file was deleted.

src/Spring/Spring.Core/Expressions/OpLike.cs

+99-15
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@
2020

2121
using System;
2222
using System.Runtime.Serialization;
23-
#if !MONO_2_0
24-
using Microsoft.VisualBasic;
25-
using Microsoft.VisualBasic.CompilerServices;
26-
#endif
23+
using System.Text;
24+
using System.Text.RegularExpressions;
2725

2826
namespace Spring.Expressions
2927
{
@@ -37,7 +35,7 @@ public class OpLike : BinaryOperator
3735
/// <summary>
3836
/// Create a new instance
3937
/// </summary>
40-
public OpLike():base()
38+
public OpLike()
4139
{
4240
}
4341

@@ -48,7 +46,7 @@ protected OpLike(SerializationInfo info, StreamingContext context)
4846
: base(info, context)
4947
{
5048
}
51-
49+
5250
/// <summary>
5351
/// Returns a value for the logical LIKE operator node.
5452
/// </summary>
@@ -59,14 +57,100 @@ protected OpLike(SerializationInfo info, StreamingContext context)
5957
/// </returns>
6058
protected override object Get(object context, EvaluationContext evalContext)
6159
{
62-
#if !MONO_2_0
63-
string text = GetLeftValue( context, evalContext ) as string;
64-
string pattern = GetRightValue( context, evalContext ) as string;
65-
66-
return LikeOperator.LikeString(text, pattern, CompareMethod.Text);
67-
#else
68-
throw new NotSupportedException("'like' operator is only supported in .NET 2.0 or higher.");
69-
#endif
60+
string text = GetLeftValue(context, evalContext) as string;
61+
string pattern = GetRightValue(context, evalContext) as string;
62+
63+
return LikeString(text, pattern);
64+
}
65+
66+
private static bool LikeString(string Source, string Pattern)
67+
{
68+
if (string.IsNullOrEmpty(Source) && string.IsNullOrEmpty(Pattern))
69+
{
70+
return true;
71+
// LAMESPEC : MSDN states "if either string or pattern is an empty string, the result is False."
72+
// but "" Like "[]" returns True
73+
}
74+
75+
if ((string.IsNullOrEmpty(Source) || string.IsNullOrEmpty(Pattern)) && string.Compare(Pattern, "[]") != 0)
76+
{
77+
return false;
78+
}
79+
80+
RegexOptions options = RegexOptions.Singleline | RegexOptions.CultureInvariant | RegexOptions.IgnoreCase;
81+
82+
string regexString = ConvertLikeExpression(Pattern);
83+
Regex regexpr = new Regex(regexString, options);
84+
85+
//Console.WriteLine("{0} --> {1}", Pattern, regexString)
86+
87+
return regexpr.IsMatch(Source);
88+
}
89+
90+
private static string ConvertLikeExpression(string expression)
91+
{
92+
StringBuilder sb = new StringBuilder();
93+
94+
sb.Append("^");
95+
96+
for (int pos = 0; pos <= expression.Length - 1; pos++)
97+
{
98+
switch (expression[pos])
99+
{
100+
case '?':
101+
sb.Append('.');
102+
break;
103+
case '*':
104+
sb.Append('.').Append('*');
105+
break;
106+
case '#':
107+
sb.Append("\\d{1}");
108+
break;
109+
case '[':
110+
StringBuilder gsb = ConvertGroupSubexpression(expression, ref pos);
111+
// skip groups of form [], i.e. empty strings
112+
if (gsb.Length > 2)
113+
{
114+
sb.Append(gsb);
115+
}
116+
break;
117+
default:
118+
sb.Append(Regex.Escape(expression[pos].ToString()));
119+
break;
120+
}
121+
}
122+
123+
sb.Append("$");
124+
125+
return sb.ToString();
126+
}
127+
128+
private static StringBuilder ConvertGroupSubexpression(string carr, ref int pos)
129+
{
130+
StringBuilder sb = new StringBuilder();
131+
bool negate = false;
132+
133+
while (carr[pos] != ']')
134+
{
135+
if (negate)
136+
{
137+
sb.Append('^');
138+
negate = false;
139+
}
140+
if (carr[pos] == '!')
141+
{
142+
sb.Remove(1, sb.Length - 1);
143+
negate = true;
144+
}
145+
else
146+
{
147+
sb.Append(carr[pos]);
148+
}
149+
pos = pos + 1;
150+
}
151+
sb.Append(']');
152+
153+
return sb;
70154
}
71155
}
72-
}
156+
}

src/Spring/Spring.Core/Objects/Factory/Support/MethodInjectingInstantiationStrategy.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ public Type BuildType()
293293
DefineConstructors(typeBuilder);
294294
DefineProperties(typeBuilder);
295295
DefineMethods(typeBuilder);
296-
return typeBuilder.CreateType();
296+
return typeBuilder.CreateTypeInfo();
297297
}
298298

299299
private Type BaseType

0 commit comments

Comments
 (0)