Skip to content

Commit

Permalink
Add some nullable annotations to make API slightly nicer to work with
Browse files Browse the repository at this point in the history
  • Loading branch information
sbeca authored and jahav committed Apr 25, 2024
1 parent 2f8cd1e commit f99e96a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
5 changes: 2 additions & 3 deletions ClosedXML/Excel/IXLWorksheets.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#nullable disable

using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;

namespace ClosedXML.Excel
{
Expand Down Expand Up @@ -32,7 +31,7 @@ public interface IXLWorksheets : IEnumerable<IXLWorksheet>

void Delete(Int32 position);

bool TryGetWorksheet(string sheetName, out IXLWorksheet worksheet);
bool TryGetWorksheet(string sheetName, [NotNullWhen(true)] out IXLWorksheet? worksheet);

IXLWorksheet Worksheet(String sheetName);

Expand Down
5 changes: 3 additions & 2 deletions ClosedXML/Excel/XLWorksheets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;

namespace ClosedXML.Excel
Expand Down Expand Up @@ -50,7 +51,7 @@ public Boolean Contains(String sheetName)
return _worksheets.ContainsKey(sheetName);
}

bool IXLWorksheets.TryGetWorksheet(string sheetName, out IXLWorksheet? worksheet)
bool IXLWorksheets.TryGetWorksheet(string sheetName, [NotNullWhen(true)] out IXLWorksheet? worksheet)
{
if (TryGetWorksheet(sheetName, out var foundSheet))
{
Expand All @@ -62,7 +63,7 @@ bool IXLWorksheets.TryGetWorksheet(string sheetName, out IXLWorksheet? worksheet
return false;
}

internal bool TryGetWorksheet(string sheetName, out XLWorksheet? worksheet)
internal bool TryGetWorksheet(string sheetName, [NotNullWhen(true)] out XLWorksheet? worksheet)
{
if (_worksheets.TryGetValue(sheetName.UnescapeSheetName(), out worksheet))
{
Expand Down

0 comments on commit f99e96a

Please sign in to comment.