From fdefe3234c29e781b0a26e414b9e1787004740a3 Mon Sep 17 00:00:00 2001 From: Justin Date: Sat, 11 Nov 2017 02:02:55 -0500 Subject: [PATCH] Apply the new editorconfig formatting stuff to all the netstandard files: - This doesn't apply all conventions, since some are just suggestions, and some only apply to new code. - Lots of BOMs are gone...we'll see if that was a good idea. - Some of these settings might not be the best, or need tweaking, but at least things will get to be more standardized moving forward. --- .editorconfig | 32 +++++-- Keen.NetStandard.Test/AddOnsTest.cs | 6 +- Keen.NetStandard.Test/DatasetTests.cs | 6 +- .../DatasetTests_Integration.cs | 8 +- .../DelegatingHandlerMock.cs | 2 +- .../EventCachePortableTestable.cs | 4 +- Keen.NetStandard.Test/EventCacheTest.cs | 6 +- Keen.NetStandard.Test/EventCollectionMock.cs | 4 +- Keen.NetStandard.Test/EventMock.cs | 4 +- Keen.NetStandard.Test/FuncHandler.cs | 5 +- Keen.NetStandard.Test/FunnelTest.cs | 84 ++++++++--------- .../HttpClientHandlerMock.cs | 2 +- Keen.NetStandard.Test/HttpTests.cs | 8 +- Keen.NetStandard.Test/IHttpMessageHandler.cs | 5 +- Keen.NetStandard.Test/KeenClientTest.cs | 94 +++++++++---------- .../ProjectSettingsProviderTest.cs | 4 +- Keen.NetStandard.Test/QueryTest.cs | 94 +++++++++---------- .../QueryTests_Integration.cs | 18 ++-- Keen.NetStandard.Test/ScopedKeyTest.cs | 18 ++-- Keen.NetStandard.Test/TestBase.cs | 4 +- .../TestKeenHttpClientProvider.cs | 3 +- .../TimeframeConverterTest.cs | 8 +- Keen.NetStandard.Test/UrlToMessageHandler.cs | 6 +- Keen.NetStandard/AsyncLazy.cs | 3 +- Keen.NetStandard/CachedEvent.cs | 2 +- Keen.NetStandard/DataEnrichment/EventAddOn.cs | 12 +-- Keen.NetStandard/Dataset/DatasetDefinition.cs | 2 +- .../Dataset/DatasetDefinitionCollection.cs | 2 +- Keen.NetStandard/Dataset/Datasets.cs | 23 ++--- Keen.NetStandard/Dataset/IDataset.cs | 2 +- .../Dataset/QueryDefinitionExtensions.cs | 2 +- Keen.NetStandard/DynamicPropertyValue.cs | 2 +- Keen.NetStandard/Event.cs | 26 ++--- Keen.NetStandard/EventCacheMemory.cs | 3 +- Keen.NetStandard/EventCachePortable.cs | 9 +- Keen.NetStandard/EventCollection.cs | 2 +- Keen.NetStandard/HttpClientCache.cs | 4 +- Keen.NetStandard/IDynamicPropertyValue.cs | 2 +- Keen.NetStandard/IEvent.cs | 4 +- Keen.NetStandard/IEventCache.cs | 2 +- Keen.NetStandard/IEventCollection.cs | 2 +- Keen.NetStandard/IHttpClientProvider.cs | 4 +- Keen.NetStandard/IKeenHttpClient.cs | 2 +- Keen.NetStandard/IKeenHttpClientProvider.cs | 2 +- Keen.NetStandard/IProjectSettings.cs | 2 +- Keen.NetStandard/KeenClient.cs | 18 ++-- Keen.NetStandard/KeenConstants.cs | 56 +++++------ Keen.NetStandard/KeenException.cs | 18 ++-- Keen.NetStandard/KeenHttpClient.cs | 2 +- Keen.NetStandard/KeenHttpClientFactory.cs | 2 +- Keen.NetStandard/KeenHttpClientProvider.cs | 2 +- Keen.NetStandard/KeenUtil.cs | 2 +- Keen.NetStandard/ProjectSettingsProvider.cs | 6 +- .../ProjectSettingsProviderEnv.cs | 5 +- .../ProjectSettingsProviderFile.cs | 16 ++-- Keen.NetStandard/Query/FunnelResult.cs | 4 +- Keen.NetStandard/Query/FunnelResultStep.cs | 2 +- Keen.NetStandard/Query/FunnelStep.cs | 4 +- Keen.NetStandard/Query/IQueries.cs | 4 +- Keen.NetStandard/Query/IQueryTimeframe.cs | 2 +- Keen.NetStandard/Query/MultiAnalysisParam.cs | 4 +- Keen.NetStandard/Query/Queries.cs | 16 ++-- .../Query/QueryAbsoluteTimeframe.cs | 4 +- Keen.NetStandard/Query/QueryDefinition.cs | 2 +- Keen.NetStandard/Query/QueryFilter.cs | 11 +-- Keen.NetStandard/Query/QueryGroupValue.cs | 4 +- Keen.NetStandard/Query/QueryInterval.cs | 2 +- Keen.NetStandard/Query/QueryIntervalValue.cs | 3 +- .../Query/QueryRelativeTimeframe.cs | 11 ++- Keen.NetStandard/Query/QueryType.cs | 4 +- Keen.NetStandard/Query/TimeframeConverter.cs | 4 +- Keen.NetStandard/ScopedKey.cs | 6 +- Keen/Query/QueryInterval.cs | 12 +++ 73 files changed, 398 insertions(+), 367 deletions(-) diff --git a/.editorconfig b/.editorconfig index ecddbb3..78b9d26 100644 --- a/.editorconfig +++ b/.editorconfig @@ -82,7 +82,6 @@ csharp_style_throw_expression = true:suggestion csharp_style_conditional_delegate_call = true:suggestion ## Braces - csharp_prefer_braces = true ## Newline settings @@ -102,7 +101,6 @@ csharp_indent_switch_labels = true csharp_indent_labels = flush_left ## Spacing - csharp_space_after_cast = false csharp_space_after_colon_in_inheritance_clause = true csharp_space_after_comma = true @@ -126,18 +124,25 @@ csharp_space_between_method_declaration_parameter_list_parentheses = false csharp_space_between_parentheses = false csharp_space_between_square_brackets = false - # name all constant fields using PascalCase - dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style -dotnet_naming_symbols.constant_fields.applicable_kinds = field -dotnet_naming_symbols.constant_fields.required_modifiers = const +dotnet_naming_symbols.constant_fields.applicable_kinds = field +dotnet_naming_symbols.constant_fields.required_modifiers = const dotnet_naming_style.pascal_case_style.capitalization = pascal_case +# name all readonly fields using PascalCase +dotnet_naming_rule.readonly_fields_should_be_pascal_case.severity = suggestion +dotnet_naming_rule.readonly_fields_should_be_pascal_case.symbols = readonly_fields +dotnet_naming_rule.readonly_fields_should_be_pascal_case.style = pascal_case_style + +dotnet_naming_symbols.readonly_fields.applicable_kinds = field +dotnet_naming_symbols.readonly_fields.required_modifiers = readonly + + # internal and private fields should be _camelCase dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields @@ -148,3 +153,18 @@ dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = priva dotnet_naming_style.camel_case_underscore_style.required_prefix = _ dotnet_naming_style.camel_case_underscore_style.capitalization = camel_case + +# async methods end in Async +dotnet_naming_rule.async_methods_end_in_async.symbols = any_async_methods +dotnet_naming_rule.async_methods_end_in_async.style = end_in_async +dotnet_naming_rule.async_methods_end_in_async.severity = suggestion + +dotnet_naming_symbols.any_async_methods.applicable_kinds = method +dotnet_naming_symbols.any_async_methods.applicable_accessibilities = * +dotnet_naming_symbols.any_async_methods.required_modifiers = async + +### NOTE : unfortunately just looking for the 'async' modifier won't catch all methods that +### return an awaitable. + +dotnet_naming_style.end_in_async.required_suffix = Async +dotnet_naming_style.end_in_async.capitalization = pascal_case diff --git a/Keen.NetStandard.Test/AddOnsTest.cs b/Keen.NetStandard.Test/AddOnsTest.cs index d7f48be..b0b25ae 100644 --- a/Keen.NetStandard.Test/AddOnsTest.cs +++ b/Keen.NetStandard.Test/AddOnsTest.cs @@ -1,7 +1,7 @@ -using Keen.Core.DataEnrichment; -using NUnit.Framework; using System; using System.Collections.Generic; +using Keen.Core.DataEnrichment; +using NUnit.Framework; namespace Keen.Core.Test @@ -38,7 +38,7 @@ public void IpToGeo_Send_Success() var a = AddOn.IpToGeo("an_ip", "geocode"); - Assert.DoesNotThrow(() => client.AddEvent("AddOnTest", new {an_ip = "70.187.8.97"}, new List {a})); + Assert.DoesNotThrow(() => client.AddEvent("AddOnTest", new { an_ip = "70.187.8.97" }, new List { a })); } [Test] diff --git a/Keen.NetStandard.Test/DatasetTests.cs b/Keen.NetStandard.Test/DatasetTests.cs index e9ab361..2b1a049 100644 --- a/Keen.NetStandard.Test/DatasetTests.cs +++ b/Keen.NetStandard.Test/DatasetTests.cs @@ -1,10 +1,10 @@ -using Keen.Core.Dataset; +using System.Collections.Generic; +using System.Threading.Tasks; +using Keen.Core.Dataset; using Keen.Core.Query; using Moq; using Newtonsoft.Json.Linq; using NUnit.Framework; -using System.Collections.Generic; -using System.Threading.Tasks; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/DatasetTests_Integration.cs b/Keen.NetStandard.Test/DatasetTests_Integration.cs index 1af77c2..7827fee 100644 --- a/Keen.NetStandard.Test/DatasetTests_Integration.cs +++ b/Keen.NetStandard.Test/DatasetTests_Integration.cs @@ -1,7 +1,3 @@ -using Keen.Core.Dataset; -using Keen.Core.Query; -using Moq; -using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; @@ -9,6 +5,10 @@ using System.Net; using System.Net.Http; using System.Threading.Tasks; +using Keen.Core.Dataset; +using Keen.Core.Query; +using Moq; +using NUnit.Framework; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/DelegatingHandlerMock.cs b/Keen.NetStandard.Test/DelegatingHandlerMock.cs index dd14386..a85fadd 100644 --- a/Keen.NetStandard.Test/DelegatingHandlerMock.cs +++ b/Keen.NetStandard.Test/DelegatingHandlerMock.cs @@ -1,4 +1,4 @@ -using System.Net.Http; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; diff --git a/Keen.NetStandard.Test/EventCachePortableTestable.cs b/Keen.NetStandard.Test/EventCachePortableTestable.cs index d705c50..29d6307 100644 --- a/Keen.NetStandard.Test/EventCachePortableTestable.cs +++ b/Keen.NetStandard.Test/EventCachePortableTestable.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Keen.Core.Test @@ -16,4 +16,4 @@ internal static async Task NewTestableAsync() internal void ResetStaticMembers() => events.Clear(); } -} \ No newline at end of file +} diff --git a/Keen.NetStandard.Test/EventCacheTest.cs b/Keen.NetStandard.Test/EventCacheTest.cs index 8394a8a..66100df 100644 --- a/Keen.NetStandard.Test/EventCacheTest.cs +++ b/Keen.NetStandard.Test/EventCacheTest.cs @@ -1,10 +1,10 @@ -using Keen.Core.EventCache; -using Newtonsoft.Json.Linq; -using NUnit.Framework; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; +using Keen.Core.EventCache; +using Newtonsoft.Json.Linq; +using NUnit.Framework; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/EventCollectionMock.cs b/Keen.NetStandard.Test/EventCollectionMock.cs index 1310e85..93bf05d 100644 --- a/Keen.NetStandard.Test/EventCollectionMock.cs +++ b/Keen.NetStandard.Test/EventCollectionMock.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json.Linq; using System; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Keen.Core.Test @@ -20,7 +20,7 @@ class EventCollectionMock : IEventCollection public Task GetSchema(string collection) { - return Task.Run(()=>_getSchema(collection, _settings)); + return Task.Run(() => _getSchema(collection, _settings)); } public Task DeleteCollection(string collection) diff --git a/Keen.NetStandard.Test/EventMock.cs b/Keen.NetStandard.Test/EventMock.cs index dcd73cc..f886be6 100644 --- a/Keen.NetStandard.Test/EventMock.cs +++ b/Keen.NetStandard.Test/EventMock.cs @@ -1,8 +1,8 @@ -using Keen.Core.EventCache; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Threading.Tasks; +using Keen.Core.EventCache; +using Newtonsoft.Json.Linq; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/FuncHandler.cs b/Keen.NetStandard.Test/FuncHandler.cs index ffbe4df..6c76d5b 100644 --- a/Keen.NetStandard.Test/FuncHandler.cs +++ b/Keen.NetStandard.Test/FuncHandler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -30,7 +30,8 @@ internal class FuncHandler : IHttpMessageHandler public Func> DefaultAsync { get; set; } + Task> DefaultAsync + { get; set; } public async Task SendAsync( diff --git a/Keen.NetStandard.Test/FunnelTest.cs b/Keen.NetStandard.Test/FunnelTest.cs index 507edae..55acbad 100644 --- a/Keen.NetStandard.Test/FunnelTest.cs +++ b/Keen.NetStandard.Test/FunnelTest.cs @@ -1,11 +1,11 @@ -using Keen.Core.Query; -using Moq; -using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; +using Keen.Core.Query; +using Moq; +using NUnit.Framework; namespace Keen.Core.Test @@ -59,27 +59,27 @@ public async Task Funnel_Simple_Success() { new FunnelStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, ActorProperty = "id", }, new FunnelStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, ActorProperty = "id" }, }; var expected = new FunnelResult { - Steps = new [] + Steps = new[] { new FunnelResultStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, }, new FunnelResultStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, }, }, Result = new[] { 3, 2 } @@ -119,12 +119,12 @@ public async Task Funnel_Inverted_Success() { new FunnelStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, ActorProperty = "id", }, new FunnelStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, ActorProperty = "id", Inverted = true }, @@ -132,18 +132,18 @@ public async Task Funnel_Inverted_Success() var expected = new FunnelResult { - Steps = new [] + Steps = new[] { new FunnelResultStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, }, new FunnelResultStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, }, }, - Result = new [] { 3, 1 } + Result = new[] { 3, 1 } }; Mock queryMock = null; @@ -177,44 +177,44 @@ public async Task Funnel_Optional_Success() var client = new KeenClient(SettingsEnv); var timeframe = QueryRelativeTimeframe.ThisHour(); - IEnumerable funnelsteps = new [] + IEnumerable funnelsteps = new[] { new FunnelStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, ActorProperty = "id", }, new FunnelStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, ActorProperty = "id", Optional = true, }, new FunnelStep { - EventCollection = FunnelColC, + EventCollection = FunnelColC, ActorProperty = "id" }, }; var expected = new FunnelResult { - Steps = new [] + Steps = new[] { new FunnelResultStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, }, new FunnelResultStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, }, new FunnelResultStep { - EventCollection = FunnelColC, + EventCollection = FunnelColC, }, }, - Result = new [] { 3, 2, 1 } + Result = new[] { 3, 2, 1 } }; Mock queryMock = null; @@ -249,36 +249,36 @@ public async Task Funnel_ValidFilter_Success() var timeframe = QueryRelativeTimeframe.ThisHour(); var filters = new List { new QueryFilter("id", QueryFilter.FilterOperator.GreaterThanOrEqual(), 0) }; - IEnumerable funnelsteps = new [] + IEnumerable funnelsteps = new[] { new FunnelStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, ActorProperty = "id", Filters = filters, }, new FunnelStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, ActorProperty = "id" }, }; var expected = new FunnelResult { - Steps = new [] + Steps = new[] { new FunnelResultStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, Filters = filters }, new FunnelResultStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, }, }, - Result = new [] { 3, 2 } + Result = new[] { 3, 2 } }; Mock queryMock = null; @@ -312,7 +312,7 @@ public async Task Funnel_ValidTimeframe_Success() var client = new KeenClient(SettingsEnv); var timeframe = QueryRelativeTimeframe.ThisHour(); - IEnumerable funnelsteps = new [] + IEnumerable funnelsteps = new[] { new FunnelStep { @@ -328,7 +328,7 @@ public async Task Funnel_ValidTimeframe_Success() var expected = new FunnelResult { - Steps = new [] + Steps = new[] { new FunnelResultStep { @@ -339,7 +339,7 @@ public async Task Funnel_ValidTimeframe_Success() EventCollection = FunnelColB, }, }, - Result = new [] { 3, 2 } + Result = new[] { 3, 2 } }; Mock queryMock = null; @@ -372,7 +372,7 @@ public async Task Funnel_ValidTimeframeInSteps_Success() { var client = new KeenClient(SettingsEnv); - IEnumerable funnelsteps = new [] + IEnumerable funnelsteps = new[] { new FunnelStep { @@ -435,37 +435,37 @@ public async Task Funnel_WithActors_Success() var client = new KeenClient(SettingsEnv); var timeframe = QueryRelativeTimeframe.ThisHour(); - IEnumerable funnelsteps = new [] + IEnumerable funnelsteps = new[] { new FunnelStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, ActorProperty = "id", WithActors = true }, new FunnelStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, ActorProperty = "id" }, }; var expected = new FunnelResult { - Actors = new []{ new []{"sam", "dean"}, null}, - Steps = new [] + Actors = new[] { new[] { "sam", "dean" }, null }, + Steps = new[] { new FunnelResultStep { - EventCollection = FunnelColA, + EventCollection = FunnelColA, WithActors = true }, new FunnelResultStep { - EventCollection = FunnelColB, + EventCollection = FunnelColB, }, }, - Result = new [] { 3, 2 } + Result = new[] { 3, 2 } }; diff --git a/Keen.NetStandard.Test/HttpClientHandlerMock.cs b/Keen.NetStandard.Test/HttpClientHandlerMock.cs index 27e35df..db4cb2d 100644 --- a/Keen.NetStandard.Test/HttpClientHandlerMock.cs +++ b/Keen.NetStandard.Test/HttpClientHandlerMock.cs @@ -1,4 +1,4 @@ -using System.Net.Http; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; diff --git a/Keen.NetStandard.Test/HttpTests.cs b/Keen.NetStandard.Test/HttpTests.cs index 60ba2be..a2fa027 100644 --- a/Keen.NetStandard.Test/HttpTests.cs +++ b/Keen.NetStandard.Test/HttpTests.cs @@ -1,13 +1,13 @@ -using Keen.Core.Query; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using NUnit.Framework; using System; using System.Linq; using System.Net; using System.Net.Http; using System.Net.Http.Headers; using System.Threading.Tasks; +using Keen.Core.Query; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using NUnit.Framework; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/IHttpMessageHandler.cs b/Keen.NetStandard.Test/IHttpMessageHandler.cs index 07d5dc2..484eb32 100644 --- a/Keen.NetStandard.Test/IHttpMessageHandler.cs +++ b/Keen.NetStandard.Test/IHttpMessageHandler.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net.Http; using System.Threading; using System.Threading.Tasks; @@ -26,6 +26,7 @@ internal interface IHttpMessageHandler Func> DefaultAsync { get; set; } + Task> DefaultAsync + { get; set; } } } diff --git a/Keen.NetStandard.Test/KeenClientTest.cs b/Keen.NetStandard.Test/KeenClientTest.cs index 005866d..fdae48f 100644 --- a/Keen.NetStandard.Test/KeenClientTest.cs +++ b/Keen.NetStandard.Test/KeenClientTest.cs @@ -1,12 +1,12 @@ -using Keen.Core.EventCache; -using Moq; -using Newtonsoft.Json.Linq; -using NUnit.Framework; using System; using System.Collections.Generic; using System.Dynamic; using System.Linq; using System.Threading.Tasks; +using Keen.Core.EventCache; +using Moq; +using Newtonsoft.Json.Linq; +using NUnit.Framework; namespace Keen.Core.Test @@ -24,12 +24,12 @@ public void AddEvents_InvalidProject_Throws() addEvents: new Func>((e, p) => { if ((p == settings) - &&(p.ProjectId=="X")) + && (p.ProjectId == "X")) throw new KeenException(); else throw new Exception("Unexpected value"); })); - Assert.Throws(() => client.AddEvents("AddEventTest", new []{ new {AProperty = "AValue" }})); + Assert.Throws(() => client.AddEvents("AddEventTest", new[] { new { AProperty = "AValue" } })); } @@ -45,19 +45,19 @@ public void AddEvents_PartialFailure_Throws() if (null == err) throw new Exception("Unexpected error, test data not found"); - return new List(){new CachedEvent("AddEventTest", e)}; + return new List() { new CachedEvent("AddEventTest", e) }; })); object invalidEvent = new ExpandoObject(); ((IDictionary)invalidEvent).Add("$" + new string('.', 260), "AValue"); var events = (from i in Enumerable.Range(1, 2) - select new { AProperty = "AValue" + i }).ToList(); + select new { AProperty = "AValue" + i }).ToList(); events.Add(invalidEvent); Assert.Throws(() => client.AddEvents("AddEventTest", events)); } - + [Test] public void AddEvents_NoCache_Success() { @@ -76,8 +76,8 @@ public void AddEvents_NoCache_Success() return new List(); })); - var events = from i in Enumerable.Range(1,3) - select new { AProperty = "AValue" + i}; + var events = from i in Enumerable.Range(1, 3) + select new { AProperty = "AValue" + i }; Assert.DoesNotThrow(() => client.AddEvents("AddEventTest", events)); Assert.True((UseMocks && done) || !UseMocks, "AddEvent mock was not called"); @@ -295,17 +295,17 @@ public void AddEvent_InvalidKeenNamespaceProperty_Throws() var client = new KeenClient(SettingsEnv); if (UseMocks) client.EventCollection = new EventCollectionMock(SettingsEnv, - addEvent: new Action((c,e,p) => - { - if ((p == SettingsEnv) - && (c == "X") - && (null != e.Property("keen")) - && (e.Property("keen").Value.GetType()==typeof(JObject)) - && (null!=((JObject)e.Property("keen").Value).Property("AProperty"))) - throw new KeenInvalidKeenNamespacePropertyException(); - else - throw new Exception("Unexpected value"); - })); + addEvent: new Action((c, e, p) => + { + if ((p == SettingsEnv) + && (c == "X") + && (null != e.Property("keen")) + && (e.Property("keen").Value.GetType() == typeof(JObject)) + && (null != ((JObject)e.Property("keen").Value).Property("AProperty"))) + throw new KeenInvalidKeenNamespacePropertyException(); + else + throw new Exception("Unexpected value"); + })); Assert.Throws(() => client.AddEvent("X", new { keen = new { AProperty = "AValue" } })); } @@ -318,7 +318,7 @@ public void AddEvent_Success() client.EventCollection = new EventCollectionMock(SettingsEnv, addEvent: new Action((c, e, p) => { - if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value()=="AValue")) + if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value() == "AValue")) return; else throw new Exception("Unexpected values"); @@ -470,8 +470,8 @@ public void AddGlobalProperty_SimpleValue_Success() client.EventCollection = new EventCollectionMock(SettingsEnv, addEvent: new Action((c, e, p) => { - if ((p == SettingsEnv) && (c == "AddEventTest") - && (e["AProperty"].Value() == "AValue") + if ((p == SettingsEnv) && (c == "AddEventTest") + && (e["AProperty"].Value() == "AValue") && (e["AGlobal"].Value() == "AValue")) return; else @@ -529,8 +529,8 @@ public void AddGlobalProperty_ObjectValue_Success() client.EventCollection = new EventCollectionMock(SettingsEnv, addEvent: new Action((c, e, p) => { - if ((p == SettingsEnv) && (c == "AddEventTest") - && (e["AProperty"].Value() == "AValue") + if ((p == SettingsEnv) && (c == "AddEventTest") + && (e["AProperty"].Value() == "AValue") && (e["AGlobal"]["AProperty"].Value() == "AValue")) return; else @@ -577,7 +577,7 @@ public void AddGlobalProperty_DelegateSimpleValue_Success() { if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value() == "AValue") - && (e["AGlobal"]!=null)) + && (e["AGlobal"] != null)) return; else throw new Exception("Unexpected value"); @@ -599,7 +599,7 @@ public void AddGlobalProperty_DelegateArrayValue_Success() client.EventCollection = new EventCollectionMock(SettingsEnv, addEvent: new Action((c, e, p) => { - if ((p == SettingsEnv) && (c == "AddEventTest") + if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value() == "AValue") && (e["AGlobal"].Values().All((x) => (x == 1) || (x == 2) || (x == 3)))) return; @@ -622,8 +622,8 @@ public void AddGlobalProperty_DelegateObjectValue_Success() client.EventCollection = new EventCollectionMock(SettingsEnv, addEvent: new Action((c, e, p) => { - if ((p == SettingsEnv) && (c == "AddEventTest") - && (e["AProperty"].Value() == "AValue") + if ((p == SettingsEnv) && (c == "AddEventTest") + && (e["AProperty"].Value() == "AValue") && (e["AGlobal"].Value()["SubProp1"].Value() == "Value")) return; else @@ -659,7 +659,7 @@ public void AddGlobalProperty_DelegateValueProviderNullReturn_Throws() client.EventCollection = new EventCollectionMock(SettingsEnv, addEvent: new Action((c, e, p) => { - if ((p == SettingsEnv) && (c == "AddEventTest") + if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value() == "AValue") && (e["AGlobal"].Value() == "value")) return; @@ -719,9 +719,9 @@ public async Task Caching_SendEvents_Success() client.Event = new EventMock(SettingsEnv, addEvents: new Func>((e, p) => { - if ((p == SettingsEnv) - && (null!=e.Property("CachedEventTest")) - && (e.Property("CachedEventTest").Value.Children().Count()==3)) + if ((p == SettingsEnv) + && (null != e.Property("CachedEventTest")) + && (e.Property("CachedEventTest").Value.Children().Count() == 3)) return new List(); else throw new Exception("Unexpected value"); @@ -760,7 +760,7 @@ public async Task Caching_SendManyEvents_Success() Assert.DoesNotThrow(() => client.SendCachedEvents()); Assert.Null(await client.EventCache.TryTakeAsync(), "Cache is empty"); - Assert.True( !UseMocks || ( total == KeenConstants.BulkBatchSize)); + Assert.True(!UseMocks || (total == KeenConstants.BulkBatchSize)); } [Test] @@ -772,8 +772,8 @@ public void Caching_SendInvalidEvents_Throws() addEvents: new Func>((e, p) => { if (p == SettingsEnv) - throw new KeenBulkException("Mock exception", - new List(){new CachedEvent("CachedEventTest", e, new Exception())}); + throw new KeenBulkException("Mock exception", + new List() { new CachedEvent("CachedEventTest", e, new Exception()) }); else throw new Exception("Unexpected value"); })); @@ -781,15 +781,15 @@ public void Caching_SendInvalidEvents_Throws() var anEvent = new JObject(); anEvent.Add("AProperty", "AValue"); client.AddEvent("CachedEventTest", anEvent); - - anEvent.Add("keen", JObject.FromObject(new {invalidPropName = "value"} )); + + anEvent.Add("keen", JObject.FromObject(new { invalidPropName = "value" })); client.AddEvent("CachedEventTest", anEvent); - Assert.DoesNotThrow(() => + Assert.DoesNotThrow(() => { try { client.SendCachedEvents(); - } + } catch (KeenBulkException ex) { if (ex.FailedEvents.Count() != 1) @@ -824,7 +824,7 @@ public async Task Async_DeleteCollection_Success() public void Async_GetCollectionSchema_NullProjectId_Throws() { var client = new KeenClient(SettingsEnv); - Assert.ThrowsAsync( () => client.GetSchemaAsync(null)); + Assert.ThrowsAsync(() => client.GetSchemaAsync(null)); } [Test] @@ -840,7 +840,7 @@ public void Async_AddEvent_InvalidProjectId_Throws() throw new KeenResourceNotFoundException(c); })); - Assert.ThrowsAsync( () => client.AddEventAsync("AddEventTest", new { AProperty = "Value" })); + Assert.ThrowsAsync(() => client.AddEventAsync("AddEventTest", new { AProperty = "Value" })); } [Test] @@ -870,7 +870,7 @@ public async Task Async_AddEvent_Success() if ((p == SettingsEnv) && (c == "AddEventTest") && (e["AProperty"].Value() == "Value")) throw new KeenResourceNotFoundException(c); })); - + await client.AddEventAsync("AddEventTest", new { AProperty = "AValue" }); } @@ -878,7 +878,7 @@ public async Task Async_AddEvent_Success() public void Async_AddEvents_NullCollection_Throws() { var client = new KeenClient(SettingsEnv); - Assert.ThrowsAsync( () => client.AddEventsAsync("AddEventTest", null)); + Assert.ThrowsAsync(() => client.AddEventsAsync("AddEventTest", null)); } [Test] @@ -944,7 +944,7 @@ public async Task Async_Caching_SendInvalidEvents_Throws() events.Add(invalidEvent); await client.AddEventsAsync("AddEventTest", events); - Assert.ThrowsAsync( () => client.SendCachedEventsAsync()); + Assert.ThrowsAsync(() => client.SendCachedEventsAsync()); } } } diff --git a/Keen.NetStandard.Test/ProjectSettingsProviderTest.cs b/Keen.NetStandard.Test/ProjectSettingsProviderTest.cs index 669d189..dd0c335 100644 --- a/Keen.NetStandard.Test/ProjectSettingsProviderTest.cs +++ b/Keen.NetStandard.Test/ProjectSettingsProviderTest.cs @@ -1,8 +1,8 @@ -using Newtonsoft.Json; -using NUnit.Framework; using System; using System.Collections.Generic; using System.IO; +using Newtonsoft.Json; +using NUnit.Framework; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/QueryTest.cs b/Keen.NetStandard.Test/QueryTest.cs index adc4f7d..1e9c577 100644 --- a/Keen.NetStandard.Test/QueryTest.cs +++ b/Keen.NetStandard.Test/QueryTest.cs @@ -1,13 +1,13 @@ -using Keen.Core.Query; -using Moq; -using Newtonsoft.Json.Linq; -using NUnit.Framework; using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; using System.Linq; using System.Threading.Tasks; +using Keen.Core.Query; +using Moq; +using Newtonsoft.Json.Linq; +using NUnit.Framework; namespace Keen.Core.Test @@ -39,7 +39,7 @@ public override void Setup() [Test] public void ReadKeyOnly_Success() { - var settings = new ProjectSettingsProvider(SettingsEnv.ProjectId, readKey: SettingsEnv.ReadKey); + var settings = new ProjectSettingsProvider(SettingsEnv.ProjectId, readKey: SettingsEnv.ReadKey); var client = new KeenClient(settings); if (!UseMocks) @@ -59,8 +59,8 @@ public async Task AvailableQueries_Success() if (UseMocks) { // A few values that should be present and are unlikely to change - IEnumerable> testResult = new List>() - { + IEnumerable> testResult = new List>() + { new KeyValuePair("minimum", "url" ), new KeyValuePair("average", "url" ), new KeyValuePair("maximum", "url" ), @@ -68,7 +68,7 @@ public async Task AvailableQueries_Success() }; queryMock = new Mock(); - queryMock.Setup(m=>m.AvailableQueries()) + queryMock.Setup(m => m.AvailableQueries()) .Returns(Task.FromResult(testResult)); client.Queries = queryMock.Object; @@ -106,7 +106,7 @@ public void Query_InvalidCollection_Throws() client.Queries = queryMock.Object; } - Assert.ThrowsAsync( () => client.QueryAsync(QueryType.Count(), null, "", timeframe, null)); + Assert.ThrowsAsync(() => client.QueryAsync(QueryType.Count(), null, "", timeframe, null)); } [Test] @@ -124,7 +124,7 @@ public async Task Query_ValidAbsolute_Success() It.Is(c => c == testCol), It.Is(p => p == ""), It.Is(t => t == timeframe), - It.Is>(f=>f==null), + It.Is>(f => f == null), It.Is(z => z == ""))) .Returns(Task.FromResult("0")); @@ -184,20 +184,20 @@ public async Task Query_ValidRelativeGroupInterval_Success() IEnumerable>>> reply = new List>>>() { - new QueryIntervalValue>>( + new QueryIntervalValue>>( new List>() { new QueryGroupValue( "1", "field1" ), new QueryGroupValue( "1", "field1" ), - }, + }, DateTime.Now, DateTime.Now.AddSeconds(2) ), - new QueryIntervalValue>>( + new QueryIntervalValue>>( new List>() { new QueryGroupValue( "2", "field1" ), new QueryGroupValue( "2", "field1" ), - }, + }, DateTime.Now, DateTime.Now.AddSeconds(2) ), }; @@ -330,7 +330,7 @@ public async Task Query_ValidRelativeInterval_Success() public async Task Query_ValidFilter_Success() { var client = new KeenClient(SettingsEnv); - var filters = new List(){ new QueryFilter("field1", QueryFilter.FilterOperator.GreaterThan(), "1") }; + var filters = new List() { new QueryFilter("field1", QueryFilter.FilterOperator.GreaterThan(), "1") }; var timeframe = QueryRelativeTimeframe.ThisHour(); Mock queryMock = null; @@ -372,10 +372,10 @@ public async Task CountUnique_ValidAbsolute_Success() queryMock.Setup(m => m.Metric( It.Is(q => q == QueryType.CountUnique()), It.Is(c => c == testCol), - It.Is(p=> p == prop), + It.Is(p => p == prop), It.Is(t => t == timeframe), It.Is>(f => f == null), - It.Is(t=>t=="") + It.Is(t => t == "") )) .Returns(Task.FromResult("0")); @@ -688,20 +688,20 @@ public async Task SelectUnique_ValidAbsoluteIntervalGroup_Success() var resultl = "hello,goodbye,I'm late"; IEnumerable>>> result = - new List>>>() - { + new List>>>() + { new QueryIntervalValue>>( new List>(){ new QueryGroupValue(resultl, "abc"), new QueryGroupValue(resultl, "def") - }, + }, timeframe.Start, timeframe.End ), new QueryIntervalValue>>( new List>(){ new QueryGroupValue(resultl, "abc"), new QueryGroupValue(resultl, "def") - }, + }, timeframe.Start, timeframe.End ), }; @@ -783,7 +783,7 @@ public async Task ExtractResource_ValidAbsolute_Success() It.Is(c => c == testCol), It.Is(t => t == timeframe), It.Is>(f => f == null), - It.Is( l => l == 0), + It.Is(l => l == 0), It.Is(t => t == "") )) .Returns(Task.FromResult(result)); @@ -866,8 +866,8 @@ public async Task MultiAnalysis_Valid_Success() var client = new KeenClient(SettingsEnv); var timeframe = QueryRelativeTimeframe.ThisHour(); - IEnumerable param = new List() - { + IEnumerable param = new List() + { new MultiAnalysisParam("first", MultiAnalysisParam.Metric.Count()), new MultiAnalysisParam("second", MultiAnalysisParam.Metric.Maximum("field1")), new MultiAnalysisParam("third", MultiAnalysisParam.Metric.Minimum("field1")), @@ -907,8 +907,8 @@ public async Task MultiAnalysis_ValidRelativeTimeFrame_Success() { var client = new KeenClient(SettingsEnv); var timeframe = QueryRelativeTimeframe.PreviousNDays(2); - IEnumerable param = new List() - { + IEnumerable param = new List() + { new MultiAnalysisParam("first", MultiAnalysisParam.Metric.Count()), new MultiAnalysisParam("second", MultiAnalysisParam.Metric.Maximum("field1")), new MultiAnalysisParam("third", MultiAnalysisParam.Metric.Minimum("field1")), @@ -949,8 +949,8 @@ public async Task MultiAnalysis_ValidGroupBy_Success() var client = new KeenClient(SettingsEnv); var timeframe = QueryRelativeTimeframe.ThisHour(); var groupby = "field1"; - IEnumerable param = new List() - { + IEnumerable param = new List() + { new MultiAnalysisParam("first", MultiAnalysisParam.Metric.Count()), new MultiAnalysisParam("second", MultiAnalysisParam.Metric.Maximum("field1")), new MultiAnalysisParam("third", MultiAnalysisParam.Metric.Minimum("field1")), @@ -999,8 +999,8 @@ public async Task MultiAnalysis_ValidIntervalGroupBy_Success() var timeframe = QueryRelativeTimeframe.PreviousNDays(3); var interval = QueryInterval.Daily(); var groupby = "field1"; - IEnumerable param = new List() - { + IEnumerable param = new List() + { new MultiAnalysisParam("first", MultiAnalysisParam.Metric.Count()), new MultiAnalysisParam("second", MultiAnalysisParam.Metric.Maximum("field1")), new MultiAnalysisParam("third", MultiAnalysisParam.Metric.Minimum("field1")), @@ -1018,14 +1018,14 @@ public async Task MultiAnalysis_ValidIntervalGroupBy_Success() new List>>(){ new QueryGroupValue>(dict, groupby), new QueryGroupValue>(dict, groupby) - }, + }, DateTime.Now, DateTime.Now.AddSeconds(2) ), new QueryIntervalValue>>>( new List>>(){ new QueryGroupValue>(dict, groupby), new QueryGroupValue>(dict, groupby) - }, + }, DateTime.Now, DateTime.Now.AddSeconds(2) ), }; @@ -1038,7 +1038,7 @@ public async Task MultiAnalysis_ValidIntervalGroupBy_Success() It.Is(c => c == testCol), It.Is>(p => p == param), It.Is(t => t == timeframe), - It.Is(i=>i==interval), + It.Is(i => i == interval), It.Is>(f => f == null), It.Is(g => g == groupby), It.Is(tz => tz == "") @@ -1058,8 +1058,8 @@ public async Task MultiAnalysis_ValidIntervalGroupBy_Success() public async Task MultiAnalysis_ValidInterval_Success() { var client = new KeenClient(SettingsEnv); - IEnumerable param = new List() - { + IEnumerable param = new List() + { new MultiAnalysisParam("first", MultiAnalysisParam.Metric.Count()), new MultiAnalysisParam("second", MultiAnalysisParam.Metric.Maximum("field1")), new MultiAnalysisParam("third", MultiAnalysisParam.Metric.Minimum("field1")), @@ -1067,14 +1067,14 @@ public async Task MultiAnalysis_ValidInterval_Success() var timeframe = QueryRelativeTimeframe.PreviousNDays(3); var interval = QueryInterval.Daily(); IEnumerable>> result = new List>>(); - foreach( var i in Enumerable.Range(1,3)) + foreach (var i in Enumerable.Range(1, 3)) { var dic = new Dictionary(); dic.Add("second", "fff"); dic.Add("third", "aaa"); dic.Add("first", "123"); - var qv = new QueryIntervalValue>(dic, DateTime.Now, DateTime.Now.AddSeconds(2)); + var qv = new QueryIntervalValue>(dic, DateTime.Now, DateTime.Now.AddSeconds(2)); ((List>>)result).Add(qv); } @@ -1167,16 +1167,16 @@ public void Serialize_GeoValue_Success() var json = JObject.FromObject(filter).ToString(Newtonsoft.Json.Formatting.None); Trace.WriteLine(json); - const string expectedJson = "{"+ - "\"property_name\":\"prop\","+ - "\"operator\":\"within\","+ - "\"property_value\":{"+ - "\"coordinates\":["+ - "10.0,"+ - "10.0"+ - "],"+ - "\"max_distance_miles\":5.0"+ - "}"+ + const string expectedJson = "{" + + "\"property_name\":\"prop\"," + + "\"operator\":\"within\"," + + "\"property_value\":{" + + "\"coordinates\":[" + + "10.0," + + "10.0" + + "]," + + "\"max_distance_miles\":5.0" + + "}" + "}"; Assert.AreEqual(expectedJson, json); diff --git a/Keen.NetStandard.Test/QueryTests_Integration.cs b/Keen.NetStandard.Test/QueryTests_Integration.cs index 2578791..d0cc03e 100644 --- a/Keen.NetStandard.Test/QueryTests_Integration.cs +++ b/Keen.NetStandard.Test/QueryTests_Integration.cs @@ -1,14 +1,14 @@ -using Keen.Core.Query; -using NUnit.Framework; using System; using System.Collections.Generic; -using System.Threading.Tasks; +using System.Collections.Specialized; using System.Linq; -using System.Text; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json; +using System.Threading.Tasks; using System.Web; -using System.Collections.Specialized; +using Keen.Core.Query; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using NUnit.Framework; + namespace Keen.Core.Test { @@ -290,7 +290,7 @@ FuncHandler CreateQueryRequestHandler(QueryParameters queryParameters, object re $"{HttpTests.GetUriForResource(SettingsEnv, KeenConstants.QueriesResource)}/" + $"{queryParameters.GetResourceName()}"; - string actualPath = + string actualPath = $"{request.RequestUri.Scheme}{Uri.SchemeDelimiter}" + $"{request.RequestUri.Authority}{request.RequestUri.AbsolutePath}"; @@ -357,7 +357,7 @@ public async Task Query_SimpleSelectUnique_Success() "theOtherThing" }; - var expectedResponse = new + var expectedResponse = new { result = results, }; diff --git a/Keen.NetStandard.Test/ScopedKeyTest.cs b/Keen.NetStandard.Test/ScopedKeyTest.cs index 5a0ed2d..0a7510f 100644 --- a/Keen.NetStandard.Test/ScopedKeyTest.cs +++ b/Keen.NetStandard.Test/ScopedKeyTest.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json.Linq; -using NUnit.Framework; using System; using System.Collections.Generic; using System.Diagnostics; using System.Dynamic; using System.Linq; +using Newtonsoft.Json.Linq; +using NUnit.Framework; namespace Keen.Core.Test @@ -95,11 +95,11 @@ public void Encrypt_PopulatedObject_Success() dynamic secOps = new ExpandoObject(); IDictionary filter = new ExpandoObject(); - filter.Add("property_name", "account_id" ); - filter.Add("operator", "eq" ); - filter.Add("property_value", 123 ); - secOps.filters = new List(){ filter }; - secOps.allowed_operations = new List(){ "read" }; + filter.Add("property_name", "account_id"); + filter.Add("operator", "eq"); + filter.Add("property_value", 123); + secOps.filters = new List() { filter }; + secOps.allowed_operations = new List() { "read" }; var scopedKey = ScopedKey.Encrypt(settings.MasterKey, (object)secOps); }); @@ -122,7 +122,7 @@ public void RoundTrip_PopulatedObject_Success() { var scopedKey = ScopedKey.Encrypt(settings.MasterKey, (object)secOpsIn); var decrypted = ScopedKey.Decrypt(settings.MasterKey, scopedKey); - var secOpsOut = JObject.Parse(decrypted); + var secOpsOut = JObject.Parse(decrypted); Assert.True(secOpsIn.allowed_operations[0] == (string)(secOpsOut["allowed_operations"].First())); }); } @@ -186,7 +186,7 @@ public void Roundtrip_RndIV_Success() var rnd = new System.Security.Cryptography.RNGCryptoServiceProvider(); var bytes = new byte[16]; rnd.GetBytes(bytes); - + var iv = String.Concat(bytes.Select(b => b.ToString("X2"))); Trace.WriteLine("IV: " + iv); Trace.WriteLine("plaintext: " + str); diff --git a/Keen.NetStandard.Test/TestBase.cs b/Keen.NetStandard.Test/TestBase.cs index 60cad8e..07dcbd2 100644 --- a/Keen.NetStandard.Test/TestBase.cs +++ b/Keen.NetStandard.Test/TestBase.cs @@ -1,4 +1,4 @@ -using System; +using System; using NUnit.Framework; @@ -43,4 +43,4 @@ public static void ResetEnv() Environment.SetEnvironmentVariable(s, null); } } -} \ No newline at end of file +} diff --git a/Keen.NetStandard.Test/TestKeenHttpClientProvider.cs b/Keen.NetStandard.Test/TestKeenHttpClientProvider.cs index 8684a98..035cc6a 100644 --- a/Keen.NetStandard.Test/TestKeenHttpClientProvider.cs +++ b/Keen.NetStandard.Test/TestKeenHttpClientProvider.cs @@ -1,5 +1,4 @@ -using System; -using Keen.Core; +using System; namespace Keen.Core.Test diff --git a/Keen.NetStandard.Test/TimeframeConverterTest.cs b/Keen.NetStandard.Test/TimeframeConverterTest.cs index cf541f4..6fde2e0 100644 --- a/Keen.NetStandard.Test/TimeframeConverterTest.cs +++ b/Keen.NetStandard.Test/TimeframeConverterTest.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; -using System.Text; -using NUnit.Framework; -using Newtonsoft.Json; using Keen.Core.Query; +using Newtonsoft.Json; +using NUnit.Framework; + namespace Keen.NetStandard.Test { diff --git a/Keen.NetStandard.Test/UrlToMessageHandler.cs b/Keen.NetStandard.Test/UrlToMessageHandler.cs index 186ce84..1f8c7e7 100644 --- a/Keen.NetStandard.Test/UrlToMessageHandler.cs +++ b/Keen.NetStandard.Test/UrlToMessageHandler.cs @@ -1,11 +1,8 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Net.Http; -using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; @@ -37,7 +34,8 @@ internal class UrlToMessageHandler : IHttpMessageHandler public Func> DefaultAsync { get; set; } + Task> DefaultAsync + { get; set; } internal bool DeferToDefault { get; set; } = true; diff --git a/Keen.NetStandard/AsyncLazy.cs b/Keen.NetStandard/AsyncLazy.cs index 01eb43e..40aa3f6 100644 --- a/Keen.NetStandard/AsyncLazy.cs +++ b/Keen.NetStandard/AsyncLazy.cs @@ -1,7 +1,8 @@ -using System; +using System; using System.Runtime.CompilerServices; using System.Threading.Tasks; + namespace Keen.Core { // Simple version of AsyncLazy based on diff --git a/Keen.NetStandard/CachedEvent.cs b/Keen.NetStandard/CachedEvent.cs index 9cc2714..b802f42 100644 --- a/Keen.NetStandard/CachedEvent.cs +++ b/Keen.NetStandard/CachedEvent.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json.Linq; using System; +using Newtonsoft.Json.Linq; namespace Keen.Core.EventCache diff --git a/Keen.NetStandard/DataEnrichment/EventAddOn.cs b/Keen.NetStandard/DataEnrichment/EventAddOn.cs index e69759d..f8a8e3e 100644 --- a/Keen.NetStandard/DataEnrichment/EventAddOn.cs +++ b/Keen.NetStandard/DataEnrichment/EventAddOn.cs @@ -1,11 +1,11 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using Newtonsoft.Json; namespace Keen.Core.DataEnrichment { /// - /// Represents a Data Enrichment add-on. + /// Represents a Data Enrichment add-on. /// /// https://keen.io/docs/data-collection/data-enrichment/ /// @@ -16,19 +16,19 @@ public sealed class AddOn /// Name of the add-on /// [JsonProperty(PropertyName = "name")] - public string Name { get; private set; } + public string Name { get; } /// /// Parameters required by the add-on /// [JsonProperty(PropertyName = "input")] - public Dictionary Input { get; private set; } + public Dictionary Input { get; } /// /// Target property name where the enriched data should be stored. /// [JsonProperty(PropertyName = "output")] - public string Output { get; private set; } + public string Output { get; } /// Name of the data enhancement add-on. /// Name-value pairs of input parameters required by the add-on. @@ -108,4 +108,4 @@ public static AddOn ReferrerParser(string referrerUrlField, string pageUrlField, outputField); } } -} \ No newline at end of file +} diff --git a/Keen.NetStandard/Dataset/DatasetDefinition.cs b/Keen.NetStandard/Dataset/DatasetDefinition.cs index 4439346..ba1d10d 100644 --- a/Keen.NetStandard/Dataset/DatasetDefinition.cs +++ b/Keen.NetStandard/Dataset/DatasetDefinition.cs @@ -1,7 +1,7 @@ -using Keen.Core.Query; using System; using System.Collections.Generic; using System.Linq; +using Keen.Core.Query; namespace Keen.Core.Dataset diff --git a/Keen.NetStandard/Dataset/DatasetDefinitionCollection.cs b/Keen.NetStandard/Dataset/DatasetDefinitionCollection.cs index adf6a10..dc9aa2c 100644 --- a/Keen.NetStandard/Dataset/DatasetDefinitionCollection.cs +++ b/Keen.NetStandard/Dataset/DatasetDefinitionCollection.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Keen.Core.Dataset diff --git a/Keen.NetStandard/Dataset/Datasets.cs b/Keen.NetStandard/Dataset/Datasets.cs index b6759e0..f14224a 100644 --- a/Keen.NetStandard/Dataset/Datasets.cs +++ b/Keen.NetStandard/Dataset/Datasets.cs @@ -1,11 +1,11 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; namespace Keen.Core.Dataset @@ -16,8 +16,9 @@ namespace Keen.Core.Dataset /// internal class Datasets : IDataset { - private const int MAX_DATASET_DEFINITION_LIST_LIMIT = 100; - private static readonly JsonSerializerSettings SERIALIZER_SETTINGS = + private const int MaxDatasetDefinitionListLimit = 100; + + private static readonly JsonSerializerSettings SerializerSettings = new JsonSerializerSettings { ContractResolver = new DefaultContractResolver @@ -150,7 +151,7 @@ public async Task GetDefinitionAsync(string datasetName) } return JsonConvert.DeserializeObject(responseString, - SERIALIZER_SETTINGS); + SerializerSettings); } public async Task ListDefinitionsAsync( @@ -191,13 +192,13 @@ public async Task GetDefinitionAsync(string datasetName) } return JsonConvert.DeserializeObject(responseString, - SERIALIZER_SETTINGS); + SerializerSettings); } public async Task> ListAllDefinitionsAsync() { var allDefinitions = new List(); - var firstSet = await ListDefinitionsAsync(MAX_DATASET_DEFINITION_LIST_LIMIT) + var firstSet = await ListDefinitionsAsync(MaxDatasetDefinitionListLimit) .ConfigureAwait(continueOnCapturedContext: false); if (null == firstSet?.Datasets) @@ -219,7 +220,7 @@ public async Task> ListAllDefinitionsAsync() do { - var nextSet = await ListDefinitionsAsync(MAX_DATASET_DEFINITION_LIST_LIMIT, + var nextSet = await ListDefinitionsAsync(MaxDatasetDefinitionListLimit, allDefinitions.Last().DatasetName) .ConfigureAwait(continueOnCapturedContext: false); @@ -281,7 +282,7 @@ public async Task CreateDatasetAsync(DatasetDefinition datase // This throws if dataset is not valid. dataset.Validate(); - var content = JsonConvert.SerializeObject(dataset, SERIALIZER_SETTINGS); + var content = JsonConvert.SerializeObject(dataset, SerializerSettings); var responseMsg = await _keenHttpClient .PutAsync(GetDatasetUrl(dataset.DatasetName), _masterKey, content) @@ -302,7 +303,7 @@ public async Task CreateDatasetAsync(DatasetDefinition datase } return JsonConvert.DeserializeObject(responseString, - SERIALIZER_SETTINGS); + SerializerSettings); } private string GetDatasetUrl(string datasetName = null) diff --git a/Keen.NetStandard/Dataset/IDataset.cs b/Keen.NetStandard/Dataset/IDataset.cs index e24b1f5..d7fe6e4 100644 --- a/Keen.NetStandard/Dataset/IDataset.cs +++ b/Keen.NetStandard/Dataset/IDataset.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Keen.Core.Dataset diff --git a/Keen.NetStandard/Dataset/QueryDefinitionExtensions.cs b/Keen.NetStandard/Dataset/QueryDefinitionExtensions.cs index 616d966..ea8b62b 100644 --- a/Keen.NetStandard/Dataset/QueryDefinitionExtensions.cs +++ b/Keen.NetStandard/Dataset/QueryDefinitionExtensions.cs @@ -1,4 +1,4 @@ -using Keen.Core.Query; +using Keen.Core.Query; namespace Keen.Core.Dataset diff --git a/Keen.NetStandard/DynamicPropertyValue.cs b/Keen.NetStandard/DynamicPropertyValue.cs index 5afe658..42001cd 100644 --- a/Keen.NetStandard/DynamicPropertyValue.cs +++ b/Keen.NetStandard/DynamicPropertyValue.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Keen.Core diff --git a/Keen.NetStandard/Event.cs b/Keen.NetStandard/Event.cs index ec6a690..67ce730 100644 --- a/Keen.NetStandard/Event.cs +++ b/Keen.NetStandard/Event.cs @@ -1,9 +1,9 @@ -using Keen.Core.EventCache; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Keen.Core.EventCache; +using Newtonsoft.Json.Linq; namespace Keen.Core @@ -138,17 +138,17 @@ public async Task> AddEvents(JObject events) // or if the HTTP response is a failure, throw. var failedItems = from respCols in jsonResponse.Properties() - from eventsCols in events.Properties() - where respCols.Name == eventsCols.Name - let collection = respCols.Name - let combined = eventsCols.Children().Children() - .Zip(respCols.Children().Children(), - (e, r) => new { eventObj = (JObject)e, result = (JObject)r }) - from e in combined - where !(bool)(e.result.Property("success").Value) - select new CachedEvent(collection, - e.eventObj, - KeenUtil.GetBulkApiError(e.result)); + from eventsCols in events.Properties() + where respCols.Name == eventsCols.Name + let collection = respCols.Name + let combined = eventsCols.Children().Children() + .Zip(respCols.Children().Children(), + (e, r) => new { eventObj = (JObject)e, result = (JObject)r }) + from e in combined + where !(bool)(e.result.Property("success").Value) + select new CachedEvent(collection, + e.eventObj, + KeenUtil.GetBulkApiError(e.result)); return failedItems; } diff --git a/Keen.NetStandard/EventCacheMemory.cs b/Keen.NetStandard/EventCacheMemory.cs index da77f33..d4624fa 100644 --- a/Keen.NetStandard/EventCacheMemory.cs +++ b/Keen.NetStandard/EventCacheMemory.cs @@ -1,7 +1,8 @@ -using Keen.Core.EventCache; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Keen.Core.EventCache; + namespace Keen.Core { diff --git a/Keen.NetStandard/EventCachePortable.cs b/Keen.NetStandard/EventCachePortable.cs index e59f395..3bfa9fa 100644 --- a/Keen.NetStandard/EventCachePortable.cs +++ b/Keen.NetStandard/EventCachePortable.cs @@ -1,11 +1,12 @@ -using Keen.Core.EventCache; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; using System.IO; +using System.Linq; using System.Text; +using System.Threading.Tasks; +using Keen.Core.EventCache; +using Newtonsoft.Json.Linq; + namespace Keen.Core { diff --git a/Keen.NetStandard/EventCollection.cs b/Keen.NetStandard/EventCollection.cs index eb5fc24..85e876a 100644 --- a/Keen.NetStandard/EventCollection.cs +++ b/Keen.NetStandard/EventCollection.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json.Linq; using System; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Keen.Core diff --git a/Keen.NetStandard/HttpClientCache.cs b/Keen.NetStandard/HttpClientCache.cs index 3dd943c..e7d2064 100644 --- a/Keen.NetStandard/HttpClientCache.cs +++ b/Keen.NetStandard/HttpClientCache.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; @@ -72,7 +72,7 @@ internal HttpClientCache() if (null == httpClient) { throw new KeenException( - string.Format("Existing HttpClient for baseUrl \"{0}\" has been" + + string.Format("Existing HttpClient for baseUrl \"{0}\" has been" + "garbage collected.", baseUrl)); } } diff --git a/Keen.NetStandard/IDynamicPropertyValue.cs b/Keen.NetStandard/IDynamicPropertyValue.cs index 9015095..21aecd3 100644 --- a/Keen.NetStandard/IDynamicPropertyValue.cs +++ b/Keen.NetStandard/IDynamicPropertyValue.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core { interface IDynamicPropertyValue diff --git a/Keen.NetStandard/IEvent.cs b/Keen.NetStandard/IEvent.cs index 568d4b2..6f08416 100644 --- a/Keen.NetStandard/IEvent.cs +++ b/Keen.NetStandard/IEvent.cs @@ -1,7 +1,7 @@ -using Keen.Core.EventCache; -using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.Threading.Tasks; +using Keen.Core.EventCache; +using Newtonsoft.Json.Linq; namespace Keen.Core diff --git a/Keen.NetStandard/IEventCache.cs b/Keen.NetStandard/IEventCache.cs index a4297cb..6a3592e 100644 --- a/Keen.NetStandard/IEventCache.cs +++ b/Keen.NetStandard/IEventCache.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; namespace Keen.Core.EventCache diff --git a/Keen.NetStandard/IEventCollection.cs b/Keen.NetStandard/IEventCollection.cs index dfb96c9..19195c5 100644 --- a/Keen.NetStandard/IEventCollection.cs +++ b/Keen.NetStandard/IEventCollection.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json.Linq; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Keen.Core diff --git a/Keen.NetStandard/IHttpClientProvider.cs b/Keen.NetStandard/IHttpClientProvider.cs index e7db7d1..5bd803f 100644 --- a/Keen.NetStandard/IHttpClientProvider.cs +++ b/Keen.NetStandard/IHttpClientProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net.Http; @@ -63,4 +63,4 @@ public interface IHttpClientProvider /// otherwise. bool ExistsForUrl(Uri baseUrl); } -} \ No newline at end of file +} diff --git a/Keen.NetStandard/IKeenHttpClient.cs b/Keen.NetStandard/IKeenHttpClient.cs index 812e07c..f3d0f20 100644 --- a/Keen.NetStandard/IKeenHttpClient.cs +++ b/Keen.NetStandard/IKeenHttpClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Net.Http; using System.Threading.Tasks; diff --git a/Keen.NetStandard/IKeenHttpClientProvider.cs b/Keen.NetStandard/IKeenHttpClientProvider.cs index 6212b74..1b53217 100644 --- a/Keen.NetStandard/IKeenHttpClientProvider.cs +++ b/Keen.NetStandard/IKeenHttpClientProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Keen.Core diff --git a/Keen.NetStandard/IProjectSettings.cs b/Keen.NetStandard/IProjectSettings.cs index 45ed7a3..63523e9 100644 --- a/Keen.NetStandard/IProjectSettings.cs +++ b/Keen.NetStandard/IProjectSettings.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core { /// diff --git a/Keen.NetStandard/KeenClient.cs b/Keen.NetStandard/KeenClient.cs index 2c8ed91..a230f95 100644 --- a/Keen.NetStandard/KeenClient.cs +++ b/Keen.NetStandard/KeenClient.cs @@ -1,13 +1,13 @@ -using Keen.Core.DataEnrichment; -using Keen.Core.Dataset; -using Keen.Core.EventCache; -using Keen.Core.Query; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Threading.Tasks; +using Keen.Core.DataEnrichment; +using Keen.Core.Dataset; +using Keen.Core.EventCache; +using Keen.Core.Query; +using Newtonsoft.Json.Linq; namespace Keen.Core @@ -275,7 +275,7 @@ public void AddEvents(string collection, IEnumerable eventsInfo, IEnumer if (!eventsInfo.Any()) return new List(); // Build a container object with a property to identify the collection - var jEvent = new JObject {{collection, JToken.FromObject(eventsInfo)}}; + var jEvent = new JObject { { collection, JToken.FromObject(eventsInfo) } }; // Use the bulk interface to add events return await Event.AddEvents(jEvent).ConfigureAwait(false); @@ -385,12 +385,12 @@ private JObject PrepareUserObject(object eventInfo, IEnumerable addOns) // Ensure this event has a 'keen' object of the correct type if (null == jEvent.Property("keen")) jEvent.Add("keen", new JObject()); - else if (jEvent.Property("keen").Value.GetType() != typeof (JObject)) + else if (jEvent.Property("keen").Value.GetType() != typeof(JObject)) throw new KeenException(string.Format("Value of property \"keen\" must be an object, is {0}", jEvent.Property("keen").GetType())); - var keen = ((JObject) jEvent.Property("keen").Value); + var keen = ((JObject)jEvent.Property("keen").Value); if (addOns != null && addOns.Any()) keen.Add("addons", JArray.FromObject(addOns)); @@ -1039,7 +1039,7 @@ public DatasetDefinitionCollection ListDatasetDefinitions(int limit = 10, string { return ListDatasetDefinitionsAsync(limit, afterName).Result; } - catch(AggregateException ex) + catch (AggregateException ex) { throw ex.TryUnwrap(); } diff --git a/Keen.NetStandard/KeenConstants.cs b/Keen.NetStandard/KeenConstants.cs index 0b1c6a4..4756eda 100644 --- a/Keen.NetStandard/KeenConstants.cs +++ b/Keen.NetStandard/KeenConstants.cs @@ -1,88 +1,88 @@ - + namespace Keen.Core { public class KeenConstants { private const string serverAddress = "https://api.keen.io"; - public static string ServerAddress { get { return serverAddress; } protected set { ;} } + public static string ServerAddress { get { return serverAddress; } protected set {; } } private const string eventsResource = "events"; - public static string EventsResource { get { return eventsResource; } protected set { ;} } + public static string EventsResource { get { return eventsResource; } protected set {; } } private const string queriesResource = "queries"; - public static string QueriesResource { get { return queriesResource; } protected set { ;} } + public static string QueriesResource { get { return queriesResource; } protected set {; } } private const string queryCount = "count"; - public static string QueryCount { get { return queryCount; } protected set { ;} } + public static string QueryCount { get { return queryCount; } protected set {; } } private const string queryCountUnique = "count_unique"; - public static string QueryCountUnique { get { return queryCountUnique; } protected set { ;} } + public static string QueryCountUnique { get { return queryCountUnique; } protected set {; } } private const string queryMinimum = "minimum"; - public static string QueryMinimum { get { return queryMinimum; } protected set { ;} } + public static string QueryMinimum { get { return queryMinimum; } protected set {; } } private const string queryMaximum = "maximum"; - public static string QueryMaximum { get { return queryMaximum; } protected set { ;} } + public static string QueryMaximum { get { return queryMaximum; } protected set {; } } private const string queryAverage = "average"; - public static string QueryAverage { get { return queryAverage; } protected set { ;} } + public static string QueryAverage { get { return queryAverage; } protected set {; } } private const string querySum = "sum"; - public static string QuerySum { get { return querySum; } protected set { ;} } + public static string QuerySum { get { return querySum; } protected set {; } } private const string querySelectUnique = "select_unique"; - public static string QuerySelectUnique { get { return querySelectUnique; } protected set { ;} } + public static string QuerySelectUnique { get { return querySelectUnique; } protected set {; } } private const string queryExtraction = "extraction"; - public static string QueryExtraction { get { return queryExtraction; } protected set { ;} } + public static string QueryExtraction { get { return queryExtraction; } protected set {; } } private const string queryFunnel = "funnel"; - public static string QueryFunnel { get { return queryFunnel; } protected set { ;} } + public static string QueryFunnel { get { return queryFunnel; } protected set {; } } private const string queryMultiAnalysis = "multi_analysis"; - public static string QueryMultiAnalysis { get { return queryMultiAnalysis; } protected set { ;} } + public static string QueryMultiAnalysis { get { return queryMultiAnalysis; } protected set {; } } private const string queryParmEventCollection = "event_collection"; - public static string QueryParmEventCollection { get { return queryParmEventCollection; } protected set { ;} } + public static string QueryParmEventCollection { get { return queryParmEventCollection; } protected set {; } } private const string queryParmTargetProperty = "target_property"; - public static string QueryParmTargetProperty { get { return queryParmTargetProperty; } protected set { ;} } + public static string QueryParmTargetProperty { get { return queryParmTargetProperty; } protected set {; } } private const string queryParmTimeframe = "timeframe"; - public static string QueryParmTimeframe { get { return queryParmTimeframe; } protected set { ;} } + public static string QueryParmTimeframe { get { return queryParmTimeframe; } protected set {; } } private const string queryParmGroupBy = "group_by"; - public static string QueryParmGroupBy { get { return queryParmGroupBy; } protected set { ;} } + public static string QueryParmGroupBy { get { return queryParmGroupBy; } protected set {; } } private const string queryParmInterval = "interval"; - public static string QueryParmInterval { get { return queryParmInterval; } protected set { ;} } + public static string QueryParmInterval { get { return queryParmInterval; } protected set {; } } private const string queryParmTimezone = "timezone"; - public static string QueryParmTimezone { get { return queryParmTimezone; } protected set { ;} } + public static string QueryParmTimezone { get { return queryParmTimezone; } protected set {; } } private const string queryParmFilters = "filters"; - public static string QueryParmFilters { get { return queryParmFilters; } protected set { ;} } + public static string QueryParmFilters { get { return queryParmFilters; } protected set {; } } private const string queryParmEmail = "email"; - public static string QueryParmEmail { get { return queryParmEmail; } protected set { ;} } + public static string QueryParmEmail { get { return queryParmEmail; } protected set {; } } private const string queryParmLatest = "latest"; - public static string QueryParmLatest { get { return queryParmLatest; } protected set { ;} } + public static string QueryParmLatest { get { return queryParmLatest; } protected set {; } } private const string queryParmSteps = "steps"; - public static string QueryParmSteps { get { return queryParmSteps; } protected set { ;} } + public static string QueryParmSteps { get { return queryParmSteps; } protected set {; } } private const string queryParmAnalyses = "analyses"; - public static string QueryParmAnalyses { get { return queryParmAnalyses; } protected set { ;} } + public static string QueryParmAnalyses { get { return queryParmAnalyses; } protected set {; } } private const string apiVersion = "3.0"; - public static string ApiVersion { get { return apiVersion; } protected set { ;} } + public static string ApiVersion { get { return apiVersion; } protected set {; } } private const int bulkBatchSize = 1000; - public static int BulkBatchSize { get { return bulkBatchSize; } protected set { ;} } + public static int BulkBatchSize { get { return bulkBatchSize; } protected set {; } } private const string datasetsResource = "datasets"; - public static string DatasetsResource { get { return datasetsResource; } protected set { ;} } + public static string DatasetsResource { get { return datasetsResource; } protected set {; } } private const string keenProjectId = "KEEN_PROJECT_ID"; public static string KeenProjectId { get { return keenProjectId; } protected set {; } } diff --git a/Keen.NetStandard/KeenException.cs b/Keen.NetStandard/KeenException.cs index ed5e833..c5a215f 100644 --- a/Keen.NetStandard/KeenException.cs +++ b/Keen.NetStandard/KeenException.cs @@ -1,6 +1,6 @@ -using Keen.Core.EventCache; using System; using System.Collections.Generic; +using Keen.Core.EventCache; namespace Keen.Core @@ -23,7 +23,7 @@ public class KeenResourceNotFoundException : KeenException { public KeenResourceNotFoundException() { } public KeenResourceNotFoundException(string message) : base(message) { } - public KeenResourceNotFoundException(string message, Exception inner) : base(message, inner) { } + public KeenResourceNotFoundException(string message, Exception inner) : base(message, inner) { } } public class KeenNamespaceTypeException : KeenException @@ -44,7 +44,7 @@ public class KeenListsOfNonPrimitivesNotAllowedException : KeenException { public KeenListsOfNonPrimitivesNotAllowedException() { } public KeenListsOfNonPrimitivesNotAllowedException(string message) : base(message) { } - public KeenListsOfNonPrimitivesNotAllowedException(string message, Exception inner) : base(message, inner) { } + public KeenListsOfNonPrimitivesNotAllowedException(string message, Exception inner) : base(message, inner) { } } public class KeenInvalidBatchException : KeenException @@ -60,15 +60,15 @@ public class KeenInternalServerErrorException : KeenException public KeenInternalServerErrorException(string message) : base(message) { } public KeenInternalServerErrorException(string message, Exception inner) : base(message, inner) { } } - - public class KeenInvalidKeenNamespacePropertyException: KeenException + + public class KeenInvalidKeenNamespacePropertyException : KeenException { public KeenInvalidKeenNamespacePropertyException() { } public KeenInvalidKeenNamespacePropertyException(string message) : base(message) { } public KeenInvalidKeenNamespacePropertyException(string message, Exception inner) : base(message, inner) { } } - - public class KeenInvalidPropertyNameException: KeenException + + public class KeenInvalidPropertyNameException : KeenException { public KeenInvalidPropertyNameException() { } public KeenInvalidPropertyNameException(string message) : base(message) { } @@ -78,8 +78,8 @@ public class KeenInvalidPropertyNameException: KeenException public class KeenBulkException : KeenException { private IEnumerable _failedEvents; - public IEnumerable FailedEvents { get { return _failedEvents; } protected set { ; } } + public IEnumerable FailedEvents { get { return _failedEvents; } protected set {; } } public KeenBulkException(IEnumerable failedEvents) { _failedEvents = failedEvents; } - public KeenBulkException(string message, IEnumerable failedEvents ) : base(message) { _failedEvents = failedEvents; } + public KeenBulkException(string message, IEnumerable failedEvents) : base(message) { _failedEvents = failedEvents; } } } diff --git a/Keen.NetStandard/KeenHttpClient.cs b/Keen.NetStandard/KeenHttpClient.cs index 4ebccbf..818bdeb 100644 --- a/Keen.NetStandard/KeenHttpClient.cs +++ b/Keen.NetStandard/KeenHttpClient.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Net.Http; using System.Net.Http.Headers; diff --git a/Keen.NetStandard/KeenHttpClientFactory.cs b/Keen.NetStandard/KeenHttpClientFactory.cs index 191029c..8099619 100644 --- a/Keen.NetStandard/KeenHttpClientFactory.cs +++ b/Keen.NetStandard/KeenHttpClientFactory.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; diff --git a/Keen.NetStandard/KeenHttpClientProvider.cs b/Keen.NetStandard/KeenHttpClientProvider.cs index 2703d8b..d5361b6 100644 --- a/Keen.NetStandard/KeenHttpClientProvider.cs +++ b/Keen.NetStandard/KeenHttpClientProvider.cs @@ -1,4 +1,4 @@ -using System; +using System; namespace Keen.Core diff --git a/Keen.NetStandard/KeenUtil.cs b/Keen.NetStandard/KeenUtil.cs index a377a18..c1665a4 100644 --- a/Keen.NetStandard/KeenUtil.cs +++ b/Keen.NetStandard/KeenUtil.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Text.RegularExpressions; +using Newtonsoft.Json.Linq; namespace Keen.Core diff --git a/Keen.NetStandard/ProjectSettingsProvider.cs b/Keen.NetStandard/ProjectSettingsProvider.cs index 46fd266..2b0077d 100644 --- a/Keen.NetStandard/ProjectSettingsProvider.cs +++ b/Keen.NetStandard/ProjectSettingsProvider.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core { public class ProjectSettingsProvider : IProjectSettings @@ -8,7 +8,7 @@ public class ProjectSettingsProvider : IProjectSettings /// server address and API version. /// public string KeenUrl { get; protected set; } - + /// /// The Project ID, identifying the data silo to be accessed. /// @@ -53,7 +53,7 @@ public class ProjectSettingsProvider : IProjectSettings /// /// Protected constructor to allow base classes to share initialization code more conveniently than by having to pass parameters through a constructor /// - protected ProjectSettingsProvider() {} + protected ProjectSettingsProvider() { } protected void Initialize( string projectId, diff --git a/Keen.NetStandard/ProjectSettingsProviderEnv.cs b/Keen.NetStandard/ProjectSettingsProviderEnv.cs index d758b5a..f4d4cde 100644 --- a/Keen.NetStandard/ProjectSettingsProviderEnv.cs +++ b/Keen.NetStandard/ProjectSettingsProviderEnv.cs @@ -1,6 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; +using System; + namespace Keen.Core { diff --git a/Keen.NetStandard/ProjectSettingsProviderFile.cs b/Keen.NetStandard/ProjectSettingsProviderFile.cs index 3f47b77..cf40072 100644 --- a/Keen.NetStandard/ProjectSettingsProviderFile.cs +++ b/Keen.NetStandard/ProjectSettingsProviderFile.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json.Linq; using System.IO; -using System.Linq; +using Newtonsoft.Json.Linq; + namespace Keen.Core { @@ -25,13 +25,13 @@ public ProjectSettingsProviderFile(string filePath) { // http://www.newtonsoft.com/json/help/html/ReadJson.htm JObject jsonProjectSettings = JObject.Parse(File.ReadAllText(filePath)); - + Initialize( - (string)jsonProjectSettings[KeenConstants.KeenProjectId], - (string)jsonProjectSettings[KeenConstants.KeenMasterKey], - (string)jsonProjectSettings[KeenConstants.KeenWriteKey], - (string)jsonProjectSettings[KeenConstants.KeenReadKey], - (string)jsonProjectSettings[KeenConstants.KeenServerUrl]); + (string)jsonProjectSettings[KeenConstants.KeenProjectId], + (string)jsonProjectSettings[KeenConstants.KeenMasterKey], + (string)jsonProjectSettings[KeenConstants.KeenWriteKey], + (string)jsonProjectSettings[KeenConstants.KeenReadKey], + (string)jsonProjectSettings[KeenConstants.KeenServerUrl]); } catch (Newtonsoft.Json.JsonReaderException ex) { diff --git a/Keen.NetStandard/Query/FunnelResult.cs b/Keen.NetStandard/Query/FunnelResult.cs index 148799a..f5b0329 100644 --- a/Keen.NetStandard/Query/FunnelResult.cs +++ b/Keen.NetStandard/Query/FunnelResult.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using Newtonsoft.Json; namespace Keen.Core.Query @@ -13,6 +13,6 @@ public class FunnelResult public IEnumerable Steps { get; set; } [JsonProperty(PropertyName = "result", NullValueHandling = NullValueHandling.Ignore)] - public IEnumerable Result{ get; set; } + public IEnumerable Result { get; set; } } } diff --git a/Keen.NetStandard/Query/FunnelResultStep.cs b/Keen.NetStandard/Query/FunnelResultStep.cs index f77d157..7ba5e4c 100644 --- a/Keen.NetStandard/Query/FunnelResultStep.cs +++ b/Keen.NetStandard/Query/FunnelResultStep.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using Newtonsoft.Json; namespace Keen.Core.Query diff --git a/Keen.NetStandard/Query/FunnelStep.cs b/Keen.NetStandard/Query/FunnelStep.cs index 54f464d..ce3d710 100644 --- a/Keen.NetStandard/Query/FunnelStep.cs +++ b/Keen.NetStandard/Query/FunnelStep.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using Newtonsoft.Json; namespace Keen.Core.Query @@ -32,7 +32,7 @@ public class FunnelStep /// May not be applied to an initial step. /// [JsonProperty(PropertyName = "inverted", NullValueHandling = NullValueHandling.Ignore)] - public bool Inverted{ get; set; } + public bool Inverted { get; set; } /// /// If set to true, filtering applied to this step won't apply to any steps after it. diff --git a/Keen.NetStandard/Query/IQueries.cs b/Keen.NetStandard/Query/IQueries.cs index 462fcb6..cc275a7 100644 --- a/Keen.NetStandard/Query/IQueries.cs +++ b/Keen.NetStandard/Query/IQueries.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json.Linq; using System.Collections.Generic; using System.Threading.Tasks; +using Newtonsoft.Json.Linq; namespace Keen.Core.Query @@ -27,6 +27,6 @@ public interface IQueries Task> Extract(string collection, IQueryTimeframe timeframe = null, IEnumerable filters = null, int latest = 0, string email = ""); - Task Funnel(IEnumerable steps, IQueryTimeframe timeframe = null, string timeZone = "" ); + Task Funnel(IEnumerable steps, IQueryTimeframe timeframe = null, string timeZone = ""); } } diff --git a/Keen.NetStandard/Query/IQueryTimeframe.cs b/Keen.NetStandard/Query/IQueryTimeframe.cs index 059e244..8416b45 100644 --- a/Keen.NetStandard/Query/IQueryTimeframe.cs +++ b/Keen.NetStandard/Query/IQueryTimeframe.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core.Query { public interface IQueryTimeframe diff --git a/Keen.NetStandard/Query/MultiAnalysisParam.cs b/Keen.NetStandard/Query/MultiAnalysisParam.cs index 0542faf..b086e0d 100644 --- a/Keen.NetStandard/Query/MultiAnalysisParam.cs +++ b/Keen.NetStandard/Query/MultiAnalysisParam.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core.Query { public sealed class MultiAnalysisParam @@ -8,7 +8,7 @@ public sealed class Metric private readonly string _value; public readonly string TargetProperty; internal Metric(string value) { _value = value; } - internal Metric(string value, string targetProperty) { _value = value; TargetProperty = targetProperty; } + internal Metric(string value, string targetProperty) { _value = value; TargetProperty = targetProperty; } public override string ToString() { return _value; } public static implicit operator string(Metric value) { return value.ToString(); } diff --git a/Keen.NetStandard/Query/Queries.cs b/Keen.NetStandard/Query/Queries.cs index 35ec9b6..8461245 100644 --- a/Keen.NetStandard/Query/Queries.cs +++ b/Keen.NetStandard/Query/Queries.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Keen.Core.Query @@ -99,17 +99,17 @@ internal class Queries : IQueries var reply = await KeenWebApiRequest().ConfigureAwait(false); return from j in reply.Children() let p = j as JProperty - where p != null + where p != null select new KeyValuePair(p.Name, (string)p.Value); } #region metric - public async Task Metric(string queryName, Dictionary parms) + public async Task Metric(string queryName, Dictionary parms) { if (string.IsNullOrEmpty(queryName)) throw new ArgumentNullException("queryName"); - if (null==parms) + if (null == parms) throw new ArgumentNullException("parms"); return await KeenWebApiRequest(queryName, parms).ConfigureAwait(false); @@ -303,7 +303,7 @@ public async Task> Extract(string collection, IQueryTimefra { parms.Add(KeenConstants.QueryParmTimeframe, timeframe.ToString()); } - + parms.Add(KeenConstants.QueryParmTimezone, timezone); parms.Add(KeenConstants.QueryParmSteps, stepsJson); @@ -395,7 +395,7 @@ string SerializeMultiAnalysisQueryParameter(IEnumerable anal d.Add(p.Name, (string)p.Value); var t = i.Value("timeframe"); - var qv = new QueryIntervalValue>(d , t.Value("start"), t.Value("end")); + var qv = new QueryIntervalValue>(d, t.Value("start"), t.Value("end")); result.Add(qv); } @@ -430,7 +430,7 @@ string SerializeMultiAnalysisQueryParameter(IEnumerable anal else d.Add(p.Name, (string)p.Value); } - qgl.Add( new QueryGroupValue>(d, grpVal)); + qgl.Add(new QueryGroupValue>(d, grpVal)); } var t = i.Value("timeframe"); diff --git a/Keen.NetStandard/Query/QueryAbsoluteTimeframe.cs b/Keen.NetStandard/Query/QueryAbsoluteTimeframe.cs index 1e3d1d4..7a0d762 100644 --- a/Keen.NetStandard/Query/QueryAbsoluteTimeframe.cs +++ b/Keen.NetStandard/Query/QueryAbsoluteTimeframe.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Keen.Core.Query diff --git a/Keen.NetStandard/Query/QueryDefinition.cs b/Keen.NetStandard/Query/QueryDefinition.cs index 49edecb..1522850 100644 --- a/Keen.NetStandard/Query/QueryDefinition.cs +++ b/Keen.NetStandard/Query/QueryDefinition.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; namespace Keen.Core.Query diff --git a/Keen.NetStandard/Query/QueryFilter.cs b/Keen.NetStandard/Query/QueryFilter.cs index 69ba3a1..d2ae0b8 100644 --- a/Keen.NetStandard/Query/QueryFilter.cs +++ b/Keen.NetStandard/Query/QueryFilter.cs @@ -1,5 +1,5 @@ -using Newtonsoft.Json; using System; +using Newtonsoft.Json; namespace Keen.Core.Query @@ -115,7 +115,7 @@ public class GeoValue public GeoValue(double longitude, double latitude, double maxDistanceMiles) { - Coordinates = new [] { longitude, latitude }; + Coordinates = new[] { longitude, latitude }; MaxDistanceMiles = maxDistanceMiles; } } @@ -150,13 +150,8 @@ public QueryFilter(string property, FilterOperator op, object value) throw new ArgumentNullException(nameof(property), "Property name is required."); } - if (null == op) - { - throw new ArgumentNullException(nameof(op), "Filter operator is required."); - } - PropertyName = property; - Operator = op; + Operator = op ?? throw new ArgumentNullException(nameof(op), "Filter operator is required."); Value = value; } } diff --git a/Keen.NetStandard/Query/QueryGroupValue.cs b/Keen.NetStandard/Query/QueryGroupValue.cs index d11e532..498ee87 100644 --- a/Keen.NetStandard/Query/QueryGroupValue.cs +++ b/Keen.NetStandard/Query/QueryGroupValue.cs @@ -1,6 +1,6 @@ - using System.Collections.Generic; + namespace Keen.Core.Query { /// @@ -13,7 +13,7 @@ public sealed class QueryGroupValue /// The value for the group. Varies with the type of query performed. /// public T Value { get; private set; } - + /// /// The value of the groupby field for this value. /// diff --git a/Keen.NetStandard/Query/QueryInterval.cs b/Keen.NetStandard/Query/QueryInterval.cs index e6f21c3..d60b731 100644 --- a/Keen.NetStandard/Query/QueryInterval.cs +++ b/Keen.NetStandard/Query/QueryInterval.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core.Query { /// diff --git a/Keen.NetStandard/Query/QueryIntervalValue.cs b/Keen.NetStandard/Query/QueryIntervalValue.cs index 01dd55e..1dc3585 100644 --- a/Keen.NetStandard/Query/QueryIntervalValue.cs +++ b/Keen.NetStandard/Query/QueryIntervalValue.cs @@ -1,6 +1,7 @@ -using System; +using System; using System.Collections.Generic; + namespace Keen.Core.Query { /// diff --git a/Keen.NetStandard/Query/QueryRelativeTimeframe.cs b/Keen.NetStandard/Query/QueryRelativeTimeframe.cs index 28989bf..2bececb 100644 --- a/Keen.NetStandard/Query/QueryRelativeTimeframe.cs +++ b/Keen.NetStandard/Query/QueryRelativeTimeframe.cs @@ -1,5 +1,6 @@ -using Newtonsoft.Json; using System.Collections.Generic; +using Newtonsoft.Json; + namespace Keen.Core.Query { @@ -209,9 +210,11 @@ public static QueryRelativeTimeframe PreviousMinute() public override bool Equals(object obj) { - var timeframe = obj as QueryRelativeTimeframe; - return timeframe != null && - _value == timeframe._value; + //var timeframe = obj as QueryRelativeTimeframe; + //return timeframe != null && + // _value == timeframe._value; + + return (obj is QueryRelativeTimeframe timeframe) && _value == timeframe._value; } public override int GetHashCode() diff --git a/Keen.NetStandard/Query/QueryType.cs b/Keen.NetStandard/Query/QueryType.cs index f9c1079..d038fa3 100644 --- a/Keen.NetStandard/Query/QueryType.cs +++ b/Keen.NetStandard/Query/QueryType.cs @@ -1,4 +1,4 @@ - + namespace Keen.Core.Query { public sealed class QueryType @@ -14,7 +14,7 @@ public sealed class QueryType /// Returns the number of resources in the event collection. Parameter targetProperty is ignored. /// public static QueryType Count() { return count; } - + private static QueryType countunique = new QueryType("count_unique"); /// /// Returns the number of unique resources in the event collection. diff --git a/Keen.NetStandard/Query/TimeframeConverter.cs b/Keen.NetStandard/Query/TimeframeConverter.cs index 820c60a..c2eccbf 100644 --- a/Keen.NetStandard/Query/TimeframeConverter.cs +++ b/Keen.NetStandard/Query/TimeframeConverter.cs @@ -1,6 +1,6 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Keen.Core.Query diff --git a/Keen.NetStandard/ScopedKey.cs b/Keen.NetStandard/ScopedKey.cs index bb7b5e3..2713c11 100644 --- a/Keen.NetStandard/ScopedKey.cs +++ b/Keen.NetStandard/ScopedKey.cs @@ -1,10 +1,10 @@ -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace Keen.Core @@ -149,7 +149,7 @@ private static byte[] HexToByte(string hex) if (hex.Length % 2 == 1) throw new Exception("Hex string must have an even number of characters"); - Func hexMap = (h) => h - (h < 58 ? 48 : (h < 97 ? 55 : 87)); + Func hexMap = (h) => h - (h < 58 ? 48 : (h < 97 ? 55 : 87)); var result = new byte[hex.Length >> 1]; for (int i = 0; i < (hex.Length >> 1); ++i) diff --git a/Keen/Query/QueryInterval.cs b/Keen/Query/QueryInterval.cs index e6f21c3..418cd07 100644 --- a/Keen/Query/QueryInterval.cs +++ b/Keen/Query/QueryInterval.cs @@ -11,56 +11,68 @@ public sealed class QueryInterval private QueryInterval(string value, int n) { _value = string.Format(value, n); } public override string ToString() { return _value; } public static implicit operator string(QueryInterval value) { return value.ToString(); } + /// /// breaks your timeframe into minute long chunks. /// public static QueryInterval Minutely() { return new QueryInterval("minutely"); } + /// /// breaks your timeframe into hour long chunks. /// public static QueryInterval Hourly() { return new QueryInterval("hourly"); } + /// /// breaks your timeframe into day long chunks. /// public static QueryInterval Daily() { return new QueryInterval("daily"); } + /// /// breaks your timeframe into week long chunks. /// public static QueryInterval Weekly() { return new QueryInterval("weekly"); } + /// /// breaks your timeframe into month long chunks. /// public static QueryInterval Monthly() { return new QueryInterval("monthly"); } + /// /// breaks your timeframe into year long chunks. /// public static QueryInterval Yearly() { return new QueryInterval("yearly"); } + /// /// breaks your timeframe into chunks of the specified length /// /// chunk length public static QueryInterval EveryNMinutes(int n) { return new QueryInterval("every_{0}_minutes", n); } + /// /// breaks your timeframe into chunks of the specified length /// /// chunk length public static QueryInterval EveryNHours(int n) { return new QueryInterval("every_{0}_hours", n); } + /// /// breaks your timeframe into chunks of the specified length /// /// chunk length public static QueryInterval EveryNDays(int n) { return new QueryInterval("every_{0}_days", n); } + /// /// breaks your timeframe into chunks of the specified length /// /// chunk length public static QueryInterval EveryNWeeks(int n) { return new QueryInterval("every_{0}_weeks", n); } + /// /// breaks your timeframe into chunks of the specified length /// /// chunk length public static QueryInterval EveryNMonths(int n) { return new QueryInterval("every_{0}_months", n); } + /// /// breaks your timeframe into chunks of the specified length ///