Skip to content

Commit 76ca4fe

Browse files
authored
Enable nullability context for all projects (#176)
1 parent ca80879 commit 76ca4fe

75 files changed

Lines changed: 313 additions & 345 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<LangVersion>10</LangVersion>
5-
<Nullable>warnings</Nullable>
5+
<Nullable>enable</Nullable>
66
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
77
<!--
88
> [CS8785] warning is emitted if a source generator failed to produce output

eg/SourceGenerator/Extensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#nullable enable
2-
31
using System;
42
using System.Collections.Generic;
53
using System.IO;

eg/SourceGenerator/Git/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#nullable enable
2-
31
using System;
42
using System.Collections.Generic;
53
using System.Linq;

src/DocoptNet.Playground/DocoptNet.Playground.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
5-
<Nullable>disable</Nullable>
65
</PropertyGroup>
76

87
<ItemGroup>

src/DocoptNet.Playground/Pages/Index.razor

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@
8181
{
8282
bool _optionsFirst;
8383
bool _lastOptionsFirst;
84-
string _commandLine;
85-
string _lastCommandLine;
86-
string _input;
87-
string _lastInput;
88-
string _output;
89-
IDictionary<string, ArgValue> _args;
90-
List<Node> _nodes;
84+
string _commandLine = string.Empty;
85+
string? _lastCommandLine;
86+
string? _input;
87+
string? _lastInput;
88+
string? _output;
89+
IDictionary<string, ArgValue>? _args;
90+
List<Node>? _nodes;
9191
bool _error;
9292
TimeSpan? _ms;
9393
ElementReference _inputTextArea;
@@ -145,7 +145,7 @@ Options:
145145
_error = false;
146146
_ms = null;
147147

148-
if (_input.Length == 0)
148+
if (_input is null or { Length: 0 })
149149
return;
150150

151151
var sw = Stopwatch.StartNew();
@@ -174,15 +174,15 @@ Options:
174174
_output = sb.ToString();
175175

176176
var docopt = new Docopt();
177-
var argv = _commandLine.Split((char[])null, StringSplitOptions.RemoveEmptyEntries);
177+
var argv = _commandLine.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries);
178178
_nodes = Docopt.Internal
179179
.GetNodes(_input,
180180
(name, value) => new Node(name, value.Kind, 0, ArgValue.None),
181181
(name, value) => new Node(name, value.IsStringList ? ArgValueKind.StringList : ArgValueKind.String, 0, ArgValue.None),
182182
(name, _, _, _, value) => new Node(name, value.Kind, 0, ArgValue.None))
183183
.GroupBy(e => e.Name, e => e, (_, g) => new Node(g.First().Name, g.First().ValueKind, g.Count(), ArgValue.None))
184184
.ToList();
185-
_args = Docopt.Internal.Apply(docopt, _input, argv.AsEnumerable(), help: false, version: null, optionsFirst: _optionsFirst, exit: false);
185+
_args = Docopt.Internal.Apply(docopt, _input, argv.AsEnumerable(), help: false, version: null, optionsFirst: _optionsFirst, exit: false)!;
186186
_nodes = _nodes.Select(n => new Node(n.Name, n.ValueKind, n.Count, _args.TryGetValue(n.Name, out var v) ? v : ArgValue.None)).ToList();
187187
_ms = sw.Elapsed;
188188
}

src/DocoptNet/ApplicationResult.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed under terms of MIT license (see LICENSE-MIT)
22
// Copyright 2021 Atif Aziz, Dinh Doan Van Bien
33

4-
#nullable enable
5-
64
namespace DocoptNet
75
{
86
using System;

src/DocoptNet/ApplicationResultAccumulator.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed under terms of MIT license (see LICENSE-MIT)
22
// Copyright 2021 Atif Aziz, Dinh Doan Van Bien
33

4-
#nullable enable
5-
64
namespace DocoptNet
75
{
86
using System.Collections.Generic;

src/DocoptNet/ArgValue.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed under terms of MIT license (see LICENSE-MIT)
22
// Copyright 2021 Atif Aziz, Dinh Doan Van Bien
33

4-
#nullable enable
5-
64
namespace DocoptNet
75
{
86
using System;

src/DocoptNet/ArgsParseOptions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed under terms of MIT license (see LICENSE-MIT)
22
// Copyright 2021 Atif Aziz, Dinh Doan Van Bien
33

4-
#nullable enable
5-
64
namespace DocoptNet
75
{
86
sealed partial class ArgsParseOptions

src/DocoptNet/CodeGeneration/CSharpSourceBuilder.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Licensed under terms of MIT license (see LICENSE-MIT)
22
// Copyright 2021 Atif Aziz, Dinh Doan Van Bien
33

4-
#nullable enable
5-
64
namespace DocoptNet.CodeGeneration
75
{
86
using System;

0 commit comments

Comments
 (0)