Skip to content

Commit

Permalink
Enable nullable from src/Directory.Build.props
Browse files Browse the repository at this point in the history
  • Loading branch information
menees committed Dec 27, 2021
1 parent 1e2ca51 commit a579140
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 20 deletions.
2 changes: 2 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<CodeAnalysisRuleSet>$(RepoSrcFolder)/Menees.Libraries.ruleset</CodeAnalysisRuleSet>
<AssemblyOriginatorKeyFile>$(RepoSrcFolder)/Menees.Libraries.snk</AssemblyOriginatorKeyFile>
<UseCustomCodeAnalyzers>true</UseCustomCodeAnalyzers>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>

<!-- Make the assembly, file, and NuGet package versions the same. -->
<Version>5.0.0</Version>
Expand Down
1 change: 0 additions & 1 deletion src/Menees.Common/Menees.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<RootNamespace>Menees</RootNamespace>
<Description>Helpers for files, text, XML, logging, exceptions, etc.</Description>
<Nullable>enable</Nullable>
</PropertyGroup>

<Choose>
Expand Down
15 changes: 9 additions & 6 deletions src/Menees.Common/TextUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Menees
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -196,11 +197,12 @@ public static string Replace(string text, string oldValue, string newValue, Stri
/// <param name="text">The text to update.</param>
/// <param name="replacement">The character to substitute for control characters.</param>
/// <returns>The text with the control characters replaced.</returns>
public static string ReplaceControlCharacters(string text, char replacement)
[return: NotNullIfNotNull("text")]
public static string? ReplaceControlCharacters(string? text, char replacement)
{
string result = text;
string? result = text;

if (!string.IsNullOrEmpty(text))
if (text.IsNotEmpty())
{
StringBuilder sb = new(text);
int length = text.Length;
Expand All @@ -223,11 +225,12 @@ public static string ReplaceControlCharacters(string text, char replacement)
/// </summary>
/// <param name="text">The text to update.</param>
/// <returns>The text with the control characters replaced.</returns>
public static string ReplaceControlCharacters(string text)
[return: NotNullIfNotNull("text")]
public static string? ReplaceControlCharacters(string? text)
{
string result = text;
string? result = text;

if (!string.IsNullOrEmpty(text))
if (text.IsNotEmpty())
{
StringBuilder sb = new(text);
int length = text.Length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<UseWindowsForms>true</UseWindowsForms>
<Description>Windows Forms controls for showing diffs of text, files, and directories</Description>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Menees.Diffs/Menees.Diffs.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFrameworks>netstandard2.0;$(MeneesTargetNetCoreBase);$(MeneesTargetNetFramework)</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Description>Differencing algorithms for text files, binary files, and directories</Description>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Menees.Windows.Forms/Menees.Windows.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<UseWindowsForms>true</UseWindowsForms>
<Description>Windows Forms helpers and custom controls</Description>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<COMReference Include="tom.dll">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFrameworks>$(MeneesTargetNetCoreWindows);$(MeneesTargetNetFramework)</TargetFrameworks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<UseWPF>true</UseWPF>
<Description>WPF helpers and custom controls</Description>
<Nullable>enable</Nullable>
<!-- Needed for Nullable support in .NET Framework. https://github.com/manuelroemer/Nullable#quickstart -->
<IncludePackageReferencesDuringMarkupCompilation>true</IncludePackageReferencesDuringMarkupCompilation>
</PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/Menees.Windows/Menees.Windows.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Description>Windows-specific helpers for WMI, shell dialogs, and Visual Studio invocation</Description>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion tests/Menees.Common.Tests/Menees.Common.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<UseWindowsForms>true</UseWindowsForms>
<Version>1.2.3</Version>
<Copyright>Copyright For Unit Test</Copyright>
<Nullable>enable</Nullable>
<BuildTime>2021-12-26 17:50:00Z</BuildTime>
</PropertyGroup>

Expand Down
6 changes: 1 addition & 5 deletions tests/Menees.Diffs.Tests/Menees.Diffs.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Nullable>enable</Nullable>
</PropertyGroup>

<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\Menees.Diffs\Menees.Diffs.csproj" />
</ItemGroup>
Expand Down
1 change: 0 additions & 1 deletion tests/Menees.Windows.Tests/Menees.Windows.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(MeneesTargetNetCoreWindows);$(MeneesTargetNetFramework)</TargetFrameworks>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
Expand Down

0 comments on commit a579140

Please sign in to comment.