Skip to content

Add support for C# Implicit Usings#2697

Open
CapeGuyBen wants to merge 1 commit into
premake:masterfrom
CapeGuyGames:feature/implicitusings
Open

Add support for C# Implicit Usings#2697
CapeGuyBen wants to merge 1 commit into
premake:masterfrom
CapeGuyGames:feature/implicitusings

Conversation

@CapeGuyBen

@CapeGuyBen CapeGuyBen commented Jun 1, 2026

Copy link
Copy Markdown

What does this PR do?

Adds support for Implicit Usings

How does this PR change Premake's behavior?

It adds a new project property called enableimplicitusings which defaults to "Off" but can be switched to "On"

Anything else we should know?

It's pretty much a straight copy of the enabledefaultcompileitems implementation

Did you check all the boxes?

  • Focus on a single fix or feature; remove any unrelated formatting or code changes
  • Add unit tests showing fix or feature works; all tests pass
  • Mention any related issues (put closes #XXXX in comment to auto-close issue when PR is merged)
  • Follow our coding conventions
  • Minimize the number of commits
  • Align documentation to your changes

You can now support Premake on our OpenCollective. Your contributions help us spend more time responding to requests like these!

@Jarod42 Jarod42 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are missing.

Appreciated to add testing project into https://github.com/Jarod42/premake-sample-projects too ;-)

Comment thread website/docs/enableimplicitusings.md Outdated
@CapeGuyBen CapeGuyBen force-pushed the feature/implicitusings branch from bea454d to 5724229 Compare June 4, 2026 20:43
@CapeGuyBen

Copy link
Copy Markdown
Author

Updated (amended commit) to add "Default" option which doesn't add the ImplicitUsings project property to ensure backwards compatibility. Updated documentation to match. Added tests. Require VS2022 or above (which is when I think it was first available).

For the samples, I'll take a look. I've got a few PRs to follow for changes I needed to get my project working. I might try to get those in first and then add a sample which uses them all, if that makes sense.

Comment thread tests/test.sh Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this file

@CapeGuyBen CapeGuyBen Jun 5, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP. Removed. Would you like me to submit it in a separate PR or not at all?

Comment thread modules/vstudio/vs2005_dotnetbase.lua Outdated
On = "true"
}

if _ACTION >= "vs2022" and

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typical style throughout the code base is to put this on a single line.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment thread modules/vstudio/vs2005_dotnetbase.lua Outdated

if _ACTION >= "vs2022" and
dotnetbase.isNewFormatProject(cfg) and
types[cfg.enableImplicitUsings] then

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be cfg.enableimplicitusings?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should! Fixed. I'm not sure why it also worked with the incorrect casing?

It looks like dotnetbase.netcore.enableDefaultCompileItems has the same issue with cfg.enableDefaultCompileItems.

@CapeGuyBen CapeGuyBen force-pushed the feature/implicitusings branch from 5724229 to dd4c5d0 Compare June 5, 2026 09:56
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

Successfully merging this pull request may close these issues.

3 participants