Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions modules/vstudio/_preload.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,17 @@
default = false
}

p.api.register {
name = "enableimplicitusings",
scope = "config",
kind = "string",
allowed = {
"Default",
"On",
"Off"
}
}

p.api.register {
name = "externalanglebrackets",
scope = "config",
Expand Down
34 changes: 34 additions & 0 deletions modules/vstudio/tests/cs2005/test_netcore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,40 @@ function suite.allowUnsafeProperty_core()
]]
end

function suite.implicitUsings_on()
p.action.set("vs2022")
dotnetframework "net10.0"
enableimplicitusings "On"
prepareProjectProperties()
test.capture [[
<PropertyGroup>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFramework>net10.0</TargetFramework>
<Configurations>Debug;Release;Distribution</Configurations>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<ImplicitUsings>true</ImplicitUsings>
</PropertyGroup>
]]
end

function suite.implicitUsings_off()
p.action.set("vs2022")
dotnetframework "net10.0"
enableimplicitusings "Off"
prepareProjectProperties()
test.capture [[
<PropertyGroup>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFramework>net10.0</TargetFramework>
<Configurations>Debug;Release;Distribution</Configurations>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
<ImplicitUsings>false</ImplicitUsings>
</PropertyGroup>
]]
end

function suite.project_element_configurations()
p.action.set("vs2022")
dotnetframework "net8.0"
Expand Down
1 change: 1 addition & 0 deletions modules/vstudio/vs2005_csproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
dotnetbase.csversion,
dotnetbase.projectConfigurations,
dotnetbase.netcore.enableDefaultCompileItems,
dotnetbase.netcore.enableImplicitUsings,
dotnetbase.netcore.dotnetsdk
}
else
Expand Down
11 changes: 11 additions & 0 deletions modules/vstudio/vs2005_dotnetbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,17 @@
_p(2,'<EnableDefaultCompileItems>%s</EnableDefaultCompileItems>', iif(cfg.enableDefaultCompileItems, "true", "false"))
end

function dotnetbase.netcore.enableImplicitUsings(cfg)
local types = {
Off = "false",
On = "true"
}

if _ACTION >= "vs2022" and dotnetbase.isNewFormatProject(cfg) and types[cfg.enableimplicitusings] then
_p(2,'<ImplicitUsings>%s</ImplicitUsings>', types[cfg.enableimplicitusings])
end
end

function dotnetbase.netcore.useWpf(cfg)
if cfg.wpf == p.ON then
_p(2,'<UseWpf>true</UseWpf>')
Expand Down
29 changes: 29 additions & 0 deletions website/docs/enableimplicitusings.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Specifies if C# implicit usings should be enabled. Defaults to `Off`.

```lua
enableimplicitusings ("value")
```

### Parameters ###

`value` is one of:

| Value | Description |
|---------|-------------|
| Default | Don't include property for implicit usings |
| On | Enable C# implicit usings. |
| Off | Disable C# implicit usings. |

## Applies To ###

Project configurations.

### Availability ###

Premake 5.0.0 or later for Visual Studio C# Projects.

### Examples ###

```lua
enableimplicitusings "On"
```
1 change: 1 addition & 0 deletions website/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ module.exports = {
'embedandsign',
'enable64bitchecks',
'enabledefaultcompileitems',
'enableimplicitusings',
'enablemodules',
'enablepch',
'enableunitybuild',
Expand Down
Loading