From 5612fec80cf3035f1726fefe3c54a32acc577e84 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Philippe=20Bruy=C3=A8re?= Date: Sun, 23 Feb 2020 08:18:12 +0100 Subject: [PATCH] wip --- Crow/src/Widgets/Widget.cs | 3 +- Samples/HelloWorld/HelloWorld.csproj | 8 +-- Samples/HelloWorld/main.cs | 74 +++++++++++++++++++++++++--- 3 files changed, 74 insertions(+), 11 deletions(-) diff --git a/Crow/src/Widgets/Widget.cs b/Crow/src/Widgets/Widget.cs index 8596a86f..aed4d8ff 100644 --- a/Crow/src/Widgets/Widget.cs +++ b/Crow/src/Widgets/Widget.cs @@ -1404,7 +1404,7 @@ namespace Crow dbgEvt.end = DebugLog.chrono.ElapsedTicks; #endif } - /// Full update, content and layouting, taking care of sizing policy + /// Full update, if width or height is 'Fit' a layouting is requested, and a redraw is done in any case. [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; } } + /// Query a layouting for the type pass as parameter, redraw only if layout changed. public virtual void RegisterForLayouting(LayoutingType layoutType){ #if DEBUG if (disposed) { diff --git a/Samples/HelloWorld/HelloWorld.csproj b/Samples/HelloWorld/HelloWorld.csproj index 7d3574d0..5a976be0 100644 --- a/Samples/HelloWorld/HelloWorld.csproj +++ b/Samples/HelloWorld/HelloWorld.csproj @@ -1,6 +1,6 @@  - net472 + netcoreapp3.1 Exe false 0.8.0 @@ -24,17 +24,17 @@ - + - + diff --git a/Samples/HelloWorld/main.cs b/Samples/HelloWorld/main.cs index 75a2683b..c95ee8e4 100644 --- a/Samples/HelloWorld/main.cs +++ b/Samples/HelloWorld/main.cs @@ -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 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 { public void Report (ProjectLoadProgress value) @@ -373,6 +434,7 @@ namespace HelloWorld } } + } //void compile () //{ -- 2.47.3