From e9970b7f7e385d3467c4ac932a653064a7749163 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Thu, 13 Dec 2018 18:31:05 +0100 Subject: [PATCH] some caching for reflexion, other debug --- Crow.NetStd.sln | 20 +-- Crow.sln | 26 ++-- Crow/Crow.csproj | 12 +- Crow/src/CompilerServices/CompilerServices.cs | 122 ++++++++++++++--- Crow/src/GraphicObjects/GraphicObject.cs | 5 +- Crow/src/GraphicObjects/TemplatedGroup.cs | 23 ++-- Crow/src/Instantiator.cs | 16 ++- Crow/src/Interface.cs | 26 +--- Crow/src/ItemTemplate.cs | 40 ++---- Crow/src/backends/xcb/XCBBackend.cs | 17 ++- Crow/src/{ => backends/xcb}/XCursor.cs | 0 Tests/Tests.NetStd.csproj | 5 +- Tests/Tests.csproj | 129 +++++++++++------- Tests/testClass.cs | 25 ++++ Tests/ui/TreeExpandable.template | 30 ++++ 15 files changed, 335 insertions(+), 161 deletions(-) rename Crow/src/{ => backends/xcb}/XCursor.cs (100%) create mode 100644 Tests/testClass.cs create mode 100644 Tests/ui/TreeExpandable.template diff --git a/Crow.NetStd.sln b/Crow.NetStd.sln index c12c637c..a62e1600 100644 --- a/Crow.NetStd.sln +++ b/Crow.NetStd.sln @@ -27,28 +27,12 @@ Global {75BDE4C7-4BAF-4A03-B697-5D1370775E20}.Release|Any CPU.ActiveCfg = Release|Any CPU {75BDE4C7-4BAF-4A03-B697-5D1370775E20}.Release|Any CPU.Build.0 = Release|Any CPU {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x64.ActiveCfg = Debug|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x64.Build.0 = Debug|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x86.ActiveCfg = Debug|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|x86.Build.0 = Debug|Any CPU {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Debug|Any CPU.Build.0 = Debug|Any CPU {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|Any CPU.Build.0 = Release|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x64.ActiveCfg = Release|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x64.Build.0 = Release|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x86.ActiveCfg = Release|Any CPU - {28BAF8B8-6A6E-40D5-8E9C-E7C1165C59DD}.Release|x86.Build.0 = Release|Any CPU {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x64.ActiveCfg = Debug|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x64.Build.0 = Debug|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x86.ActiveCfg = Debug|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|x86.Build.0 = Debug|Any CPU {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A01B3151-BC81-437C-B526-CC8DBB808638}.Debug|Any CPU.Build.0 = Debug|Any CPU {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|Any CPU.Build.0 = Release|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x64.ActiveCfg = Release|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x64.Build.0 = Release|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x86.ActiveCfg = Release|Any CPU - {A01B3151-BC81-437C-B526-CC8DBB808638}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Crow.sln b/Crow.sln index a992af34..68347c39 100644 --- a/Crow.sln +++ b/Crow.sln @@ -30,22 +30,30 @@ Global Policies = $0 $0.StandardHeader = $1 $1.Text = @\n${FileName}\n \nAuthor:\n ${AuthorName} <${AuthorEmail}>\n\nCopyright (c) 2013-2017 Jean-Philippe Bruyère\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the "Software"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE. - $1.IncludeInNewFiles = True $0.DotNetNamingPolicy = $2 - $2.DirectoryNamespaceAssociation = None - $2.ResourceNamePolicy = FileFormatDefault $0.TextStylePolicy = $3 - $3.FileWidth = 120 - $3.TabsToSpaces = False $3.EolMarker = Unix - $3.inheritsSet = VisualStudio - $3.inheritsScope = text/plain $3.scope = text/x-csharp $0.CSharpFormattingPolicy = $4 $4.AfterDelegateDeclarationParameterComma = True - $4.inheritsSet = Mono - $4.inheritsScope = text/x-csharp $4.scope = text/x-csharp + $4.IndentSwitchSection = False + $4.NewLinesForBracesInProperties = False + $4.NewLinesForBracesInAccessors = False + $4.NewLinesForBracesInAnonymousMethods = False + $4.NewLinesForBracesInControlBlocks = False + $4.NewLinesForBracesInAnonymousTypes = False + $4.NewLinesForBracesInObjectCollectionArrayInitializers = False + $4.NewLinesForBracesInLambdaExpressionBody = False + $4.NewLineForElse = False + $4.NewLineForCatch = False + $4.NewLineForFinally = False + $4.NewLineForMembersInObjectInit = False + $4.NewLineForMembersInAnonymousTypes = False + $4.NewLineForClausesInQuery = False + $4.SpacingAfterMethodDeclarationName = True + $4.SpaceAfterMethodCallName = True + $4.SpaceBeforeOpenSquareBracket = True $0.VersionControlPolicy = $5 $5.CommitMessageStyle = $6 $6.Indent = @\t diff --git a/Crow/Crow.csproj b/Crow/Crow.csproj index 656c9da9..ade2082c 100644 --- a/Crow/Crow.csproj +++ b/Crow/Crow.csproj @@ -62,7 +62,6 @@ --> - @@ -179,5 +178,16 @@ PreserveNewest + + + + + + + + + + + diff --git a/Crow/src/CompilerServices/CompilerServices.cs b/Crow/src/CompilerServices/CompilerServices.cs index 5112fb12..ceb09c1a 100644 --- a/Crow/src/CompilerServices/CompilerServices.cs +++ b/Crow/src/CompilerServices/CompilerServices.cs @@ -33,12 +33,23 @@ using System.Collections.Generic; using System.Runtime.CompilerServices; using System.Xml; using Crow.IML; - +using System.Text; namespace Crow.IML { public static class CompilerServices { + /// + /// known types cache, prevent rewalking all the assemblies of the domain + /// the key is the type simple name + /// + internal static Dictionary knownTypes = new Dictionary (); + /// + /// known extension methods. + /// key is type dot memberName. + /// + internal static Dictionary knownExtMethods = new Dictionary (); + 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"); @@ -405,20 +416,57 @@ namespace Crow.IML return query; } /// - /// search for extentions method in entry assembly then in crow assembly + /// search for extentions method in entry assembly then in assembly where the type is defined /// /// Extention MethodInfo /// Extended type /// Extention method name - internal static MethodInfo SearchExtMethod(Type t, string methodName){ + //internal static MethodInfo SearchExtMethod(Type t, string methodName){ + // MethodInfo mi = null; + // mi = GetExtensionMethods (Assembly.GetEntryAssembly(), t) + // .Where (em => em.Name == methodName).FirstOrDefault (); + // if (mi != null) + // return mi; + + // return GetExtensionMethods (t.Module.Assembly, t) + // .Where (em => em.Name == methodName).FirstOrDefault (); + //} + internal static MethodInfo SearchExtMethod (Type t, string methodName) + { + string key = t.Name + "." + methodName; + if (knownExtMethods.ContainsKey (key)) + return knownExtMethods [key]; + + //Console.WriteLine ($"*** search extension method: {t};{methodName} => key={key}"); + MethodInfo mi = null; - mi = GetExtensionMethods (Assembly.GetEntryAssembly(), t) - .Where (em => em.Name == methodName).FirstOrDefault (); - if (mi != null) - return mi; + mi = GetExtensionMethods2 (Assembly.GetEntryAssembly (), t, methodName); + if (mi == null) + mi = GetExtensionMethods2 (t.Module.Assembly, t, methodName); - return GetExtensionMethods (Assembly.GetExecutingAssembly(), t) - .Where (em => em.Name == methodName).FirstOrDefault (); + //add key even if mi is null to prevent searching again and again for propertyless bindings + knownExtMethods.Add (key, mi); + return mi; + } + + static MethodInfo GetExtensionMethods2 (Assembly assembly, Type extendedType, string methodName) + { + foreach (Type t in assembly.GetTypes ().Where + (ty => ty.IsDefined (typeof (ExtensionAttribute), false))) { + foreach (MethodInfo mi in t.GetMethods + (BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic).Where + (m=> m.Name == methodName && m.IsDefined (typeof (ExtensionAttribute), false) && + m.GetParameters ().Length == 1)) { + Type curType = extendedType; + while (curType != null) { + if (mi.GetParameters () [0].ParameterType == curType) + return mi; + curType = curType.BaseType; + } + } + + } + return null; } /// /// retrieve event handler in class or ancestors @@ -893,20 +941,32 @@ namespace Crow.IML /// /// the corresponding type object if found /// type name - internal static Type tryGetType (string strDataType){ + internal static Type getTypeFromName (string strDataType){ + if (knownTypes.ContainsKey (strDataType)) + return knownTypes [strDataType]; Type dataType = Type.GetType(strDataType); - if (dataType != null) + if (dataType != null) { + knownTypes.Add (strDataType, dataType); return dataType; - Assembly a = Assembly.GetEntryAssembly (); - foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == strDataType) - return dataType; } + foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) { + if (a.IsDynamic) + continue; + foreach (Type expT in a.GetExportedTypes ()) { + if (expT.Name != strDataType) + continue; + knownTypes.Add (strDataType, expT); + return expT; + } + } + knownTypes.Add (strDataType, null); return null; } + //get value from member of object internal static object getDataTypeAndFetch (object data, string fetchMethod){ Type dataType = data.GetType(); + //Console.WriteLine ($"get data type and fetch {data}.{fetchMethod}"); MethodInfo miGetDatas = dataType.GetMethod (fetchMethod, new Type[] {}); if (miGetDatas == null) miGetDatas = CompilerServices.SearchExtMethod (dataType, fetchMethod); @@ -923,8 +983,36 @@ namespace Crow.IML if (miGetDatas == null) throw new Exception ("Read only property for fetching data in ItemTemplate: " + fetchMethod); } - object tmp = miGetDatas.Invoke (data, null); - return tmp; + return miGetDatas.IsStatic ? + miGetDatas.Invoke (null, new object [] { data }) : miGetDatas.Invoke (data, null); + } + //TODO:memberinfo found here must be cached + internal static object getValue (Type dataType, object data, string member) + { + //Console.WriteLine ($"get value: {dataType} ; {data} ; {member}"); + + MethodInfo miGetDatas = dataType.GetMethod (member, new Type [] { }); + if (miGetDatas != null) + return miGetDatas.Invoke (data, null); + MemberInfo mbi = dataType.GetMember (member).FirstOrDefault (); + if (mbi == null) { + MethodInfo miExt = CompilerServices.SearchExtMethod (dataType, member); + if (miExt == null)//and among fields + throw new Exception ($"member {member} not found in {dataType}"); + return miExt.Invoke (null, new object [] { data }); + } + if (mbi.MemberType == MemberTypes.Property) { + miGetDatas = (mbi as PropertyInfo)?.GetGetMethod (); + if (miGetDatas == null) + throw new Exception ($"no getter found for property {member} in {dataType}"); + return miGetDatas.Invoke (data, null); + } + + FieldInfo fi = mbi as FieldInfo; + if (fi == null) + throw new Exception ($"member {member} not found in {dataType}"); + + return fi.GetValue (data); } } } diff --git a/Crow/src/GraphicObjects/GraphicObject.cs b/Crow/src/GraphicObjects/GraphicObject.cs index fb4f6393..b43ae54a 100644 --- a/Crow/src/GraphicObjects/GraphicObject.cs +++ b/Crow/src/GraphicObjects/GraphicObject.cs @@ -149,7 +149,10 @@ namespace Crow } } return di; - } + } + public string DesignName { + get { return GetType ().Name + design_id; } + } #endif #region IDisposable implementation diff --git a/Crow/src/GraphicObjects/TemplatedGroup.cs b/Crow/src/GraphicObjects/TemplatedGroup.cs index dd9afb6c..29056a50 100644 --- a/Crow/src/GraphicObjects/TemplatedGroup.cs +++ b/Crow/src/GraphicObjects/TemplatedGroup.cs @@ -411,13 +411,7 @@ namespace Crow loadingTime.ElapsedMilliseconds, this.ToString()); #endif } - string getItempKey(Type dataType, object o, string propertyName){ - try { - return dataType.GetProperty (propertyName).GetGetMethod ().Invoke (o, null)?.ToString(); - } catch { - return dataType.FullName; - } - } + protected void loadItem(object o, Group page, string _dataTest){ if (o == null)//TODO:surely a threading sync problem return; @@ -426,14 +420,23 @@ namespace Crow Type dataType = o.GetType (); string itempKey = dataType.FullName; - if (_dataTest != "TypeOf") - itempKey = getItempKey (dataType, o, _dataTest); + //if item template selection is not done depending on the type of item + //dataTest must contains a member name of the item + if (_dataTest != "TypeOf") { + try { + itempKey = CompilerServices.getValue (dataType, o, _dataTest)?.ToString (); + } catch { + itempKey = dataType.FullName; + } + } if (ItemTemplates.ContainsKey (itempKey)) iTemp = ItemTemplates [itempKey]; else { foreach (string it in ItemTemplates.Keys) { - Type t = CompilerServices.tryGetType (it); + if (it == "default") + continue; + Type t = CompilerServices.getTypeFromName (it); if (t == null) continue; if (t.IsAssignableFrom (dataType)) {//TODO:types could be cached diff --git a/Crow/src/Instantiator.cs b/Crow/src/Instantiator.cs index 4f9ee733..f42d1f13 100644 --- a/Crow/src/Instantiator.cs +++ b/Crow/src/Instantiator.cs @@ -68,6 +68,8 @@ namespace Crow.IML } #endregion + internal static Dictionary knownGOTypes = new Dictionary (); + public Type RootType; InstanciatorInvoker loader; protected Interface iface; @@ -1183,15 +1185,21 @@ namespace Crow.IML /// the corresponding type object /// graphic object type name without its namespace Type tryGetGOType (string typeName){ + if (knownGOTypes.ContainsKey (typeName)) + return knownGOTypes [typeName]; Type t = Type.GetType ("Crow." + typeName); - if (t != null) - return t; + if (t != null) { + knownGOTypes.Add (typeName, t); + return t; + } foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies()) { if (a.IsDynamic) continue; foreach (Type expT in a.GetExportedTypes ()) { - if (expT.Name == typeName) - return expT; + if (expT.Name != typeName) + continue; + knownGOTypes.Add (typeName, expT); + return expT; } } return null; diff --git a/Crow/src/Interface.cs b/Crow/src/Interface.cs index 1dfcfee2..f53a2769 100644 --- a/Crow/src/Interface.cs +++ b/Crow/src/Interface.cs @@ -24,10 +24,6 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN // THE SOFTWARE. -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; using System.Linq; using System.Reflection; using System.Threading; @@ -37,7 +33,10 @@ using Cairo; using System.Globalization; using Crow.IML; using System.Runtime.InteropServices; - +using System; +using System.IO; +using System.Diagnostics; +using System.Collections.Generic; namespace Crow @@ -412,18 +411,7 @@ namespace Crow } } - void loadCursors(){ - //Load cursors - XCursor.Cross = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.cross").Cursors[0]; - XCursor.Default = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.arrow").Cursors[0]; - XCursor.NW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_left_corner").Cursors[0]; - XCursor.NE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.top_right_corner").Cursors[0]; - XCursor.SW = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors[0]; - XCursor.SE = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors[0]; - XCursor.H = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors[0]; - XCursor.V = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors[0]; - XCursor.Text = XCursorFile.Load(this, "#Crow.Images.Icons.Cursors.ibeam").Cursors[0]; - } + #endregion #region Templates @@ -499,10 +487,10 @@ namespace Crow string resId = path.Substring (1); //try/catch added to prevent nunit error try { - stream = System.Reflection.Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); + stream = Assembly.GetEntryAssembly ().GetManifestResourceStream (resId); } catch{} if (stream == null)//try to find ressource in Crow assembly - stream = System.Reflection.Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId); + stream = Assembly.GetExecutingAssembly ().GetManifestResourceStream (resId); if (stream == null) throw new Exception("Resource not found: " + path); diff --git a/Crow/src/ItemTemplate.cs b/Crow/src/ItemTemplate.cs index 05d7c268..e42c7540 100644 --- a/Crow/src/ItemTemplate.cs +++ b/Crow/src/ItemTemplate.cs @@ -143,19 +143,10 @@ namespace Crow /// /// Host. public void CreateExpandDelegate (TemplatedGroup host){ - Type dataType = null; - //if (host.DataTest == "TypeOf"){ - dataType = CompilerServices.tryGetType(strDataType); -// if (dataType == null) { -// Debug.WriteLine ("ItemTemplate error: DataType not found: {0}.", strDataType); -// return; -// } -// } + Type dataType = CompilerServices.getTypeFromName(strDataType); Type tmpGrpType = typeof(TemplatedGroup); Type evtType = typeof(EventHandler); - //PropertyInfo piData = tmpGrpType.GetProperty ("Data"); - MethodInfo evtInvoke = evtType.GetMethod ("Invoke"); ParameterInfo [] evtParams = evtInvoke.GetParameters (); Type handlerArgsType = evtParams [1].ParameterType; @@ -195,28 +186,11 @@ namespace Crow il.Emit (OpCodes.Ldarg_1); il.Emit (OpCodes.Call, CompilerServices.miIsAlreadyExpanded); il.Emit (OpCodes.Brtrue, gotoEnd); -// il.Emit (OpCodes.Ldloc_0); -// il.Emit (OpCodes.Callvirt, piData.GetGetMethod ()); -// il.Emit (OpCodes.Brfalse, ifDataIsNull); -// il.Emit (OpCodes.Br, gotoEnd); - -// il.MarkLabel(ifDataIsNull); - - //copy the ref of ItemTemplates list TODO: maybe find another way to share it among the nodes? -// FieldInfo fiTemplates = tmpGrpType.GetField("ItemTemplates"); -// il.Emit (OpCodes.Ldloc_0); -// il.Emit (OpCodes.Ldarg_0); -// il.Emit (OpCodes.Ldfld, fiTemplates); -// il.Emit (OpCodes.Stfld, fiTemplates); - - //call 'fetchMethodName' from the dataSource to build the sub nodes list - //il.Emit (OpCodes.Ldarg_0);//load root templatedGroop + //get the dataSource of the sender il.Emit (OpCodes.Ldarg_0);//push root TemplatedGroup into the stack il.Emit (OpCodes.Ldarg_1);//load sender node of expand - il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataSource);//get the dataSource of the sender - - + il.Emit (OpCodes.Callvirt, CompilerServices.miGetDataSource); if (fetchMethodName != "self") {//special keyword self allows the use of recurent list<<< if (dataType == null) { @@ -292,9 +266,11 @@ namespace Crow if (miGetDatas == null) throw new Exception ("Write only property for fetching data in ItemTemplate: " + fetchMethodName); } - - il.Emit (OpCodes.Callvirt, miGetDatas); - } + if (miGetDatas.IsStatic) + il.Emit (OpCodes.Call, miGetDatas); + else + il.Emit (OpCodes.Callvirt, miGetDatas); + } diff --git a/Crow/src/backends/xcb/XCBBackend.cs b/Crow/src/backends/xcb/XCBBackend.cs index a3ccab91..b4199968 100644 --- a/Crow/src/backends/xcb/XCBBackend.cs +++ b/Crow/src/backends/xcb/XCBBackend.cs @@ -414,8 +414,9 @@ namespace Crow.XCB xcb_flush (conn); - IntPtr visual = findVisual (scr_it, scr.root_visual); + IntPtr visual = findVisual (scr_it, scr.root_visual); + //loadCursors (); iFace.surf = new Cairo.XcbSurface (conn, win, visual, iFace.ClientRectangle.Width, iFace.ClientRectangle.Height); } @@ -483,6 +484,20 @@ namespace Crow.XCB } #endregion + void loadCursors () + { + //Load cursors + XCursor.Cross = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.cross").Cursors [0]; + XCursor.Default = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.arrow").Cursors [0]; + XCursor.NW = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.top_left_corner").Cursors [0]; + XCursor.NE = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.top_right_corner").Cursors [0]; + XCursor.SW = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.bottom_left_corner").Cursors [0]; + XCursor.SE = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.bottom_right_corner").Cursors [0]; + XCursor.H = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.sb_h_double_arrow").Cursors [0]; + XCursor.V = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.sb_v_double_arrow").Cursors [0]; + XCursor.Text = XCursorFile.Load (iFace, "#Crow.Images.Icons.Cursors.ibeam").Cursors [0]; + } + static IntPtr findVisual (xcb_iterator_t scr_it, xcb_visualid_t visualId){ for (; scr_it.rem > 0; xcb_screen_next (ref scr_it)) { xcb_iterator_t depth_it = xcb_screen_allowed_depths_iterator (scr_it.data); diff --git a/Crow/src/XCursor.cs b/Crow/src/backends/xcb/XCursor.cs similarity index 100% rename from Crow/src/XCursor.cs rename to Crow/src/backends/xcb/XCursor.cs diff --git a/Tests/Tests.NetStd.csproj b/Tests/Tests.NetStd.csproj index 20239315..bb8a2036 100644 --- a/Tests/Tests.NetStd.csproj +++ b/Tests/Tests.NetStd.csproj @@ -17,7 +17,7 @@ portable - + @@ -36,4 +36,7 @@ + diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index 69437acc..5f1c35d0 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -8,16 +8,11 @@ Exe Tests Tests - tests.Showcase + tests.MainClass AnyCPU 0.8.0 $(SolutionDir)build/$(Configuration) $(SolutionDir)build/obj/$(Configuration) - - - - - v4.6.1 @@ -44,54 +39,87 @@ $(SolutionDir)build\obj\$(Configuration) $(SolutionDir)build\Release - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - - - Program - %24{TargetName} - %24{SolutionDir}\build\%24{ProjectConfigName} - false - + + + ..\packages\System.AppContext.4.3.0\lib\net46\System.AppContext.dll + + + + + ..\packages\System.Collections.Immutable.1.5.0\lib\netstandard2.0\System.Collections.Immutable.dll + + + ..\packages\System.Console.4.3.0\lib\net46\System.Console.dll + + + ..\packages\System.Diagnostics.FileVersionInfo.4.3.0\lib\net46\System.Diagnostics.FileVersionInfo.dll + + + ..\packages\System.Diagnostics.StackTrace.4.3.0\lib\net46\System.Diagnostics.StackTrace.dll + + + ..\packages\System.IO.Compression.4.3.0\lib\net46\System.IO.Compression.dll + + + ..\packages\System.IO.FileSystem.Primitives.4.3.0\lib\net46\System.IO.FileSystem.Primitives.dll + + + ..\packages\System.IO.FileSystem.4.3.0\lib\net46\System.IO.FileSystem.dll + + + ..\packages\System.Reflection.Metadata.1.6.0\lib\netstandard2.0\System.Reflection.Metadata.dll + + + + + ..\packages\System.Security.Cryptography.Encoding.4.3.0\lib\net46\System.Security.Cryptography.Encoding.dll + + + ..\packages\System.Security.Cryptography.Primitives.4.3.0\lib\net46\System.Security.Cryptography.Primitives.dll + + + ..\packages\System.Security.Cryptography.Algorithms.4.3.0\lib\net461\System.Security.Cryptography.Algorithms.dll + + + ..\packages\System.Security.Cryptography.X509Certificates.4.3.0\lib\net461\System.Security.Cryptography.X509Certificates.dll + + + ..\packages\System.Text.Encoding.CodePages.4.3.0\lib\net46\System.Text.Encoding.CodePages.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.3.0\lib\portable-net45+win8+wp8+wpa81\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.Threading.Thread.4.3.0\lib\net46\System.Threading.Thread.dll + + + ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll + + + ..\packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll + + + + ..\packages\System.Xml.XmlDocument.4.3.0\lib\net46\System.Xml.XmlDocument.dll + + + ..\packages\System.Xml.XPath.4.3.0\lib\net46\System.Xml.XPath.dll + + + ..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll + + + ..\packages\Microsoft.CodeAnalysis.Common.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.dll + + + ..\packages\Microsoft.CodeAnalysis.CSharp.2.10.0\lib\netstandard1.3\Microsoft.CodeAnalysis.CSharp.dll + @@ -392,6 +420,10 @@ PreserveNewest + + PreserveNewest + + @@ -443,6 +475,7 @@ PreserveNewest + diff --git a/Tests/testClass.cs b/Tests/testClass.cs new file mode 100644 index 00000000..70d19b76 --- /dev/null +++ b/Tests/testClass.cs @@ -0,0 +1,25 @@ + +using System; + +/* this is a block comment + * on several lines + */ + +namespace testRoslyn { + public class testClass { + public testClass self; + int a = 0; + int b; + public string str = "this is a test string" + + [XmlIgnore] + public string Str { + get { return str; } + set { str = value; } + } + [SecuritySafeCritical] + public testClass (int _a, int _b) { + a = _a; + } + } +} diff --git a/Tests/ui/TreeExpandable.template b/Tests/ui/TreeExpandable.template new file mode 100644 index 00000000..87fe8d4e --- /dev/null +++ b/Tests/ui/TreeExpandable.template @@ -0,0 +1,30 @@ + + + + + + + + + -- 2.47.3