]> O.S.I.I.S - jp/crow.git/commitdiff
ordinal string tests, debug log loading times, dataSourceType property
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 14 Dec 2018 19:03:50 +0000 (20:03 +0100)
committerJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Fri, 14 Dec 2018 19:03:50 +0000 (20:03 +0100)
18 files changed:
.gitignore
Crow/Crow.csproj
Crow/src/Colors.cs
Crow/src/CompilerServices/CompilerServices.cs
Crow/src/Fill/Fill.cs
Crow/src/GraphicObjects/GraphicObject.cs
Crow/src/GraphicObjects/TemplatedGroup.cs
Crow/src/IML/BindingDefinition.cs
Crow/src/IML/BindingMember.cs
Crow/src/IML/IMLContext.cs
Crow/src/IML/NodeAddress.cs
Crow/src/Instantiator.cs
Crow/src/Interface.cs
Crow/src/ItemTemplate.cs
Crow/src/Size.cs
CrowIDE/src/Editors/Parsers/CSharpParser.cs
CrowIDE/src/Project.cs
Tests/keysyms.cs

index b43159a219433a9eb7e89c3be041da59cf2a0cbc..e3dbba2de4a89ce2a566687f5f45d16663d152eb 100644 (file)
@@ -1,3 +1,4 @@
+*.log
 build
 Win_x86
 Crow.userprefs
index dfdc08f742ece086f330603953802bff8bbf407b..186019f84ac25db57249f200925b5bc651c398b0 100644 (file)
@@ -32,7 +32,7 @@
     <CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
     <Optimize>false</Optimize>
     <OutputPath>$(SolutionDir)build\Debug</OutputPath>
-    <DefineConstants>DEBUG_BINDING_FUNC_CALLS0;DEBUG_DRAGNDROP0;DEBUG_LOG0;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;TRACE0;DEBUG;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
+    <DefineConstants>TRACE0;DEBUG;DEBUG_BINDING_FUNC_CALLS0;DEBUG_DRAGNDROP0;DEBUG_LOG0;XLIB_BACKEND0;DESIGN_MODE;DEBUG_UPDATE0;DEBUG_FOCUS0;DEBUG_DISPOSE0;MEASURE_TIME;DEBUG_LOAD0;DEBUG_BINDING0;DEBUG_CLIP_RECTANGLE0</DefineConstants>
     <EnvironmentVariables>
       <EnvironmentVariables>
         <Variable name="MONO_CAIRO_DEBUG_DISPOSE" value="1" />
index 1da991357871f300c4bc072210a1e6f3b89c0ce3..8b91807413a4c4c8f9908b4def63c2c0b0e003c5 100644 (file)
@@ -41,8 +41,6 @@ namespace Crow
        /// </summary>
        public struct Color
     {
-               internal static Type TColor = typeof(Color);
-
                #region CTOR
                public Color(double _R, double _G, double _B, double _A)
                {
@@ -104,7 +102,7 @@ namespace Crow
                        if (string.IsNullOrEmpty(s))
                                return White;
                        Color cc = default(Color);
-                       if (s.StartsWith ("#")) {
+                       if (s.StartsWith ("#", StringComparison.Ordinal)) {
                                cc.R = int.Parse (s.Substring (1, 2), System.Globalization.NumberStyles.HexNumber) / 255.0;
                                cc.G = int.Parse (s.Substring (3, 2), System.Globalization.NumberStyles.HexNumber) / 255.0;
                                cc.B = int.Parse (s.Substring (5, 2), System.Globalization.NumberStyles.HexNumber) / 255.0;
@@ -151,13 +149,13 @@ namespace Crow
                }
                public static bool operator ==(Color c, string n)
                {
-                       return n.StartsWith("#") ?
+                       return n.StartsWith("#", StringComparison.Ordinal) ?
                                string.Equals(c.HtmlCode, n, StringComparison.Ordinal) :
                                string.Equals(c.Name, n, StringComparison.Ordinal);
                }
                public static bool operator !=(Color c, string n)
                {
-                       return n.StartsWith("#") ?
+                       return n.StartsWith("#", StringComparison.Ordinal) ?
                                !string.Equals(c.HtmlCode, n, StringComparison.Ordinal) :
                                !string.Equals(c.Name, n, StringComparison.Ordinal);
                }
@@ -429,7 +427,7 @@ namespace Crow
                }
                public override bool Equals (object obj)
                {
-                       return (obj == null || obj.GetType() != TColor) ?
+                       return (obj == null || obj.GetType() != typeof(Color)) ?
                                false :
                                this == (Color)obj;
                }
index 14d9bb7693405a09d0e8725927fe4136a025469b..ee6770a8001b378647db3a2398ad769bb487a3aa 100644 (file)
@@ -50,7 +50,6 @@ namespace Crow.IML
                /// </summary>
                internal static Dictionary<string, MethodInfo> knownExtMethods = new Dictionary<string, MethodInfo> ();
 
-               internal static Type TObject = typeof(object);
                internal static MethodInfo stringEquals = typeof (string).GetMethod("Equals", new Type [3] { typeof (string), typeof (string), typeof (StringComparison) });
                internal static MethodInfo miObjToString = typeof(object).GetMethod("ToString");
                internal static MethodInfo miGetType = typeof(object).GetMethod("GetType");
@@ -289,7 +288,7 @@ namespace Crow.IML
                static MemberInfo getMemberInfoWithReflexion(object instance, string member){
             Type t = instance.GetType();
 #if DEBUG_BINDING_FUNC_CALLS
-            Console.WriteLine ($"getMemberInfoWithReflexion ({instance},{member}); type:{t}");
+                       Console.WriteLine ($"getMemberInfoWithReflexion ({instance},{member}); type:{t}");
 #endif
             MemberInfo mi = t.GetMember (member)?.FirstOrDefault();
                        if (mi == null)
@@ -330,7 +329,7 @@ namespace Crow.IML
 
                        try {
                                if (value != null) {
-                                       if (destType == TObject)//TODO: check that test of destType is not causing problems
+                                       if (destType == typeof (object))//TODO: check that test of destType is not causing problems
                                                convertedVal = value;
                                        else {
                                                origType = value.GetType ();
@@ -387,7 +386,7 @@ namespace Crow.IML
 
                                if (tmp != null)
                                        return tmp;
-                               if (dstType == typeof(string) || dstType == CompilerServices.TObject)//TODO:object should be allowed to return null and not ""
+                               if (dstType == typeof(string) || dstType == typeof (object))//TODO:object should be allowed to return null and not ""
                                        return "";
                                if (dstType.IsValueType)
                                        return Activator.CreateInstance (dstType);                              
@@ -551,7 +550,7 @@ namespace Crow.IML
                /// Emit MSIL for conversion from orig type to dest type
                /// </summary>
                internal static void emitConvert(ILGenerator il, Type origType, Type destType){
-                       if (destType == CompilerServices.TObject)
+                       if (destType == typeof(object))
                                return;
                        if (destType == typeof(string)) {
                                System.Reflection.Emit.Label emitNullStr = il.DefineLabel ();
@@ -600,7 +599,7 @@ namespace Crow.IML
                                else {
                                        //implicit conversion can't be defined from or to object base class,
                                        //so we will check if object underlying type is one of the implicit converter of destType
-                                       if (origType == TObject) {//test all implicit converter to destType on obj
+                                       if (origType == typeof(object)) {//test all implicit converter to destType on obj
                                                System.Reflection.Emit.Label emitTestNextImpOp;
                                                System.Reflection.Emit.Label emitImpOpFound = il.DefineLabel ();
                                                foreach (MethodInfo mi in destType.GetMethods(BindingFlags.Public|BindingFlags.Static)) {
@@ -691,11 +690,11 @@ namespace Crow.IML
                                il.MarkLabel (convert);
                                il.Emit (OpCodes.Ldnull);//null instance for invoke
                                il.Emit (OpCodes.Ldc_I4_1);
-                               il.Emit(OpCodes.Newarr, CompilerServices.TObject);
+                               il.Emit(OpCodes.Newarr, typeof (object));
                                il.Emit (OpCodes.Dup);//duplicate the array ref
                                il.Emit (OpCodes.Ldc_I4_0);//push the index 0
                                il.Emit (OpCodes.Ldloc_0);//push the orig value to convert
-                               il.Emit (OpCodes.Stelem, CompilerServices.TObject);//set the array element at index 0
+                               il.Emit (OpCodes.Stelem, typeof (object));//set the array element at index 0
                                il.Emit (OpCodes.Callvirt, miMIInvoke);
                        }
 
@@ -777,7 +776,7 @@ namespace Crow.IML
                        Type handlerArgsType = evtParams [1].ParameterType;
 #endregion
 
-                       Type [] args = { CompilerServices.TObject, handlerArgsType };
+                       Type [] args = { typeof (object), handlerArgsType };
                        DynamicMethod dm = new DynamicMethod ("dyn_eventHandler",
                                typeof(void),
                                args, true);
index d98e47cfe4a0a00e2065d1c133ebf1ba5c1f11b8..0c0bdf5b671be0a26c257ffbd09c53db9f5a57b9 100644 (file)
@@ -44,16 +44,16 @@ namespace Crow
                public static object Parse (string s){
                        if (string.IsNullOrEmpty (s))
                                return null;
-                       if (s.Substring (1).StartsWith ("gradient"))
+                       if (s.Substring (1).StartsWith ("gradient", StringComparison.Ordinal))
                                return (Gradient)Gradient.Parse (s);
                        if (s.EndsWith (".svg", true, System.Globalization.CultureInfo.InvariantCulture))
-                               return SvgPicture.Parse (s);
+                               return Parse (s);
                        if (s.EndsWith (".png", true, System.Globalization.CultureInfo.InvariantCulture) ||
                            s.EndsWith (".jpg", true, System.Globalization.CultureInfo.InvariantCulture) ||
                            s.EndsWith (".jpeg", true, System.Globalization.CultureInfo.InvariantCulture) ||
                            s.EndsWith (".bmp", true, System.Globalization.CultureInfo.InvariantCulture) ||
                            s.EndsWith (".gif", true, System.Globalization.CultureInfo.InvariantCulture))
-                               return BmpPicture.Parse (s);
+                               return Parse (s);
                        
                        return (SolidColor)SolidColor.Parse (s);
                }
index b43ae54a9a4e647095d01c290f9cd305936cc90e..aa200802165ff9bc5522414c6dcec9f40725de68 100644 (file)
@@ -297,6 +297,7 @@ namespace Crow
                Size minimumSize = "0,0";
                bool cacheEnabled = false;
                bool clipToClientRect = true;
+               Type dataSourceType;
                protected object dataSource;
                bool rootDataLevel;
                string style;
@@ -929,15 +930,26 @@ namespace Crow
 
                                maximumSize = value;
 
-                               NotifyValueChanged ("MaximumSize", maximumSize);
+                               NotifyValueChanged (nameof(MaximumSize), maximumSize);
                                RegisterForLayouting (LayoutingType.Sizing);
                        }
                }
                /// <summary>
+               /// Fully qualify type name of expected data source.
+               /// If set, datasource bindings will be speedup by avoiding reflexion in generated dyn methods.
+               /// If an object of a different type is set as datasource, bindings will be canceled.
+               /// It accepts all derived type.
+               /// </summary>
+               [DesignCategory ("Data")]
+               public Type DataSourceType {
+                       get { return dataSourceType; }
+                       set { dataSourceType = value; }
+               }
+               /// <summary>
                /// Seek first logical tree upward if logicalParent is set, or seek graphic tree for
                /// a not null dataSource that will be active for all descendants having dataSource=null
                /// </summary>
-               [DesignCategory ("Data")]
+                       [DesignCategory ("Data")]
                public virtual object DataSource {
                        set {
                                if (DataSource == value)
@@ -1097,19 +1109,14 @@ namespace Crow
                        //all other instance of this type would not longer use reflexion to init properly
                        //but will fetch the  dynamic initialisation method compiled for this precise type
                        //TODO:measure speed gain.
-                       #region Delfault values Loading dynamic compilation
+#region Delfault values Loading dynamic compilation
                        DynamicMethod dm = null;
                        ILGenerator il = null;
 
-            /*dm = new DynamicMethod("dyn_loadDefValues",
-                               MethodAttributes.Family | MethodAttributes.FamANDAssem | MethodAttributes.NewSlot,
-                               CallingConventions.Standard,
-                               typeof(void),new Type[] {CompilerServices.TObject}, thisType, true);*/
-
-            dm = new DynamicMethod("dyn_loadDefValues", null, new Type[] {CompilerServices.TObject}, thisType, true);
+                       dm = new DynamicMethod("dyn_loadDefValues", null, new Type[] { typeof (object) }, thisType, true);
 
             il = dm.GetILGenerator(256);
-                       il.DeclareLocal(CompilerServices.TObject);
+                       il.DeclareLocal(typeof (object));//store root
                        il.Emit(OpCodes.Nop);
                        //set local GraphicObject to root object passed as 1st argument
                        il.Emit (OpCodes.Ldarg_0);
@@ -1122,7 +1129,7 @@ namespace Crow
                                //TODO:dynEventHandler could be cached somewhere, maybe a style instanciator class holding the styling delegate and bound to it.
                                foreach (string exp in CompilerServices.splitOnSemiColumnOutsideAccolades(expression)) {
                                        string trimed = exp.Trim();
-                                       if (trimed.StartsWith ("{", StringComparison.OrdinalIgnoreCase)){
+                                       if (trimed.StartsWith ("{", StringComparison.Ordinal)){
                                                il.Emit (OpCodes.Ldloc_0);//load this as 1st arg of event Add
 
                                                //push eventInfo as 1st arg of compile
@@ -1225,7 +1232,7 @@ namespace Crow
                        }
                        return false;
                }
-               #endregion
+#endregion
 
                public virtual GraphicObject FindByName(string nameToFind){
                        return string.Equals(nameToFind, name, StringComparison.Ordinal) ? this : null;
index 29056a5086a0902f4fcd55841c51ed7251f4c6d6..b8a7c084b1c4e6b55028bf81cb5d84c975ca2e55 100644 (file)
@@ -35,6 +35,7 @@ using System.Threading;
 using System.Linq;
 using Crow.IML;
 using System.Diagnostics;
+using System.IO;
 
 namespace Crow
 {
@@ -365,8 +366,7 @@ namespace Crow
                void loadPage(IList _data, Group page, string _dataTest)
                {
                        #if DEBUG_LOAD
-                       Stopwatch loadingTime = new Stopwatch ();
-                       loadingTime.Start ();
+                       Stopwatch loadingTime = Stopwatch.StartNew ();
                        #endif
 
 
@@ -404,12 +404,12 @@ namespace Crow
 //                     lock (CurrentInterface.LayoutMutex)
 //                             items.AddChild (page);
 
-                       #if DEBUG_LOAD
+#if DEBUG_LOAD
                        loadingTime.Stop ();
-                       Debug.WriteLine("Listbox {2} Loading: {0} ticks \t, {1} ms",
-                       loadingTime.ElapsedTicks,
-                       loadingTime.ElapsedMilliseconds, this.ToString());
-                       #endif
+                       using (StreamWriter sw = new StreamWriter ("loading.log", true)) {
+                               sw.WriteLine ($"NEW ;{this.ToString(),-50};{loadingTime.ElapsedTicks,8};{loadingTime.ElapsedMilliseconds,8}");
+                       }
+#endif
                }
 
                protected void loadItem(object o, Group page, string _dataTest){
index 075b80b32191a4360f4556aefe1044b4fa685ec7..9cbaf62bbaf5c10279a77426b1cf1453cc3349cc 100644 (file)
@@ -33,12 +33,13 @@ namespace Crow.IML
        /// </summary>
        public class BindingDefinition
        {
-               public NodeAddress SourceNA = null;
-               public string SourceMember = "";
-               public NodeAddress TargetNA = null;
+               public NodeAddress SourceNA = null;//the widget declaring this binding in a member
+               public string SourceMember = "";//the member where the binding string has been found
+               public NodeAddress TargetNA = null;//
                public string TargetMember = "";
                public string TargetName = "";
-               public bool TwoWay = false;
+               public bool TwoWay = false;//two way binding
+               public Type targetType = null;//added to store dataSourceType if set
 
                #region CTOR
                public BindingDefinition (NodeAddress _sourceNA, string _sourceMember){
index 47cba5fc8197ba3dade4ae546d21ebb4899117e1..f6cc047df0ec45edc21b0ba3403b4cc28ce2677b 100644 (file)
@@ -89,8 +89,8 @@ namespace Crow.IML
 
                        int ptr = 0;
                        if (splitedExp.Length == 1) {
-                               if (splitedExp [0].StartsWith ("\'")) {
-                                       if (!splitedExp [0].EndsWith ("\'"))
+                               if (splitedExp [0].StartsWith ("\'",StringComparison.Ordinal)) {
+                                       if (!splitedExp [0].EndsWith ("\'", StringComparison.Ordinal))
                                                throw new Exception (string.Format
                                                        ("IML:malformed string constant in binding expression: {0}", splitedExp [0]));
                                        Tokens = new string[] { splitedExp [0].Substring (1, splitedExp [0].Length - 2) };
index 6042e6daec3ae5f7185c8cc8d58e7b790f4bb2ae..8e12c41bfbdb45619c11c91b3e7a214ea9d152eb 100644 (file)
@@ -64,7 +64,7 @@ namespace Crow.IML
                {
                        RootType = rootType;
                        dm = new DynamicMethod ("dyn_instantiator",
-                               CompilerServices.TObject, new Type [] { typeof (Instantiator), typeof (Interface) }, true);
+                               typeof (object), new Type [] { typeof (Instantiator), typeof (Interface) }, true);
                        il = dm.GetILGenerator (256);
 
                        il.DeclareLocal (typeof (GraphicObject));
@@ -112,6 +112,10 @@ namespace Crow.IML
                        if (bindDef.TwoWay)
                                StorePropertyBinding (bindDef.SourceNA, bindDef.SourceMember, bindDef.TargetNA, bindDef.TargetMember);
                }
+               /// <summary>
+               /// Stores all the names found in current iml for binding resolution if any of them
+               /// are targeting named widget 
+               /// </summary>
                public void StoreCurrentName(string name){
                        if (!Names.ContainsKey(name))
                                Names[name] = new List<NodeAddress>();
index 450a9d2d454b60f1fdb37d0874df6484ea9e41c9..55ef21b0eb357113e7a970dbe6cc1cc0ef6f3668 100644 (file)
@@ -86,7 +86,7 @@ namespace Crow.IML
                        if (string.IsNullOrEmpty (expression)) {
                                return bindingDef;
                        } else {
-                               if (expression.StartsWith ("²")) {
+                               if (expression.StartsWith ("²", StringComparison.Ordinal)) {
                                        bindingDef.TwoWay = true;
                                        expression = expression.Substring (1);
                                }
index 09479f056a7fdb469b98c4dbafb8508489b7a1fe..14218bfc6f85cee1cadfc60219e49ff07af93055 100644 (file)
@@ -101,8 +101,7 @@ namespace Crow.IML
                        iface = _iface;
                        sourcePath = srcPath;
                        #if DEBUG_LOAD
-                       Stopwatch loadingTime = new Stopwatch ();
-                       loadingTime.Start ();
+                       Stopwatch loadingTime = Stopwatch.StartNew ();
                        #endif
                        try {
                                using (XmlReader itr = XmlReader.Create (stream)) {
@@ -114,8 +113,9 @@ namespace Crow.IML
                        } finally {
                                #if DEBUG_LOAD
                                loadingTime.Stop ();
-                               Debug.WriteLine ("IML Instantiator creation '{2}' : {0} ticks, {1} ms",
-                               loadingTime.ElapsedTicks, loadingTime.ElapsedMilliseconds, sourcePath);
+                               using (StreamWriter sw = new StreamWriter ("loading.log", true)) {
+                                       sw.WriteLine ($"ITOR;{sourcePath,-50};{loadingTime.ElapsedTicks,8};{loadingTime.ElapsedMilliseconds,8}");
+                               }
                                #endif
                        }
                }
@@ -155,21 +155,38 @@ namespace Crow.IML
 
                /// <summary>
                /// Creates a new instance of the GraphicObject compiled in the instantiator
-               /// and bind it the an interface
                /// </summary>
                /// <returns>The new graphic object instance</returns>
-               /// <param name="iface">The interface to bind to</param>
                public GraphicObject CreateInstance(){
+#if DEBUG_LOAD
+                       Stopwatch loadingTime = Stopwatch.StartNew ();
+                       GraphicObject o = loader (iface) as GraphicObject;
+                       loadingTime.Stop ();
+                       using (StreamWriter sw = new StreamWriter ("loading.log", true)) {
+                               sw.WriteLine ($"NEW ;{sourcePath,-50};{loadingTime.ElapsedTicks,8};{loadingTime.ElapsedMilliseconds,8}");
+                       }
+                       return o;
+#else
                        return loader (iface) as GraphicObject;
+#endif
                }
                /// <summary>
                /// Creates a new instance of T compiled in the instantiator
                /// and bind it the an interface
                /// </summary>
                /// <returns>The new T instance</returns>
-               /// <param name="iface">The interface to bind to</param>
                public T CreateInstance<T>(){
+#if DEBUG_LOAD
+                       Stopwatch loadingTime = Stopwatch.StartNew ();
+                       T i = (T)loader (iface);
+                       loadingTime.Stop ();
+                       using (StreamWriter sw = new StreamWriter ("loading.log", true)) {
+                               sw.WriteLine ($"NEW ;{sourcePath,-50};{loadingTime.ElapsedTicks,8};{loadingTime.ElapsedMilliseconds,8}");
+                       }
+                       return i;
+#else
                        return (T)loader (iface);
+#endif
                }
                List<DynamicMethod> dsValueChangedDynMeths = new List<DynamicMethod>();
                List<Delegate> cachedDelegates = new List<Delegate>();
@@ -428,8 +445,7 @@ namespace Crow.IML
                                        ctx.il.Emit (OpCodes.Ldstr, sourcePath);
                                        ctx.il.Emit (OpCodes.Stfld, typeof(GraphicObject).GetField("design_imlPath"));
                                }
-                               #endif
-
+#endif
                                #region Styling and default values loading
                                //first check for Style attribute then trigger default value loading
                                if (reader.HasAttributes) {
@@ -464,7 +480,7 @@ namespace Crow.IML
                                                if (mi.MemberType == MemberTypes.Event) {
                                                        foreach (string exp in CompilerServices.splitOnSemiColumnOutsideAccolades(reader.Value)) {
                                                                string trimed = exp.Trim();
-                                                               if (trimed.StartsWith ("{", StringComparison.OrdinalIgnoreCase))
+                                                               if (trimed.StartsWith ("{", StringComparison.Ordinal))
                                                                        compileAndStoreDynHandler (ctx, mi as EventInfo, trimed.Substring (1, trimed.Length - 2));
                                                                else
                                                                        emitHandlerBinding (ctx, mi as EventInfo, trimed);
@@ -479,7 +495,7 @@ namespace Crow.IML
                                                if (pi.Name == "Name")
                                                        ctx.StoreCurrentName (reader.Value);
 
-                                               if (reader.Value.StartsWith ("{", StringComparison.OrdinalIgnoreCase))
+                                               if (reader.Value.StartsWith ("{", StringComparison.Ordinal))
                                                        readPropertyBinding (ctx, reader.Name, reader.Value.Substring (1, reader.Value.Length - 2));
                                                else
                                                        CompilerServices.EmitSetValue (ctx.il, pi, reader.Value);
@@ -548,7 +564,12 @@ namespace Crow.IML
                        }
                }
                #endregion
-
+               /// <summary>
+               /// Reads binding expression found as attribute value in iml
+               /// </summary>
+               /// <param name="ctx">IML Context</param>
+               /// <param name="sourceMember">IML Attribute name</param>
+               /// <param name="expression">Binding Expression with accollades trimed</param>
                void readPropertyBinding (IMLContext ctx, string sourceMember, string expression)
                {
                        NodeAddress sourceNA = ctx.CurrentNodeAddress;
@@ -707,7 +728,7 @@ namespace Crow.IML
 
                        System.Reflection.Emit.Label endMethod = il.DefineLabel ();
 
-                       il.DeclareLocal (CompilerServices.TObject);
+                       il.DeclareLocal (typeof(object));
 
                        il.Emit (OpCodes.Nop);
 
@@ -814,8 +835,8 @@ namespace Crow.IML
 
                        System.Reflection.Emit.Label endMethod = il.DefineLabel ();
 
-                       il.DeclareLocal (CompilerServices.TObject);
-                       ilPC.DeclareLocal (CompilerServices.TObject);//used for checking propery less bindings
+                       il.DeclareLocal (typeof(object));
+                       ilPC.DeclareLocal (typeof(object));//used for checking propery less bindings
                        ilPC.DeclareLocal (typeof(MemberInfo));//used for checking propery less bindings
 
                        System.Reflection.Emit.Label cancel = ilPC.DefineLabel ();
@@ -970,7 +991,7 @@ namespace Crow.IML
 
                                System.Reflection.Emit.Label endMethod = il.DefineLabel ();
 
-                               il.DeclareLocal (CompilerServices.TObject);
+                               il.DeclareLocal (typeof(object));
 
                                il.Emit (OpCodes.Nop);
 
@@ -993,7 +1014,6 @@ namespace Crow.IML
                                //by default, source value type is deducted from target member type to allow
                                //memberless binding, if targetMember exists, it will be used to determine target
                                //value type for conversion
-
                                CompilerServices.emitConvert (il, piSource.PropertyType);
 
                                if (!piSource.CanWrite)
@@ -1022,7 +1042,7 @@ namespace Crow.IML
 
                        il = dm.GetILGenerator (256);
 
-                       il.DeclareLocal (CompilerServices.TObject);//used for checking propery less bindings
+                       il.DeclareLocal (typeof(object));//used for checking propery less bindings
                        il.DeclareLocal (typeof(MemberInfo));//used for checking propery less bindings
                        System.Reflection.Emit.Label cancel = il.DefineLabel ();
                        System.Reflection.Emit.Label newDSIsNull = il.DefineLabel ();
@@ -1148,7 +1168,7 @@ namespace Crow.IML
 
                        System.Reflection.Emit.Label endMethod = il.DefineLabel ();
 
-                       il.DeclareLocal (CompilerServices.TObject);
+                       il.DeclareLocal (typeof(object));
                        il.Emit (OpCodes.Nop);
 
                        //load value changed member name onto the stack
index 621d5549dfadc5f8e1022e03077d80a9a56f3fe4..f47434026cd67f2304f1140dc11c647ea6d6a437 100644 (file)
@@ -462,12 +462,12 @@ namespace Crow
                {
                        Stream stream = null;
 
-                       if (path.StartsWith ("#")) {
+                       if (path.StartsWith ("#", StringComparison.Ordinal)) {
                                string resId = path.Substring (1);
                                //try/catch added to prevent nunit error
                                try {                                   
                                        stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId);
-                               } catch{}
+                               } catch {}
                                if (stream == null)//try to find ressource in Crow assembly
                                        stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId);
                                if (stream == null)
@@ -483,7 +483,7 @@ namespace Crow
                {
                        Stream stream = null;
 
-                       if (path.StartsWith ("#")) {
+                       if (path.StartsWith ("#", StringComparison.Ordinal)) {
                                string resId = path.Substring (1);
                                //try/catch added to prevent nunit error
                                try {
index e42c7540af666b1743006151776d5715f3e70bf0..a12823cc2e00f174265c5777caac0016833a409d 100644 (file)
@@ -151,7 +151,7 @@ namespace Crow
                        ParameterInfo [] evtParams = evtInvoke.GetParameters ();
                        Type handlerArgsType = evtParams [1].ParameterType;
 
-                       Type [] args = { CompilerServices.TObject, CompilerServices.TObject, handlerArgsType };
+                       Type [] args = { typeof(object), typeof(object), handlerArgsType };
 
                        #region Expand dyn meth
                        //DM is bound to templatedGroup root (arg0)
@@ -222,7 +222,7 @@ namespace Crow
                        #region Items counting dyn method
                        //dm is unbound, arg0 is instance of Item container to expand
                        dm = new DynamicMethod ("dyn_count_" + fetchMethodName,
-                               typeof (bool), new Type[] {CompilerServices.TObject}, true);
+                               typeof (bool), new Type[] {typeof(object)}, true);
                        il = dm.GetILGenerator (256);
 
                        //get the dataSource of the arg0
index 891c1fb5f231f4bc3f900015458a584a4485ede6..4d0bcb58bd65adfec4b77a6118d424404734820c 100644 (file)
@@ -33,7 +33,6 @@ namespace Crow
 {
     public struct Size
     {
-               internal static Type TSize = typeof(Size);
         public static Size Zero
         { get { return new Size(0, 0); } }
 
@@ -186,7 +185,7 @@ namespace Crow
                }
                public override bool Equals (object obj)
                {
-                       return (obj == null || obj.GetType() != TSize) ?
+                       return (obj == null || obj.GetType() != typeof(Size)) ?
                                false :
                                this == (Size)obj;
                }
index 11e7259839af95807f5fa27ed7209750f19c133a..23655aa67d607857164b9b3a30987833aa37ca5f 100644 (file)
@@ -358,9 +358,9 @@ namespace Crow.Coding
                                                closeNodeAndGoUp (ref currentNode, cl);
                                                break;
                                        case TokenType.Preprocessor:
-                                               if (cl.Tokens [tokPtr].Content.StartsWith ("#region")) {
+                                               if (cl.Tokens [tokPtr].Content.StartsWith ("#region", StringComparison.Ordinal)) {
                                                        currentNode = addChildNode (currentNode, cl, tokPtr, "region");
-                                               } else if (cl.Tokens [tokPtr].Content.StartsWith ("#endregion")) {
+                                               } else if (cl.Tokens [tokPtr].Content.StartsWith ("#endregion", StringComparison.Ordinal)) {
                                                        
                                                        closeNodeAndGoUp (ref currentNode, cl,"region");
                                                }
index 407f60b33c20148aeeaf018aea34d13889db4f0e..3b4063672fec39a2d6f35061739e7bba8d7b8bc8 100644 (file)
@@ -427,7 +427,7 @@ namespace Crow.Coding {
             return pi != null;
         }
         public bool TryGetProjectFileFromPath (string path, out ProjectFile pi) {
-            if (path.StartsWith ("#"))
+            if (path.StartsWith ("#", StringComparison.Ordinal))
                 pi = flattenNodes.OfType<ProjectFile> ().FirstOrDefault
                     (pp => pp.Type == ItemType.EmbeddedResource && pp.ResourceID == path.Substring (1));
             else
index e33add92dba56b2d4cf5d9ee9bfd2794155f22a2..412d06b169ae6a8f110ede11aea0fbab7ebd7589 100644 (file)
@@ -48,16 +48,16 @@ namespace Tests
                                        while (!r.EndOfStream) {
                                                string s = r.ReadLine ().Trim();
                                                if (skip) {
-                                                       if (s.EndsWith ("*/"))
+                                                       if (s.EndsWith ("*/", StringComparison.Ordinal))
                                                                skip = false;
                                                        continue;
                                                }
-                                               if (s.StartsWith ("/*")) {
-                                                       if (!s.EndsWith ("*/"))
+                                               if (s.StartsWith ("/*", StringComparison.Ordinal)) {
+                                                       if (!s.EndsWith ("*/", StringComparison.Ordinal))
                                                                skip = true;
                                                        continue;                                                       
                                                }
-                                               if (!s.StartsWith ("#define"))
+                                               if (!s.StartsWith ("#define", StringComparison.Ordinal))
                                                        continue;
                                                string[] tmp = s.Split (new char[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);