Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Commit 822e706

Browse files
committed
[Build] Enable nullable feature
1 parent 8810f0a commit 822e706

Some content is hidden

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

43 files changed

+213
-165
lines changed

src/Markdig.Wpf.SampleApp/Markdig.Wpf.SampleApp.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<AnalysisLevel>latest</AnalysisLevel>
1010
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1111
<LangVersion>9</LangVersion>
12+
<Nullable>enable</Nullable>
1213
</PropertyGroup>
1314
<ItemGroup>
1415
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />

src/Markdig.Wpf.SampleAppCustomized/Customized/LinkInlineRenderer.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
using Markdig.Syntax.Inlines;
1+
using System;
2+
3+
using Markdig.Syntax.Inlines;
24

35
namespace Markdig.Wpf.SampleAppCustomized.Customized
46
{
@@ -13,7 +15,7 @@ public LinkInlineRenderer(string linkpath)
1315

1416
protected override void Write(Renderers.WpfRenderer renderer, LinkInline link)
1517
{
16-
if (link.IsImage)
18+
if (link?.IsImage ?? throw new ArgumentNullException(nameof(link)))
1719
link.Url = _linkpath + link.Url;
1820

1921
base.Write(renderer, link);

src/Markdig.Wpf.SampleAppCustomized/Markdig.Wpf.SampleAppCustomized.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<AnalysisLevel>latest</AnalysisLevel>
1010
<EnableNETAnalyzers>true</EnableNETAnalyzers>
1111
<LangVersion>9</LangVersion>
12+
<Nullable>enable</Nullable>
1213
</PropertyGroup>
1314
<ItemGroup>
1415
<EmbeddedResource Update="Properties\Resources.resx" Generator="ResXFileCodeGenerator" LastGenOutput="Resources.Designer.cs" />

src/Markdig.Wpf/Annotations/CanBeNullAttribute.cs

Lines changed: 0 additions & 32 deletions
This file was deleted.

src/Markdig.Wpf/Annotations/NotNullAttribute.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/Markdig.Wpf/Markdig.Wpf.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<AnalysisLevel>latest</AnalysisLevel>
2929
<EnableNETAnalyzers>true</EnableNETAnalyzers>
3030
<LangVersion>9</LangVersion>
31+
<Nullable>enable</Nullable>
3132
</PropertyGroup>
3233
<PropertyGroup Condition=" '$(SignAssembly)' == 'true' ">
3334
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>

src/Markdig.Wpf/Markdown.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
using System;
66
using System.IO;
77
using System.Windows.Documents;
8-
using Markdig.Annotations;
98
using Markdig.Renderers;
109
using Markdig.Syntax;
1110

@@ -23,8 +22,7 @@ public static partial class Markdown
2322
/// <param name="pipeline">The pipeline used for the conversion.</param>
2423
/// <returns>The result of the conversion</returns>
2524
/// <exception cref="System.ArgumentNullException">if markdown variable is null</exception>
26-
[NotNull]
27-
public static FlowDocument ToFlowDocument([NotNull] string markdown, MarkdownPipeline pipeline = null, WpfRenderer renderer = null)
25+
public static FlowDocument ToFlowDocument(string markdown, MarkdownPipeline? pipeline = null, WpfRenderer? renderer = null)
2826
{
2927
if (markdown == null) throw new ArgumentNullException(nameof(markdown));
3028
pipeline = pipeline ?? new MarkdownPipelineBuilder().Build();
@@ -52,8 +50,7 @@ public static FlowDocument ToFlowDocument([NotNull] string markdown, MarkdownPip
5250
/// <param name="pipeline">The pipeline used for the conversion.</param>
5351
/// <returns>The result of the conversion</returns>
5452
/// <exception cref="ArgumentNullException">if markdown variable is null</exception>
55-
[NotNull]
56-
public static string ToXaml([NotNull] string markdown, [CanBeNull] MarkdownPipeline pipeline = null)
53+
public static string ToXaml(string markdown, MarkdownPipeline? pipeline = null)
5754
{
5855
if (markdown == null) throw new ArgumentNullException(nameof(markdown));
5956
using (var writer = new StringWriter())
@@ -71,8 +68,7 @@ public static string ToXaml([NotNull] string markdown, [CanBeNull] MarkdownPipel
7168
/// <param name="pipeline">The pipeline used for the conversion.</param>
7269
/// <returns>The Markdown document that has been parsed</returns>
7370
/// <exception cref="ArgumentNullException">if reader or writer variable are null</exception>
74-
public static MarkdownDocument ToXaml([NotNull] string markdown, [NotNull] TextWriter writer,
75-
[CanBeNull] MarkdownPipeline pipeline = null)
71+
public static MarkdownDocument ToXaml(string markdown, TextWriter writer, MarkdownPipeline? pipeline = null)
7672
{
7773
if (markdown == null) throw new ArgumentNullException(nameof(markdown));
7874
if (writer == null) throw new ArgumentNullException(nameof(writer));

src/Markdig.Wpf/MarkdownExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// See the LICENSE.md file in the project root for more information.
44

55
using System;
6-
using Markdig.Annotations;
76

87
// ReSharper disable once CheckNamespace
98
namespace Markdig.Wpf
@@ -18,7 +17,7 @@ public static class MarkdownExtensions
1817
/// </summary>
1918
/// <param name="pipeline">The pipeline.</param>
2019
/// <returns>The modified pipeline</returns>
21-
public static MarkdownPipelineBuilder UseSupportedExtensions([NotNull] this MarkdownPipelineBuilder pipeline)
20+
public static MarkdownPipelineBuilder UseSupportedExtensions(this MarkdownPipelineBuilder pipeline)
2221
{
2322
if (pipeline == null) throw new ArgumentNullException(nameof(pipeline));
2423
return pipeline

src/Markdig.Wpf/MarkdownViewer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static MarkdownViewer()
4343
/// <summary>
4444
/// Gets the flow document to display.
4545
/// </summary>
46-
public FlowDocument Document
46+
public FlowDocument? Document
4747
{
4848
get { return (FlowDocument)GetValue(DocumentProperty); }
4949
protected set { SetValue(DocumentPropertyKey, value); }
@@ -52,7 +52,7 @@ public FlowDocument Document
5252
/// <summary>
5353
/// Gets or sets the markdown to display.
5454
/// </summary>
55-
public string Markdown
55+
public string? Markdown
5656
{
5757
get { return (string)GetValue(MarkdownProperty); }
5858
set { SetValue(MarkdownProperty, value); }

src/Markdig.Wpf/Renderers/Wpf/CodeBlockRenderer.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,21 @@
22
// This file is licensed under the MIT license.
33
// See the LICENSE.md file in the project root for more information.
44

5+
using System;
56
using System.Windows;
67
using System.Windows.Documents;
7-
using Markdig.Annotations;
88
using Markdig.Syntax;
99
using Markdig.Wpf;
1010

1111
namespace Markdig.Renderers.Wpf
1212
{
1313
public class CodeBlockRenderer : WpfObjectRenderer<CodeBlock>
1414
{
15-
protected override void Write([NotNull] WpfRenderer renderer, [NotNull] CodeBlock obj)
15+
protected override void Write(WpfRenderer renderer, CodeBlock obj)
1616
{
17-
var paragraph = new Paragraph();
17+
if (renderer == null) throw new ArgumentNullException(nameof(renderer));
1818

19+
var paragraph = new Paragraph();
1920
paragraph.SetResourceReference(FrameworkContentElement.StyleProperty, Styles.CodeBlockStyleKey);
2021
renderer.Push(paragraph);
2122
renderer.WriteLeafRawLines(obj);

0 commit comments

Comments
 (0)