eXpandFramework / eXpand

DevExpress XAF (eXpressApp) extension framework. ๐—น๐—ถ๐—ป๐—ธ๐—ฒ๐—ฑ๐—ถ๐—ป.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ, ๐˜†๐—ผ๐˜‚๐˜๐˜‚๐—ฏ๐—ฒ.๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ.๐—ฐ๐—ผ๐—บ and ๐˜๐˜„๐—ถ๐˜๐˜๐—ฒ๐—ฟ @๐—ฒ๐˜…๐—ฝ๐—ฎ๐—ป๐—ฑ๐—ณ๐—ฟ๐—ฎ๐—บ๐—ฒ๐˜„๐—ผ๐—ฟ๐—ธ and or simply ๐—ฆ๐˜๐—ฎ๐—ฟ/๐˜„๐—ฎ๐˜๐—ฐ๐—ต this repository and get notified from ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ
http://expand.expandframework.com
Microsoft Public License
220 stars 114 forks source link

WorldCreator Module in .Net Core Framework #1021

Closed huncu16 closed 5 months ago

huncu16 commented 11 months ago

๐—ค๐˜‚๐—ฒ๐˜€๐˜๐—ถ๐—ผ๐—ป Hi Tolis, When i convert our projects framework to .NetCore wich uses WorldCreator Module it doesn't compile the generated code becouse of using cSharpCodeProvider.CompileAssemblyFromSource(compilerParameters, code); code doesn't supported in .Net Core.

I've two question 1-Do you plan to fix this neartime 2-For System.Drawing.Image typed properties and also doesn't support in .Net Core for We platform. Do you advice to convert it any type for easiest way?

Thanx for answers by now. And tell a way to buy you a cup of coffe ;)

apobekiaris commented 11 months ago

Hi,

Without a sample really I can only make guesses. Also unfortuately WC has no tests nor is used from other modules to verify it works on same level. However we have this Xpand.Extensions.Compiler.CodeCompiler.Compile which is used from the ModelMapper module and has tests for .NET Core.

So your options currently are

  1. Try to use this extensions instread with WC and post your modified sources so I can include it for others
  2. Wait until 23.2 is out so I can have a look my self given you post a sample I can repro the case.

Coffees or boost in my todo queque available at https://github.com/sponsors/apobekiaris

huncu16 commented 10 months ago

Ok thanks for answer, We are waiting for your solution about this, we are in aggrieved position about that we cannot update our projects framework to .Net Core. Please notify us wich coffeer type is appropriate for you.

Best wishes.

apobekiaris commented 10 months ago

please get in contact with me 2 apostolis.bekiaris@gmail.com and provide a sample app

apobekiaris commented 10 months ago

I checked this case and in general WorldCreator is not at all trivial to get it to comply with the latest changes in XAF architecutre. In addition to non available tests/docs for the package I have no other option as to redesign it from scratch under the Reactive.XAF. So if there are interested sponsors get in touch with me.

huncu16 commented 7 months ago

Tolis, hello again i've changed the method from CSharpCodeProvider.CompileAssemblyFromSource to CSharpCompilation.Emit

I put all assemblies our generated code needed and wich u add in Xpand.Extensions.Compiler.CodeCompiler.Compile method use this CSharpCompilation.Emit method. But the line we generate

public class DynamicDocumentLibraryModule: DevExpress.ExpressApp.ModuleBase{ }

gives error like below

"CS0012: The type 'Component' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.ComponentModel.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'"

if code generator skip to generate DynamicDocumentLibraryModule:DevExpress.ExpressApp.ModuleBase{} line Emit method compile it successfully but then i cannot get moduleType with code below

assembly.GetTypes().First(type => typeof(ModuleBase).IsAssignableFrom(type)); for adding it to ApplicationModulesManager

do u have an idea what am i missing?

apobekiaris commented 7 months ago

do u have an idea what am i missing?

I bet u miss this :)

You must add a reference to assembly 'System.ComponentModel.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

I am not sure if a missleading message though, it might refer to .net6 runtime rather to this specific assembly. In any case I would first verify that the assembly dependecy is there

apobekiaris commented 7 months ago

as far as I remember there was a parse of all dependecies on the runtime and automatically added to the dynamic assembly so in theory u should not go add dependecies manually.

huncu16 commented 7 months ago

But if i donโ€™t add them CSharpCompilation gives assembly missing error.

Its very clear that it needs system.component ๐Ÿ˜€

Even i add System.Conponent and System.Component.Primitives dlls manually and nothing change.

apobekiaris commented 7 months ago

look I am suggesting out of my mind, so I might be totally wrong cause no test no gain. Anyway these are core assemblies which points towards a .netframework version problem rather than specific assemblies

huncu16 commented 7 months ago

Yes i can see, so do you know anyone else using this for .net core successfull or another xpand module generating bussines class assemblies in run time with xaf blazor?

apobekiaris commented 7 months ago

Xpand generates assmblies at runtime with the Xpand.Extensions.Compiler.CodeCompiler.Compile extension in many places, in the RX repository at:

Search target
    Xpand.Extensions.Compiler.CodeCompiler.Compile(this SyntaxTree syntaxTree, params string[] references) : MemoryStream
Found usages  (3 usages found)
    <Editors>\<ProgressBarViewItem>\<Xpand.XAF.Modules.ProgressBarViewItem>  (1 usage found)
        Xpand.XAF.Modules.ProgressBarViewItem  (1 usage found)
            ProgressBarViewItemModule  (1 usage found)
                (55: 71)  using var memoryStream = CSharpSyntaxTree.ParseText(code).Compile(references);
    <Model>\<ModelMapper>\<Xpand.XAF.Modules.ModelMapper.Tests>  (1 usage found)
        Xpand.XAF.Modules.ModelMapper.Tests  (1 usage found)
            ModelMapperCommonTest  (1 usage found)
                (71: 60)  using var st= CSharpSyntaxTree.ParseText(code).Compile(typeof(object).Assembly.Location,typeof(AssemblyVersionAttribute).Assembly.Location);
    <Model>\<ModelMapper>\<Xpand.XAF.Modules.ModelMapper>  (1 usage found)
        Xpand.XAF.Modules.ModelMapper.Services.TypeMapping  (1 usage found)
            TypeMappingService  (1 usage found)
                (40: 75)  using var memoryStream = CSharpSyntaxTree.ParseText(code).Compile(references.ToArray());

ModelMapper works for .netcore. The dependecy collection is pretty similar to what I previously said (from the runtime) however is not a blazor module not that it matters and does not create Bussiness objects but rather maps any class to a model interface. You can get a lot of guidance from its codebase.

huncu16 commented 7 months ago

i've checked ur ModelMapper Module. And i think its DBFirst based and if i use it i must model DB at first then get it to my application. Am i wrong?

apobekiaris commented 7 months ago

the packages generates assemblies with dependecies for .netcore you can look how we did it there and apply it to your case

expand commented 5 months ago

Closing issue for age. Feel free to reopen it at any time.

.Thank you for your contribution.