Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with Roslyn Generator in Unity and Visual Studio #503

Closed
nbreum15 opened this issue Nov 30, 2017 · 23 comments
Closed

Problems with Roslyn Generator in Unity and Visual Studio #503

nbreum15 opened this issue Nov 30, 2017 · 23 comments

Comments

@nbreum15
Copy link

nbreum15 commented Nov 30, 2017

Hi I just did some testing with the Roslyn generator trying to figure out why it worked with the .NET Experimental 4.6 in Unity, and why it did not work with lower versions.

Reposting my messages from gitter here:

My initial guess was that Roslyn or Entitas needs the version in .csproj to be 4.6. However, upon further inspection of the .csproj i discovered the <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> under <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> and tried to remove it. And BAM! Lower versions of .NET now works with Roslyn for me. This is the same that happens when you switch to .NET Experimental 4.6 in Unity, the line <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> is not there, only <TargetFrameworkVersion>v4.6</TargetFrameworkVersion> which makes it able to generate.
It should be noted that the test above was done with Unity + Visual Studio. I just tried it with MonoDevelop, and you know what? Unity does not add <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> only <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>, when Unity generates the .csproj for MonoDevelop, making the Roslyn generator able to generate just fine.

Would be interesting to see if this fix works for others.

@optimisez
Copy link

optimisez commented Dec 1, 2017

Sadly it does not work for me. Each time I hit generate on Roslyn code generator it will write <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> back to .csproj.

@nbreum15
Copy link
Author

nbreum15 commented Dec 1, 2017

Do you do it through Unity or with command line? Also, have you tried switching to MonoDevelop temporarily and see if it works with that? (Remember to change the .csproj in Entitas.properties if you decide to try it 😄)

@optimisez
Copy link

optimisez commented Dec 1, 2017

I think needs @sschmid to do extra care to handle it when .csproj file has <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> inside. Technically after fixing this bug Roslyn code generator should able to generate code without needing to switch to Unity Scripting Runtime Version to .Net 4.6. I think I not able to change IDE other than Visual Studio 2017 for the moment.

@sschmid
Copy link
Owner

sschmid commented Dec 16, 2017

Repost from the chat:

That's something that we could report to the roslyn team, because this is out of my hand. I could add a new feature to the code generator: IPreProcessor, so I could implement and DeleteCrazyVSStudioTagsFromProjectPreProcessor. That could fix the issue for us until roslyn will properly parse the project.

Could some please provide a .csproj file for me, so I can write unit tests to fix this? I don't have VS

@nbreum15
Copy link
Author

Here is one: https://pastebin.com/bPDZhsNn

@roygear
Copy link
Contributor

roygear commented Dec 16, 2017

here is another not work sample: https://gist.github.com/roygear/770a448aba7194ec550f7f76f8ee2620

@sschmid
Copy link
Owner

sschmid commented Dec 16, 2017

great, thanks! I will take a look. Just to clarify: your suggested solution is to remove <TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile> right?

@sschmid
Copy link
Owner

sschmid commented Dec 16, 2017

Is the issue described in #521 the one you guys have been experiencing? (fingers crossed :))

@roygear
Copy link
Contributor

roygear commented Dec 16, 2017

if Unity using .Net 3.5, this content will generate again, but the roslyn will work only one time!!
"< TargetFrameworkProfile >Unity Subset v3.5 < /TargetFrameworkProfile >"

if Unity switch to .Net 4.5, the content of TargetFrameworkProfile will be empty, and roslyn WORK!

@roygear
Copy link
Contributor

roygear commented Dec 16, 2017

Rider do not generate this Profile

@sschmid
Copy link
Owner

sschmid commented Dec 16, 2017

Awesome, thanks! That's what I wanted to hear :) I can fix this

@roygear
Copy link
Contributor

roygear commented Dec 16, 2017

happy holiday!

@sschmid
Copy link
Owner

sschmid commented Dec 16, 2017

Released Entitas 0.46.3

Use auto import or manually add the new TargetFrameworkProfilePreProcessor.
This pre processor will remove <TargetFrameworkProfile >Unity Subset v3.5 < /TargetFrameworkProfile >" if it exists.

Let me know if this fixes the issue, then I will (happily) close

@sschmid
Copy link
Owner

sschmid commented Dec 17, 2017

Did anyone try Entitas 0.46.3 already? I'm desperately waiting for positive feedback :) I hope this is the fix that we were looking for

@Neikice
Copy link

Neikice commented Dec 18, 2017

I tried 0.46.3. But it didn’t work .I still had to Manually delete

<TargetFrameworkProfile>Unity Subset v3.5 </TargetFrameworkProfile>"

@sschmid
Copy link
Owner

sschmid commented Dec 18, 2017

@Neikice Did you activate the TargetFrameworkProfilePreProcessor as shown in release notes?
https://github.com/sschmid/Entitas-CSharp/releases

@Neikice
Copy link

Neikice commented Dec 18, 2017

@sschmid yes, i did.

CodeGenerator.SearchPaths = CodeGenerator\Plugins, \
                            CodeGenerator\Plugins\Entitas, \
                            CodeGenerator\Plugins\Entitas.Roslyn, \
                            CodeGenerator\Plugins\Jenny

CodeGenerator.Plugins = Entitas.CodeGeneration.Plugins, \
                        Entitas.VisualDebugging.CodeGeneration.Plugins, \
                        DesperateDevs.CodeGeneration.Plugins, \
                        Entitas.Roslyn.CodeGeneration.Plugins

CodeGenerator.DataProviders = Entitas.CodeGeneration.Plugins.ContextDataProvider, \
                              Entitas.Roslyn.CodeGeneration.Plugins.ComponentDataProvider, \
                              Entitas.Roslyn.CodeGeneration.Plugins.EntityIndexDataProvider

CodeGenerator.CodeGenerators = Entitas.CodeGeneration.Plugins.ComponentContextGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentEntityGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentEntityInterfaceGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentMatcherGenerator, \
                               Entitas.CodeGeneration.Plugins.ComponentsLookupGenerator, \
                               Entitas.CodeGeneration.Plugins.ContextAttributeGenerator, \
                               Entitas.CodeGeneration.Plugins.ContextGenerator, \
                               Entitas.CodeGeneration.Plugins.ContextMatcherGenerator, \
                               Entitas.CodeGeneration.Plugins.ContextsGenerator, \
                               Entitas.CodeGeneration.Plugins.EntityGenerator, \
                               Entitas.CodeGeneration.Plugins.EntityIndexGenerator, \
                               Entitas.VisualDebugging.CodeGeneration.Plugins.ContextObserverGenerator, \
                               Entitas.VisualDebugging.CodeGeneration.Plugins.FeatureClassGenerator

CodeGenerator.PostProcessors = DesperateDevs.CodeGeneration.Plugins.AddFileHeaderPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.CleanTargetDirectoryPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.MergeFilesPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.NewLinePostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.UpdateCSProjPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.WriteToDiskPostProcessor, \
                               DesperateDevs.CodeGeneration.Plugins.ConsoleWriteLinePostProcessor

CodeGenerator.Server.Port = 3333
CodeGenerator.Client.Host = localhost
Entitas.CodeGeneration.Plugins.Contexts = Game, \
                                          Input

DesperateDevs.CodeGeneration.Plugins.ProjectPath = Town.csproj
Entitas.CodeGeneration.Plugins.IgnoreNamespaces = false
DesperateDevs.CodeGeneration.Plugins.TargetDirectory = Assets/Sources
CodeGenerator.PreProcessors = DesperateDevs.CodeGeneration.Plugins.TargetFrameworkProfilePreProcessor
CodeGenerator.CLI.Ignore.UnusedKeys = 

@sschmid
Copy link
Owner

sschmid commented Dec 18, 2017

@Neikice

I tried 0.46.3. But it didn’t work .I still had to Manually delete <TargetFrameworkProfile>Unity Subset v3.5 </TargetFrameworkProfile>"

If have to ask, did you copy this line right from your project file? It contains a space after v3.5.
If that's the case I have to update the TargetFrameworkProfilePreProcessor. Currently it really only removes this (without a space)

<TargetFrameworkProfile>Unity Subset v3.5</TargetFrameworkProfile>

@Neikice
Copy link

Neikice commented Dec 18, 2017

@sschmid sorry ,i I forgot to put the DesperateDevs.CodeGeneration.Plugins.dll in the Entitas.Roslyn folder.
It works perfect now.
Thanks, Entitas 's getting better.

@sschmid
Copy link
Owner

sschmid commented Dec 18, 2017

ok great, so did I forget do ship DesperateDevs.CodeGeneration.Plugins.dll in the Entitas.Roslyn plugin?

@Neikice
Copy link

Neikice commented Dec 18, 2017

@sschmid
Github released doesn't contain Entitas.Roslyn plugin.
AssetStore version doesn't update to 0.46.3.
Next time, maybe you should remind us.
😄

@optimisez
Copy link

Hi @sschmid. So far so good. It still need a bit of manual work to get it working though.
image

Another thing is I see × Could not resolve: SQLitePCLRaw.core.dll slows down the code gen. I think fix that warning will speed up code gen.
image

@sschmid
Copy link
Owner

sschmid commented Dec 20, 2017

Don't mind the warning. It won't speed up the process. I already added a few custom dll to reduce the warnings but that's just how roslyn gets shipped by microsoft. Ironically, it's Windows only again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

5 participants