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

Please add a simple project example using the Roslyn tool CLI / further documentation #56

Open
lol768 opened this issue Feb 12, 2023 · 2 comments

Comments

@lol768
Copy link
Contributor

lol768 commented Feb 12, 2023

Using .NET 7

In my experience:

  • The ts-gen command doesn't manage to compile the root types provider properly. It doesn't add assembly references to common types, such as those in the System.Collections.Generic namespace
  • This leads to compilation errors:
dotnet ts-gen -a bin/Debug/net7.0/ExtDep.dll --directory "." --outputDir frontend/ 
Generating TypeScript
MyRootTypesProvider.cs(1,13): error CS0234: The type or namespace name 'Models' does not exist in the namespace 'Example' (are you missing an assembly reference?)
MyRootTypesProvider.cs(12,20): error CS0246: The type or namespace name 'List<>' could not be found (are you missing a using directive or an assembly reference?)
MyRootTypesProvider.cs(12,25): error CS0246: The type or namespace name 'Type' could not be found (are you missing a using directive or an assembly reference?)
MyRootTypesProvider.cs(12,42): error CS0246: The type or namespace name 'ConfirmationViewModel' could not be found (are you missing a using directive or an assembly reference?)

I don't know how to fix these, except perhaps by not using AdhocProject.

  • The README doesn't really document that you need to write an IRootTypesProvider implementation when using the CLI tool in the first place
  • For using the Roslyn support in code rather than at the CLI, there is no real documentation about what should be passed to AdhocProject.GetCompilation. It turned out that the root types provider source code must be available within the list of directories, but I did not know that initially - and I just got NullReference exceptions referencing the use of x.SourceTree! in GetNamespaceTypes. It makes sense now that I've read through the library's code a bit more.
  • I'm just generally a bit lost with getting this to actually work using Roslyn
@fakefeik
Copy link
Contributor

Hello, thank you for taking interest in this project, sorry for the delayed response

Could you provide your type script generator configuration? And a simple repro example that you have trouble with

I agree that the documentation is lacking and I intend to make it more clear in the fututre, thank you for the feedback

@fakefeik
Copy link
Contributor

Also in your example dotnet ts-gen -a bin/Debug/net7.0/ExtDep.dll --directory "." --outputDir frontend/ it seems that --directory flag and Roslyn in general is not needed since you already provided build .dll file in -a flag

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

No branches or pull requests

2 participants