]> O.S.I.I.S - jp/crow.git/commitdiff
wip
authorJean-Philippe Bruyère <jp_bruyere@hotmail.com>
Sun, 23 Feb 2020 07:18:12 +0000 (08:18 +0100)
committerj-p <jp_bruyere@hotmail.com>
Sat, 9 May 2020 22:50:02 +0000 (00:50 +0200)
Crow/src/Widgets/Widget.cs
Samples/HelloWorld/HelloWorld.csproj
Samples/HelloWorld/main.cs

index 8596a86f5a677c3c460d522c90019128e6c58659..aed4d8ff06d67e02ae7956a7faed62bdc26592fd 100644 (file)
@@ -1404,7 +1404,7 @@ namespace Crow
                        dbgEvt.end = DebugLog.chrono.ElapsedTicks;
                        #endif
                }
-               /// <summary> Full update, content and layouting, taking care of sizing policy </summary>
+               /// <summary> Full update, if width or height is 'Fit' a layouting is requested, and a redraw is done in any case. </summary>
                [MethodImpl(MethodImplOptions.AggressiveInlining)]
                public void RegisterForGraphicUpdate ()
                {
@@ -1448,6 +1448,7 @@ namespace Crow
                public virtual void ChildrenLayoutingConstraints(ref LayoutingType layoutType){
                }
                public virtual bool ArrangeChildren { get { return false; } }
+               /// <summary> Query a layouting for the type pass as parameter, redraw only if layout changed. </summary>
                public virtual void RegisterForLayouting(LayoutingType layoutType){
 #if DEBUG
                        if (disposed) {
index 7d3574d06b69921d7ab2c9534a79e5c2de34a5aa..5a976be02026e2dd6b36cf4b417ad05bbd881e9c 100644 (file)
@@ -1,6 +1,6 @@
 <Project Sdk="Microsoft.NET.Sdk">  
   <PropertyGroup>
-    <TargetFramework>net472</TargetFramework>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
     <OutputType>Exe</OutputType>        
     <EnableDefaultNoneItems>false</EnableDefaultNoneItems>     
     <ReleaseVersion>0.8.0</ReleaseVersion>
     </EmbeddedResource>                
   </ItemGroup>
   <ItemGroup>    
-    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
 <!--           <PackageReference Include="Microsoft.CodeAnalysis.Features" Version="3.4.0" />-->
     <PackageReference Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="3.4.0" />
+    <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
     <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.4.0" />
                <PackageReference Include="Microsoft.CodeAnalysis.CSharp.Features" Version="3.4.0" />
   </ItemGroup>
        
-  <ItemGroup>    
+  <!--<ItemGroup>    
                <PackageReference Include="SQLitePCLRaw.core" Version="2.0.2" />
                <PackageReference Include="System.Memory" Version="4.5.3" />
-  </ItemGroup> 
+  </ItemGroup> -->
        
        <ItemGroup>
          <PackageReference Include="Microsoft.Build" Version="16.4.0">
index 75a2683b575c698b76ddee9b83bac3b193a96ba1..c95ee8e41fdef6006da36827ab9ea532c2ba5026 100644 (file)
@@ -1,19 +1,15 @@
 using System;
-using System.CodeDom.Compiler;
 using System.Collections.Generic;
-using System.Composition;
+using System.Collections.Immutable;
 using System.IO;
 using System.Linq;
 using System.Reflection;
-using System.Reflection.Emit;
 using System.Threading.Tasks;
 using Crow;
-using Crow.IML;
 using Microsoft.CodeAnalysis;
 using Microsoft.CodeAnalysis.Completion;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
 using Microsoft.CodeAnalysis.Emit;
+using Microsoft.CodeAnalysis.Host;
 using Microsoft.CodeAnalysis.Host.Mef;
 using Microsoft.CodeAnalysis.MSBuild;
 using Microsoft.CodeAnalysis.Text;
@@ -329,11 +325,71 @@ namespace HelloWorld
 
                        var host = MefHostServices.Create (MSBuildMefHostServices.DefaultAssemblies);
 
+                       Solution sol = null;
+
+                       //using (var ws = new AdhocWorkspace ()) {
+                       //      ws.WorkspaceFailed += (sender, e) => Console.WriteLine ($"Workspace error: {e.Diagnostic}");
+                       //      ws.WorkspaceChanged += (sender, e) => Console.WriteLine ($"Workspace changed: {e.Kind} proj={e.ProjectId} doc={e.DocumentId}");
+
+                       //      var solId = SolutionId.CreateNewId ();
+                       //      SolutionInfo solutionInfo = SolutionInfo.Create (solId, VersionStamp.Create (), @"/tmp/testSol/testSolu.sln");
+
+                       //      sol = ws.AddSolution (solutionInfo);
+                       //      if (!ws.TryApplyChanges (sol))
+                       //              Console.WriteLine ("error saving sol");
+
+                       //      Microsoft.CodeAnalysis.Host.IPersistentStorageService p = ws.Services.PersistentStorage;
+
+                       //      using (Stream s = new FileStream (solutionInfo.FilePath, FileMode.Create)) {
+                       //              IPersistentStorage store = p.GetStorage (sol);
+
+                       //              if (!await p.GetStorage (sol).WriteStreamAsync ("testSol", s))
+                       //                      Console.WriteLine ("error saving sol");
+                       //      }
+
+
+
+                       //var projectInfo = ProjectInfo.Create (ProjectId.CreateNewId (),
+                       //                                                               VersionStamp.Create (),
+                       //                                                               "testSolu",
+                       //                                                               "testSolu.dll",
+                       //                                                               LanguageNames.CSharp,
+                       //                                                               @"/tmp/testSol/testSolu.csproj");
+
+
+                       //      var proj = ws.AddProject (projectInfo);
+                       //      var sourceText = SourceText.From ("public class A { }");
+                       //      ws.AddDocument (DocumentInfo.Create (DocumentId.CreateNewId (proj.Id), "ClassA.cs"));
+
+
+
+                       //      if (!ws.CanApplyChange (ApplyChangesKind.AddDocument))
+                       //              Console.WriteLine ("cant apply add Document");
+                       //}
+
                        using (var workspace = MSBuildWorkspace.Create (globalProperties)) {
                                //workspace. Properties["BuildingInsideVisualStudio"] = "false";
                                workspace.WorkspaceFailed += (sender, e) => Console.WriteLine ($"Workspace error: {e.Diagnostic}");
+                               workspace.WorkspaceChanged += (sender, e) => Console.WriteLine ($"Workspace changed: {e.Kind} proj={e.ProjectId} doc={e.DocumentId}");
+
+                               IPersistentStorageService p = workspace.Services.PersistentStorage;
+                               Console.WriteLine (p);
+
+
+
+                               //workspace.Services.PersistentStorage.GetStorage(sol).WriteStreamAsync()
+
+
                                Console.WriteLine ($"Opening Solution {slnPath}");
                                var solution = await workspace.OpenSolutionAsync (slnPath, new ProgressLog ());
+
+                               IPersistentStorage ip = p.GetStorage (solution);
+                               Console.WriteLine (ip);
+                               using (Stream s = new FileStream (@"/tmp/testSol/testSolu.sln", FileMode.Create)) {
+                                       if (!await ip.WriteStreamAsync ("testSolu", s))
+                                               Console.WriteLine ("error saving sol");
+                               }
+
                                Console.WriteLine ($"Proj Count:{solution.Projects.Count ()}");
                                foreach (Project project in solution.Projects) {
                                        Console.WriteLine ($"Compiling project:{project.FilePath}");
@@ -341,6 +397,9 @@ namespace HelloWorld
                                        Compilation compilation = await project.GetCompilationAsync ();
                                        Document doc = project.Documents.First ();
 
+                                       Task<SourceText> src = doc.GetTextAsync ();
+
+
                                        CompletionService.GetService (doc);
                                        using (var ms = new MemoryStream ()) {
                                                EmitResult result = compilation.Emit (ms);
@@ -362,9 +421,11 @@ namespace HelloWorld
 
                                //workspace.TryApplyChanges()
                        }
+                       
                        Console.WriteLine ($"end.");
                }
        }
+
        class ProgressLog : IProgress<ProjectLoadProgress>
        {
                public void Report (ProjectLoadProgress value)
@@ -373,6 +434,7 @@ namespace HelloWorld
                }
        }
 
+
 }
 //void compile ()
 //{