-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
500 additions
and
362 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,13 @@ | ||
try { | ||
dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=opencover /p:ExcludeByAttribute=GeneratedCodeAttribute | ||
reportgenerator "-reports:*/*.xml" "-targetdir:.cover" -reporttypes:HTML | ||
serve .cover | ||
$out = "../.cover/" | ||
$json = "../.cover/coverage.json" | ||
dotnet test Bootsharp.Common.Test/Bootsharp.Common.Test.csproj /p:CollectCoverage=true /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out | ||
dotnet test Bootsharp.Generate.Test/Bootsharp.Generate.Test.csproj /p:CollectCoverage=true /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out /p:MergeWith=$json | ||
dotnet test Bootsharp.Inject.Test/Bootsharp.Inject.Test.csproj /p:CollectCoverage=true /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out /p:MergeWith=$json | ||
dotnet test Bootsharp.Publish.Test/Bootsharp.Publish.Test.csproj /p:CollectCoverage=true /p:CoverletOutputFormat="json%2copencover" /p:ExcludeByAttribute=GeneratedCodeAttribute /p:CoverletOutput=$out /p:MergeWith=$json | ||
reportgenerator "-reports:*/*.xml" "-targetdir:.cover" -reporttypes:HTML | ||
python -m webbrowser http://localhost:3000 | ||
serve .cover | ||
} finally { | ||
rm ./*/coverage.opencover.xml -force | ||
rm ./.cover -r -force | ||
rm .cover -r -force | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Bootsharp; | ||
|
||
/// <summary> | ||
/// Bootsharp-specific metadata of an interop method argument. | ||
/// </summary> | ||
public sealed record ArgumentMeta | ||
{ | ||
/// <summary> | ||
/// C# name of the argument, as specified in source code. | ||
/// </summary> | ||
public required string Name { get; init; } | ||
/// <summary> | ||
/// JavaScript name of the argument, to be specified in source code. | ||
/// </summary> | ||
public required string JSName { get; init; } | ||
/// <summary> | ||
/// Metadata of the argument's value. | ||
/// </summary> | ||
public required ValueMeta Value { get; init; } | ||
|
||
public override string ToString () => $"{Name}: {Value.JSTypeSyntax}"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Bootsharp; | ||
|
||
/// <summary> | ||
/// Bootsharp-specific metadata of a C# assembly included in compiled solution. | ||
/// </summary> | ||
public sealed record AssemblyMeta | ||
{ | ||
/// <summary> | ||
/// Name of the assembly; equals DLL file name, w/o the extension. | ||
/// </summary> | ||
public required string Name { get; init; } | ||
/// <summary> | ||
/// Raw binary content of the assembly. | ||
/// </summary> | ||
public required byte[] Bytes { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
namespace Bootsharp; | ||
|
||
/// <summary> | ||
/// Bootsharp-specific metadata of an interop method. | ||
/// </summary> | ||
public sealed record MethodMeta | ||
{ | ||
/// <summary> | ||
/// Type of interop the method is implementing. | ||
/// </summary> | ||
public required MethodType Type { get; init; } | ||
/// <summary> | ||
/// C# assembly name (DLL file name, w/o the extension), under which the method is declared. | ||
/// </summary> | ||
public required string Assembly { get; init; } | ||
/// <summary> | ||
/// Full name of the C# type (including namespace), under which the method is declared. | ||
/// </summary> | ||
public required string Space { get; init; } | ||
/// <summary> | ||
/// JavaScript object name(s) (joined with dot when nested) under which the associated interop | ||
/// function will be declared; resolved from <see cref="Space"/> with user-defined converters. | ||
/// </summary> | ||
public required string JSSpace { get; init; } | ||
/// <summary> | ||
/// C# name of the method, as specified in source code. | ||
/// </summary> | ||
public required string Name { get; init; } | ||
/// <summary> | ||
/// JavaScript name of the method (function), as will be specified in source code. | ||
/// </summary> | ||
public required string JSName { get; init; } | ||
/// <summary> | ||
/// Arguments of the method, in declaration order. | ||
/// </summary> | ||
public required IReadOnlyList<ArgumentMeta> Arguments { get; init; } | ||
/// <summary> | ||
/// Metadata of the value returned by the method. | ||
/// </summary> | ||
public required ValueMeta ReturnValue { get; init; } | ||
|
||
public override string ToString () | ||
{ | ||
var args = string.Join(", ", Arguments.Select(a => a.ToString())); | ||
return $"[{Type}] {Assembly}.{Space}.{Name} ({args}) => {ReturnValue}"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Bootsharp; | ||
|
||
/// <summary> | ||
/// Type of interop method. | ||
/// </summary> | ||
public enum MethodType | ||
{ | ||
/// <summary> | ||
/// The method is implemented in C# and invoked from JavaScript; | ||
/// implementation has <see cref="JSInvokableAttribute"/>. | ||
/// </summary> | ||
Invokable, | ||
/// <summary> | ||
/// The method is implemented in JavaScript and invoked from C#; | ||
/// implementation has <see cref="JSFunctionAttribute"/>. | ||
/// </summary> | ||
Function, | ||
/// <summary> | ||
/// The method is invoked from C# to notify subscribers in JavaScript; | ||
/// implementation has <see cref="JSEventAttribute"/>. | ||
/// </summary> | ||
Event | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Bootsharp; | ||
|
||
/// <summary> | ||
/// Bootsharp-specific metadata of the compiled solution. | ||
/// </summary> | ||
public sealed record SolutionMeta | ||
{ | ||
/// <summary> | ||
/// Assemblies included in the solution. | ||
/// </summary> | ||
public required IReadOnlyCollection<AssemblyMeta> Assemblies { get; init; } | ||
/// <summary> | ||
/// Interop methods in the solution: either top-level (eg [JSInvokable]) or | ||
/// members of the auto-generated interop classes (eg [JSExport]). | ||
/// </summary> | ||
public required IReadOnlyCollection<MethodMeta> Methods { get; init; } | ||
/// <summary> | ||
/// Types referenced in the interop methods signatures, including | ||
/// types associated with the prior types, crawled recursively. | ||
/// </summary> | ||
public required IReadOnlyCollection<Type> Types { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
namespace Bootsharp; | ||
|
||
/// <summary> | ||
/// Bootsharp-specific metadata of interop method's argument or returned value. | ||
/// </summary> | ||
public sealed record ValueMeta | ||
{ | ||
/// <summary> | ||
/// C# type of the value. | ||
/// </summary> | ||
public required Type Type { get; init; } | ||
/// <summary> | ||
/// C# syntax of the value type, as specified in source code. | ||
/// </summary> | ||
public required string TypeSyntax { get; init; } | ||
/// <summary> | ||
/// TypeScript syntax of the value type, to be specified in source code. | ||
/// </summary> | ||
public required string JSTypeSyntax { get; init; } | ||
/// <summary> | ||
/// Whether the value is optional/nullable. | ||
/// </summary> | ||
public required bool Nullable { get; init; } | ||
/// <summary> | ||
/// Whether the value type is of an async nature (eg, task or promise). | ||
/// </summary> | ||
public required bool Async { get; init; } | ||
/// <summary> | ||
/// Whether the value is void (when method return value). | ||
/// </summary> | ||
public required bool Void { get; init; } | ||
/// <summary> | ||
/// Whether the value has to be marshalled to/from JSON for interop. | ||
/// </summary> | ||
public required bool Serialized { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// namespace Bootsharp; | ||
|
||
// /// <summary> | ||
// /// User preferences for Bootsharp behaviour. | ||
// /// </summary> | ||
// public record Preferences | ||
// { | ||
// | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Bootsharp.Publish.Test/Emit/ExportTest.cs → ...rp.Publish.Test/Emit/InteropExportTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...Bootsharp.Publish.Test/Emit/ImportTest.cs → ...rp.Publish.Test/Emit/InteropImportTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
src/cs/Bootsharp.Publish.Test/Pack/AssemblyInspectionTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Bootsharp.Publish.Test; | ||
|
||
public class AssemblyInspectionTest : PackTest | ||
{ | ||
[Fact] | ||
public void AllAssembliesAreInspected () | ||
{ | ||
AddAssembly("Foo.dll"); | ||
Execute(); | ||
Assert.Contains(Engine.Messages, w => w.Contains("Foo")); | ||
Assert.Contains(Engine.Messages, w => w.Contains("Bootsharp.Common")); | ||
Assert.Contains(Engine.Messages, w => w.Contains("System.Runtime")); | ||
Assert.Contains(Engine.Messages, w => w.Contains("System.Private.CoreLib")); | ||
} | ||
|
||
[Fact] | ||
public void WhenAssemblyInspectionFailsWarningIsLogged () | ||
{ | ||
File.WriteAllText(Path.Combine(Project.Root, "foo.dll"), "corrupted"); | ||
Execute(); | ||
Assert.Contains(Engine.Warnings, w => w.Contains("Failed to inspect 'foo.dll' assembly")); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.