Skip to content

Commit c6777ea

Browse files
committed
Add nullable & implicit usings
1 parent 81833cc commit c6777ea

37 files changed

+164
-197
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ bool IsValidTwilioRequest(HttpContext httpContext)
552552
?.Value ?? throw new Exception("TwilioRequestValidationOptions missing.");
553553

554554
string? urlOverride = null;
555-
if (options.BaseUrlOverride != null)
555+
if (options.BaseUrlOverride is not null)
556556
{
557557
var request = httpContext.Request;
558558
urlOverride = $"{options.BaseUrlOverride.TrimEnd('/')}{request.Path}{request.QueryString}";

src/Twilio.AspNet.Common/SmsRequest.cs

+8-7
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,33 @@ public class SmsRequest : TwilioRequest
99
/// <summary>
1010
/// A 34 character unique identifier for the message. May be used to later retrieve this message from the REST API.
1111
/// </summary>
12-
public string MessageSid { get; set; }
13-
12+
public string MessageSid { get; set; } = null!;
13+
1414
/// <summary>
1515
/// Same value as MessageSid. Deprecated and included for backward compatibility.
1616
/// </summary>
17-
public string SmsSid { get; set; }
17+
[Obsolete("Use MessageSid instead")]
18+
public string SmsSid { get; set; }= null!;
1819

1920
/// <summary>
2021
/// The text body of the SMS message. Up to 160 characters long
2122
/// </summary>
22-
public string Body { get; set; }
23+
public string Body { get; set; }= null!;
2324

2425
/// <summary>
2526
/// The status of the message
2627
/// </summary>
27-
public string MessageStatus { get; set; }
28+
public string MessageStatus { get; set; }= null!;
2829

2930
/// <summary>
3031
/// The message OptOut type
3132
/// </summary>
32-
public string OptOutType { get; set; }
33+
public string? OptOutType { get; set; }
3334

3435
/// <summary>
3536
/// A unique identifier of the messaging service
3637
/// </summary>
37-
public string MessagingServiceSid { get; set; }
38+
public string? MessagingServiceSid { get; set; }
3839

3940
/// <summary>
4041
/// The number of media items associated with your message

src/Twilio.AspNet.Common/SmsStatusCallbackRequest.cs

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,32 +9,32 @@ public class SmsStatusCallbackRequest: SmsRequest
99
/// will be present. Find the possible values here:
1010
/// https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors
1111
/// </summary>
12-
public string ErrorCode { get; set; }
12+
public string? ErrorCode { get; set; }
1313

1414
/// <summary>
1515
/// The Installed Channel SID (found on the Channel detail page) that was
1616
/// used to send this message. Only present if the message was sent using a
1717
/// Channel.
1818
/// </summary>
19-
public string ChannelInstallSid { get; set; }
19+
public string? ChannelInstallSid { get; set; }
2020

2121
/// <summary>
2222
/// The Error message returned by the underlying Channel if Message delivery
2323
/// failed. Only present if the message was sent using a Channel and message
2424
/// delivery failed.
2525
/// </summary>
26-
public string ChannelStatusMessage { get; set; }
26+
public string? ChannelStatusMessage { get; set; }
2727

2828
/// <summary>
2929
/// Channel specific prefix that allows you to identify which channel this
3030
/// message was sent over.
3131
/// </summary>
32-
public string ChannelPrefix { get; set; }
32+
public string? ChannelPrefix { get; set; }
3333

3434
/// <summary>
3535
/// Contains post-delivery events. If the Channel supports Read receipts, this
3636
/// parameter will be included with a value of READ after the user has read
3737
/// the message. Currently supported only for WhatsApp.
3838
/// </summary>
39-
public string EventType { get; set; }
39+
public string? EventType { get; set; }
4040
}

src/Twilio.AspNet.Common/StatusCallbackRequest.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class StatusCallbackRequest : VoiceRequest
1111
/// </summary>
1212
public float CallDuration { get; set; }
1313

14-
public string Called { get; set; }
15-
public string Caller { get; set; }
14+
public string? Called { get; set; }
15+
public string? Caller { get; set; }
1616
public float Duration { get; set; }
1717
}

src/Twilio.AspNet.Common/Twilio.AspNet.Common.csproj

+3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<PropertyGroup>
33
<TargetFramework>netstandard2.0</TargetFramework>
44
<LangVersion>13</LangVersion>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
57
<OutputType>Library</OutputType>
68
<Version>0.0.0-alpha</Version>
79
<PackageId>Twilio.AspNet.Common</PackageId>
@@ -15,6 +17,7 @@
1517
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
1618
<PackageProjectUrl>https://github.com/twilio/twilio-aspnet</PackageProjectUrl>
1719
<RepositoryUrl>https://github.com/twilio-labs/twilio-aspnet.git</RepositoryUrl>
20+
<RepositoryType>git</RepositoryType>
1821
<PackageIconUrl>https://s3.amazonaws.com/com.twilio.prod.twilio-docs/images/twilio-icon-64x64.png</PackageIconUrl>
1922
<PackageIcon>icon.png</PackageIcon>
2023
<PackageReadmeFile>README.md</PackageReadmeFile>

src/Twilio.AspNet.Common/TwilioRequest.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -8,61 +8,61 @@ public abstract class TwilioRequest
88
/// <summary>
99
/// Your Twilio account id. It is 34 characters long, and always starts with the letters AC
1010
/// </summary>
11-
public string AccountSid { get; set; }
11+
public string AccountSid { get; set; } = null!;
1212

1313
/// <summary>
1414
/// The phone number or client identifier of the party that initiated the call
1515
/// </summary>
1616
/// <remarks>
1717
/// Phone numbers are formatted with a '+' and country code, e.g. +16175551212 (E.164 format). Client identifiers begin with the client: URI scheme; for example, for a call from a client named 'tommy', the From parameter will be client:tommy.
1818
/// </remarks>
19-
public string From { get; set; }
19+
public string From { get; set; } = null!;
2020

2121
/// <summary>
2222
/// The phone number or client identifier of the called party
2323
/// </summary>
2424
/// <remarks>
2525
/// Phone numbers are formatted with a '+' and country code, e.g. +16175551212 (E.164 format). Client identifiers begin with the client: URI scheme; for example, for a call to a client named 'jenny', the To parameter will be client:jenny.
2626
/// </remarks>
27-
public string To { get; set; }
27+
public string To { get; set; } = null!;
2828

2929
/// <summary>
3030
/// The city of the caller
3131
/// </summary>
32-
public string FromCity { get; set; }
32+
public string? FromCity { get; set; }
3333

3434
/// <summary>
3535
/// The state or province of the caller
3636
/// </summary>
37-
public string FromState { get; set; }
37+
public string? FromState { get; set; }
3838

3939
/// <summary>
4040
/// The postal code of the caller
4141
/// </summary>
42-
public string FromZip { get; set; }
42+
public string? FromZip { get; set; }
4343

4444
/// <summary>
4545
/// The country of the caller
4646
/// </summary>
47-
public string FromCountry { get; set; }
47+
public string? FromCountry { get; set; }
4848

4949
/// <summary>
5050
/// The city of the called party
5151
/// </summary>
52-
public string ToCity { get; set; }
52+
public string? ToCity { get; set; }
5353

5454
/// <summary>
5555
/// The state or province of the called party
5656
/// </summary>
57-
public string ToState { get; set; }
57+
public string? ToState { get; set; }
5858

5959
/// <summary>
6060
/// The postal code of the called party
6161
/// </summary>
62-
public string ToZip { get; set; }
62+
public string? ToZip { get; set; }
6363

6464
/// <summary>
6565
/// The country of the called party
6666
/// </summary>
67-
public string ToCountry { get; set; }
67+
public string? ToCountry { get; set; }
6868
}

src/Twilio.AspNet.Common/VoiceRequest.cs

+27-27
Original file line numberDiff line numberDiff line change
@@ -9,53 +9,53 @@ public class VoiceRequest : TwilioRequest
99
/// <summary>
1010
/// A unique identifier for this call, generated by Twilio
1111
/// </summary>
12-
public string CallSid { get; set; }
12+
public string CallSid { get; set; } = null!;
1313

1414
/// <summary>
1515
/// A descriptive status for the call. The value is one of queued, ringing, in-progress, completed, busy, failed or no-answer
1616
/// </summary>
17-
public string CallStatus { get; set; }
17+
public string CallStatus { get; set; } = null!;
1818

1919
/// <summary>
2020
/// The version of the Twilio API used to handle this call. For incoming calls, this is determined by the API version set on the called number. For outgoing calls, this is the API version used by the outgoing call's REST API request
2121
/// </summary>
22-
public string ApiVersion { get; set; }
22+
public string ApiVersion { get; set; } = null!;
2323

2424
/// <summary>
2525
/// Indicates the direction of the call. In most cases this will be inbound, but if you are using Dial it will be outbound-dial
2626
/// </summary>
27-
public string Direction { get; set; }
27+
public string Direction { get; set; } = null!;
2828

2929
/// <summary>
3030
/// This parameter is set only when Twilio receives a forwarded call, but its value depends on the caller's carrier including information when forwarding. Not all carriers support passing this information
3131
/// </summary>
32-
public string ForwardedFrom { get; set; }
32+
public string? ForwardedFrom { get; set; }
3333

3434
/// <summary>
3535
/// This parameter is set when the IncomingPhoneNumber that received the call has had its VoiceCallerIdLookup value set to true.
3636
/// </summary>
37-
public string CallerName { get; set; }
37+
public string? CallerName { get; set; }
3838

3939
/// <summary>
4040
/// A unique identifier for the call that created this leg. This parameter is not passed if this is the first leg of a call.
4141
/// </summary>
42-
public string ParentCallSid { get; set; }
42+
public string? ParentCallSid { get; set; }
4343

4444
/// <summary>A token string needed to invoke a forwarded call.</summary>
45-
public string CallToken { get; set; }
45+
public string? CallToken { get; set; }
4646

4747
#region Gather & Record Parameters
4848

4949
/// <summary>
5050
/// When used with the Gather verb, the digits the caller pressed, excluding the finishOnKey digit if used.
5151
/// When used with the Record verb, the key (if any) pressed to end the recording or 'hangup' if the caller hung up
5252
/// </summary>
53-
public string Digits { get; set; }
53+
public string? Digits { get; set; }
5454

5555
/// <summary>
5656
/// When used with the Gather verb, the transcribed result of the speech
5757
/// </summary>
58-
public string SpeechResult { get; set; }
58+
public string? SpeechResult { get; set; }
5959

6060
/// <summary>
6161
/// When used with the Gather verb, a confidence score between 0.0 and 1.0 respectively.
@@ -66,17 +66,17 @@ public class VoiceRequest : TwilioRequest
6666
/// <summary>
6767
/// The URL of the recorded audio. When the result of a transcription, the URL for the transcription's source recording resource.
6868
/// </summary>
69-
public string RecordingUrl { get; set; }
69+
public string? RecordingUrl { get; set; }
7070

7171
/// <summary>
7272
/// The status of the recording. Possible values are: completed, failed.
7373
/// </summary>
74-
public string RecordingStatus { get; set; }
74+
public string? RecordingStatus { get; set; }
7575

7676
/// <summary>
7777
/// The duration of the recorded audio (in seconds)
7878
/// </summary>
79-
public string RecordingDuration { get; set; }
79+
public string? RecordingDuration { get; set; }
8080

8181
/// <summary>
8282
/// The number of channels in the final recording file as an integer.
@@ -86,12 +86,12 @@ public class VoiceRequest : TwilioRequest
8686
/// <summary>
8787
/// The source of the recorded audio.
8888
/// </summary>
89-
public string RecordingSource { get; set; }
89+
public string? RecordingSource { get; set; }
9090

9191
/// <summary>
9292
/// The key used to submit the digits
9393
/// </summary>
94-
public string FinishedOnKey { get; set; }
94+
public string? FinishedOnKey { get; set; }
9595

9696
#endregion
9797

@@ -100,27 +100,27 @@ public class VoiceRequest : TwilioRequest
100100
/// <summary>
101101
/// The unique 34 character ID of the transcription
102102
/// </summary>
103-
public string TranscriptionSid { get; set; }
103+
public string? TranscriptionSid { get; set; }
104104

105105
/// <summary>
106106
/// Contains the text of the transcription
107107
/// </summary>
108-
public string TranscriptionText { get; set; }
108+
public string? TranscriptionText { get; set; }
109109

110110
/// <summary>
111111
/// The status of the transcription attempt: either 'completed' or 'failed'
112112
/// </summary>
113-
public string TranscriptionStatus { get; set; }
113+
public string? TranscriptionStatus { get; set; }
114114

115115
/// <summary>
116116
/// The URL for the transcription's REST API resource
117117
/// </summary>
118-
public string TranscriptionUrl { get; set; }
118+
public string? TranscriptionUrl { get; set; }
119119

120120
/// <summary>
121121
/// The unique 34 character ID of the recording from which the transcription was generated
122122
/// </summary>
123-
public string RecordingSid { get; set; }
123+
public string? RecordingSid { get; set; }
124124

125125
#endregion
126126

@@ -129,17 +129,17 @@ public class VoiceRequest : TwilioRequest
129129
/// <summary>
130130
/// The outcome of the Dial attempt. See the DialCallStatus section below for details
131131
/// </summary>
132-
public string DialCallStatus { get; set; }
132+
public string? DialCallStatus { get; set; }
133133

134134
/// <summary>
135135
/// The call sid of the new call leg. This parameter is not sent after dialing a conference
136136
/// </summary>
137-
public string DialCallSid { get; set; }
137+
public string? DialCallSid { get; set; }
138138

139139
/// <summary>
140140
/// The duration in seconds of the dialed call. This parameter is not sent after dialing a conference
141141
/// </summary>
142-
public string DialCallDuration { get; set; }
142+
public string? DialCallDuration { get; set; }
143143

144144
#endregion
145145

@@ -148,22 +148,22 @@ public class VoiceRequest : TwilioRequest
148148
/// <summary>
149149
/// The Twilio SIP Domain to which the INVITE was sent
150150
/// </summary>
151-
public string SipDomain { get; set; }
151+
public string? SipDomain { get; set; }
152152

153153
/// <summary>
154154
/// The username given when authenticating the request, if Credential List is the authentication method.
155155
/// </summary>
156-
public string SipUsername { get; set; }
156+
public string? SipUsername { get; set; }
157157

158158
/// <summary>
159159
/// The Call-Id of the incoming INVITE
160160
/// </summary>
161-
public string SipCallId { get; set; }
161+
public string? SipCallId { get; set; }
162162

163163
/// <summary>
164164
/// The IP Address the incoming INVITE came from.
165165
/// </summary>
166-
public string SipSourceIp { get; set; }
166+
public string? SipSourceIp { get; set; }
167167

168168
#endregion
169169
}

0 commit comments

Comments
 (0)