GithubHelp home page GithubHelp logo

cs-util-com / cscore Goto Github PK

View Code? Open in Web Editor NEW
181.0 181.0 31.0 39.83 MB

cscore is a minimal-footprint library providing commonly used helpers & patterns for your C# projects. It can be used in both pure C# and Unity projects.

Home Page: https://cs-util-com.github.io/cscore/

License: Apache License 2.0

C# 98.27% Batchfile 0.45% Shell 0.32% ShaderLab 0.58% HLSL 0.22% JavaScript 0.16%
csharp eventbus eventbus-library injection injection-framework logging logging-library rest-client unity unity3d

cscore's People

Contributors

cs-util avatar david-brenn avatar dependabot[bot] avatar equidevium avatar htotheb avatar jtone123 avatar lenaschoenburg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cscore's Issues

Cannot build - Error CS0246 The type or namespace name 'CSCore' could not be found

Hi
I downloaded the Zip
Started VS 2022
Got a bunch of framework error that the wizard could not fix.
I responded several time to use .NET 8.1 but at the end none of the project were set with that Framework. This is not a new issue for your repository. I always had this problem since I upgraded to VS2022. Seems unfixable.

Anyway I manuelly set the 3 main project to .NET 8.1. The one in Samples are still with not framework
References are no longer yellow for the 3 main project.
When I build I receive hundred of error saying CSCore could not be found
Installed : install-package CSCore
Still have the error.

I am hoping to write an app that will detect what app is emitting a sound and log it somewhere ... in the WIndows notification zone hopefully.

I use aboudt 5 Chrome profile each connected to a different Microsoft Tenant as I am a consultant with many customers.
I use different Chrome profile so each one stays connected to a specific MS Tenant for Teams specifically. This way I dont have to logout/login to each Tenant all the time.

WHen someone contacts me, the sound may come from
Any of these 5 Chrome profile
From local Teams app
From local Outlook app
From Outlook in one of the Chrome tab

Obviously I always miss the call.

I hope that with your library CSCore I will be able to detect.

  • The app that just use the sound system
  • If it is Chrome, what instance (profile) and in which tab

Extend support for the new Unity input system

  1. Create an example scene that implements a new variant of IUnityInputSystem that connects with the new Unity input system.
  2. https://www.youtube.com/watch?v=fzPHAOuo57k shows a few good examples of the old and new methods. From that method it becomes also obvious that a few important methods are most likely still missing in IUnityInputSystem
  3. The purpose of IUnityInputSystem is mainly that internal cscore building blocks like the touch and dragging helpers could use it no matter if the old or new input system is used in the scene. So extending support for the new input system might mainly be useful extension methods or similar and not so much focusing on that IUnityInputSystem singleton since developers should not be forced to use it in their own code of they don't want to
  4. Some existing helper classes such as ScaleCanvasViaZoom don't use the IUnityInputSystem yet, should be easy to fix and a good validation what methods are still missing in the interface

UI visual diffing / Image diff calculation - Implement MeanSquared ErrorMetric in pure C#

Implement the Compare method using the ErrorMetric.MeanSquared in pure C# or Unity to be able to get rid of the ImageMagick dependency

On http://www.imagemagick.org/Usage/compare/ the different compare methods are explained and can be digged into to reimplement the most relevant (ErrorMetric.MeanSquared) for visual UI regression in C#.

Related pull request for this tasks are:

  • #40 (Initial introduction of ImageMagick for the Visual Regression System)
  • #110 (Another image library included in cscore)

Compiler Error with Unity 2021.2.2f1 (.Net Standard 2.1)

Hi, thanks for your great work here!
It looks like there's no perfect fix, and so I thought you might want to look at it yourself.

Issue: The cscore Unity Package doesn't work without changes in Unity 2021.2.2f1 which uses .Net Standard 2.1.

There's a clash between the ToHashSet implementation in com.csutil.netstandard2_1polyfill and System.Linq, if a class uses both. This affects BackButtonListener.cs and RootCanvas.cs of cscore unity.

Unfortunately, Unity doesn't seem to define NETSTANDARD2_1_OR_GREATER or NETSTANDARD2_1 so it might get a little tricky, but I think the Polyfill should be disabled if .Net Standard 2.1 or greater is used.

KeyValueStore performance tests

In KeyValueStoreIntegrationTests add a KeyValueStore performance test that compares the raw usage of a zip based FileSystem and many writes and reads (with normal synchronous operations) to the asynchronous get and set operations of a KeyValueStore that is internally also using a zip based FileSystem to evaluate the overhead that the KeyValueStore adds.

Broken prefabs

image

After I updated to the latest version 1.8.7 I noticed that the components for unity cannot be added. Somehow I saw that on the resources folder of the UiTemplates all of the prefabs have missing scripts.

Is this an issue being created due to the update or something else may have broken them?

Evaluate switch to LiteDb

Switch to LiteDB ( https://github.com/mbdavid/LiteDB ) prepared on branch https://github.com/cs-util-com/cscore/tree/feature/switchToLiteDb

The main open task is to create a WebGL build of the XunitTestRunnerScene and check that all LiteDb tests still work when running in WebGL.

If LiteDB does not work in WebGL due to threading requirements that WebGL does not support, the code in the branch should be changed that it does not delete the UltraLiteDB code but instead uses it in WebGL builds and in all other environments the default LiteDB is used.

This way developers could make full use of the latest LiteDB and some core components like the key value store could still offer a WebGL compatible UltraLiteDB implementation.

Can't import CSCore namespace

using CSCore doesn't work.

Assets\test.cs(4,7): error CS0246: The type or namespace name 'CSCore' could not be found (are you missing a using directive or an assembly reference?)

I imported the plugin via the asset store.
This is a fresh and clean project version 2019.1.10f1.
I am using Visual Studio 2019

Solve Unity import problem caused by System.Threading.dll

When importing the CsCore Unity package the main problem is the System.Threading.dll since when compiling the Unity project with .Net 4 or later this will cause duplicate class errors because the Threading classes will already be already present

So if people who import the Unity project do not read the import instructions and import the complete CsCoreNet3.5Compat folder with the rest they will have to manually delete the CsCoreNet3.5Compat folder again before the project even compiles again.

I did not find a good solution yet since it's not possible to execute and Editor scripts included in the package before the package is fully imported, so the 2 options are that it does not work for users using .Net 4 or later or it will not work for users using .net 3.5 or earlier.

Add test data generator

The easiest way to find performance problems is to test with realistic data or even better testing with data models that are much larger than whatever will be used in production.

The idea for this ticket is to simplify the generation of mock data for example by providing an interface to enforce very large test models and to help with generation of example values

This ticket is an ideal candidate to be build test driven and potentially improve the performance guards (e.g. add a few more performance focused assertions)

Spamming message of namespace missing

I keep getting a missing namespace even though my code is not missing.

The message is also sent for CsCore assembly as well which makes it even more confusing.

image

Unity LTS Support broken - 2021.3.23f1

We wanted to update our project from 1.8.5 to the latest release 1.8.8 and found it breaks compatibility with the lastet available Unity LTS release (2021.3.23f1), as it doesn't have the useDelaunayMesh option, see https://docs.unity3d.com/2021.3/Documentation/ScriptReference/PolygonCollider2D.html

So the PolygonCreatorV2, which was added in 1.8.6, causes a compiler error

I'm not sure if this is intentional? (I couldn't find a list of supported unity releases)

It would b easy to fix by checking the UNITY_2022_1_OR_NEWER symbol

Extend the CsvParserTests to include a CSV to JSON conversion example

Assuming that the parsed data that comes out of List<List<string>> parsedData = CsvParser.ReadCsvStream(stream) has its json keys in the first row and the values all in one row to X rows in the csv can be converted to X json objects to operate on these afterwards more easily.
Create a xunit test in the CsvParserTests class to demonstrate this and potentially shape a few new helper methods to let developers easily do such a mapping process.

Browser Feature wrappers

Unity provides lots of features in a platform-agnostic way. However there are several functionalities of a browser we can and need to exploit when running in the web (via WebGL).

We want to implement a couple of helper functions to access basic browser functionality from within unity without having to venture into the javascript world. The focus will lie on functions that are not provided by Unity for other build targets (i.e. browser history interaction, warning dialogs, etc.).

We have ventured into other features like getting the microphone working in the browser, but Unity already provides an API for that and we don't want to encourage people to writing platform-specific code, as it is the main benefit of using an engine in the first place.

How would we go about doing this? Our current plan would be to create a plugin in the unity package of the repository, including all of the scripts required (maybe append the readme with an example).

[REQUEST] Singleton ScriptableObject

how about a way to create a Singleton ScriptableObject and then use it in-game and make a way to never enable user to create more than one of the type (to guarantee errors free). thank's !

KeyValue store

Adding a simple async KeyValue store interface e.g for persisting constants

IReadableFileRef - Extract an immutable parent interface from IFileRef

Currently IFileRef enforces that also setters are included in the concrete implementations of it, extract a parent interface of IFileRef that does not require setters and review in which methods a switch to this IReadableFileRef is possible.
Some of the current methods might make use of the set methods and will have to use the current IFileRef. For these methods separate new methods that use IReadableFileRef plus mutation callbacks should be created so that every helper method in cscore can also be used with IReadableFileRef objects.

Update README.md to include all latest features

Improve the https://github.com/cs-util-com/cscore/blob/master/README.md to include more of the features of cscore. The readme was not updated regularly with all the new features, only the unit tests that serve also as usage examples are still up to date, so reviewing all tests and adding the relevant/interesting features that are still missing in the readme would be a good idea to give the reader a quick and easy overview on what is available.

Here are all usage examples how to use the pure C# components (that can be used in any C# project and in Unity):
https://github.com/cs-util-com/cscore/tree/master/CsCore/xUnitTests/src/Plugins/CsCoreXUnitTests/com/csutil/tests

And here are Unity specific examples / demo scenes on the components that can be used only in Unity:
https://github.com/cs-util-com/cscore/tree/master/CsCore/UnityTests/Assets/Plugins/CsCoreUnityDemoScenes

Also include the info that the xunit tests are now split in a "tests" namespace and an "integrationTests" namespace:

  • tests - These are xunit tests that can be run all in parallel and must never fail. They can also be used in mutation testing via Stryker
  • integrationTests - These are tests that use some global state or APIs and can fail from time to time because of these external dependencies the test cant control. Because of this they are also not suited to be used in mutation testing

Make sure the xUnit tests all run in parallel without problems

Currently when running all xUnit tests at once not all tests run through successfully

Some tests fail since they depend on internal singleton constructs, testing generic interfaces that internally use injection and because of this are affected by the other running tests. If the interface of the components is not modified the only way to manage to run all tests at once successfully is to separate the tests into fully independent processes without any shared memory, I guess/hope this is possible in xUnit but did not invest time into figuring out how to tell xUnit to run all tests fully separate in memory

Another type of test are the performance tests which fail because they expect the CPU to not be busy with running hundreds of other tests in parallel, maybe there is something in xUnit that allows specifying that a test should only be executed if no other tests are running at the same time? So queuing all performance tests to execute them linearly at the very end of a test run?

One bonus if this is fixed and all tests run reliably through each time they are executed at once is that the Stryker mutation test system can be used again

Interfacing with environment variables

Provide a simple interface that interacts with environment variables of the system (via EnvironmentV2 so that it can also be overridden for systems/operating systems that do not support the default implementation.
Using these new methods create an IKeyValueStore so that a developer has this as a new option when choosing an IKeyValueStore implementation.
Create a unit test that tests that the new IKeyValueStore is thread safe (might be possible to reuse one of the existing IKeyValueStore tests for this).

I will prepare a draft for this on a new branch that can be continued/completed.

Improve localization to support

The problem:

Currently the json structure that has to be used is not conform with the I18n standard, see the https://github.com/cs-util-com/cscore/blob/master/CsCore/xUnitTests/src/Plugins/CsCoreXUnitTests/com/csutil/tests/system/I18nTests.cs examples.

Todos:

Use the following example I18n conform json files to create an implementation of the I18n class that would traverse the flexible json tree correctly and support e.g. the [1, 1, "Due Tomorrow"] notation specified in there:

After I introduced cscore, I threw the following exception

WebException: Error: NameResolutionFailure
System.Net.WebConnection.Connect (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) (at :0)
System.Net.WebConnection.InitConnection (System.Net.WebOperation operation, System.Threading.CancellationToken cancellationToken) (at :0)
System.Net.WebOperation.Run () (at :0)
System.Net.WebCompletionSource1[T].WaitForCompletion () (at <e6940d8ae2364839bd68ca06089600fc>:0) System.Net.HttpWebRequest.RunWithTimeoutWorker[T] (System.Threading.Tasks.Task1[TResult] workerTask, System.Int32 timeout, System.Action abort, System.Func1[TResult] aborted, System.Threading.CancellationTokenSource cts) (at <e6940d8ae2364839bd68ca06089600fc>:0) System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) (at <e6940d8ae2364839bd68ca06089600fc>:0) System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) (at <a40b0ad4a868437393ad434631fb6ff1>:0) --- End of stack trace from previous location where exception was thrown --- System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) (at <1b59c4f9ea544230b97be3f722642171>:0) Rethrow as HttpRequestException: An error occurred while sending the request System.Net.Http.MonoWebRequestHandler.SendAsync (System.Net.Http.HttpRequestMessage request, System.Threading.CancellationToken cancellationToken) (at <1b59c4f9ea544230b97be3f722642171>:0) System.Net.Http.HttpClient.SendAsyncWorker (System.Net.Http.HttpRequestMessage request, System.Net.Http.HttpCompletionOption completionOption, System.Threading.CancellationToken cancellationToken) (at <1b59c4f9ea544230b97be3f722642171>:0) com.csutil.http.UriRestRequest.SendAsync (System.Net.Http.HttpMethod method) (at Library/PackageCache/com.csutil.cscore@feee7300cd/CsCore/com/csutil/http/UriRestRequest.cs:161) com.csutil.http.UriRestRequest.GetResult[T] () (at Library/PackageCache/com.csutil.cscore@feee7300cd/CsCore/com/csutil/http/UriRestRequest.cs:105) com.csutil.editor.LatestCsCoreVersionChecker.CheckForUpdates (System.Collections.Generic.List1[T] installedPackages, System.String urlToLoadPackageJsonFrom) (at Library/PackageCache/com.csutil.cscore.unity@feee7300cd/CsCoreUnity/com/csutil/editor/compilationTasks/LatestCsCoreVersionChecker.cs:31)
com.csutil.editor.LatestCsCoreVersionChecker.CheckForLatestVersion () (at Library/PackageCache/com.csutil.cscore.unity@feee7300cd/CsCoreUnity/com/csutil/editor/compilationTasks/LatestCsCoreVersionChecker.cs:25)
Rethrow as AggregateException: One or more errors occurred. (An error occurred while sending the request)
UnityEngine.Debug:LogException(Exception, Object)
com.csutil.logging.LogToUnityDebugLog:PrintException(Exception, Object[]) (at Library/PackageCache/com.csutil.cscore.unity@feee7300cd/CsCoreUnity/com/csutil/logging/LogToUnityDebugLog.cs:27)
com.csutil.logging.LogDefaultImpl:LogExeption(Exception, Object[]) (at Library/PackageCache/com.csutil.cscore@feee7300cd/CsCore/com/csutil/logging/LogDefaultImpl.cs:39)
com.csutil.Log:e(Exception, Object[]) (at Library/PackageCache/com.csutil.cscore@feee7300cd/CsCore/com/csutil/logging/Log.cs:37)
com.csutil.<>c:b__6_0(Exception) (at Library/PackageCache/com.csutil.cscore@feee7300cd/CsCore/com/csutil/extensions/TaskExtensions.cs:52)
com.csutil.<>c__DisplayClass5_0`1:b__0(Task) (at Library/PackageCache/com.csutil.cscore@feee7300cd/CsCore/com/csutil/extensions/TaskExtensions.cs:48)
UnityEngine.UnitySynchronizationContext:ExecuteTasks()

Update license

In your LICENSE file, it shows:

Copyright [yyyy] [name of copyright owner]

Can you update it, so I can include it in my LICENSE?

Thank you.

OpenAI API Extensions

Add support for OpenAIs latest features, e.g.:

GPT4V Image Upload support

  1. First use the already existing DALL E API to generate an image (eg “of a dog”)
  2. Then use the GPT4V API ( https://platform.openai.com/docs/guides/vision ) to upload that image again and assert that the word “dog” is contained in the response
  3. The already added json response support (see usage in ExampleUsage4_ChatGptJsonResponses) should be used for a few extended demo unit tests where the response from the image analysis is put into a structured json, eg an image analysis class that contains labels, maybe even bounding boxes etc
    3.1. E.g.: "Generate a dog with a cowboy hat" and the structured response should contain both the labels dog and cowboy hat

TTS & STT Combined in a single xUnit test to make use of each other:

  1. Text to speech: See https://platform.openai.com/docs/guides/text-to-speech and https://platform.openai.com/docs/models/tts
    1.1. Stores the audio as a file on disk, logs the path to it (for the developer to take a look) and to use it for the next step:
  2. Speech to text via https://platform.openai.com/docs/guides/speech-to-text
    2.2. Takes as the input the audio file from step 1 and converts it back to text
    2.3. Asserts that the original input text4 from step 1 is the same as the result (this verifies that the uploads, download, storing etc all work correctly)

Implementing handling of Streaming responses

Not only for the TTS endpoint but also the normal chat completions endpoints (that are already implemented, see eg test ExampleUsage3_ChatGpt) this would be useful for real time user interactions. The docu on streaming seems to be easy to understand, see eg: https://platform.openai.com/docs/api-reference/chat/create

Extending the json response examples

The structured responses now allow some extended agents, for example build a code generator demo for the following structured json responses:

  1. An action class AddCSharpCodeFile that contains fields such as projectFilePath, fileContent
  2. An action class EditCSharpCodeFile that contains also references to the parts of the file that should be replaced (references maybe in the form of line numbers or method names)?
  3. An action class AddUnitTestFile that contains fields such as CodeFileContentToTest
  4. Actions to generate the needed .csproj files and also the outer .sln file

Here it will be relevant to ensure the compilation of the generated code happens in a sandbox, so that the generated code cant accidentally delete all data on the developers disk etc. so maybe automatic compilation of this code could be another interesting Action to add but running the code or generated xUnit tests should only be done if such sandbox is possible somehow. Maybe by wrapping everything into a virtual container?

If the automatic execution of the generated unit tests in such an container becomes possible, then the next step would be to run Stryker.net to ensure the completeness and consistency of these tests to cover the generated code. This should probably ensure that the code and xunit tests convert to a result that is correct in the sense that it fulfills the input requirements.

Regex based data validation

Annotating a data model class with fancy regex annotations that are then validated whenever the setter of a property is used and which throws an error or logs an assertion if the regex matching fails is what I had initially in mind but maybe not relying on magic via annotations but instead doing it first only via plain validation method calls would be a better and more flexible start

Build a Weather.cs helper that abstracts away the differences of the different weather APIs for the common use cases

Take a look at the different weather APIs and their responses in WeatherReportExamples

Define a few user stories what are common use cases how weather APIs are typically used.
E.g. this one is probably a good one to start with:

Get the weather state at GPS position (e.g. the users position) for now and the next x hours. This state per hour should include the temperature, if its raining, ...

This Weather.cs should not try to do that much (for most use cases the specific APIs should be used) and it should also try to be stateless. One thing that can be tested is if it can normalize the responses from the different providers to map to a common WeatherResponse

Use mutation testing to improve test coverage

The xUnit tests are now prepared in a way that should make them consistently pass or fail across arbitrary many runs. This now unlocks to finally use Stryker for mutation testing again. Running Stryker and then reviewing the findings is the next step here, if you are interested to learn about mutation testing in general this is the right task for you. And at the same time most likely you will find a few bugs that exist in cscore.

Improve Image processing helper methods

There is already a branch ( https://github.com/cs-util-com/cscore/tree/update/StbImageSharp ) prepared to switch to the latest version of StbImageSharp ( https://github.com/StbSharp/StbImageSharp )

The main missing piece according to my notes is that the images are currently all vertically flipped since Conversion.stbi__vertical_flip(image.Data, image.Width, image.Height, 4); had to be removed. Maybe the latest StbImageSharp version has it included again, so take the 2 commits on that branch more as an inspiration than a mandatory path to take.

There are also alternatives like https://github.com/StbSharp/SafeStbImageSharp that should be tested if the work better, might be better to switch to this one to have full compatibility with Unity?

On top of that update a few more usage examples should be created in the form of further unit tests to do typical image operations around resizing, rotating, cropping, saving in different compressed formats, ..

Related branches with drafts of images algorithms to add:

UI test recorder and replayer

The new idea:

  • Recording the state changes of the application is much easier to achieve on the redux store level by just storing the json of each dispatched Action in a Recorder middleware and this way being able to replay all actions later.
  • Any change that the user does via the UI that changes the state of the application will be captured with this approach as well and replaying the actions will allow to test and validate the effects of the state changes on the UI

The initial idea:

A recorder component for the Unity UI system that:

  • Records UI input from buttons (and input fields?). or even more high level just the clicks and the keyboard input?
  • Takes screenshots for visual regression (after each click?). Could use the visual diff system to detect when the UI finished loading and only afterwards takes the visual regression screenshot. The screenshot logic for visual regression tests is already in cscore and should be used for this
  • To be able to use the recoding as a visual unit test the recording should start when the scene is started and the recorder is attached to the scene. A recording file should contain normal json, so that it can be versioned with the rest of the code
  • Is it possible to auto update the recording by replaying it? E.g if the recording contains "click on button at (x,y)" and the button moved in the latest UI so that the button center is not (x,y) anymore but (x+10,y) the recording could update itself automatically to adapt to such small UI changes
  • What are the typical UI actions on a "click, type, drag, .." level that the recorder should be able to record? Does any research exist to compare low level UI actions like "drag mouse from x1,y1 to x2,y2" vs more UI focused actions like "drag button from x1,y1 to x2,y2"? Low level sounds more reusable, what are the drawbacks?

Create a small generic Netpromoter score UI that talks to the IAppFlow event system

Using the IAppFlow interface a fully generic and reusable net promoter score UI can be created that shows after a specified time and collects reports the users feedback

  • This should use the LocalAnalytics system to build on top of the UsageRule , and this way allow to let the developer specify when the UI should be shown and how often. See the Ui15_NewsManager example how the NewAppUsedXDaysRule is used for example
  • To explain the individual components like LocalAnalytics, UsageRule and the UsageRuleFactory separatly and at the same time fully understand them, it would be good to add additional XUnit tests next to the existing ones, that focus on collecting analytics events and then asking the UsageRule system if a certain condition is met like "The user used the app at least 10 days and there wasnt any net promoter score notification fired in the last 5 days (see NewNotificationMinXDaysOldRule)"

JSON Schema to UI generator improvements

There are multiple open todos in the logic that takes a json schema and generates a UI from it:

  1. It would make sense to introduce an annotation that defines the order of the input UIs for the fields of the class. The order of the fields in the class does not automatically define this order in the UI so a [UiOrder(“Section X”, 1)] where both a grouping of UI elements into sections and a sorting of these elements can be set would be quite useful.
  2. The GenerateViewFrom(..) logic needs to be extended to use the values of the fields as input to set the default values of the UI elements correctly. Eg if a field in the class is a bool keepUserLoggedIn = false flag the UI generation should take that default “false” value and generate the UI accordingly that the checkbox is false by default.
  3. The default slider Unity UI element ignores the min and max values defined in the [Range(min,max)]
  4. It might be possible to delete most of the annotation classes (e.g. Range) and instead switch the logic to only rely on the classes with the same names in the System.ComponentModel.DataAnnotations namespace . Depends on if Unity also included these annotation classes, easiest way is to test with the Range attribute by deleting the manually written class from cscore and switch to the official one https://learn.microsoft.com/de-de/dotnet/api/system.componentmodel.dataannotations.rangeattribute

There are probably many more smaller improvements that would make sense to make the JSON schema to UI generation system production ready. Easiest way to discover these is probably to build more demo scenes in Unity that resemble realistic usage scenarios for such UIs. E.g.:

  1. Generating a settings UI just from the concrete instance of the settings class that is used by the application during runtime.
  2. Generating debug UIs to be able to look into instances of classes during runtime to have an easier to consume visualization of the state of the application compared to a json dump in a log console
  3. Demonstrating how a model class of eg a Login UI (where email and password are validated via regex etc) can be used to be able in Unity editor time to generate a first draft of the Login UI and then save that as a prefab and further modify it to fit the developers preferences. Demonstrating this ability is important to make the system really helpful, the UI generation is only the first step in the workflow of the developer and does not block them from modifying the generated UI prefab in any way they want afterwards.

Add EventBus

The eventbus will be the foundation for many other features so it we be build and tested first

Switch entirely to Textmesh Pro

Many of the UI components that cscore provides still use the old TextMesh and since its considered deprecated switch over entirely for all of these to Textmesh Pro. This would ensure performance improvements of all UIs and also better readability of the text elements. Please add a comment if you see any potential drawbacks with this.

The best backwards compatible way to do this that would not break existing projects using the current approach would be to introduce new prefabs that the current presenters could just switch to transparently.

And Textmesh Pro has to be added as a mandatory new dependency of cscore to the Unity manifest, which should be fine.

The main code change that would be needed is to extend the UI Link map with returning for text objects a generic wrapper interface (or maybe there is already a common interface between the Text and TextMesh Pro text classes?).
That approach would also allow developers who currently use the UI Link map for their own UIs to switch to text mesh Pro in their own UI prefabs at any time without having to change their code.

ThemeColor is another cscore component that needs to learn to work not only with Text instances but also with TextMesh Pro instances. The .ApplyColor method needs to be extended to support it.

I will prepare a draft on a new branch to make that idea more clear but won’t implement it for now.

PointerInputHandler issue with detecting single clicks.

There is an issue with the PointerInputHandler that I stumbled upon last week, that does not correctly track correctly single clicks. The onClick event is not properly triggered. It seems that sometimes the PointerEventData clickTime is not in sync with the Time.time timer.

I found a fix that could be worth merging in the library. I changed which timers we use in Lines 32 and line 95 of PointerInputHandler.cs with Time.unscaledTime and this fixes the issue.

Make the EventBus disposable?

Not fully sure yet if that's necessary, I would be happy if someone could comment on this

disposing all the values in the dictionary might make sense, or at least clearing the Dictionary onDispose so that anyone who might still have a ref on the disposed eventbus would not be able to use it anymore

Some objects were not cleaned up when closing the scene (on scene start)

I'm getting the following error every time I start a scene (including the included demo scenes) with cscore imported:

Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
The following scene GameObjects were found:
Singletons
com.csutil.MainThread

Any ideas why? Interestingly I'm getting this when STARTING the scene, not stopping it.

Improve/Extend the Redux Store Action Recorder & Replayer Logic

Collected requirements

The idea is to capture all dispatched actions to the store as typed JSON with a wrapper that also contains the timestamp when they were dispatched and then build a replayer that can load these JSONs and dispatch the same actions again. This allows to record the entire interaction of the user with the application so that it can be replayed arbitrarily often for testing purposes and to investigate bugs.

The recorder middleware should have some filter functions to let the developer black or whitelist certain actions they do not want to be recorded. And it should be able to turn the recorder on and off during runtime.

The replay system should allow setting the replay speed, if the actions should happen in real time or as fast as possible or something in between. If the user did not do any action for a longer time there should also be a max time between actions the developer can specify to automatically skip these pauses during replay.

The developer should be able to tell the replay system “now load the user session from this target DirectoryEntry and start playing it”. Replaying multiple recordings after another might be tricky, for that a middleware might be needed to restore the initial state of the store before the second recording is started. And to be able to generically restore the initial state of the store the middleware has to store it in its middleware when the very first action is dispatched.

The developer should be able to build himself some UI on top of the replay system where he can load and unload arbitrary many replays during runtime, so that he can also include that system in a test version of their application.

The current implementation

The current implementation of this idea can be found in the “ReplayRecorder” class, take a look at the unit tests like TestReplayRecorder that make use of it.

This implementation does not meet all the requirements yet that are described above and should be extended and changed. Some examples where the logic should be changed:

  • The current “ResetStoreAction” should be deprecated in favor of the middleware storing the initial state of the store itself. Otherwise the developer using this system would have to implement in his reducers the ResetStoreAction manually. Maybe there is also some middle ground where the developer is still informed via the ResetStoreAction that this reset is happening but does not have to implement any reducer logic himself for it to happen. Then he could optionally react to the reset and maybe reset some other state of the system that is not in the store.
  • The ResetStoreAction.Entry class does not store the timestamp yet, so this has to be added in that class.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.