Skip to content

remove redundant nullable #4608

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions Source/Csla.Channels.RabbitMq/RabbitMqPortal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private async Task<DataPortalResponse> Create(CriteriaRequest request)
request = ConvertRequest(request);

// unpack criteria data into object
object? criteria = GetCriteria(_applicationContext, request.CriteriaData);
object criteria = GetCriteria(_applicationContext, request.CriteriaData);
if (criteria is DataPortalClient.PrimitiveCriteria primitiveCriteria)
{
criteria = primitiveCriteria.Value;
Expand Down Expand Up @@ -194,7 +194,7 @@ private async Task<DataPortalResponse> Fetch(CriteriaRequest request)
request = ConvertRequest(request);

// unpack criteria data into object
object? criteria = GetCriteria(_applicationContext, request.CriteriaData);
object criteria = GetCriteria(_applicationContext, request.CriteriaData);
if (criteria is DataPortalClient.PrimitiveCriteria primitiveCriteria)
{
criteria = primitiveCriteria.Value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private async Task InvokeTextPortal(string operation, Stream requestStream, Stre
var requestBuffer = new MemoryStream(requestArray);

var serializer = _applicationContext.GetRequiredService<ISerializationFormatter>();
DataPortalResponse? result = new DataPortalResponse();
DataPortalResponse result = new DataPortalResponse();
try
{
var request = await DeserializeRequestBody(requestBuffer, serializer);
Expand Down
2 changes: 1 addition & 1 deletion Source/Csla/Core/MobileBindingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected virtual void OnGetChildren(SerializationInfo info, MobileFormatter for
List<int> references = new List<int>();
for (int x = 0; x < Count; x++)
{
T? child = this[x];
T child = this[x];
if (child != null)
{
SerializationInfo childInfo = formatter.SerializeObject(child);
Expand Down
2 changes: 1 addition & 1 deletion Source/Csla/Core/MobileDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void IMobileObject.GetChildren(SerializationInfo info, MobileFormatter formatter
}
else
{
V? value = this[key];
V value = this[key];
info.AddValue(_valuePrefix + count, value);
}
count++;
Expand Down
2 changes: 1 addition & 1 deletion Source/Csla/Core/MobileObservableCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ protected virtual void OnGetChildren(SerializationInfo info, MobileFormatter for
List<int> references = new List<int>();
for (int x = 0; x < Count; x++)
{
T? child = this[x];
T child = this[x];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt this still be T?` because of the next line? Otherwise the check could be removed due to the missing annotation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no because MobileObservableCollection<T> has no notnull constraint.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But exactly because of that we have to assume it can be nullable.
So T? child is more correct than T. With T we don't express the possibility of the child being null so the compiler can help us avoiding possible null errors?

if (child != null)
{
SerializationInfo childInfo = formatter.SerializeObject(child);
Expand Down
2 changes: 1 addition & 1 deletion Source/Csla/Data/SafeDataReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ public object? this[string name]
if (string.IsNullOrWhiteSpace(name))
throw new ArgumentException(string.Format(Properties.Resources.StringNotNullOrWhiteSpaceException, nameof(name)), nameof(name));

object? val = DataReader[name];
object val = DataReader[name];
if (DBNull.Value.Equals(val))
return null;
else
Expand Down
Loading