Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Group 3] Enable nullable annotations for Microsoft.Extensions.Configuration.Tests #57422

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/libraries/Common/tests/Extensions/ConfigurationRootTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void ChainedConfigurationIsDisposed(bool shouldDispose)

Assert.False(provider.IsDisposed);

(config as IDisposable).Dispose();
(config as IDisposable)?.Dispose();

Assert.Equal(shouldDispose, provider.IsDisposed);
}
Expand All @@ -95,13 +95,13 @@ public void Dispose()

public class ChangeToken : IChangeToken
{
public List<(Action<object>, object)> Callbacks { get; } = new List<(Action<object>, object)>();
public List<(Action<object?>, object?)> Callbacks { get; } = new List<(Action<object?>, object?)>();

public bool HasChanged => false;

public bool ActiveChangeCallbacks => true;

public IDisposable RegisterChangeCallback(Action<object> callback, object state)
public IDisposable RegisterChangeCallback(Action<object?> callback, object? state)
{
var item = (callback, state);
Callbacks.Add(item);
Expand All @@ -110,9 +110,9 @@ public IDisposable RegisterChangeCallback(Action<object> callback, object state)

private class DisposableAction : IDisposable
{
private Action _action;
private Action? _action;

public DisposableAction(Action action)
public DisposableAction(Action? action)
{
_action = action;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,68 +12,32 @@ public static class TestStreamHelpers
{
public static readonly string ArbitraryFilePath = "Unit tests do not touch file system";

public static IFileProvider StringToFileProvider(string str)
public static IFileProvider StringToFileProvider(string? str)
{
return new TestFileProvider(str);

}

private class TestFile : IFileInfo
{
private readonly string _data;
private readonly string? _data;

public TestFile(string str)
public TestFile(string? str)
{
_data = str;
}

public bool Exists
{
get
{
return true;
}
}
public bool Exists => true;

public bool IsDirectory
{
get
{
return false;
}
}
public bool IsDirectory => false;

public DateTimeOffset LastModified
{
get
{
throw new NotImplementedException();
}
}
public DateTimeOffset LastModified => throw new NotImplementedException();

public long Length
{
get
{
return 0;
}
}
public long Length => 0;

public string Name
{
get
{
return null;
}
}
public string Name => string.Empty;

public string PhysicalPath
{
get
{
return null;
}
}
public string? PhysicalPath => null;

public Stream CreateReadStream()
{
Expand All @@ -83,13 +47,13 @@ public Stream CreateReadStream()

private class TestFileProvider : IFileProvider
{
private string _data;
public TestFileProvider(string str)
private string? _data;
public TestFileProvider(string? str)
{
_data = str;
}

public IDirectoryContents GetDirectoryContents(string subpath)
public IDirectoryContents GetDirectoryContents(string? subpath)
{
throw new NotImplementedException();
}
Expand All @@ -99,13 +63,13 @@ public IFileInfo GetFileInfo(string subpath)
return new TestFile(_data);
}

public IChangeToken Watch(string filter)
public IChangeToken Watch(string? filter)
{
throw new NotImplementedException();
}
}

public static Stream StringToStream(string str)
public static Stream StringToStream(string? str)
{
var memStream = new MemoryStream();
var textWriter = new StreamWriter(memStream);
Expand Down
Loading