From 8f98d25fdacd58371c84b7c6a70fdcd245c6634e Mon Sep 17 00:00:00 2001 From: Steven Pears Date: Sun, 30 Jan 2022 10:49:45 +0000 Subject: [PATCH 1/4] Migrate to targeted new --- Alexa.NET/Alexa.NET.csproj | 4 ++-- .../IConnectionTaskExtensions.cs | 2 +- .../ConnectionTasks/Inputs/PinConfirmation.cs | 5 +++-- Alexa.NET/Helpers/MixedDateTimeConverter.cs | 2 +- Alexa.NET/Request/IntentSignature.cs | 6 ++--- Alexa.NET/Request/RequestVerification.cs | 4 ++-- .../Type/ConnectionResponseTypeConverter.cs | 2 +- Alexa.NET/Request/Type/RequestConverter.cs | 2 +- .../Response/AskForPermissionsConsentCard.cs | 2 +- .../Response/Converters/CardConverter.cs | 4 ++-- .../Converters/ConnectionTaskConverter.cs | 6 ++--- .../Response/Converters/DirectiveConverter.cs | 4 ++-- .../Converters/OutputSpeechConverter.cs | 4 ++-- .../Response/Converters/TemplateConverter.cs | 4 ++-- .../Directive/AskForPermissionDirective.cs | 2 +- .../Response/Directive/AudioItemMetadata.cs | 4 ++-- .../Response/Directive/AudioItemSources.cs | 2 +- .../Directive/CompleteTaskDirective.cs | 2 +- .../ConnectionsSendRequestFactory.cs | 2 +- .../Directive/DialogUpdateDynamicEntities.cs | 2 +- Alexa.NET/Response/Directive/HintDirective.cs | 2 +- Alexa.NET/Response/Directive/JsonDirective.cs | 2 +- .../Directive/Templates/TemplateImage.cs | 2 +- .../Templates/Types/ListTemplate1.cs | 2 +- .../Templates/Types/ListTemplate2.cs | 2 +- .../Response/Directive/VideoAppDirective.cs | 2 +- Alexa.NET/Response/ProgressiveResponse.cs | 10 ++++----- Alexa.NET/Response/Ssml/AmazonDomain.cs | 2 +- Alexa.NET/Response/Ssml/AmazonEmotion.cs | 2 +- Alexa.NET/Response/Ssml/Audio.cs | 2 +- Alexa.NET/Response/Ssml/Break.cs | 6 ++--- Alexa.NET/Response/Ssml/Emphasis.cs | 2 +- Alexa.NET/Response/Ssml/Lang.cs | 2 +- Alexa.NET/Response/Ssml/Paragraph.cs | 2 +- Alexa.NET/Response/Ssml/Prosody.cs | 4 ++-- Alexa.NET/Response/Ssml/SayAs.cs | 2 +- Alexa.NET/Response/Ssml/Sentence.cs | 2 +- Alexa.NET/Response/Ssml/Speech.cs | 4 ++-- Alexa.NET/Response/Ssml/Voice.cs | 2 +- Alexa.NET/Response/Ssml/Word.cs | 2 +- Alexa.NET/ResponseBuilder.cs | 22 +++++++++---------- 41 files changed, 72 insertions(+), 71 deletions(-) diff --git a/Alexa.NET/Alexa.NET.csproj b/Alexa.NET/Alexa.NET.csproj index c1596b9..e73159e 100644 --- a/Alexa.NET/Alexa.NET.csproj +++ b/Alexa.NET/Alexa.NET.csproj @@ -6,7 +6,7 @@ 1.20.0 Tim Heuer, Steven Pears netstandard2.0 - Alexa.NET + Alexa.NET Alexa.NET amazon;alexa;echo;dot;echo dot;skills Adds support for PIN confirmation support . Thanks @stoiveyp @@ -19,7 +19,7 @@ false false false - 8 + 10 true true embedded diff --git a/Alexa.NET/ConnectionTasks/IConnectionTaskExtensions.cs b/Alexa.NET/ConnectionTasks/IConnectionTaskExtensions.cs index 1cdac28..ef85610 100644 --- a/Alexa.NET/ConnectionTasks/IConnectionTaskExtensions.cs +++ b/Alexa.NET/ConnectionTasks/IConnectionTaskExtensions.cs @@ -10,7 +10,7 @@ public static class IConnectionTaskExtensions public static StartConnectionDirective ToConnectionDirective(this IConnectionTask task, string token = null) { - return new StartConnectionDirective(task, token); + return new(task, token); } } } diff --git a/Alexa.NET/ConnectionTasks/Inputs/PinConfirmation.cs b/Alexa.NET/ConnectionTasks/Inputs/PinConfirmation.cs index 8f84419..2bdafdb 100644 --- a/Alexa.NET/ConnectionTasks/Inputs/PinConfirmation.cs +++ b/Alexa.NET/ConnectionTasks/Inputs/PinConfirmation.cs @@ -13,9 +13,10 @@ public class PinConfirmation:IConnectionTask [JsonProperty("requestedAuthenticationConfidenceLevel")] public AuthenticationConfidenceLevel RequestedAuthenticationConfidenceLevel { get; } = - new AuthenticationConfidenceLevel { + new() + { Level = 400, - Custom = new AuthenticationConfidenceLevelCustomPolicy("VOICE_PIN") + Custom = new("VOICE_PIN") }; } diff --git a/Alexa.NET/Helpers/MixedDateTimeConverter.cs b/Alexa.NET/Helpers/MixedDateTimeConverter.cs index 30fe373..47a7c3e 100644 --- a/Alexa.NET/Helpers/MixedDateTimeConverter.cs +++ b/Alexa.NET/Helpers/MixedDateTimeConverter.cs @@ -6,7 +6,7 @@ namespace Alexa.NET.Helpers { public class MixedDateTimeConverter : Newtonsoft.Json.Converters.DateTimeConverterBase { - static readonly DateTime UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + static readonly DateTime UnixEpoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { diff --git a/Alexa.NET/Request/IntentSignature.cs b/Alexa.NET/Request/IntentSignature.cs index f7e377a..3cbe620 100644 --- a/Alexa.NET/Request/IntentSignature.cs +++ b/Alexa.NET/Request/IntentSignature.cs @@ -11,7 +11,7 @@ public sealed class IntentSignature public string Action { get; private set; } public System.Collections.ObjectModel.ReadOnlyDictionary Properties { get; private set; } - private static Regex PropertyFinder = new Regex(@"(\w+?)@(\w+?)\b(\[(\w+)\])*", RegexOptions.Compiled); + private static Regex PropertyFinder = new(@"(\w+?)@(\w+?)\b(\[(\w+)\])*", RegexOptions.Compiled); private IntentSignature(string fullName) { @@ -89,11 +89,11 @@ private static void ParseComplex(string action, IntentSignature name) { propertyDictionary.Add( match.Groups[1].Value, - new IntentProperty(match.Groups[2].Value,match.Groups[4].Value) + new(match.Groups[2].Value,match.Groups[4].Value) ); } - name.Properties = new System.Collections.ObjectModel.ReadOnlyDictionary(propertyDictionary); + name.Properties = new(propertyDictionary); } } } diff --git a/Alexa.NET/Request/RequestVerification.cs b/Alexa.NET/Request/RequestVerification.cs index bf1a2b1..8cfbcea 100644 --- a/Alexa.NET/Request/RequestVerification.cs +++ b/Alexa.NET/Request/RequestVerification.cs @@ -61,14 +61,14 @@ public static async Task GetCertificate(Uri certificatePath) { var response = await new HttpClient().GetAsync(certificatePath); var bytes = await response.Content.ReadAsByteArrayAsync(); - return new X509Certificate2(bytes); + return new(bytes); } public static bool VerifyChain(X509Certificate2 certificate) { //https://stackoverflow.com/questions/24618798/automated-downloading-of-x509-certificatePath-chain-from-remote-host - X509Chain certificateChain = new X509Chain(); + X509Chain certificateChain = new(); //If you do not provide revokation information, use the following line. certificateChain.ChainPolicy.RevocationMode = X509RevocationMode.NoCheck; return certificateChain.Build(certificate); diff --git a/Alexa.NET/Request/Type/ConnectionResponseTypeConverter.cs b/Alexa.NET/Request/Type/ConnectionResponseTypeConverter.cs index a348d05..d0bf949 100644 --- a/Alexa.NET/Request/Type/ConnectionResponseTypeConverter.cs +++ b/Alexa.NET/Request/Type/ConnectionResponseTypeConverter.cs @@ -7,7 +7,7 @@ namespace Alexa.NET.Request.Type { public class ConnectionResponseTypeConverter : IDataDrivenRequestTypeConverter { - public static List Handlers = new List + public static List Handlers = new() { new AskForRequestHandler() }; diff --git a/Alexa.NET/Request/Type/RequestConverter.cs b/Alexa.NET/Request/Type/RequestConverter.cs index e2cff05..a114077 100644 --- a/Alexa.NET/Request/Type/RequestConverter.cs +++ b/Alexa.NET/Request/Type/RequestConverter.cs @@ -9,7 +9,7 @@ namespace Alexa.NET.Request.Type { public class RequestConverter : JsonConverter { - public static readonly List RequestConverters = new List(new IRequestTypeConverter[] + public static readonly List RequestConverters = new(new IRequestTypeConverter[] { new DefaultRequestTypeConverter(), new AudioPlayerRequestTypeConverter(), diff --git a/Alexa.NET/Response/AskForPermissionsConsentCard.cs b/Alexa.NET/Response/AskForPermissionsConsentCard.cs index 4f063c6..a2d5dbd 100644 --- a/Alexa.NET/Response/AskForPermissionsConsentCard.cs +++ b/Alexa.NET/Response/AskForPermissionsConsentCard.cs @@ -15,6 +15,6 @@ public string Type [JsonProperty("permissions")] [JsonRequired] - public List Permissions { get; set; } = new List(); + public List Permissions { get; set; } = new(); } } diff --git a/Alexa.NET/Response/Converters/CardConverter.cs b/Alexa.NET/Response/Converters/CardConverter.cs index aed0f10..f5d58ff 100644 --- a/Alexa.NET/Response/Converters/CardConverter.cs +++ b/Alexa.NET/Response/Converters/CardConverter.cs @@ -12,7 +12,7 @@ public class CardConverter : JsonConverter public override bool CanRead => true; - public static Dictionary> TypeFactories = new Dictionary> + public static Dictionary> TypeFactories = new() { { "Simple", () => new SimpleCard() }, { "Standard", () => new StandardCard() }, @@ -33,7 +33,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist var hasFactory = TypeFactories.ContainsKey(typeValue); if (!hasFactory) - throw new Exception( + throw new( $"unable to deserialize response. " + $"unrecognized card type '{typeValue}'" ); diff --git a/Alexa.NET/Response/Converters/ConnectionTaskConverter.cs b/Alexa.NET/Response/Converters/ConnectionTaskConverter.cs index 2ba5b5c..55a4209 100644 --- a/Alexa.NET/Response/Converters/ConnectionTaskConverter.cs +++ b/Alexa.NET/Response/Converters/ConnectionTaskConverter.cs @@ -11,7 +11,7 @@ namespace Alexa.NET.Response.Converters { public class ConnectionTaskConverter : JsonConverter { - public static Dictionary> TaskFactoryFromUri = new Dictionary> + public static Dictionary> TaskFactoryFromUri = new() { {"PrintPDFRequest/1",() => new PrintPdfV1() }, {"PrintImageRequest/1", () => new PrintImageV1() }, @@ -20,7 +20,7 @@ public class ConnectionTaskConverter : JsonConverter {"ScheduleFoodEstablishmentReservationRequest/1",() => new ScheduleFoodEstablishmentReservation()} }; - public static readonly List ConnectionTaskConverters = new List(); + public static readonly List ConnectionTaskConverters = new(); public override bool CanRead => true; public override bool CanWrite => false; @@ -49,7 +49,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist // Check task converters var converter = ConnectionTaskConverters.FirstOrDefault(c => c.CanConvert(jsonObject)); if(converter is null) - throw new Exception( + throw new( $"unable to deserialize response. " + $"unrecognized task type '{typeKey}' with version '{versionKey}'" ); diff --git a/Alexa.NET/Response/Converters/DirectiveConverter.cs b/Alexa.NET/Response/Converters/DirectiveConverter.cs index 3877d6c..1fc6d77 100644 --- a/Alexa.NET/Response/Converters/DirectiveConverter.cs +++ b/Alexa.NET/Response/Converters/DirectiveConverter.cs @@ -12,7 +12,7 @@ public class DirectiveConverter : JsonConverter public override bool CanWrite => false; - public static Dictionary> TypeFactories = new Dictionary> + public static Dictionary> TypeFactories = new() { { "AudioPlayer.Play", () => new AudioPlayerPlayDirective() }, { "AudioPlayer.ClearQueue", () => new ClearQueueDirective() }, @@ -30,7 +30,7 @@ public class DirectiveConverter : JsonConverter }; public static Dictionary> DataDrivenTypeFactory = - new Dictionary> + new() { {"Connections.SendRequest", ConnectionSendRequestFactory.Create} }; diff --git a/Alexa.NET/Response/Converters/OutputSpeechConverter.cs b/Alexa.NET/Response/Converters/OutputSpeechConverter.cs index 9a5c281..18b3f61 100644 --- a/Alexa.NET/Response/Converters/OutputSpeechConverter.cs +++ b/Alexa.NET/Response/Converters/OutputSpeechConverter.cs @@ -12,7 +12,7 @@ public class OutputSpeechConverter : JsonConverter public override bool CanWrite => false; - public static Dictionary> TypeFactories = new Dictionary> + public static Dictionary> TypeFactories = new() { { "SSML", () => new SsmlOutputSpeech() }, { "PlainText", () => new PlainTextOutputSpeech() }, @@ -31,7 +31,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist var hasFactory = TypeFactories.ContainsKey(typeValue); if (!hasFactory) - throw new Exception( + throw new( $"unable to deserialize response. " + $"unrecognized output speech type '{typeValue}'" ); diff --git a/Alexa.NET/Response/Converters/TemplateConverter.cs b/Alexa.NET/Response/Converters/TemplateConverter.cs index 5fb07d9..89dcab1 100644 --- a/Alexa.NET/Response/Converters/TemplateConverter.cs +++ b/Alexa.NET/Response/Converters/TemplateConverter.cs @@ -14,7 +14,7 @@ public class TemplateConverter : JsonConverter public override bool CanWrite => false; - public static Dictionary> TypeFactories = new Dictionary> + public static Dictionary> TypeFactories = new() { { "BodyTemplate1", () => new BodyTemplate1() }, { "BodyTemplate2", () => new BodyTemplate2() }, @@ -38,7 +38,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist var hasFactory = TypeFactories.ContainsKey(typeValue); if (!hasFactory) - throw new Exception( + throw new( $"unable to deserialize response. " + $"unrecognized template type '{typeValue}'" ); diff --git a/Alexa.NET/Response/Directive/AskForPermissionDirective.cs b/Alexa.NET/Response/Directive/AskForPermissionDirective.cs index 3ac5018..3dbe36d 100644 --- a/Alexa.NET/Response/Directive/AskForPermissionDirective.cs +++ b/Alexa.NET/Response/Directive/AskForPermissionDirective.cs @@ -9,7 +9,7 @@ public AskForPermissionDirective() public AskForPermissionDirective(string permissionScope) { - this.Payload = new AskForPermissionPayload(permissionScope); + this.Payload = new(permissionScope); } } } \ No newline at end of file diff --git a/Alexa.NET/Response/Directive/AudioItemMetadata.cs b/Alexa.NET/Response/Directive/AudioItemMetadata.cs index 8126537..ef0d742 100644 --- a/Alexa.NET/Response/Directive/AudioItemMetadata.cs +++ b/Alexa.NET/Response/Directive/AudioItemMetadata.cs @@ -12,9 +12,9 @@ public class AudioItemMetadata public string Subtitle { get; set; } [JsonProperty("art")] - public AudioItemSources Art { get; set; } = new AudioItemSources(); + public AudioItemSources Art { get; set; } = new(); [JsonProperty("backgroundImage")] - public AudioItemSources BackgroundImage { get; set; } = new AudioItemSources(); + public AudioItemSources BackgroundImage { get; set; } = new(); } } \ No newline at end of file diff --git a/Alexa.NET/Response/Directive/AudioItemSources.cs b/Alexa.NET/Response/Directive/AudioItemSources.cs index 4ad60b9..06f140e 100644 --- a/Alexa.NET/Response/Directive/AudioItemSources.cs +++ b/Alexa.NET/Response/Directive/AudioItemSources.cs @@ -6,6 +6,6 @@ namespace Alexa.NET.Response.Directive public class AudioItemSources { [JsonProperty("sources")] - public List Sources { get; set; } = new List(); + public List Sources { get; set; } = new(); } } \ No newline at end of file diff --git a/Alexa.NET/Response/Directive/CompleteTaskDirective.cs b/Alexa.NET/Response/Directive/CompleteTaskDirective.cs index ef10da3..57fdd41 100644 --- a/Alexa.NET/Response/Directive/CompleteTaskDirective.cs +++ b/Alexa.NET/Response/Directive/CompleteTaskDirective.cs @@ -12,7 +12,7 @@ public CompleteTaskDirective() { } public CompleteTaskDirective(int statusCode, string statusMessage) { - Status = new ConnectionStatus(statusCode,statusMessage); + Status = new(statusCode,statusMessage); } [JsonProperty("type")] diff --git a/Alexa.NET/Response/Directive/ConnectionsSendRequestFactory.cs b/Alexa.NET/Response/Directive/ConnectionsSendRequestFactory.cs index a3f3a4e..b00f366 100644 --- a/Alexa.NET/Response/Directive/ConnectionsSendRequestFactory.cs +++ b/Alexa.NET/Response/Directive/ConnectionsSendRequestFactory.cs @@ -7,7 +7,7 @@ namespace Alexa.NET.Response.Directive { public static class ConnectionSendRequestFactory { - public static List Handlers = new List + public static List Handlers = new() { new AskForPermissionDirectiveHandler() }; diff --git a/Alexa.NET/Response/Directive/DialogUpdateDynamicEntities.cs b/Alexa.NET/Response/Directive/DialogUpdateDynamicEntities.cs index b6208ba..be1ca51 100644 --- a/Alexa.NET/Response/Directive/DialogUpdateDynamicEntities.cs +++ b/Alexa.NET/Response/Directive/DialogUpdateDynamicEntities.cs @@ -13,6 +13,6 @@ public class DialogUpdateDynamicEntities : IDirective public UpdateBehavior UpdateBehavior { get; set; } [JsonProperty("types")] - public List Types { get; set; } = new List(); + public List Types { get; set; } = new(); } } diff --git a/Alexa.NET/Response/Directive/HintDirective.cs b/Alexa.NET/Response/Directive/HintDirective.cs index ad4c664..888cc7f 100644 --- a/Alexa.NET/Response/Directive/HintDirective.cs +++ b/Alexa.NET/Response/Directive/HintDirective.cs @@ -11,7 +11,7 @@ public HintDirective() public HintDirective(string hintText, string textType = TextType.Plain) { - Hint = new Hint(hintText, textType); + Hint = new(hintText, textType); } [JsonProperty("type")] diff --git a/Alexa.NET/Response/Directive/JsonDirective.cs b/Alexa.NET/Response/Directive/JsonDirective.cs index 0d5309d..8fbc983 100644 --- a/Alexa.NET/Response/Directive/JsonDirective.cs +++ b/Alexa.NET/Response/Directive/JsonDirective.cs @@ -18,6 +18,6 @@ public JsonDirective(string type) public string Type { get; } [JsonExtensionData] - public Dictionary Properties { get; set; } = new Dictionary(); + public Dictionary Properties { get; set; } = new(); } } diff --git a/Alexa.NET/Response/Directive/Templates/TemplateImage.cs b/Alexa.NET/Response/Directive/Templates/TemplateImage.cs index b37bb88..8b7d47b 100644 --- a/Alexa.NET/Response/Directive/Templates/TemplateImage.cs +++ b/Alexa.NET/Response/Directive/Templates/TemplateImage.cs @@ -9,6 +9,6 @@ public class TemplateImage public string ContentDescription { get; set; } [JsonProperty("sources")] - public List Sources {get;set;} = new List(); + public List Sources {get;set;} = new(); } } \ No newline at end of file diff --git a/Alexa.NET/Response/Directive/Templates/Types/ListTemplate1.cs b/Alexa.NET/Response/Directive/Templates/Types/ListTemplate1.cs index fce3e09..1cfc9a3 100644 --- a/Alexa.NET/Response/Directive/Templates/Types/ListTemplate1.cs +++ b/Alexa.NET/Response/Directive/Templates/Types/ListTemplate1.cs @@ -20,7 +20,7 @@ public class ListTemplate1:IListTemplate [JsonProperty("backgroundImage", NullValueHandling = NullValueHandling.Ignore)] public TemplateImage BackgroundImage { get; set; } - public List Items { get; set; } = new List(); + public List Items { get; set; } = new(); public bool ShouldSerializeItems() { diff --git a/Alexa.NET/Response/Directive/Templates/Types/ListTemplate2.cs b/Alexa.NET/Response/Directive/Templates/Types/ListTemplate2.cs index af926a6..a7c19b8 100644 --- a/Alexa.NET/Response/Directive/Templates/Types/ListTemplate2.cs +++ b/Alexa.NET/Response/Directive/Templates/Types/ListTemplate2.cs @@ -20,7 +20,7 @@ public class ListTemplate2:IListTemplate [JsonProperty("backgroundImage", NullValueHandling = NullValueHandling.Ignore)] public TemplateImage BackgroundImage { get; set; } - public List Items { get; set; } = new List(); + public List Items { get; set; } = new(); public bool ShouldSerializeItems() { diff --git a/Alexa.NET/Response/Directive/VideoAppDirective.cs b/Alexa.NET/Response/Directive/VideoAppDirective.cs index b4b951b..61f1248 100644 --- a/Alexa.NET/Response/Directive/VideoAppDirective.cs +++ b/Alexa.NET/Response/Directive/VideoAppDirective.cs @@ -10,7 +10,7 @@ public VideoAppDirective() public VideoAppDirective(string source) { - VideoItem = new VideoItem(source); + VideoItem = new(source); } [JsonProperty("type")] diff --git a/Alexa.NET/Response/ProgressiveResponse.cs b/Alexa.NET/Response/ProgressiveResponse.cs index 3655873..366b0f1 100644 --- a/Alexa.NET/Response/ProgressiveResponse.cs +++ b/Alexa.NET/Response/ProgressiveResponse.cs @@ -22,7 +22,7 @@ public static bool IsSupported(SkillRequest request) } - public ProgressiveResponse(SkillRequest request) : this(request, new HttpClient()) + public ProgressiveResponse(SkillRequest request) : this(request, new()) { } @@ -34,7 +34,7 @@ public ProgressiveResponse(SkillRequest request,HttpClient client) : this( { } - public ProgressiveResponse(string requestId, string authToken, string baseAddress):this(requestId,authToken,baseAddress,new HttpClient()) + public ProgressiveResponse(string requestId, string authToken, string baseAddress):this(requestId,authToken,baseAddress,new()) { } @@ -44,17 +44,17 @@ public ProgressiveResponse(string requestId, string authToken,string baseAddress Client = client; if (!string.IsNullOrWhiteSpace(baseAddress)) { - Client.BaseAddress = new Uri(baseAddress, UriKind.Absolute); + Client.BaseAddress = new(baseAddress, UriKind.Absolute); } if (!string.IsNullOrWhiteSpace(authToken)) { - Client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", authToken); + Client.DefaultRequestHeaders.Authorization = new("Bearer", authToken); } if (!string.IsNullOrWhiteSpace(requestId)) { - Header = new ProgressiveResponseHeader(requestId); + Header = new(requestId); } } diff --git a/Alexa.NET/Response/Ssml/AmazonDomain.cs b/Alexa.NET/Response/Ssml/AmazonDomain.cs index 104e67a..7df53ee 100644 --- a/Alexa.NET/Response/Ssml/AmazonDomain.cs +++ b/Alexa.NET/Response/Ssml/AmazonDomain.cs @@ -9,7 +9,7 @@ public class AmazonDomain : ICommonSsml { public string Name { get; set; } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public AmazonDomain(string name) { diff --git a/Alexa.NET/Response/Ssml/AmazonEmotion.cs b/Alexa.NET/Response/Ssml/AmazonEmotion.cs index ace47ae..4f5a6f3 100644 --- a/Alexa.NET/Response/Ssml/AmazonEmotion.cs +++ b/Alexa.NET/Response/Ssml/AmazonEmotion.cs @@ -11,7 +11,7 @@ public class AmazonEmotion : ICommonSsml public string Intensity { get; set; } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public AmazonEmotion(string name, string intensity) { diff --git a/Alexa.NET/Response/Ssml/Audio.cs b/Alexa.NET/Response/Ssml/Audio.cs index ce7ea79..f77188e 100644 --- a/Alexa.NET/Response/Ssml/Audio.cs +++ b/Alexa.NET/Response/Ssml/Audio.cs @@ -8,7 +8,7 @@ namespace Alexa.NET.Response.Ssml public class Audio:ISsml { public string Source { get; set; } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public Audio() { } diff --git a/Alexa.NET/Response/Ssml/Break.cs b/Alexa.NET/Response/Ssml/Break.cs index 0f4aedd..53dc74e 100644 --- a/Alexa.NET/Response/Ssml/Break.cs +++ b/Alexa.NET/Response/Ssml/Break.cs @@ -11,15 +11,15 @@ public class Break : ICommonSsml public XNode ToXml() { - List attributes = new List(); + List attributes = new(); if (!string.IsNullOrWhiteSpace(Time)) { - attributes.Add(new XAttribute("time", Time)); + attributes.Add(new("time", Time)); } if (!string.IsNullOrWhiteSpace(Strength)) { - attributes.Add(new XAttribute("strength",Strength)); + attributes.Add(new("strength",Strength)); } return new XElement("break", attributes); } diff --git a/Alexa.NET/Response/Ssml/Emphasis.cs b/Alexa.NET/Response/Ssml/Emphasis.cs index be77213..126c95c 100644 --- a/Alexa.NET/Response/Ssml/Emphasis.cs +++ b/Alexa.NET/Response/Ssml/Emphasis.cs @@ -16,7 +16,7 @@ public Emphasis(string text) public XNode ToXml() { - List objects = new List(); + List objects = new(); if (!string.IsNullOrWhiteSpace(Level)) { diff --git a/Alexa.NET/Response/Ssml/Lang.cs b/Alexa.NET/Response/Ssml/Lang.cs index 68c2259..43f682d 100644 --- a/Alexa.NET/Response/Ssml/Lang.cs +++ b/Alexa.NET/Response/Ssml/Lang.cs @@ -10,7 +10,7 @@ public class Lang:ICommonSsml { public string LanguageCode { get; set; } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public Lang(string languageCode) { diff --git a/Alexa.NET/Response/Ssml/Paragraph.cs b/Alexa.NET/Response/Ssml/Paragraph.cs index 5bda139..4fea599 100644 --- a/Alexa.NET/Response/Ssml/Paragraph.cs +++ b/Alexa.NET/Response/Ssml/Paragraph.cs @@ -7,7 +7,7 @@ namespace Alexa.NET.Response.Ssml { public class Paragraph : ISsml { - public List Elements {get;set;} = new List(); + public List Elements {get;set;} = new(); public Paragraph() { } diff --git a/Alexa.NET/Response/Ssml/Prosody.cs b/Alexa.NET/Response/Ssml/Prosody.cs index df1a35f..7b77500 100644 --- a/Alexa.NET/Response/Ssml/Prosody.cs +++ b/Alexa.NET/Response/Ssml/Prosody.cs @@ -17,11 +17,11 @@ public Prosody(params ISsml[] elements) Elements = elements.ToList(); } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public XNode ToXml() { - List attributes = new List(); + List attributes = new(); if(!string.IsNullOrWhiteSpace(Rate)) { diff --git a/Alexa.NET/Response/Ssml/SayAs.cs b/Alexa.NET/Response/Ssml/SayAs.cs index 9c917f4..d54a81a 100644 --- a/Alexa.NET/Response/Ssml/SayAs.cs +++ b/Alexa.NET/Response/Ssml/SayAs.cs @@ -28,7 +28,7 @@ public SayAs(string text, string interpretAs) public XNode ToXml() { - List objects = new List(); + List objects = new(); objects.Add(new XText(Text)); objects.Add(new XAttribute("interpret-as", InterpretAs)); diff --git a/Alexa.NET/Response/Ssml/Sentence.cs b/Alexa.NET/Response/Ssml/Sentence.cs index 2766fc0..ff26dd9 100644 --- a/Alexa.NET/Response/Ssml/Sentence.cs +++ b/Alexa.NET/Response/Ssml/Sentence.cs @@ -16,7 +16,7 @@ public Sentence(params ISentenceSsml[] elements) Elements = elements.ToList(); } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public XNode ToXml() { diff --git a/Alexa.NET/Response/Ssml/Speech.cs b/Alexa.NET/Response/Ssml/Speech.cs index 0719432..4e78251 100644 --- a/Alexa.NET/Response/Ssml/Speech.cs +++ b/Alexa.NET/Response/Ssml/Speech.cs @@ -17,7 +17,7 @@ public Speech(params ISsml[] elements) Elements = elements.ToList(); } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public string ToXml() @@ -27,7 +27,7 @@ public string ToXml() throw new InvalidOperationException("No text available"); } - XElement root = new XElement("speak", + XElement root = new("speak", new XAttribute(XNamespace.Xmlns + "amazon", Namespaces.TempAmazon), new XAttribute(XNamespace.Xmlns + "alexa",Namespaces.TempAlexa)); root.Add(Elements.Select(e => e.ToXml())); diff --git a/Alexa.NET/Response/Ssml/Voice.cs b/Alexa.NET/Response/Ssml/Voice.cs index c0a1077..6b13d3b 100644 --- a/Alexa.NET/Response/Ssml/Voice.cs +++ b/Alexa.NET/Response/Ssml/Voice.cs @@ -10,7 +10,7 @@ public class Voice:ICommonSsml { public string Name { get; set; } - public List Elements { get; set; } = new List(); + public List Elements { get; set; } = new(); public Voice(string name) { diff --git a/Alexa.NET/Response/Ssml/Word.cs b/Alexa.NET/Response/Ssml/Word.cs index 6c5fb0e..0af6f28 100644 --- a/Alexa.NET/Response/Ssml/Word.cs +++ b/Alexa.NET/Response/Ssml/Word.cs @@ -27,7 +27,7 @@ public Word(string text, string role) public XNode ToXml() { - List objects = new List(); + List objects = new(); objects.Add(new XAttribute("role", Role)); objects.Add(new XText(Text)); diff --git a/Alexa.NET/ResponseBuilder.cs b/Alexa.NET/ResponseBuilder.cs index 0442f12..114f621 100644 --- a/Alexa.NET/ResponseBuilder.cs +++ b/Alexa.NET/ResponseBuilder.cs @@ -71,7 +71,7 @@ public static SkillResponse TellWithReprompt(Response.Ssml.Speech speechResponse public static SkillResponse TellWithCard(IOutputSpeech speechResponse, string title, string content) { - SimpleCard card = new SimpleCard(); + SimpleCard card = new(); card.Content = content; card.Title = title; @@ -90,7 +90,7 @@ public static SkillResponse TellWithCard(Response.Ssml.Speech speechResponse, st public static SkillResponse TellWithCard(IOutputSpeech speechResponse, string title, string content, Session sessionAttributes) { - SimpleCard card = new SimpleCard + SimpleCard card = new() { Content = content, Title = title @@ -111,7 +111,7 @@ public static SkillResponse TellWithCard(Response.Ssml.Speech speechResponse, st public static SkillResponse TellWithLinkAccountCard(IOutputSpeech speechResponse) { - LinkAccountCard card = new LinkAccountCard(); + LinkAccountCard card = new(); return BuildResponse(speechResponse, true, null, null, card); } @@ -128,7 +128,7 @@ public static SkillResponse TellWithLinkAccountCard(Response.Ssml.Speech speechR public static SkillResponse TellWithLinkAccountCard(IOutputSpeech speechResponse, Session sessionAttributes) { - LinkAccountCard card = new LinkAccountCard(); + LinkAccountCard card = new(); return BuildResponse(speechResponse, true, sessionAttributes, null, card); } @@ -145,7 +145,7 @@ public static SkillResponse TellWithLinkAccountCard(Response.Ssml.Speech speechR public static SkillResponse TellWithAskForPermissionsConsentCard(IOutputSpeech speechResponse, IEnumerable permissions) { - AskForPermissionsConsentCard card = new AskForPermissionsConsentCard {Permissions = permissions.ToList()}; + AskForPermissionsConsentCard card = new() {Permissions = permissions.ToList()}; return BuildResponse(speechResponse, true, null, null, card); } @@ -161,7 +161,7 @@ public static SkillResponse TellWithAskForPermissionConsentCard(Response.Ssml.Sp public static SkillResponse TellWithAskForPermissionsConsentCard(IOutputSpeech speechResponse, IEnumerable permissions, Session sessionAttributes) { - AskForPermissionsConsentCard card = new AskForPermissionsConsentCard {Permissions = permissions.ToList()}; + AskForPermissionsConsentCard card = new() {Permissions = permissions.ToList()}; return BuildResponse(speechResponse, true, sessionAttributes, null, card); } @@ -225,7 +225,7 @@ public static SkillResponse AskWithCard(Response.Ssml.Speech speechResponse, str public static SkillResponse AskWithCard(IOutputSpeech speechResponse, string title, string content, Reprompt reprompt, Session sessionAttributes) { - SimpleCard card = new SimpleCard + SimpleCard card = new() { Content = content, Title = title @@ -263,9 +263,9 @@ public static SkillResponse AudioPlayerPlay(PlayBehavior playBehavior, string ur response.Response.Directives.Add(new AudioPlayerPlayDirective() { PlayBehavior = playBehavior, - AudioItem = new AudioItem() + AudioItem = new() { - Stream = new AudioItemStream() + Stream = new() { Url = url, Token = token, @@ -357,10 +357,10 @@ public static SkillResponse Empty() #region Main Response Builder private static SkillResponse BuildResponse(IOutputSpeech outputSpeech, bool shouldEndSession, Session sessionAttributes, Reprompt reprompt, ICard card) { - SkillResponse response = new SkillResponse {Version = "1.0"}; + SkillResponse response = new() {Version = "1.0"}; if (sessionAttributes != null) response.SessionAttributes = sessionAttributes.Attributes; - ResponseBody body = new ResponseBody + ResponseBody body = new() { ShouldEndSession = shouldEndSession, OutputSpeech = outputSpeech From 62ebb1b00be926070c586838b085bd1e872b5b76 Mon Sep 17 00:00:00 2001 From: Steven Pears Date: Sun, 30 Jan 2022 11:01:48 +0000 Subject: [PATCH 2/4] bump test project to 6.0 to keep runtimes aligned --- Alexa.NET.Tests/Alexa.NET.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Alexa.NET.Tests/Alexa.NET.Tests.csproj b/Alexa.NET.Tests/Alexa.NET.Tests.csproj index e374868..15cc771 100644 --- a/Alexa.NET.Tests/Alexa.NET.Tests.csproj +++ b/Alexa.NET.Tests/Alexa.NET.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 CS0612,CS0618 From d9867071a5ee478b220b088edb0eeb9b464d7a75 Mon Sep 17 00:00:00 2001 From: Steven Pears Date: Sun, 30 Jan 2022 11:04:30 +0000 Subject: [PATCH 3/4] bump workflows to install 6.0.x --- .github/workflows/build.yml | 2 +- .github/workflows/prbuild.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a03699..b2a9bde 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -31,7 +31,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v1.8.0 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Restore run: dotnet restore diff --git a/.github/workflows/prbuild.yaml b/.github/workflows/prbuild.yaml index f617f07..784f8b2 100644 --- a/.github/workflows/prbuild.yaml +++ b/.github/workflows/prbuild.yaml @@ -15,7 +15,7 @@ jobs: - name: Setup .NET Core SDK uses: actions/setup-dotnet@v1.8.0 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Restore run: dotnet restore From 0170352f95dec742d54b0b505cae3ecf26d7f441 Mon Sep 17 00:00:00 2001 From: Steven Pears Date: Sun, 3 Apr 2022 09:34:00 +0100 Subject: [PATCH 4/4] add global.json shouls stop analysis being blocked by 5.0 limitation --- global.json | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 global.json diff --git a/global.json b/global.json new file mode 100644 index 0000000..d85a7b6 --- /dev/null +++ b/global.json @@ -0,0 +1,6 @@ +{ + "sdk": { + "version": "6.0.201", + "rollForward": "latestMinor" + } +} \ No newline at end of file