Use more verbatim strings

This commit is contained in:
Dan Balasescu 2022-10-28 16:32:17 +09:00
parent 2f731f86ba
commit efa8256911
10 changed files with 25 additions and 22 deletions

View File

@ -7,6 +7,6 @@ namespace osu.Game.Online.API.Requests
{ {
public class GetNotificationsRequest : APIRequest<APINotificationsBundle> public class GetNotificationsRequest : APIRequest<APINotificationsBundle>
{ {
protected override string Target => "notifications"; protected override string Target => @"notifications";
} }
} }

View File

@ -10,28 +10,28 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonObject(MemberSerialization.OptIn)] [JsonObject(MemberSerialization.OptIn)]
public class APINotification public class APINotification
{ {
[JsonProperty("id")] [JsonProperty(@"id")]
public long Id { get; set; } public long Id { get; set; }
[JsonProperty("name")] [JsonProperty(@"name")]
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
[JsonProperty("created_at")] [JsonProperty(@"created_at")]
public DateTimeOffset? CreatedAt { get; set; } public DateTimeOffset? CreatedAt { get; set; }
[JsonProperty("object_type")] [JsonProperty(@"object_type")]
public string ObjectType { get; set; } = null!; public string ObjectType { get; set; } = null!;
[JsonProperty("object_id")] [JsonProperty(@"object_id")]
public string ObjectId { get; set; } = null!; public string ObjectId { get; set; } = null!;
[JsonProperty("source_user_id")] [JsonProperty(@"source_user_id")]
public long? SourceUserId { get; set; } public long? SourceUserId { get; set; }
[JsonProperty("is_read")] [JsonProperty(@"is_read")]
public bool IsRead { get; set; } public bool IsRead { get; set; }
[JsonProperty("details")] [JsonProperty(@"details")]
public Dictionary<string, string>? Details { get; set; } public Dictionary<string, string>? Details { get; set; }
} }
} }

View File

@ -8,13 +8,13 @@ namespace osu.Game.Online.API.Requests.Responses
[JsonObject(MemberSerialization.OptIn)] [JsonObject(MemberSerialization.OptIn)]
public class APINotificationsBundle public class APINotificationsBundle
{ {
[JsonProperty("has_more")] [JsonProperty(@"has_more")]
public bool HasMore { get; set; } public bool HasMore { get; set; }
[JsonProperty("notifications")] [JsonProperty(@"notifications")]
public APINotification[] Notifications { get; set; } = null!; public APINotification[] Notifications { get; set; } = null!;
[JsonProperty("notification_endpoint")] [JsonProperty(@"notification_endpoint")]
public string Endpoint { get; set; } = null!; public string Endpoint { get; set; } = null!;
} }
} }

View File

@ -10,7 +10,7 @@ namespace osu.Game.Online.Notifications
{ {
public EndChatRequest() public EndChatRequest()
{ {
Event = "chat.end"; Event = @"chat.end";
} }
} }
} }

View File

@ -13,10 +13,10 @@ namespace osu.Game.Online.Notifications
[JsonObject(MemberSerialization.OptIn)] [JsonObject(MemberSerialization.OptIn)]
public class NewChatMessageData public class NewChatMessageData
{ {
[JsonProperty("messages")] [JsonProperty(@"messages")]
public List<Message> Messages { get; set; } = null!; public List<Message> Messages { get; set; } = null!;
[JsonProperty("users")] [JsonProperty(@"users")]
private List<APIUser> users { get; set; } = null!; private List<APIUser> users { get; set; } = null!;
[OnDeserialized] [OnDeserialized]

View File

@ -87,7 +87,7 @@ namespace osu.Game.Online.Notifications
{ {
try try
{ {
await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Disconnecting", CancellationToken.None).ConfigureAwait(false); await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, @"Disconnecting", CancellationToken.None).ConfigureAwait(false);
} }
catch catch
{ {

View File

@ -48,7 +48,7 @@ namespace osu.Game.Online.Notifications
string endpoint = await tcs.Task; string endpoint = await tcs.Task;
ClientWebSocket socket = new ClientWebSocket(); ClientWebSocket socket = new ClientWebSocket();
socket.Options.SetRequestHeader("Authorization", $"Bearer {api.AccessToken}"); socket.Options.SetRequestHeader(@"Authorization", @$"Bearer {api.AccessToken}");
socket.Options.Proxy = WebRequest.DefaultWebProxy; socket.Options.Proxy = WebRequest.DefaultWebProxy;
if (socket.Options.Proxy != null) if (socket.Options.Proxy != null)
socket.Options.Proxy.Credentials = CredentialCache.DefaultCredentials; socket.Options.Proxy.Credentials = CredentialCache.DefaultCredentials;

View File

@ -27,6 +27,9 @@ namespace osu.Game.Online.Notifications
get => enableChat; get => enableChat;
set set
{ {
if (enableChat == value)
return;
enableChat = value; enableChat = value;
Task.Run(startChatIfEnabledAsync); Task.Run(startChatIfEnabledAsync);
} }
@ -68,7 +71,7 @@ namespace osu.Game.Online.Notifications
{ {
switch (message.Event) switch (message.Event)
{ {
case "chat.message.new": case @"chat.message.new":
Debug.Assert(message.Data != null); Debug.Assert(message.Data != null);
NewChatMessageData? messageData = JsonConvert.DeserializeObject<NewChatMessageData>(message.Data.ToString()); NewChatMessageData? messageData = JsonConvert.DeserializeObject<NewChatMessageData>(message.Data.ToString());

View File

@ -9,13 +9,13 @@ namespace osu.Game.Online.Notifications
[JsonObject(MemberSerialization.OptIn)] [JsonObject(MemberSerialization.OptIn)]
public class SocketMessage public class SocketMessage
{ {
[JsonProperty("event")] [JsonProperty(@"event")]
public string Event { get; set; } = null!; public string Event { get; set; } = null!;
[JsonProperty("data")] [JsonProperty(@"data")]
public JObject? Data { get; set; } public JObject? Data { get; set; }
[JsonProperty("error")] [JsonProperty(@"error")]
public string? Error { get; set; } public string? Error { get; set; }
} }
} }

View File

@ -10,7 +10,7 @@ namespace osu.Game.Online.Notifications
{ {
public StartChatRequest() public StartChatRequest()
{ {
Event = "chat.start"; Event = @"chat.start";
} }
} }
} }