Ignore enum CA warnings and scope the osutil deprecation suppression. Also, fix project reference so the .vcx project system understands it.
Ignore enum CA warnings and scope the osutil deprecation suppression. Also, fix project reference so the .vcx project system understands it.
Sean Hall committed
Feb 7, 2021 at 17:56 UTC
bee6a20d1c7d807b5023d932ae179db1bc9a0f80
5 files changed
+23
-5
src/Cpp.Build.props
+4
@@ -12,6 +12,10 @@
12
<WindowsTargetPlatformVersion>$([Microsoft.Build.Utilities.ToolLocationHelper]::GetLatestSDKTargetPlatformVersion('Windows', '10.0'))</WindowsTargetPlatformVersion>
13
</PropertyGroup>
14
15
+ <PropertyGroup>
16
+ <CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)CustomizedNativeRecommendedRules.ruleset</CodeAnalysisRuleSet>
17
+ </PropertyGroup>
18
+
19
<ItemDefinitionGroup>
20
<ClCompile>
21
<DisableSpecificWarnings>$(DisableSpecificCompilerWarnings)</DisableSpecificWarnings>
src/CustomizedNativeRecommendedRules.ruleset
new
+8
@@ -0,0 +1,8 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<RuleSet Name="Customized Microsoft Native Recommended Rules" Description="Microsoft Native Recommended Rules, -C26812" ToolsVersion="16.0">
3
+ <Include Path="nativerecommendedrules.ruleset" Action="Default" />
4
+ <Rules AnalyzerId="Microsoft.Analyzers.NativeCodeAnalysis" RuleNamespace="Microsoft.Rules.Native">
5
+ <!-- We need C style enums since we support BAs written in C -->
6
+ <Rule Id="C26812" Action="None" />
7
+ </Rules>
8
+</RuleSet>
\ No newline at end of file
src/dutil/dutil.vcxproj
+1
-4
@@ -83,10 +83,7 @@
83
<ClCompile Include="memutil.cpp" />
84
<ClCompile Include="metautil.cpp" />
85
<ClCompile Include="monutil.cpp" />
86
- <ClCompile Include="osutil.cpp">
87
- <!-- turn off deprecation warning -->
88
- <DisableSpecificWarnings>4996</DisableSpecificWarnings>
89
- </ClCompile>
86
+ <ClCompile Include="osutil.cpp" />
87
<ClCompile Include="path2utl.cpp" />
88
<ClCompile Include="pathutil.cpp" />
89
<ClCompile Include="perfutil.cpp" />
src/dutil/osutil.cpp
+7
@@ -22,7 +22,14 @@ extern "C" void DAPI OsGetVersion(
22
if (OS_VERSION_UNKNOWN == vOsVersion)
23
{
24
ovi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
25
+
26
+#pragma warning (push)
27
+#pragma warning(suppress: 4996) // deprecated
28
+#pragma warning (push)
29
+#pragma warning(suppress: 28159)// deprecated, use other function instead
30
::GetVersionExW(reinterpret_cast<OSVERSIONINFOW*>(&ovi)); // only fails if version info size is set incorrectly.
31
+#pragma warning (pop)
32
+#pragma warning (pop)
33
34
vdwOsServicePack = static_cast<DWORD>(ovi.wServicePackMajor) << 16 | ovi.wServicePackMinor;
35
if (4 == ovi.dwMajorVersion)
src/test/DUtilUnitTest/DUtilUnitTest.vcxproj
+3
-1
@@ -70,7 +70,9 @@
70
</Reference>
71
</ItemGroup>
72
<ItemGroup>
73
- <ProjectReference Include="..\..\dutil\dutil.vcxproj" />
73
+ <ProjectReference Include="..\..\dutil\dutil.vcxproj">
74
+ <Project>{1244E671-F108-4334-BA52-8A7517F26ECD}</Project>
75
+ </ProjectReference>
76
</ItemGroup>
77
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
78
<Import Project="..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.47\build\WixBuildTools.TestSupport.Native.targets" Condition="Exists('..\..\..\packages\WixBuildTools.TestSupport.Native.4.0.47\build\WixBuildTools.TestSupport.Native.targets')" />