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

AllowUnsafeBlocks will now be a project level property in new format #1565

Merged
merged 1 commit into from
Dec 8, 2020
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
12 changes: 11 additions & 1 deletion modules/vstudio/tests/cs2005/test_compiler_props.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
]]
end


--
-- Check handling of the Unsafe flag.
--
Expand All @@ -55,6 +54,17 @@
]]
end

function suite.allowUnsafeBlocks_onUnsafeFlagNonConfigOnNetcore()
dotnetframework "netcoreapp3.1"
clr "Unsafe"
prepare()
test.capture [[
<DefineConstants></DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
]]
end


--
-- Check handling of FatalWarnings flag.
Expand Down
23 changes: 23 additions & 0 deletions modules/vstudio/tests/cs2005/test_netcore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
local p = premake
local suite = test.declare("vstudio_cs2005_netcore_prj")
local dn2005 = p.vstudio.dotnetbase
local cs2005 = p.vstudio.cs2005
local project = p.project


Expand Down Expand Up @@ -36,6 +37,13 @@ local function prepareNetcore()
dn2005.projectElement(prj)
end

local function prepareProjectProperties()
local localProj = test.getproject(wks, 1)

dn2005.prepare(cs2005)
dn2005.projectProperties(localProj)
end

function suite.targetFrameworkProperty_framework()
dotnetframework "4.7.2"
targetFrameworkPrepare()
Expand Down Expand Up @@ -101,3 +109,18 @@ function suite.project_element_framework()
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
]]
end

function suite.allowUnsafeProperty_core()
dotnetframework "netcoreapp2.2"
clr "Unsafe"
prepareProjectProperties()
test.capture [[
<PropertyGroup>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
</PropertyGroup>
]]
end
1 change: 1 addition & 0 deletions modules/vstudio/vs2005_csproj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
dotnetbase.rootNamespace,
dotnetbase.assemblyName,
dotnetbase.netcore.targetFramework,
dotnetbase.allowUnsafeBlocks,
dotnetbase.fileAlignment,
dotnetbase.bindingRedirects,
dotnetbase.netcore.useWpf,
Expand Down
10 changes: 8 additions & 2 deletions modules/vstudio/vs2005_dotnetbase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@
_p(2,'<ErrorReport>prompt</ErrorReport>')
_p(2,'<WarningLevel>4</WarningLevel>')

if cfg.clr == "Unsafe" then
_p(2,'<AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
if not dotnetbase.isNewFormatProject(cfg) then
dotnetbase.allowUnsafeBlocks(cfg)
end

if cfg.flags.FatalCompileWarnings then
Expand Down Expand Up @@ -772,4 +772,10 @@
if cfg.flags.WPF then
_p(2,'<UseWpf>true</UseWpf>')
end
end

function dotnetbase.allowUnsafeBlocks(cfg)
if cfg.clr == "Unsafe" then
_p(2,'<AllowUnsafeBlocks>true</AllowUnsafeBlocks>')
end
end