Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 1a732c1

Browse files
committed
Enable warnings-as-errors for the build
I also explicitly enabled WarningLevel 4 for all projects, and I fixed a few straggling warnings that fire with the VS2013 compiler but not with VS2015 (by design).
1 parent 02a6f1c commit 1a732c1

File tree

9 files changed

+8
-14
lines changed

9 files changed

+8
-14
lines changed

dir.props

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@
186186
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
187187
</PropertyGroup>
188188

189+
<!-- Set up handling of build warnings -->
190+
<PropertyGroup>
191+
<WarningLevel>4</WarningLevel>
192+
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
193+
</PropertyGroup>
194+
189195
<!-- Set up some common paths -->
190196
<PropertyGroup>
191197
<CommonPath>$(SourceDir)Common\src</CommonPath>

src/System.Collections.Immutable/src/System.Collections.Immutable.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<Optimize>false</Optimize>
2424
<DefineConstants>DEBUG;TRACE</DefineConstants>
2525
<ErrorReport>prompt</ErrorReport>
26-
<WarningLevel>4</WarningLevel>
2726
<Prefer32Bit>false</Prefer32Bit>
2827
<CodeAnalysisRuleSet>System.Collections.Immutable.ruleset</CodeAnalysisRuleSet>
2928
</PropertyGroup>
@@ -32,7 +31,6 @@
3231
<Optimize>true</Optimize>
3332
<DefineConstants>TRACE</DefineConstants>
3433
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
3634
<Prefer32Bit>false</Prefer32Bit>
3735
</PropertyGroup>
3836
<ItemGroup>

src/System.IO.MemoryMappedFiles/tests/MemoryMappedFile/System.IO.MemoryMappedFiles.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
<Optimize>false</Optimize>
1717
<DefineConstants>TRACE;DEBUG</DefineConstants>
1818
<ErrorReport>prompt</ErrorReport>
19-
<WarningLevel>4</WarningLevel>
2019
</PropertyGroup>
2120
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2221
<DebugType>pdbonly</DebugType>
2322
<Optimize>true</Optimize>
2423
<DefineConstants>TRACE</DefineConstants>
2524
<ErrorReport>prompt</ErrorReport>
26-
<WarningLevel>4</WarningLevel>
2725
</PropertyGroup>
2826
<PropertyGroup>
2927
</PropertyGroup>

src/System.IO.MemoryMappedFiles/tests/MemoryMappedViewAccessor/System.IO.MemoryMappedViewAccessor.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
<Optimize>false</Optimize>
1919
<DefineConstants>TRACE;DEBUG</DefineConstants>
2020
<ErrorReport>prompt</ErrorReport>
21-
<WarningLevel>4</WarningLevel>
2221
</PropertyGroup>
2322
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2423
<DebugType>pdbonly</DebugType>
2524
<Optimize>true</Optimize>
2625
<DefineConstants>TRACE</DefineConstants>
2726
<ErrorReport>prompt</ErrorReport>
28-
<WarningLevel>4</WarningLevel>
2927
</PropertyGroup>
3028
<PropertyGroup>
3129
</PropertyGroup>

src/System.IO.MemoryMappedFiles/tests/MemoryMappedViewStream/System.IO.MemoryMappedViewStream.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,12 @@
1717
<Optimize>false</Optimize>
1818
<DefineConstants>TRACE;DEBUG</DefineConstants>
1919
<ErrorReport>prompt</ErrorReport>
20-
<WarningLevel>4</WarningLevel>
2120
</PropertyGroup>
2221
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2322
<DebugType>pdbonly</DebugType>
2423
<Optimize>true</Optimize>
2524
<DefineConstants>TRACE</DefineConstants>
2625
<ErrorReport>prompt</ErrorReport>
27-
<WarningLevel>4</WarningLevel>
2826
</PropertyGroup>
2927
<PropertyGroup>
3028
</PropertyGroup>

src/System.IO.Pipes/src/System/IO/Pipes/NamedPipeServerStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private void CheckDisconnectOperations()
185185
{
186186
throw new InvalidOperationException(SR.InvalidOperation_PipeAlreadyDisconnected);
187187
}
188-
if (CheckOperationsRequiresSetHandle && InternalHandle == null)
188+
if (InternalHandle == null && CheckOperationsRequiresSetHandle)
189189
{
190190
throw new InvalidOperationException(SR.InvalidOperation_PipeHandleNotSet);
191191
}

src/System.Reflection.Metadata/src/System.Reflection.Metadata.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
<Optimize>false</Optimize>
2424
<DefineConstants>DEBUG;TRACE</DefineConstants>
2525
<ErrorReport>prompt</ErrorReport>
26-
<WarningLevel>4</WarningLevel>
2726
<CheckForOverflowUnderflow>true</CheckForOverflowUnderflow>
2827
</PropertyGroup>
2928
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
@@ -32,7 +31,6 @@
3231
<Optimize>true</Optimize>
3332
<DefineConstants>TRACE</DefineConstants>
3433
<ErrorReport>prompt</ErrorReport>
35-
<WarningLevel>4</WarningLevel>
3634
</PropertyGroup>
3735
<ItemGroup>
3836
<Compile Include="Properties\InternalsVisibleTo.cs" />

src/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@
2121
<Optimize>false</Optimize>
2222
<DefineConstants>DEBUG;TRACE</DefineConstants>
2323
<ErrorReport>prompt</ErrorReport>
24-
<WarningLevel>4</WarningLevel>
2524
</PropertyGroup>
2625
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
2726
<PlatformTarget>AnyCPU</PlatformTarget>
2827
<DebugType>pdbonly</DebugType>
2928
<Optimize>true</Optimize>
3029
<DefineConstants>TRACE</DefineConstants>
3130
<ErrorReport>prompt</ErrorReport>
32-
<WarningLevel>4</WarningLevel>
3331
</PropertyGroup>
3432
<ItemGroup>
3533
<ProjectReference Include="..\src\System.Reflection.Metadata.csproj">

src/System.Threading.Tasks/tests/UnwrapTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ private static CancellationToken GetCanceledTaskToken(Task task)
532532

533533
private sealed class CountingScheduler : TaskScheduler
534534
{
535-
public volatile int QueueTaskCalls = 0;
535+
public int QueueTaskCalls = 0;
536536

537537
protected override void QueueTask(Task task)
538538
{

0 commit comments

Comments
 (0)