Skip to content

Commit 191aa4e

Browse files
committed
Cleanup code, setup projects for library pushing.
1 parent 72e388a commit 191aa4e

File tree

13 files changed

+130
-20
lines changed

13 files changed

+130
-20
lines changed

VRChat.API.Client/VRCGuid.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public static VRCGuid Create(VRCKind kind, Guid underlyingId) =>
5858
/// <summary>
5959
/// Creates a new <see cref="VRCGuid"/> randomly, with the specified <see cref="VRCKind"/>, otherwise <c>VRCGuidType.File</c>
6060
/// </summary>
61-
/// <param name="type">The kind of <see cref="VRCGuid"/> to create.</param>
61+
/// <param name="kind">The kind of <see cref="VRCGuid"/> to create.</param>
6262
/// <returns>A new <see cref="VRCGuid"/>.</returns>
6363
public static VRCGuid NewGuid(VRCKind kind = VRCKind.File) =>
6464
VRCGuid.Create(kind, Guid.NewGuid());

VRChat.API.Client/VRCKind.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,35 @@
11
namespace VRChat
22
{
3+
/// <summary>
4+
/// A kind formatter for specifying the <see cref="VRCGuid.Kind"/> property
5+
/// <br /> This can be used to ensure proper IDs are used in business-first applications.
6+
/// </summary>
37
public enum VRCKind
48
{
9+
/// <summary>
10+
/// A VRChat ID of type "file", representing a File object.
11+
/// </summary>
512
File,
13+
14+
/// <summary>
15+
/// A VRChat ID of type "usr", representing a User object.
16+
/// </summary>
617
User,
18+
19+
/// <summary>
20+
/// A VRChat ID of type "wrld", representing a World object.
21+
/// </summary>
722
World,
23+
24+
/// <summary>
25+
/// A VRChat ID of type "avtr", representing an Avatar object.
26+
/// </summary>
827
Avatar
928
}
1029

30+
/// <summary>
31+
/// Extensions methods for the <see cref="VRCKind"/> enum.
32+
/// </summary>
1133
public static class VRCKindEnum
1234
{
1335
/// <summary>
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
6+
<SignAssembly>False</SignAssembly>
7+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
8+
<Description>Fluent interface API around VRChat.API, allowing for fluent usage of the library in enterprise-grade environments.</Description>
9+
<Copyright>(c) binn</Copyright>
10+
<PackageProjectUrl>https://github.com/binn/VRChat.API.Client</PackageProjectUrl>
11+
<RepositoryUrl>https://github.com/binn/VRChat.API.Client</RepositoryUrl>
12+
<RepositoryType>git</RepositoryType>
13+
<PackageTags>vrchat,vrcapi,microsoft.extensions.hosting,aspnetcore,servicecollection,vrc-api,vrc</PackageTags>
14+
<AssemblyVersion>1.0.0</AssemblyVersion>
15+
<FileVersion>1.0.0</FileVersion>
16+
<EnableNETAnalyzers>True</EnableNETAnalyzers>
17+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
18+
<AnalysisLevel>latest</AnalysisLevel>
19+
</PropertyGroup>
20+
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
22+
<FileAlignment>1024</FileAlignment>
23+
</PropertyGroup>
24+
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
26+
<FileAlignment>1024</FileAlignment>
527
</PropertyGroup>
628

729
<ItemGroup>
8-
<PackageReference Include="VRChat.API" Version="1.6.2" />
30+
<PackageReference Include="VRChat.API" Version="1.6.3" />
931
</ItemGroup>
1032

1133
</Project>

VRChat.API.Client/VRChat.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
namespace VRChat.API.Client
77
{
8+
/// <summary>
9+
/// A generic interface for communicating against VRChat's API.
10+
/// </summary>
811
public interface IVRChat
912
{
1013
/// <summary>
@@ -84,7 +87,7 @@ public interface IVRChat
8487

8588
/// <summary>
8689
/// <b>The Permissions API for VRChat.</b> <br />
87-
/// The Permissions API provides access to querying permissions & assigned permissions on VRChat
90+
/// The Permissions API provides access to querying permissions &amp; assigned permissions on VRChat
8891
/// <br /> This API is used for managing VRChat+ related permissions (inferred).
8992
/// </summary>
9093
PermissionsApi Permissions { get; }
@@ -132,7 +135,7 @@ public interface IVRChat
132135
Task<CurrentUser> LoginAsync(bool throwOnFail = false, CancellationToken ct = default);
133136
}
134137

135-
public class VRChat : IVRChat
138+
internal class VRChat : IVRChat
136139
{
137140
private VRChat(Configuration configuration)
138141
{

VRChat.API.Client/VRChatClientBuilder.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
namespace VRChat.API.Client
55
{
6+
/// <summary>
7+
/// The core of VRChat.API.Client. The VRChatClientBuilder class provides a Fluent API for building <see cref="IVRChat"/> clients, and smoothly
8+
/// <b/> authentication against VRChat's API, with a rebuilding pipeline if ever needed.
9+
/// </summary>
610
public class VRChatClientBuilder
711
{
812
private const string _defaultUserAgent = "VRChat.API.Client/1.0 (.NET) netstandard2.0 (https://dot.net) VRChat.API/RestSharp";
@@ -26,11 +30,6 @@ public VRChatClientBuilder(Configuration incomingConfiguration)
2630
this.WithUserAgent(_defaultUserAgent);
2731
}
2832

29-
public void WithCredentials(object username, object password)
30-
{
31-
throw new NotImplementedException();
32-
}
33-
3433
/// <summary>
3534
/// Creates a <see cref="VRChatClientBuilder"/> from a <see cref="Configuration"/>
3635
/// <br /> <b style="color: red">Note: <em>This should not be used unless you know what you're doing</em></b>

VRChat.API.Extensions.Hosting/DefaultVRChatClientFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public DefaultVRChatClientFactory() =>
1616

1717
internal bool IsDefaultRegistered => _builders.ContainsKey("vrc_default"); // Not sure where I was going with this, but I'll keep it in here for now
1818

19-
public async Task AttemptLoginForAllClients()
19+
public async Task LoginAllClientsAsync()
2020
{
2121
foreach(var client in _builders.Keys)
2222
await this.LoginClientAsync(client);

VRChat.API.Extensions.Hosting/IVRChatClientFactory.cs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,37 @@
33

44
namespace VRChat.API.Extensions.Hosting
55
{
6+
/// <summary>
7+
/// An interface used for implementing a factory to build <see cref="IVRChat"/> clients from DI.
8+
/// </summary>
69
public interface IVRChatClientFactory
710
{
11+
/// <summary>
12+
/// Creates a client using the default client provider and configuration.
13+
/// </summary>
14+
/// <returns>An instance of <see cref="IVRChat"/> from the default client provider.</returns>
815
IVRChat CreateClient();
16+
17+
/// <summary>
18+
/// Creates a named client from the client provider and named configuration.
19+
/// </summary>
20+
/// <param name="name">The name of the client to create</param>
21+
/// <returns>An instance of <see cref="IVRChat"/> from the named client provider.</returns>
922
IVRChat CreateClient(string name);
1023

11-
Task AttemptLoginForAllClients();
24+
/// <summary>
25+
/// Calls <see cref="IVRChat.TryLoginAsync(System.Threading.CancellationToken)"/> on ALL of the registered clients, thus forcing them to have a populated authcookie.
26+
/// <br /> This also ensures that all clients are logged in. <b>This method does not throw an exception.</b>
27+
/// </summary>
28+
/// <returns>A <see cref="Task"/> representing this asyncronous operation.</returns>
29+
Task LoginAllClientsAsync();
30+
31+
/// <summary>
32+
/// Calls <see cref="IVRChat.TryLoginAsync(System.Threading.CancellationToken)"/> on the named client, thus forcing the client to have a populated authcookie.
33+
/// <br /> This also ensures that the specified client is logged in. <b>This method does not throw an exception.</b>
34+
/// </summary>
35+
/// <param name="name">The name of the client to login</param>
36+
/// <returns>A <see cref="Task"/> representing this asyncronous operation.</returns>
1237
Task LoginClientAsync(string name = "vrc_default");
1338
}
1439
}

VRChat.API.Extensions.Hosting/VRChat.API.Extensions.Hosting.csproj

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,30 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
5-
</PropertyGroup>
3+
<PropertyGroup>
4+
<TargetFramework>netstandard2.0</TargetFramework>
5+
<GenerateDocumentationFile>True</GenerateDocumentationFile>
6+
<SignAssembly>False</SignAssembly>
7+
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
8+
<Description>.NET DI-ready fluent API built around VRChat.API.Client, for use in enterprise-grade .NET environments.</Description>
9+
<Copyright>(c) binn</Copyright>
10+
<PackageProjectUrl>https://github.com/binn/VRChat.API.Client</PackageProjectUrl>
11+
<RepositoryUrl>https://github.com/binn/VRChat.API.Client</RepositoryUrl>
12+
<RepositoryType>git</RepositoryType>
13+
<PackageTags>vrchat,vrcapi,microsoft.extensions.hosting,aspnetcore,servicecollection,vrc-api,vrc</PackageTags>
14+
<AssemblyVersion>1.0.0</AssemblyVersion>
15+
<FileVersion>1.0.0</FileVersion>
16+
<EnableNETAnalyzers>True</EnableNETAnalyzers>
17+
<EnforceCodeStyleInBuild>True</EnforceCodeStyleInBuild>
18+
<AnalysisLevel>latest</AnalysisLevel>
19+
</PropertyGroup>
20+
21+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
22+
<FileAlignment>1024</FileAlignment>
23+
</PropertyGroup>
24+
25+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
26+
<FileAlignment>1024</FileAlignment>
27+
</PropertyGroup>
628

729
<ItemGroup>
830
<PackageReference Include="Microsoft.Extensions.Configuration.Abstractions" Version="6.0.0" />

VRChat.API.Extensions.Hosting/VRChatOptions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
namespace VRChat.API.Extensions.Hosting
22
{
3+
/// <summary>
4+
/// IConfiguration options binding class, can be consumed in publically shipped-APIs.
5+
/// </summary>
36
public class VRChatOptions
47
{
58
/// <summary>

VRChat.API.Extensions.Hosting/VRChatServiceCollectionExtensions.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,16 @@
66

77
namespace VRChat.API.Extensions.Hosting // Maybe we should change the namespace to Microsoft.Extensions.DependencyInjection ?
88
{
9+
/// <summary>
10+
/// Extensions against <see cref="IServiceCollection"/> for fluent addition of <see cref="IVRChat"/> clients to .NET applications.
11+
/// </summary>
912
public static class VRChatServiceCollectionExtensions
1013
{
11-
// We don't specify the <returns> or <param> for IServiceCollection because it is inferred that the user knows what they're doing
1214

1315
/// <summary>
1416
/// Registers an <see cref="IVRChat"/> to the service collection as the default <see cref="IVRChat"/>, using an <see cref="IConfigurationSection"/> to configure.
1517
/// </summary>
18+
/// <param name="services">The <see cref="IServiceCollection"/> to add this <see cref="IVRChat"/> to.</param>
1619
/// <param name="section">A configuration section used to configure the <see cref="IVRChat"/> with.</param>
1720
public static IServiceCollection AddVRChat(this IServiceCollection services, IConfigurationSection section) =>
1821
AddVRChat(services, "vrc_default", section);
@@ -21,6 +24,8 @@ public static IServiceCollection AddVRChat(this IServiceCollection services, ICo
2124
/// Registers a named <see cref="IVRChat"/> to the service collection, using an <see cref="IConfigurationSection"/> to configure.
2225
/// <br /> <b>Note, you will need to use <see cref="IVRChatClientFactory"/> to consume named <see cref="IVRChat"/> clients.</b>
2326
/// </summary>
27+
/// <param name="services">The <see cref="IServiceCollection"/> to add this <see cref="IVRChat"/> to.</param>
28+
/// <param name="clientName">The name used to refer to this <see cref="IVRChat"/> with.</param>
2429
/// <param name="section">A configuration section used to configure the <see cref="IVRChat"/> with.</param>
2530
public static IServiceCollection AddVRChat(this IServiceCollection services, string clientName, IConfigurationSection section)
2631
{
@@ -43,6 +48,7 @@ public static IServiceCollection AddVRChat(this IServiceCollection services, str
4348
/// <summary>
4449
/// Registers an <see cref="IVRChat"/> to the service collection as the default <see cref="IVRChat"/>.
4550
/// </summary>
51+
/// <param name="services">The <see cref="IServiceCollection"/> to add this <see cref="IVRChat"/> to.</param>
4652
/// <param name="builder">A configuration action to configure the <see cref="IVRChat"/> with.</param>
4753
public static IServiceCollection AddVRChat(this IServiceCollection services, Action<VRChatClientBuilder> builder = null) =>
4854
AddVRChat(services, "vrc_default", builder); // Implement a factory pattern in the future
@@ -51,6 +57,7 @@ public static IServiceCollection AddVRChat(this IServiceCollection services, Act
5157
/// Registers a named <see cref="IVRChat"/> to the service collection.
5258
/// <br /> <b>Note, you will need to use <see cref="IVRChatClientFactory"/> to consume named <see cref="IVRChat"/> clients.</b>
5359
/// </summary>
60+
/// <param name="services">The <see cref="IServiceCollection"/> to add this <see cref="IVRChat"/> to.</param>
5461
/// <param name="clientName">The name used to refer to this <see cref="IVRChat"/> with.</param>
5562
/// <param name="builder">A configuration action to configure the <see cref="IVRChat"/> with.</param>
5663
public static IServiceCollection AddVRChat(this IServiceCollection services, string clientName, Action<VRChatClientBuilder> builder = null)

0 commit comments

Comments
 (0)