Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly Support Multiple File Types #33

Merged
merged 11 commits into from
Sep 21, 2023
Merged

Properly Support Multiple File Types #33

merged 11 commits into from
Sep 21, 2023

Conversation

Axemasta
Copy link
Owner

This PR adds the ability for external providers to use any file type, previously only Json was supported.

I have refactored the library in order to support this feature and the integration testing passed when working with the github raw api. This pr will make it significantly easier to add extra file types in the future should the need arise.

Unfortunately due to Resx parsing being extremely difficult out of the box, I have taken a dependency on ResXResourcerReader.NetStandard, I ummed and ahhed about adding this but ultimately decided it wasn't a huge impact since this library requires multiple packages that DO have dependencies, the core project doesn't work on its own so it is less of an issue in my opinion. I contemplated splitting the core out to have other libraries for json & resx parsing but decided that would likely be overkill in this situation therefore we now have this added dependency.

Now they support both types of file names
So now they can support whatever has been registered
This puts less responsibility on the provider libraries and more on the initial bootstrap process. Renamed IExternalConfiguration to IExternalProviderConfiguration
Added loads of tests to cover various bits I refactored or added
Added tests for all of the localization parsers, I will then implemented the resx one afterwards
We can now read downloaded resx strings. This was way more awkward than I imagined it to be, I will rip the parts of the lib I referenced to prevent the dependency!
These tests were broken from refactors so theyre now working again
I realised that resx would need its own custom file name logic so I refactored the config to have an object for the filetype details. This has had some knock on effects but means it should be easier supporting unique file types in the future.
The version formatting didn't apply to primary cultures and the culture checking didn't work properly despite the unit tests passing so I have updated the tests to be flakier and fixed the offending code (using ==). Added resx files for external demonstration
There is now an example of config for each type of file
I have been neglecting these so here are some for the most used methods
@github-actions
Copy link

File Coverage Lines Branches Missing
All files 30% 28% 31%
Mocale.Cache.SQLite\MocaleBuilderExtension.cs 0% 0% 100% 11-33
Mocale.Cache.SQLite\Repositories\CacheRepository.cs 0% 0% 0% 13-94
Mocale.Cache.SQLite\Repositories\RepositoryBase.cs 0% 0% 100% 6-18
Mocale.Cache.SQLite\Repositories\TranslationsRepository.cs 0% 0% 0% 12-163
Mocale.Cache.SQLite\Providers\DatabaseConnectionProvider.cs 0% 0% 100% 16-50
Mocale.Cache.SQLite\Providers\DatabasePathProvider.cs 0% 0% 100% 8-18
Mocale.Cache.SQLite\Models\SqliteConfig.cs 0% 0% 100% 5-9
Mocale.Cache.SQLite\Managers\LocalisationCacheManager.cs 0% 0% 0% 18-55
Mocale.Cache.SQLite\Managers\SqlCacheUpdateManager.cs 0% 0% 0% 15-78
Mocale.Cache.SQLite\Entities\TranslationItem.cs 0% 0% 100% 10-16
Mocale.Cache.SQLite\Entities\UpdateHistoryItem.cs 0% 0% 100% 10-14
Mocale\AppBuilderExtensions.cs 0% 0% 0% 15-62
Mocale\MocaleBuilder.cs 0% 0% 0% 6-30
Mocale\MocaleBuilderExtensions.cs 0% 0% 0% 18-119
Mocale\MocaleInitializeService.cs 0% 0% 100% 6-13
Mocale\MocaleLocator.cs 0% 0% 100% 31-42
Mocale\Wrappers\DateTimeWrapper.cs 0% 0% 100% 10
Mocale\Providers\EmbeddedResourceProvider.cs 0% 0% 0% 11-97
Mocale\Providers\ResxResourceProvider.cs 0% 0% 0% 14-66
Mocale\Parsers\ResxLocalizationParser.cs 87% 100% 75%
Mocale\Models\AppResourcesConfig.cs 0% 0% 100% 8
Mocale\Models\EmbeddedResourcesConfig.cs 0% 0% 100% 6-10
Mocale\Models\MocaleConfiguration.cs 91% 83% 100% 7
Mocale\Managers\ConfigurationManager.cs 0% 0% 100% 11-21
Mocale\Managers\TranslationResolver.cs 0% 0% 0% 19-180
Mocale\Managers\TranslationResolver.cs 0% 0% 100% 100-116
Mocale\Managers\TranslationResolver.cs 0% 0% 0% 38-92
Mocale\Managers\TranslatorManager.cs 93% 93% 93% 41 102 121
Mocale\Extensions\DictionaryExtension.cs 95% 100% 90%
Mocale\Extensions\LocalizeExtension.cs 0% 0% 100% 9-37
Mocale\Extensions\TaskExtensions.cs 87% 100% 75%
Mocale\Extensions\UriExtension.cs 62% 25% 100% 12-25
Mocale\Exceptions\InitializationException.cs 0% 0% 100% 6-8
Mocale\Exceptions\MocaleException.cs 0% 0% 100% 6-13
Mocale.Providers.Aws.S3\MocaleBuilderExtension.cs 0% 0% 100% 8-20
Mocale.Providers.Aws.S3\S3BucketProvider.cs 0% 0% 0% 11-49
Mocale.Providers.Aws.S3\Models\BucketConfig.cs 0% 0% 100% 5-8
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 100% 20-40
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 0% 47-74
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 0% 104-135
Mocale.Providers.Azure.Blob\BlobLocalizationProvider.cs 0% 0% 0% 77-97
Mocale.Providers.Azure.Blob\MocaleBuilderExtension.cs 0% 0% 0% 16-31
Mocale.Providers.Azure.Blob\Models\BlobResourceInfo.cs 0% 0% 100% 5-7
Mocale.Providers.Azure.Blob\Models\BlobStorageConfig.cs 0% 0% 100% 7-16
Mocale.Providers.Azure.Blob\Managers\BlobResourceLocator.cs 0% 0% 0% 21-58
Mocale.Providers.Azure.Blob\Managers\BlobResourceLocator.cs 0% 0% 0% 66-92
Mocale.Providers.Github.Raw\GitHubRawProvider.cs 44% 39% 50% 46-53 61-67 75-83
Mocale.Providers.Github.Raw\MocaleBuilderExtension.cs 0% 0% 0% 14-32

Minimum allowed coverage is 5%

Generated by 🐒 cobertura-action against eabd25c

@Axemasta Axemasta merged commit 853d428 into main Sep 21, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant