Skip to content

Commit f0e5cd8

Browse files
committed
Added support for nullable reference types
1 parent 5284fdd commit f0e5cd8

16 files changed

Lines changed: 90 additions & 92 deletions

src/Tesla.NET/Models/IChargeState.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ public interface IChargeState : IState
1515
/// Gets the charging state of a <see cref="IVehicle"/>.
1616
/// </summary>
1717
[JsonProperty("charging_state")]
18-
string ChargingState { get; }
18+
string? ChargingState { get; }
1919

2020
/// <summary>
2121
/// Gets the type of fast charging.
2222
/// </summary>
2323
[JsonProperty("fast_charger_type")]
24-
string FastChargerType { get; }
24+
string? FastChargerType { get; }
2525

2626
/// <summary>
2727
/// Gets the brand of fast charging.
2828
/// </summary>
2929
[JsonProperty("fast_charger_brand")]
30-
string FastChargerBrand { get; }
30+
string? FastChargerBrand { get; }
3131

3232
/// <summary>
3333
/// Gets the charge limit <see cref="IVehicle"/>.
@@ -171,7 +171,7 @@ public interface IChargeState : IState
171171
/// Gets the type of the charge cable connected to a <see cref="IVehicle"/>.
172172
/// </summary>
173173
[JsonProperty("conn_charge_cable")]
174-
string ConnChargeCable { get; }
174+
string? ConnChargeCable { get; }
175175

176176
/// <summary>
177177
/// Gets the schedule charging start time of a <see cref="IVehicle"/>.
@@ -213,7 +213,7 @@ public interface IChargeState : IState
213213
/// Gets the charge port latch of a <see cref="IVehicle"/>.
214214
/// </summary>
215215
[JsonProperty("charge_port_latch")]
216-
string ChargePortLatch { get; }
216+
string? ChargePortLatch { get; }
217217

218218
/// <summary>
219219
/// Gets the charge current request of a <see cref="IVehicle"/>.

src/Tesla.NET/Models/IDriveState.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ public interface IDriveState : IState
1515
/// Gets the shift state of a <see cref="IVehicle"/>.
1616
/// </summary>
1717
[JsonProperty("shift_state")]
18-
string ShiftState { get; }
18+
string? ShiftState { get; }
1919

2020
/// <summary>
2121
/// Gets the speed <see cref="IVehicle"/>.
2222
/// </summary>
2323
[JsonProperty("speed")]
24-
string Speed { get; }
24+
string? Speed { get; }
2525

2626
/// <summary>
2727
/// Gets the power <see cref="IVehicle"/>.

src/Tesla.NET/Models/IMessageResponse.Generic.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ public interface IMessageResponse<out TData> : IMessageResponse
1515
/// <summary>
1616
/// Gets the <typeparamref name="TData"/> object.
1717
/// </summary>
18-
TData Data { get; }
18+
TData? Data { get; }
1919
}
2020
}

src/Tesla.NET/Models/IMessageResponse.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public interface IMessageResponse
2020
/// <summary>
2121
/// Gets the raw JSON of the <see cref="IMessageResponse"/>.
2222
/// </summary>
23-
JObject RawJson { get; }
23+
JObject? RawJson { get; }
2424

2525
/// <summary>
2626
/// Gets the raw JSON of the <see cref="IMessageResponse"/>.

src/Tesla.NET/Models/IVehicle.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ public interface IVehicle
2727
/// Gets the VIN (vehicle identification number) of the <see cref="IVehicle"/>.
2828
/// </summary>
2929
[JsonProperty("vin")]
30-
string Vin { get; }
30+
string? Vin { get; }
3131

3232
/// <summary>
3333
/// Gets the display name of the <see cref="IVehicle"/>.
3434
/// </summary>
3535
[JsonProperty("display_name")]
36-
string DisplayName { get; }
36+
string? DisplayName { get; }
3737

3838
/// <summary>
3939
/// Gets the option codes of the <see cref="IVehicle"/>.
4040
/// </summary>
4141
[JsonProperty("option_codes")]
42-
string OptionCodes { get; }
42+
string? OptionCodes { get; }
4343

4444
/// <summary>
4545
/// Gets the color of the <see cref="IVehicle"/>.
4646
/// </summary>
4747
[JsonProperty("color")]
48-
string Color { get; }
48+
string? Color { get; }
4949

5050
/// <summary>
5151
/// Gets the tokens of the <see cref="IVehicle"/>.
@@ -57,13 +57,13 @@ public interface IVehicle
5757
/// Gets the state of the <see cref="IVehicle"/>.
5858
/// </summary>
5959
[JsonProperty("state")]
60-
string State { get; }
60+
string? State { get; }
6161

6262
/// <summary>
6363
/// Gets the in service state of the <see cref="IVehicle"/>.
6464
/// </summary>
6565
[JsonProperty("in_service")]
66-
string InService { get; }
66+
string? InService { get; }
6767

6868
/// <summary>
6969
/// Gets a value indicating whether remote start is enabled for the <see cref="IVehicle"/>.
@@ -87,12 +87,12 @@ public interface IVehicle
8787
/// Gets the <see cref="BackseatToken"/> of the <see cref="IVehicle"/>.
8888
/// </summary>
8989
[JsonProperty("backseat_token")]
90-
string BackseatToken { get; }
90+
string? BackseatToken { get; }
9191

9292
/// <summary>
9393
/// Gets the <see cref="BackseatTokenUpdatedAt"/> of the <see cref="IVehicle"/>.
9494
/// </summary>
9595
[JsonProperty("backseat_token_updated_at")]
96-
string BackseatTokenUpdatedAt { get; }
96+
string? BackseatTokenUpdatedAt { get; }
9797
}
9898
}

src/Tesla.NET/Models/IVehicleState.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@ public interface IVehicleState : IState
2121
/// Gets the state of auto-park.
2222
/// </summary>
2323
[JsonProperty("autopark_state")]
24-
string AutoparkState { get; }
24+
string? AutoparkState { get; }
2525

2626
/// <summary>
2727
/// Gets the state of V2 auto-park.
2828
/// </summary>
2929
[JsonProperty("autopark_state_v2")]
30-
string AutoparkStateV2 { get; }
30+
string? AutoparkStateV2 { get; }
3131

3232
/// <summary>
3333
/// Gets the style of auto-park.
3434
/// </summary>
3535
[JsonProperty("autopark_style")]
36-
string AutoparkStyle { get; }
36+
string? AutoparkStyle { get; }
3737

3838
/// <summary>
3939
/// Gets a value indicating whether the Calendar is supported.
@@ -45,7 +45,7 @@ public interface IVehicleState : IState
4545
/// Gets the car firmware version.
4646
/// </summary>
4747
[JsonProperty("car_version")]
48-
string CarVersion { get; }
48+
string? CarVersion { get; }
4949

5050
/// <summary>
5151
/// Gets the state of the center display.
@@ -81,7 +81,7 @@ public interface IVehicleState : IState
8181
/// Gets the last auto-park error.
8282
/// </summary>
8383
[JsonProperty("last_autopark_error")]
84-
string LastAutoparkError { get; }
84+
string? LastAutoparkError { get; }
8585

8686
/// <summary>
8787
/// Gets a value indicating whether the car is locked.
@@ -147,7 +147,7 @@ public interface IVehicleState : IState
147147
/// Gets the state of the sunroof.
148148
/// </summary>
149149
[JsonProperty("sun_roof_state")]
150-
string SunRoofState { get; }
150+
string? SunRoofState { get; }
151151

152152
/// <summary>
153153
/// Gets a value indicating whether valet mode is enabled.
@@ -165,6 +165,6 @@ public interface IVehicleState : IState
165165
/// Gets the name of the <see cref="IVehicle"/>.
166166
/// </summary>
167167
[JsonProperty("vehicle_name")]
168-
string VehicleName { get; }
168+
string? VehicleName { get; }
169169
}
170170
}

src/Tesla.NET/Models/Internal/ChargeState.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ public class ChargeState : IChargeState
5858
/// <param name="notEnoughPowerToHeat">The <see cref="NotEnoughPowerToHeat"/>.</param>
5959
/// <param name="timestamp">The <see cref="Timestamp"/>.</param>
6060
public ChargeState(
61-
string chargingState = null,
62-
string fastChargerType = null,
63-
string fastChargerBrand = null,
61+
string? chargingState = null,
62+
string? fastChargerType = null,
63+
string? fastChargerBrand = null,
6464
long? chargeLimitSoc = null,
6565
long? chargeLimitSocStd = null,
6666
long? chargeLimitSocMin = null,
@@ -84,13 +84,13 @@ public ChargeState(
8484
bool? tripCharging = null,
8585
long? chargeRate = null,
8686
bool? chargePortDoorOpen = null,
87-
string connChargeCable = null,
87+
string? connChargeCable = null,
8888
long? scheduledChargingStartTime = null,
8989
bool? scheduledChargingPending = null,
9090
bool? userChargeEnableRequest = null,
9191
bool? chargeEnableRequest = null,
9292
int? chargerPhases = null,
93-
string chargePortLatch = null,
93+
string? chargePortLatch = null,
9494
long? chargeCurrentRequest = null,
9595
long? chargeCurrentRequestMax = null,
9696
bool? managedChargingActive = null,
@@ -146,17 +146,17 @@ public ChargeState(
146146
/// <summary>
147147
/// Gets the charging state of a <see cref="IVehicle"/>.
148148
/// </summary>
149-
public string ChargingState { get; }
149+
public string? ChargingState { get; }
150150

151151
/// <summary>
152152
/// Gets the type of fast charging.
153153
/// </summary>
154-
public string FastChargerType { get; }
154+
public string? FastChargerType { get; }
155155

156156
/// <summary>
157157
/// Gets the brand of fast charging.
158158
/// </summary>
159-
public string FastChargerBrand { get; }
159+
public string? FastChargerBrand { get; }
160160

161161
/// <summary>
162162
/// Gets the charge limit <see cref="IVehicle"/>.
@@ -276,7 +276,7 @@ public ChargeState(
276276
/// <summary>
277277
/// Gets the type of the charge cable connected to a <see cref="IVehicle"/>.
278278
/// </summary>
279-
public string ConnChargeCable { get; }
279+
public string? ConnChargeCable { get; }
280280

281281
/// <summary>
282282
/// Gets the schedule charging start time of a <see cref="IVehicle"/>.
@@ -311,7 +311,7 @@ public ChargeState(
311311
/// <summary>
312312
/// Gets the charge port latch of a <see cref="IVehicle"/>.
313313
/// </summary>
314-
public string ChargePortLatch { get; }
314+
public string? ChargePortLatch { get; }
315315

316316
/// <summary>
317317
/// Gets the charge current request of a <see cref="IVehicle"/>.

src/Tesla.NET/Models/Internal/DriveState.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ public class DriveState : IDriveState
2424
/// <param name="gpsAsOf">The <see cref="GpsAsOf"/>.</param>
2525
/// <param name="timestamp">The <see cref="Timestamp"/>.</param>
2626
public DriveState(
27-
string shiftState = null,
28-
string speed = null,
27+
string? shiftState = null,
28+
string? speed = null,
2929
long power = 0L,
3030
double latitude = 0D,
3131
double longitude = 0D,
@@ -46,12 +46,12 @@ public DriveState(
4646
/// <summary>
4747
/// Gets the shift state of a <see cref="IVehicle"/>.
4848
/// </summary>
49-
public string ShiftState { get; }
49+
public string? ShiftState { get; }
5050

5151
/// <summary>
5252
/// Gets the speed <see cref="IVehicle"/>.
5353
/// </summary>
54-
public string Speed { get; }
54+
public string? Speed { get; }
5555

5656
/// <summary>
5757
/// Gets the power <see cref="IVehicle"/>.

src/Tesla.NET/Models/Internal/MessageResponse.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ namespace Tesla.NET.Models.Internal
1717
public class MessageResponse<TData> : IMessageResponse<TData>
1818
where TData : class
1919
{
20-
private readonly JObject _rawJson;
20+
private readonly JObject? _rawJson;
2121

2222
/// <summary>
2323
/// Initializes a new instance of the <see cref="MessageResponse{TData}"/> class.
2424
/// </summary>
2525
/// <param name="httpStatusCode">The <see cref="HttpStatusCode"/>.</param>
2626
/// <param name="rawJson">The raw JSON of the <see cref="Data"/>.</param>
2727
/// <param name="data">The <see cref="Data"/> object.</param>
28-
public MessageResponse(HttpStatusCode httpStatusCode, JObject rawJson = null, TData data = null)
28+
public MessageResponse(HttpStatusCode httpStatusCode, JObject? rawJson = null, TData? data = null)
2929
{
3030
HttpStatusCode = httpStatusCode;
3131
_rawJson = rawJson;
@@ -40,7 +40,7 @@ public MessageResponse(HttpStatusCode httpStatusCode, JObject rawJson = null, TD
4040
/// <summary>
4141
/// Gets the raw JSON of the <see cref="IMessageResponse"/>.
4242
/// </summary>
43-
public JObject RawJson => (JObject)_rawJson?.DeepClone();
43+
public JObject? RawJson => (JObject?)_rawJson?.DeepClone();
4444

4545
/// <summary>
4646
/// Gets the raw JSON of the <see cref="IMessageResponse"/>.
@@ -50,7 +50,7 @@ public MessageResponse(HttpStatusCode httpStatusCode, JObject rawJson = null, TD
5050
/// <summary>
5151
/// Gets the <typeparamref name="TData"/> object.
5252
/// </summary>
53-
public TData Data { get; }
53+
public TData? Data { get; }
5454

5555
private string DebuggerDisplay => $"{GetType().Name}: {HttpStatusCode:G}";
5656
}

0 commit comments

Comments
 (0)