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

Is there support for equivalent of .csproj ImplicitUsings? Could it be added? #719

Open
charring opened this issue May 11, 2023 · 3 comments

Comments

@charring
Copy link

I was debugging a compile error with a dotnet-script file and finally realized there was a missing using.
The program worked in a cs project and I then remembered that the default is now

<ImplicitUsings>enable</ImplicitUsings>

That would be a nice to have feature in dotnet-script. Or perhaps it's there and I don't know how to set it.

@mmarvb8h
Copy link

I have similar issue.

I noticed that the .csprog file used by dotnet-script is missing the tag <ImplicitUsings>enable<ImplicitUsings>. I removed from my Webapi app and received the same wornings/errors during build.

I noticed that in dotnet script, the .csproj file re-generated. Is there a template somewhere that i can add this missing tag?

thx...

@filipw
Copy link
Member

filipw commented Jun 5, 2023

That would be a nice to have feature in dotnet-script. Or perhaps it's there and I don't know how to set it.

Implicit usings are an SDK feature, not a compiler feature.
CSX scripts already include a bunch of usings by default out of the box (in fact scripting has done this before global usings even existed).

Can you explain the use case you have?

I noticed that the .csprog file used by dotnet-script is missing the tag enable. I removed from my Webapi app and received the same wornings/errors during build.

This is currently a limitation, but we will address this (see #694 (comment))

I noticed that in dotnet script, the .csproj file re-generated. Is there a template somewhere that i can add this missing tag?

The project file is generated to only load dependencies, implicit usings would have no effect here.

@marvfinsy
Copy link

I assume my use case may be unique.

In my case i'm previous c# (Windows) developer, now at a Ruby shop. Wanted to see how dotnet with c# might be a benefit. I assume ruby devs may be more comfortable with c# scripting. I compared writing a web app using scripting and a standard dotnet minimal web app both in c#. I found the minimal app a little 'cleaner'. For example given the extensive use of global usings prevented needing 'usings' in each c# file. For me not a big deal but for devs coming from a ruby background maybe more challenging. Was thinking of a way i could set all that up. I could add all/most of the libraries from Microsoft in advance.

Also using Visual Code, I had to refresh the intellisense extension all the time.

So for my particular use case i think scripting may not be the best option.

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

4 participants