calinga.net's People
calinga.net's Issues
GetLanguagesAsync() throws JsonSerializationException
Calling
await service.GetLanguagesAsync().ConfigureAwait(false);
with service settings
Organization = "SdkSample",
Project = "ExampleProject",
ApiToken = "dd60c24b1353f14fc614742e1a9c687a",
Team = "Default Team",
IsDevMode = false,
CacheDirectory = "CacheFiles"
throws
Newtonsoft.Json.JsonSerializationException
HResult=0x80131500
Message=Cannot deserialize the current JSON array (e.g. [1,2,3]) into type 'System.Collections.Generic.Dictionary`2[System.String,System.Boolean]' because the type requires a JSON object (e.g. {"name":"value"}) to deserialize correctly.
To fix this error either change the JSON to a JSON object (e.g. {"name":"value"}) or change the deserialized type to an array or a type that implements a collection interface (e.g. ICollection, IList) like List<T> that can be deserialized from a JSON array. JsonArrayAttribute can also be added to the type to force it to deserialize from a JSON array.
Path '', line 1, position 1.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(JsonReader reader, Type objectType, JsonContract contract)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonConvert.DeserializeObject(String value, Type type, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value, JsonSerializerSettings settings)
at Newtonsoft.Json.JsonConvert.DeserializeObject[T](String value)
at Calinga.NET.Infrastructure.ConsumerHttpClient.MapGetLanguagesResult(String json) in C:\Users\Markus.Mueller\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\1C8ADE0F-570C-4365-B85E-020F5A2F4A9D\d5\279777e5\ConsumerHttpClient.cs:line 90
at Calinga.NET.Infrastructure.ConsumerHttpClient.<GetLanguagesAsync>d__6.MoveNext() in C:\Users\Markus.Mueller\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\1C8ADE0F-570C-4365-B85E-020F5A2F4A9D\d5\279777e5\ConsumerHttpClient.cs:line 70
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Calinga.NET.CalingaService.<GetLanguagesAsync>d__10.MoveNext() in C:\Users\Markus.Mueller\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\1C8ADE0F-570C-4365-B85E-020F5A2F4A9D\f9\413af499\CalingaService.cs:line 95
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Calinga.Demo.ConsoleApp.Program.<Main>d__0.MoveNext() in C:\git\calinga-dotnet-demo\Calinga.Demo.ConsoleApp\Program.cs:line 19
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Calinga.Demo.ConsoleApp.Program.<Main>()
This exception was originally thrown at this call stack:
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.EnsureArrayContract(Newtonsoft.Json.JsonReader, System.Type, Newtonsoft.Json.Serialization.JsonContract)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(Newtonsoft.Json.JsonReader, System.Type, Newtonsoft.Json.Serialization.JsonContract, Newtonsoft.Json.Serialization.JsonProperty, object, string)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(Newtonsoft.Json.JsonReader, System.Type, Newtonsoft.Json.Serialization.JsonContract, Newtonsoft.Json.Serialization.JsonProperty, Newtonsoft.Json.Serialization.JsonContainerContract, Newtonsoft.Json.Serialization.JsonProperty, object)
Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(Newtonsoft.Json.JsonReader, System.Type, bool)
Newtonsoft.Json.JsonSerializer.DeserializeInternal(Newtonsoft.Json.JsonReader, System.Type)
Newtonsoft.Json.JsonSerializer.Deserialize(Newtonsoft.Json.JsonReader, System.Type)
Newtonsoft.Json.JsonConvert.DeserializeObject(string, System.Type, Newtonsoft.Json.JsonSerializerSettings)
Newtonsoft.Json.JsonConvert.DeserializeObject<T>(string, Newtonsoft.Json.JsonSerializerSettings)
Newtonsoft.Json.JsonConvert.DeserializeObject<T>(string)
Calinga.NET.Infrastructure.ConsumerHttpClient.MapGetLanguagesResult(string) in ConsumerHttpClient.cs
...
[Call Stack Truncated]
FileNotFoundException if cache directory is empty
calling
await service.TranslateAsync("Button.Cancel", "en").ConfigureAwait(false);
with settings
Organization = "SdkSample",
Project = "ExampleProject",
ApiToken = "dd60c24b1353f14fc614742e1a9c687a",
Team = "Default Team",
IsDevMode = false,
CacheDirectory = "CacheFiles"
throws if CacheDirectory is empty
System.IO.FileNotFoundException
HResult=0x80070002
Message=File not found, path: CacheFiles\SdkSample\Default Team\ExampleProject\EN.json
Source=Calinga.NET
StackTrace:
at Calinga.NET.Infrastructure.FileSystemService.<ReadCacheFileAsync>d__2.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Calinga.NET.Infrastructure.CachingService.<GetTranslations>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Calinga.NET.CalingaService.<GetTranslationsAsync>d__9.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Calinga.NET.CalingaService.<TranslateAsync>d__8.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at Calinga.Demo.ConsoleApp.Program.<Main>d__0.MoveNext() in C:\git\calinga-dotnet-demo\Calinga.Demo.ConsoleApp\Program.cs:line 25
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Calinga.Demo.ConsoleApp.Program.<Main>()
This exception was originally thrown at this call stack:
Calinga.NET.Infrastructure.FileSystemService.ReadCacheFileAsync(string)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.ConfiguredTaskAwaitable<TResult>.ConfiguredTaskAwaiter.GetResult()
Calinga.NET.Infrastructure.CachingService.GetTranslations(string, bool)
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(System.Threading.Tasks.Task)
System.Runtime.CompilerServices.ConfiguredTaskAwaitable<TResult>.ConfiguredTaskAwaiter.GetResult()
...
[Call Stack Truncated]
Improve multiple project support
At the moment there is really only one project integration supported.
With one instance of ICalingaService
you can only access one calinga project, because it has its configured API token and project settings.
You could for sure instantiate multiple ICalingaService-instances with different backing configurations, when creating them by hand. But this raises the question how to deal with dependency injection and .AddSingleton()
as mentioned in the documentation for ASP.NET core integration.
It would be helpful, when either the documentation would be updated for supporting multiple project or the .NET SDK itself would have a way of supporting different project-configurations at runtime.
Sth like:
var projectA = calinga.Team("Team A").Project("Project A")
.WithAPIToken("***")
.WithDrafts(true)
.WithCacheInterval(30);
var translatedA = await projectA.GetTranslationsAsync("my-key");
// and for supporting current appsettings-configuration:
var projectB = calinga.Team("Team A").Project("Project B")
.WithConfiguration(nameof(CalingaServiceSettings));
var translatedB = await projectB.GetTranslationsAsync("my-key");
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.