Skip to content

Commit

Permalink
API checker (#827)
Browse files Browse the repository at this point in the history
* API checker

* dotnet format
  • Loading branch information
kblok authored Sep 6, 2020
1 parent 39c61c5 commit 37129be
Show file tree
Hide file tree
Showing 16 changed files with 16,971 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ public async Task ShouldFireCloseEventForAPersistentContext()
private async Task<(TempDirectory tmp, IBrowserContext context, IPage page)> LaunchAsync(BrowserContextOptions options = null)
{
var tmp = new TempDirectory();
var context = await BrowserType.LaunchPersistenContextAsync(
var context = await BrowserType.LaunchPersistentContextAsync(
tmp.Path,
TestConstants.GetDefaultBrowserOptions().ToPersistentOptions() + (options ?? new BrowserContextOptions()));
var page = context.Pages.First();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public async Task InitializeAsync()
var options = TestConstants.GetDefaultBrowserOptions().ToPersistentOptions();
options.DownloadsPath = _downloadsPath.Path;
options.AcceptDownloads = true;
_context = await Playwright[TestConstants.Product].LaunchPersistenContextAsync(_userDataDir.Path, options);
_context = await Playwright[TestConstants.Product].LaunchPersistentContextAsync(_userDataDir.Path, options);
_page = _context.Pages[0];
await _page.SetContentAsync($"<a href=\"{TestConstants.ServerUrl}/download\">download</a>");
}
Expand Down
9 changes: 9 additions & 0 deletions src/PlaywrightSharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaywrightSharp", "Playwrig
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PlaywrightSharp.Demo", "PlaywrightSharp.Demo\PlaywrightSharp.Demo.csproj", "{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{5C6D57B1-C82A-48D6-9EBD-73B712CAE476}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiChecker", "tools\ApiChecker\ApiChecker.csproj", "{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -44,12 +48,17 @@ Global
{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FB3348E3-9759-4B90-9C8C-391F44AD5F8F}.Release|Any CPU.Build.0 = Release|Any CPU
{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{A907B324-4541-4FAF-8CAE-D0B512B4BC36} = {D250D790-5A30-4C38-8F60-50FA96DB4E67}
{9430DBAB-C5E3-4D37-84B2-EF86566D5AAA} = {5C6D57B1-C82A-48D6-9EBD-73B712CAE476}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8D6EDE73-B005-4ABC-BCF8-BB3C154497EC}
Expand Down
8 changes: 4 additions & 4 deletions src/PlaywrightSharp/BrowserType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public Task<IBrowserContext> LaunchPersistenContextAsync(
ColorScheme? colorScheme = null,
string locale = null,
Dictionary<string, string> extraHttpHeaders = null)
=> LaunchPersistenContextAsync(
=> LaunchPersistentContextAsync(
userAgent,
new LaunchPersistentOptions
{
Expand Down Expand Up @@ -233,7 +233,7 @@ public Task<IBrowserContext> LaunchPersistenContextAsync(
ColorScheme? colorScheme = null,
string locale = null,
Dictionary<string, string> extraHttpHeaders = null)
=> LaunchPersistenContextAsync(
=> LaunchPersistentContextAsync(
userAgent,
new LaunchPersistentOptions
{
Expand Down Expand Up @@ -271,10 +271,10 @@ public Task<IBrowserContext> LaunchPersistenContextAsync(

/// <inheritdoc />
public Task<IBrowserContext> LaunchPersistenContextAsync(string userDataDir, LaunchOptions options)
=> LaunchPersistenContextAsync(userDataDir, options?.ToPersistentOptions() ?? new LaunchPersistentOptions());
=> LaunchPersistentContextAsync(userDataDir, options?.ToPersistentOptions() ?? new LaunchPersistentOptions());

/// <inheritdoc />
public async Task<IBrowserContext> LaunchPersistenContextAsync(string userDataDir, LaunchPersistentOptions options)
public async Task<IBrowserContext> LaunchPersistentContextAsync(string userDataDir, LaunchPersistentOptions options)
=> (await _channel.LaunchPersistenContextAsync(userDataDir, options ?? new LaunchPersistentOptions()).ConfigureAwait(false)).Object;

/// <inheritdoc />
Expand Down
5 changes: 1 addition & 4 deletions src/PlaywrightSharp/ConsoleMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ internal ConsoleMessage(ConnectionScope scope, string guid, ConsoleMessageInitia
/// <summary>
/// Gets the ConsoleMessage type.
/// </summary>
/// <value>ConsoleMessageType.</value>
public string Type => _initializer.Type;

/// <summary>
/// Gets the arguments.
/// </summary>
/// <value>The arguments.</value>
public IEnumerable<IJSHandle> Args => _initializer.Args.Select(a => ((JSHandleChannel)a).Object);

/// <summary>
Expand All @@ -52,7 +50,6 @@ internal ConsoleMessage(ConnectionScope scope, string guid, ConsoleMessageInitia
/// <summary>
/// Gets the console text.
/// </summary>
/// <value>The text.</value>
internal string Text => _initializer.Text;
public string Text => _initializer.Text;
}
}
6 changes: 3 additions & 3 deletions src/PlaywrightSharp/Download.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,19 @@ internal Download(ConnectionScope scope, string guid, DownloadInitializer initia
/// Returns download error if any.
/// </summary>
/// <returns>A <see cref="Task"/> that completes when failure is resolved, yielding the faulire.</returns>
internal Task<string> GetFailureAsync() => _channel.GetFailureAsync();
public Task<string> GetFailureAsync() => _channel.GetFailureAsync();

/// <summary>
/// Deletes the downloaded file.
/// </summary>
/// <returns>A <see cref="Task"/> that completes when the file is removed.</returns>
internal Task DeleteAsync() => _channel.DeleteAsync();
public Task DeleteAsync() => _channel.DeleteAsync();

/// <summary>
/// Returns readable stream for current download or null if download failed.
/// </summary>
/// <returns>A <see cref="Task"/> that completes when the stream is created, yielding the stream.</returns>
internal async Task<Stream> CreateReadStreamAsync()
public async Task<Stream> CreateReadStreamAsync()
{
string fileName = await GetPathAsync().ConfigureAwait(false);
return string.IsNullOrEmpty(fileName) ? null : new FileStream(fileName, FileMode.Open);
Expand Down
2 changes: 1 addition & 1 deletion src/PlaywrightSharp/IBrowserType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ Task<IBrowserContext> LaunchPersistenContextAsync(
/// <param name="userDataDir">Path to a User Data Directory, which stores browser session data like cookies and local storage.</param>
/// <param name="options">Launch options.</param>
/// <returns>A <see cref="Task"/> that completes when the browser is launched, yielding the browser server.</returns>
Task<IBrowserContext> LaunchPersistenContextAsync(string userDataDir, LaunchPersistentOptions options);
Task<IBrowserContext> LaunchPersistentContextAsync(string userDataDir, LaunchPersistentOptions options);

/// <summary>
/// This methods attaches PlaywrightSharp to an existing browser instance.
Expand Down
2 changes: 1 addition & 1 deletion src/PlaywrightSharp/LaunchPersistentOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace PlaywrightSharp
{
/// <summary>
/// Options for <seealso cref="IBrowserType.LaunchPersistenContextAsync(string, LaunchPersistentOptions)"/>.
/// Options for <seealso cref="IBrowserType.LaunchPersistentContextAsync(string, LaunchPersistentOptions)"/>.
/// </summary>
public class LaunchPersistentOptions : LaunchOptions
{
Expand Down
2 changes: 1 addition & 1 deletion src/PlaywrightSharp/ProxySettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace PlaywrightSharp
{
/// <summary>
/// Proxy Settings. See <see cref="IBrowserType.LaunchAsync(LaunchOptions)"/> and <see cref="IBrowserType.LaunchPersistenContextAsync(string, LaunchPersistentOptions)"/>.
/// Proxy Settings. See <see cref="IBrowserType.LaunchAsync(LaunchOptions)"/> and <see cref="IBrowserType.LaunchPersistentContextAsync(string, LaunchPersistentOptions)"/>.
/// </summary>
public class ProxySettings
{
Expand Down
20 changes: 20 additions & 0 deletions src/tools/ApiChecker/ApiChecker.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ReleaseVersion>0.0.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<None Remove="api.json" />
</ItemGroup>
<ItemGroup>
<Content Include="**/*">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\PlaywrightSharp\PlaywrightSharp.csproj" />
</ItemGroup>
</Project>
9 changes: 9 additions & 0 deletions src/tools/ApiChecker/PlaywrightArgument.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ApiChecker
{
public class PlaywrightArgument
{
public PlaywrightType Type { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/tools/ApiChecker/PlaywrightEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace ApiChecker
{
internal class PlaywrightEntity
{
public Dictionary<string, PlaywrightMember> Members { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/tools/ApiChecker/PlaywrightMember.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace ApiChecker
{
public class PlaywrightMember
{
public string Kind { get; set; }

public Dictionary<string, PlaywrightArgument> Args { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/tools/ApiChecker/PlaywrightType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace ApiChecker
{
public class PlaywrightType
{
public Dictionary<string, PlaywrightArgument> Properties { get; set; }

public string Name { get; set; }
}
}
Loading

0 comments on commit 37129be

Please sign in to comment.