Skip to content

Commit c50bc8f

Browse files
committed
adjusted null syntax
1 parent 4e0993c commit c50bc8f

7 files changed

Lines changed: 9 additions & 7 deletions

File tree

Asn1Parser/Asn1InvalidTagException.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public Asn1InvalidTagException(String message, Exception innerException) : base(
3939
/// <param name="info">The object that holds the serialized object data.</param>
4040
/// <param name="context">The contextual information about the source or destination.</param>
4141
/// <remarks>This constructor is called during deserialization to reconstitute the exception object transmitted over a stream.</remarks>
42+
[Obsolete("This overload is obsolete by SYSLIB0051.", true)]
4243
public Asn1InvalidTagException(SerializationInfo info, StreamingContext context) : base(info, context) { }
4344
/// <summary>
4445
/// Gets the offset at which invalid ASN tag appear.

Asn1Parser/Asn1Reader.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ public void MoveNextSiblingAndExpectTags(params Asn1Type[] expectedTags) {
537537
/// method calls are not necessary.
538538
/// </remarks>
539539
public Boolean Seek(Int32 newPosition) {
540-
if (!_offsetMap.TryGetValue(newPosition, out AsnInternalMap value)) {
540+
if (!_offsetMap.TryGetValue(newPosition, out AsnInternalMap? value)) {
541541
return false;
542542
}
543543
currentPosition = value;

Asn1Parser/Asn1Utils.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,11 @@ public static Asn1Reader EncodeAsReader(ReadOnlySpan<Byte> rawData, Byte enclosi
187187

188188
#region internal
189189
public static String GetViewValue(Asn1Reader asn) {
190-
if (asn.PayloadLength == 0 && asn.Tag != (Byte)Asn1Type.NULL) { return "NULL"; }
190+
if (asn.PayloadLength == 0 && asn.Tag != (Byte)Asn1Type.NULL) {
191+
return "NULL";
192+
}
191193

192194
return asn.Tag switch {
193-
194195
(Byte)Asn1Type.BOOLEAN => new Asn1Boolean(asn).Value.ToString(),
195196
(Byte)Asn1Type.INTEGER => new Asn1Integer(asn).Value.ToString(),
196197
(Byte)Asn1Type.BIT_STRING => decodeBitString(asn),

Asn1Parser/AsnFormatter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public static String BinaryToString(Asn1Reader asn, EncodingType encoding = Enco
105105
/// </para>
106106
/// </remarks>
107107
public static Byte[] StringToBinary(String input, EncodingType encoding = EncodingType.Base64) {
108-
Byte[] rawData;
108+
Byte[]? rawData;
109109
if (PemHeader.ContainsEncoding(encoding)) {
110110
var pemHeader = PemHeader.GetHeader(encoding);
111111
rawData = StringToBinaryFormatter.FromBase64Header(input, pemHeader.GetHeader(), pemHeader.GetFooter());

Asn1Parser/Universal/Asn1DateTime.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void m_encode(Asn1Type type, DateTime time, TimeZoneInfo? zone, Boolean preciseT
5454
void m_decode(ReadOnlyMemory<Byte> rawData) {
5555
var asn = new Asn1Reader(rawData);
5656
Initialize(asn);
57-
Value = DateTimeUtils.Decode(asn, out TimeZoneInfo zoneInfo);
57+
Value = DateTimeUtils.Decode(asn, out TimeZoneInfo? zoneInfo);
5858
ZoneInfo = zoneInfo;
5959
}
6060

Asn1Parser/Universal/Asn1ObjectIdentifier.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static Boolean validateOidString(String oid, out List<BigInteger> tokens) {
170170
/// <inheritdoc/>
171171
public override String GetDisplayValue() {
172172
return String.IsNullOrEmpty(Value.FriendlyName)
173-
? Value.Value
173+
? Value.Value!
174174
: $"{Value.FriendlyName} ({Value.Value})";
175175
}
176176
}

Asn1Parser/Universal/Asn1String.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public static Asn1String DecodeAnyString(ReadOnlyMemory<Byte> rawData, IEnumerab
8888
throw new ArgumentException("Raw data must have at least tag (1 byte) and length components (1 byte) in TLV structure.");
8989
}
9090

91-
IEnumerable<Asn1Type> asn1Types = allowedStringTypes?.ToList();
91+
IEnumerable<Asn1Type>? asn1Types = allowedStringTypes?.ToList();
9292
if (asn1Types is not null && !asn1Types.Contains((Asn1Type)rawData.Span[0])) {
9393
throw new ArgumentException("Input string is not permitted by restriction.");
9494
}

0 commit comments

Comments
 (0)