Skip to content

Commit

Permalink
minor: Rename WebExtension to WebExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
mingyaulee committed Jun 6, 2021
1 parent ddbd685 commit 94c4d1b
Show file tree
Hide file tree
Showing 477 changed files with 966 additions and 963 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/WebExtensions.Net-Build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@ jobs:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
shell: powershell
run: |
.\.sonar\scanner\dotnet-sonarscanner begin /k:"WebExtension.Net" /o:"mingyaulee" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /v:"v${{ needs.version.outputs.FullSemVer }}" /d:sonar.cs.vstest.reportsPaths="test/TestResults/*.trx" /d:sonar.cs.opencover.reportsPaths="test/TestResults/**/*.opencover.xml"
.\.sonar\scanner\dotnet-sonarscanner begin /k:"WebExtensions.Net" /o:"mingyaulee" /d:sonar.login="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /v:"v${{ needs.version.outputs.FullSemVer }}" /d:sonar.cs.vstest.reportsPaths="test/TestResults/*.trx" /d:sonar.cs.opencover.reportsPaths="test/TestResults/**/*.opencover.xml"
dotnet build --configuration Release
.\.coverlet\console\coverlet ./test/WebExtension.Net.BrowserExtensionIntegrationTest/bin/Release/net5.0/wwwroot/framework --include "[WebExtension.Net]*" --target "dotnet" --targetargs "test . --no-build --no-restore --configuration Release" --format opencover --output ./test/TestResults/coverage --verbosity detailed
# disable integration test for now
# .\.coverlet\console\coverlet ./test/WebExtensions.Net.BrowserExtensionIntegrationTest/bin/Release/net5.0/wwwroot/framework --include "[WebExtensions.Net]*" --target "dotnet" --targetargs "test . --no-build --no-restore --configuration Release" --format opencover --output ./test/TestResults/coverage --verbosity detailed
.\.sonar\scanner\dotnet-sonarscanner end /d:sonar.login="${{ secrets.SONAR_TOKEN }}"
tag:
Expand Down
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Pull requests are the best way to propose changes to the codebase. We actively w
## Working in this repository
### Packages shipped by this repository
There is one package that is shipped from the repository:
1. WebExtension.Net
1. WebExtensions.Net

### Project Details
#### The terms used
Expand All @@ -39,7 +39,7 @@ There is one package that is shipped from the repository:
0. Code File - An object representing a .cs file

#### The code generation process
The APIs in WebExtension.Net/Generated is generated from the WebExtension.Net.Generator project.
The APIs in WebExtensions.Net/Generated is generated from the WebExtensions.Net.Generator project.
The code generation process is summarised as follows:
1. Namespace Definitions are retrieved by the NamespaceDefinitionsClient
0. The raw Namespace Definitions are then processed by the EntitiesRegistrationManager. In this stage:
Expand Down Expand Up @@ -67,8 +67,8 @@ The code generation process is summarised as follows:

#### Supporting missing/browser specific APIs
The APIs generated are only the ones that are defined by the WebExtensions Standards. A non-standard API can be added by extending from the API's partial class.
The browser specific extensions and types should be defined in a directory under `WebExtension.Net/Extensions` based on the API namespace.
Refer to `INotificationsApi.cs` and `NotificationsApi.cs` under the path `WebExtension.Net/Extensions/Notifications/` for example.
The browser specific extensions and types should be defined in a directory under `WebExtensions.Net/Extensions` based on the API namespace.
Refer to `INotificationsApi.cs` and `NotificationsApi.cs` under the path `WebExtensions.Net/Extensions/Notifications/` for example.

### In case of conflicts in the file generated.txt
It is best to do a rebase and run the generator again to make sure the changes in the generated files are not overwritten by your pull request.
Expand Down
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# WebExtension.Net
[![Nuget](https://img.shields.io/nuget/v/WebExtension.Net?style=flat-square&color=blue)](https://www.nuget.org/packages/WebExtension.Net/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/mingyaulee/WebExtension.Net/Build?style=flat-square&color=blue)](https://github.com/mingyaulee/WebExtension.Net/actions/workflows/WebExtension.Net-Build.yml)
[![Sonar Tests](https://img.shields.io/sonar/tests/WebExtension.Net?compact_message&server=https%3A%2F%2Fsonarcloud.io&style=flat-square)](https://sonarcloud.io/dashboard?id=WebExtension.Net)
[![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/WebExtension.Net?server=https%3A%2F%2Fsonarcloud.io&style=flat-square)](https://sonarcloud.io/dashboard?id=WebExtension.Net)
# WebExtensions.Net
[![Nuget](https://img.shields.io/nuget/v/WebExtensions.Net?style=flat-square&color=blue)](https://www.nuget.org/packages/WebExtensions.Net/)
[![GitHub Workflow Status](https://img.shields.io/github/workflow/status/mingyaulee/WebExtensions.Net/Build?style=flat-square&color=blue)](https://github.com/mingyaulee/WebExtensions.Net/actions/workflows/WebExtensions.Net-Build.yml)
[![Sonar Tests](https://img.shields.io/sonar/tests/WebExtensions.Net?compact_message&server=https%3A%2F%2Fsonarcloud.io&style=flat-square)](https://sonarcloud.io/dashboard?id=WebExtensions.Net)
[![Sonar Quality Gate](https://img.shields.io/sonar/quality_gate/WebExtensions.Net?server=https%3A%2F%2Fsonarcloud.io&style=flat-square)](https://sonarcloud.io/dashboard?id=WebExtensions.Net)

A package for consuming WebExtensions API in a browser extension.

These API classes are generated based on the [Mozilla documentation for WebExtension API](https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/index.html).
These API classes are generated based on the [Mozilla documentation for WebExtensions API](https://firefox-source-docs.mozilla.org/toolkit/components/extensions/webextensions/index.html).

- [toolkit](https://searchfox.org/mozilla-central/source/toolkit/components/extensions/ext-toolkit.json)
- [browser](https://searchfox.org/mozilla-central/source/browser/components/extensions/ext-browser.json)
Expand All @@ -20,29 +20,29 @@ Create a browser extension using Blazor. Refer to the package [Blazor.BrowserExt
### Without Blazor
Create a standard browser extension using JavaScript and load the WebAssembly manually. The .Net source code can be compiled into wasm using Mono.

1. Install `WebExtension.Net` from Nuget.
2. A JavaScript file will be added to your project at the path `wwwroot/WebExtensionScripts/WebExtensionNet.js`. This `.js` file needs to be included in your application, either by using a `<script>` element in HTML or using `import` from JavaScript code.
3. Import the [WebExtension polyfill](https://github.com/mozilla/webextension-polyfill) by Mozilla for cross browser compatibility. This polyfill helps to convert the callback based Chrome extensions API to a Promise based API for asynchronous functions.
4. Consume the WebExtension API by creating an instance of `WebExtensionApi` as shown below.
1. Install `WebExtensions.Net` from Nuget.
2. A JavaScript file will be added to your project at the path `wwwroot/WebExtensionsScripts/WebExtensionsNet.js`. This `.js` file needs to be included in your application, either by using a `<script>` element in HTML or using `import` from JavaScript code.
3. Import the [WebExtensions polyfill](https://github.com/mozilla/webextension-polyfill) by Mozilla for cross browser compatibility. This polyfill helps to convert the callback based Chrome extensions API to a Promise based API for asynchronous functions.
4. Consume the WebExtensions API by creating an instance of `WebExtensionsApi` as shown below.

```csharp
using WebExtension.Net;
using WebExtensions.Net;
...
// iJsRuntime is an instance of MonoWebAssemblyJSRuntime
var webExtensionJsRuntime = new WebExtensionJSRuntime(iJsRuntime);
var webExtensionApi = new WebExtensionApi(webExtensionJsRuntime);
var manifest = await webExtensionApi.Runtime.GetManifest();
var webExtensionsJsRuntime = new WebExtensionsJSRuntime(iJsRuntime);
var webExtensionsApi = new WebExtensionsApi(webExtensionsJsRuntime);
var manifest = await webExtensionsApi.Runtime.GetManifest();
```

#### Debugging and testing
For the purpose of debugging and testing outside of the browser extension environment, there is a `MockWebExtensionJSRuntime` class under the `WebExtension.Net.Mock` namespace.
For the purpose of debugging and testing outside of the browser extension environment, there is a `MockWebExtensionsJSRuntime` class under the `WebExtensions.Net.Mock` namespace.
Initialize an instance of the mock API with:
```csharp
using WebExtension.Net;
using WebExtension.Net.Mock;
using WebExtensions.Net;
using WebExtensions.Net.Mock;
...
var webExtensionJsRuntime = new MockWebExtensionJSRuntime();
var webExtensionApi = new WebExtensionApi(webExtensionJsRuntime);
var webExtensionsJsRuntime = new MockWebExtensionsJSRuntime();
var webExtensionsApi = new WebExtensionsApi(webExtensionsJsRuntime);
```

To configure the behaviour of the mock API, you may use any combination of the following:
Expand Down Expand Up @@ -149,5 +149,5 @@ The following MSBuild properties can be specified in your project file or when r

| Property | Default value | Description |
| ------------------------- | ------------- | ------------------------------------------------------------------------- |
| WebExtensionAssetsPath | wwwroot | The root folder where the JavaScript file should be added as link. |
| IncludeWebExtensionAssets | true | If set to false, the JavaScript file will not be added as to the project. |
| WebExtensionsAssetsPath | wwwroot | The root folder where the JavaScript file should be added as link. |
| IncludeWebExtensionsAssets | true | If set to false, the JavaScript file will not be added as to the project. |
12 changes: 6 additions & 6 deletions WebExtensions.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31025.194
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtension.Net.Generator", "src\WebExtension.Net.Generator\WebExtension.Net.Generator.csproj", "{195216E0-B4BF-4058-AF5E-5F6ECA4634EC}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtensions.Net.Generator", "src\WebExtensions.Net.Generator\WebExtensions.Net.Generator.csproj", "{195216E0-B4BF-4058-AF5E-5F6ECA4634EC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtension.Net", "src\WebExtension.Net\WebExtension.Net.csproj", "{F84448CE-50BD-41BA-A49D-87F6CB4AF130}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtensions.Net", "src\WebExtensions.Net\WebExtensions.Net.csproj", "{F84448CE-50BD-41BA-A49D-87F6CB4AF130}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{36C5C454-9F2E-4505-B08D-452DED9D18F0}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -19,15 +19,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{790DED5B-7057-4D11-BD7D-79AFA689C68E}"
ProjectSection(SolutionItems) = preProject
.github\workflows\WebExtension.Net-Build.yml = .github\workflows\WebExtension.Net-Build.yml
.github\workflows\WebExtension.Net-Release.yml = .github\workflows\WebExtension.Net-Release.yml
.github\workflows\WebExtensions.Net-Build.yml = .github\workflows\WebExtensions.Net-Build.yml
.github\workflows\WebExtensions.Net-Release.yml = .github\workflows\WebExtensions.Net-Release.yml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{402C7B21-F25A-4EB2-AAAE-A8F827CD0ED4}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtension.Net.BrowserExtensionIntegrationTest", "test\WebExtension.Net.BrowserExtensionIntegrationTest\WebExtension.Net.BrowserExtensionIntegrationTest.csproj", "{C8382E8F-80E4-4EA5-B64E-D8AD46D84F90}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtensions.Net.BrowserExtensionIntegrationTest", "test\WebExtensions.Net.BrowserExtensionIntegrationTest\WebExtensions.Net.BrowserExtensionIntegrationTest.csproj", "{C8382E8F-80E4-4EA5-B64E-D8AD46D84F90}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtension.Net.IntegrationTestsRunner", "test\WebExtension.Net.IntegrationTestsRunner\WebExtension.Net.IntegrationTestsRunner.csproj", "{6F6D0020-DE47-47F5-8D85-25A4D328B0A1}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebExtensions.Net.IntegrationTestsRunner", "test\WebExtensions.Net.IntegrationTestsRunner\WebExtensions.Net.IntegrationTestsRunner.csproj", "{6F6D0020-DE47-47F5-8D85-25A4D328B0A1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{37728F80-FC95-4451-B92C-3D915C0D11B6}"
EndProject
Expand Down
8 changes: 4 additions & 4 deletions src/WebExtensions.Net.Generator/ClrTypeManager.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System.Collections.Generic;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtension.Net.Generator.Models.Entities;
using WebExtension.Net.Generator.ClrTypeTranslators;
using WebExtensions.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.Models.Entities;
using WebExtensions.Net.Generator.ClrTypeTranslators;

namespace WebExtension.Net.Generator
namespace WebExtensions.Net.Generator
{
public class ClrTypeManager
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using WebExtension.Net.Generator.Extensions;
using WebExtension.Net.Generator.Models;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtension.Net.Generator.Models.Entities;
using WebExtensions.Net.Generator.Extensions;
using WebExtensions.Net.Generator.Models;
using WebExtensions.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.Models.Entities;

namespace WebExtension.Net.Generator.ClrTypeTranslators
namespace WebExtensions.Net.Generator.ClrTypeTranslators
{
public class ClassEntityTranslator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using WebExtension.Net.Generator.Extensions;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtension.Net.Generator.Models.Entities;
using WebExtension.Net.Generator.Models.Schema;
using WebExtensions.Net.Generator.Extensions;
using WebExtensions.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.Models.Entities;
using WebExtensions.Net.Generator.Models.Schema;

namespace WebExtension.Net.Generator.ClrTypeTranslators
namespace WebExtensions.Net.Generator.ClrTypeTranslators
{
public class ClrTypeStore
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using WebExtension.Net.Generator.Extensions;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtension.Net.Generator.Models.Schema;
using WebExtensions.Net.Generator.Extensions;
using WebExtensions.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.Models.Schema;

namespace WebExtension.Net.Generator.ClrTypeTranslators
namespace WebExtensions.Net.Generator.ClrTypeTranslators
{
public static class EnumPropertyDefinitionTranslator
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using WebExtension.Net.Generator.Extensions;
using WebExtension.Net.Generator.Helpers;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtension.Net.Generator.Models.Entities;
using WebExtension.Net.Generator.Models.Schema;
using WebExtensions.Net.Generator.Extensions;
using WebExtensions.Net.Generator.Helpers;
using WebExtensions.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.Models.Entities;
using WebExtensions.Net.Generator.Models.Schema;

namespace WebExtension.Net.Generator.ClrTypeTranslators
namespace WebExtensions.Net.Generator.ClrTypeTranslators
{
public class FunctionDefinitionTranslator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
using System;
using WebExtension.Net.Generator.Extensions;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtension.Net.Generator.Models.Entities;
using WebExtension.Net.Generator.Models.Schema;
using WebExtensions.Net.Generator.Extensions;
using WebExtensions.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.Models.Entities;
using WebExtensions.Net.Generator.Models.Schema;

namespace WebExtension.Net.Generator.ClrTypeTranslators
namespace WebExtensions.Net.Generator.ClrTypeTranslators
{
public class PropertyDefinitionTranslator
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class ApiCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class ApiRootCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class ArrayCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class EnumCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class MultitypeCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class StringFormatCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using WebExtension.Net.Generator.CodeGeneration.CodeConverters;
using WebExtension.Net.Generator.Models.ClrTypes;
using WebExtensions.Net.Generator.CodeGeneration.CodeConverters;
using WebExtensions.Net.Generator.Models.ClrTypes;

namespace WebExtension.Net.Generator.CodeGeneration.CodeConverterFactories
namespace WebExtensions.Net.Generator.CodeGeneration.CodeConverterFactories
{
public class TypeCodeConverterFactory : ICodeConverterFactory
{
Expand Down
Loading

0 comments on commit 94c4d1b

Please sign in to comment.