Skip to content

Commit

Permalink
Use Nito Async for tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
dk307 committed Dec 25, 2018
1 parent ab58c04 commit 93a5828
Show file tree
Hide file tree
Showing 21 changed files with 380 additions and 398 deletions.
4 changes: 2 additions & 2 deletions FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<Weavers>
<?xml version="1.0" encoding="utf-8"?>
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<NullGuard />
</Weavers>
26 changes: 26 additions & 0 deletions FodyWeavers.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
<xs:element name="Weavers">
<xs:complexType>
<xs:all>
<xs:element name="NullGuard" minOccurs="0" maxOccurs="1" type="xs:anyType" />
</xs:all>
<xs:attribute name="VerifyAssembly" type="xs:boolean">
<xs:annotation>
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
<xs:annotation>
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="GenerateXsd" type="xs:boolean">
<xs:annotation>
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
</xs:annotation>
</xs:attribute>
</xs:complexType>
</xs:element>
</xs:schema>
10 changes: 9 additions & 1 deletion GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,12 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "SharpCaster.JsonConverters.MetadataTypeConverter.#WriteJson(Newtonsoft.Json.JsonWriter,System.Object,Newtonsoft.Json.JsonSerializer)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "SharpCaster.JsonConverters.MetadataTypeEnumConverter.#ReadJson(Newtonsoft.Json.JsonReader,System.Type,System.Object,Newtonsoft.Json.JsonSerializer)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "SharpCaster.JsonConverters.MetadataTypeEnumConverter.#WriteJson(Newtonsoft.Json.JsonWriter,System.Object,Newtonsoft.Json.JsonSerializer)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "SharpCaster.JsonConverters.PlayerStateEnumConverter.#ReadJson(Newtonsoft.Json.JsonReader,System.Type,System.Object,Newtonsoft.Json.JsonSerializer)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "SharpCaster.JsonConverters.PlayerStateEnumConverter.#ReadJson(Newtonsoft.Json.JsonReader,System.Type,System.Object,Newtonsoft.Json.JsonSerializer)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1307:SpecifyStringComparison", MessageId = "System.String.StartsWith(System.String)", Scope = "member", Target = "Hspi.Pages.ActionPage.#GetRefreshActionPostUI(System.Collections.Specialized.NameValueCollection,HomeSeerAPI.IPlugInAPI+strTrigActInfo)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1305:SpecifyIFormatProvider", MessageId = "System.Convert.ToString(System.Object)", Scope = "member", Target = "Hspi.Pages.ActionPage.#GetRefreshActionPostUI(System.Collections.Specialized.NameValueCollection,HomeSeerAPI.IPlugInAPI+strTrigActInfo)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Hspi.Pages.PageHelper.#CreateNameValueCreation`1()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Hspi.Utils.EnumUtil.#GetValues`1()")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Hspi.Utils.ObjectSerialize.#DeSerializeToObject(System.String)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Hspi.Utils.ObjectSerialize.#SerializeToString(System.Object)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Scope = "member", Target = "Hspi.Pages.ActionPage.#GetRefreshActionPostUI(System.Collections.Specialized.NameValueCollection,HomeSeerAPI.IPlugInAPI+strTrigActInfo)")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Scope = "member", Target = "Hspi.Utils.TaskHelper.#StartAsync(System.Action,System.Threading.CancellationToken)")]
22 changes: 19 additions & 3 deletions HSPI_ChromecastSpeak.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<RunCodeAnalysis>true</RunCodeAnalysis>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>Rules.ruleset</CodeAnalysisRuleSet>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
Expand All @@ -113,6 +114,7 @@
<Compile Include="Pages\ChromecastCastAction.cs" />
<Compile Include="Pages\ConfigPage.cs" />
<Compile Include="Pages\PageHelper.cs" />
<Compile Include="SharpCaster\Exceptions\ApplicationLoadException.cs" />
<Compile Include="Utils\EnumUtil.cs" />
<Compile Include="Utils\ExceptionHelper.cs" />
<Compile Include="Exceptions\VoiceGenerationException.cs" />
Expand Down Expand Up @@ -180,7 +182,7 @@
<Compile Include="SharpCaster\Services\ChromecastSocketService.cs" />
<Compile Include="SharpCaster\Services\ChromecastTcpClient.cs" />
<Compile Include="SimpleChromecast.cs" />
<Compile Include="TaskHelper.cs" />
<Compile Include="Utils\TaskHelper.cs" />
<Compile Include="Utils\ObjectSerialize.cs" />
<Compile Include="Voice\VoiceData.cs" />
<Compile Include="Voice\VoiceDataFromFile.cs" />
Expand Down Expand Up @@ -222,7 +224,7 @@
<Version>1.16.1</Version>
</PackageReference>
<PackageReference Include="Fody">
<Version>3.2.16</Version>
<Version>3.3.3</Version>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand All @@ -238,17 +240,26 @@
<PackageReference Include="Newtonsoft.Json">
<Version>12.0.1</Version>
</PackageReference>
<PackageReference Include="Nito.AsyncEx.Coordination">
<Version>5.0.0-pre-05</Version>
</PackageReference>
<PackageReference Include="Nito.AsyncEx.Tasks">
<Version>5.0.0-pre-05</Version>
</PackageReference>
<PackageReference Include="NullGuard.Fody">
<Version>1.8.5</Version>
</PackageReference>
<PackageReference Include="protobuf-net">
<Version>2.4.0</Version>
</PackageReference>
<PackageReference Include="System.Collections.Immutable">
<Version>1.6.0-preview.18571.3</Version>
</PackageReference>
<PackageReference Include="TagLib.Portable">
<Version>1.0.4</Version>
</PackageReference>
<PackageReference Include="Unosquare.Swan.Lite">
<Version>0.34.3</Version>
<Version>0.38.1</Version>
</PackageReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand All @@ -274,6 +285,11 @@
<InputAssemblies Include="$(OutputPath)\TagLib.Portable.dll" />
<InputAssemblies Include="$(OutputPath)\Unosquare.Labs.EmbedIO.dll" />
<InputAssemblies Include="$(OutputPath)\Unosquare.Swan.Lite.dll" />
<InputAssemblies Include="$(OutputPath)\Nito.AsyncEx.Coordination.dll" />
<InputAssemblies Include="$(OutputPath)\Nito.AsyncEx.Tasks.dll" />
<InputAssemblies Include="$(OutputPath)\Nito.Collections.Deque.dll" />
<InputAssemblies Include="$(OutputPath)\Nito.Disposables.dll" />
<InputAssemblies Include="$(OutputPath)\System.Collections.Immutable.dll" />
</ItemGroup>
<ItemGroup>
<!-- Must be a fully qualified name -->
Expand Down
12 changes: 0 additions & 12 deletions Pages/ActionPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,6 @@ public string GetRefreshActionUI(string uniqueControlId, IPlugInAPI.strTrigActIn
return stb.ToString();
}

private NameValueCollection CreateNameValueCreation<T>() where T : Enum
{
var collection = new NameValueCollection();

foreach (var value in EnumUtil.GetValues<T>())
{
collection.Add(value.ToString(), value.ToString());
}

return collection;
}

private const string SaveButtonName = "SaveButton";
}
}
6 changes: 4 additions & 2 deletions Pages/ConfigPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public string GetWebPage(string queryString)
System.Text.StringBuilder stb = new System.Text.StringBuilder();
stb.Append(HS.GetPageHeader(Name, "Configuration", string.Empty, string.Empty, false, false));

stb.Append(DivStart("pluginpage", ""));
stb.Append(DivStart("pluginpage", string.Empty));
switch (pageType)
{
case EditDevicePageType:
Expand All @@ -63,7 +63,8 @@ public string GetWebPage(string queryString)
case MainPageType:
case null:
default:
stb.Append(BuildMainWebPageBody()); break;
stb.Append(BuildMainWebPageBody());
break;
}
stb.Append(DivEnd());
AddBody(stb.ToString());
Expand Down Expand Up @@ -295,6 +296,7 @@ private string CreateDeviceListTable()
return stb.ToString();
}

[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Globalization", "CA1304:SpecifyCultureInfo", MessageId = "System.Speech.Synthesis.SpeechSynthesizer.GetInstalledVoices")]
private string CreateSettingTable()
{
StringBuilder stb = new StringBuilder();
Expand Down
15 changes: 14 additions & 1 deletion Pages/PageHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using HomeSeerAPI;
using Hspi.Utils;
using NullGuard;
using Scheduler;
using System;
Expand Down Expand Up @@ -83,7 +84,7 @@ protected string FormDropDown(string name, NameValueCollection options, string s
width, tooltip, autoPostBack, PageName);
}

protected string FormDropDown(string name, NameValueCollection options, string selected,
protected static string FormDropDown(string name, NameValueCollection options, string selected,
int width, string tooltip, bool autoPostBack, string pageName)
{
var dropdown = new clsJQuery.jqDropList(name, pageName, false)
Expand All @@ -109,6 +110,18 @@ protected string FormDropDown(string name, NameValueCollection options, string s
return dropdown.Build();
}

protected static NameValueCollection CreateNameValueCreation<T>() where T : Enum
{
var collection = new NameValueCollection();

foreach (var value in EnumUtil.GetValues<T>())
{
collection.Add(value.ToString(), value.ToString());
}

return collection;
}

protected const string DeviceIdId = "DeviceIdId";
protected const string PageTypeId = "type";
protected readonly IHSApplication HS;
Expand Down
Loading

0 comments on commit 93a5828

Please sign in to comment.