Conversation
e7a31be to
8112d39
Compare
8112d39 to
1feaa17
Compare
minichma
left a comment
There was a problem hiding this comment.
Wow, that's a lot of changes. LGTM, just a few thoughts. Skimmed over the code only very briefly though.
| var uriValue = Decode(a, attachment); | ||
| a.Uri = new Uri(uriValue, UriKind.RelativeOrAbsolute); | ||
|
|
||
| if (string.IsNullOrEmpty(uriValue)) return null; |
There was a problem hiding this comment.
Not sure, returning null is the best option here, is it? Anyhow, it's a functional change, right?
There was a problem hiding this comment.
I will have another look.
Not sure, returning null is the best option
I believe returning null to avoid throwing exceptions is overused in the codebase. Methods like TryGet(...) would have been a better alternative to returning a NRT. That said, enabling nullable has introduced more null checks but reduced overall coverage. However, this investment will pay off in terms of future code quality.
I've migrated projects to NRT several times, but this particular migration significantly exceeded my initial workload estimates. And that's without the unit tests still ahead of us.
There was a problem hiding this comment.
returned value can't be null here, will update the code.
Even if the uriValue were null, it would throw, then the exception is eaten up and null ist returned anyway
| try | ||
| { | ||
| var a = CreateAndAssociate() as Attendee; | ||
| if (CreateAndAssociate() is not Attendee a) return null; |
There was a problem hiding this comment.
We have different implementations using this pattern. Leave the current behavior for now.
|
|
||
| var uriString = Unescape(Decode(a, attendee)); | ||
|
|
||
| if (uriString == null) return a; |
There was a problem hiding this comment.
Here the behavior is different to AttachmentSerializer, where we return null. I think, this way is better.
There was a problem hiding this comment.
Returned value can't be null here when args are not null.
|
|
||
| public override object Deserialize(TextReader tr) => Deserialize(tr.ReadToEnd()); | ||
| } No newline at end of file | ||
| public override object? Deserialize(TextReader? tr) => tr != null ? Deserialize(tr.ReadToEnd()) : null; |
There was a problem hiding this comment.
Why would it be allowed to pass null as the TextReader? Rather make it not nullable?
There was a problem hiding this comment.
It's because of overriding the base method, SerializeToString(object? obj) which is nullable
| rawOffset = rawOffset.Substring(1, rawOffset.Length - 1); | ||
| } | ||
| // Supported formats | ||
| var formats = new[] { "hhmmss", "hhmm", "hh" }; |
There was a problem hiding this comment.
Could be declared as static property or field
| try | ||
| { | ||
| var name = Enum.GetName(typeof(DayOfWeek), ds.DayOfWeek); | ||
| value += name!.ToUpper().Substring(0, 2); |
There was a problem hiding this comment.
If name is null, it would throw and be catched silently, which is ok, but not too readable. Handle explicitly?
There was a problem hiding this comment.
Agree, if (name == null) return null; is more readable
|



DataTypeSerializerFactorysimplifiedUtcOffsetSerializer.GetOffset(string)simplified