-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'verification' into main
- Loading branch information
Showing
12 changed files
with
298 additions
and
75 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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build Artifacts | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
push: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
build-artifacts: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up .NET Core | ||
uses: actions/[email protected] | ||
with: | ||
dotnet-version: 6 | ||
|
||
- name: NuGet Restore | ||
run: dotnet restore | ||
|
||
- name: Build and Publish project | ||
run: dotnet publish BattleBitAPIRunner/BattleBitAPIRunner.csproj -c Release -o ./publish --self-contained false --framework net6.0 --runtime win-x64 | ||
|
||
- name: Build nuget | ||
run: dotnet build BattleBitAPIRunner/BattleBitAPIRunner.csproj -c Release | ||
|
||
- name: Create NuGet package | ||
run: dotnet pack BBRAPIModules/BBRAPIModules.csproj --configuration Release --output ./nuget | ||
|
||
- name: Upload NuGet package artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: NuGet Package | ||
path: ./nuget/*.nupkg | ||
|
||
- name: Upload Release artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: BattleBitAPIRunner-beta | ||
path: ./publish/* |
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\BattleBitAPIRunner\BattleBitAPIRunner.csproj" /> | ||
<ProjectReference Include="..\BBRAPIModules\BBRAPIModules.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
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,99 @@ | ||
using BattleBitAPIRunner; | ||
using BBRAPIModules; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using Microsoft.CodeAnalysis; | ||
using Newtonsoft.Json; | ||
using Microsoft.CodeAnalysis.CSharp; | ||
using System.Text; | ||
using System.Collections.ObjectModel; | ||
|
||
namespace BBRAPIModuleVerification; | ||
|
||
internal class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
Console.WriteLine("Usage: BBRAPIModuleVerification <path to module.cs>"); | ||
return; | ||
} | ||
|
||
string filePath = args[0]; | ||
|
||
Module.logToConsole = false; | ||
|
||
Module module; | ||
try | ||
{ | ||
module = new Module(filePath); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(JsonConvert.SerializeObject(new VerificationResponse(false, Path.GetFileNameWithoutExtension(filePath), null, null, null, null, e.Message))); | ||
return; | ||
} | ||
|
||
List<string> missingDependencies = new(); | ||
List<PortableExecutableReference> references = new(); | ||
|
||
foreach (string dependency in module.RequiredDependencies) | ||
{ | ||
if (!Directory.Exists($"./cache/modules/{dependency}")) | ||
{ | ||
missingDependencies.Add(dependency); | ||
} | ||
else | ||
{ | ||
references.Add(MetadataReference.CreateFromFile($"./cache/modules/{dependency}/{dependency}.dll")); | ||
} | ||
} | ||
|
||
if (missingDependencies.Count > 0) | ||
{ | ||
Console.WriteLine(JsonConvert.SerializeObject(new VerificationResponse(false, module.Name, module.Description, module.Version, module.RequiredDependencies, module.OptionalDependencies, $"Missing dependencies: {string.Join(", ", missingDependencies)}"))); | ||
return; | ||
} | ||
|
||
try | ||
{ | ||
module.Compile(references.ToArray()); | ||
if (!Directory.Exists($"./cache/modules/{module.Name}")) | ||
{ | ||
Directory.CreateDirectory($"./cache/modules/{module.Name}"); | ||
} | ||
File.WriteAllBytes($"./cache/modules/{module.Name}/{module.Name}.dll", module.AssemblyBytes); | ||
|
||
Console.WriteLine(JsonConvert.SerializeObject(new VerificationResponse(true, module.Name, module.Description, module.Version, module.RequiredDependencies, module.OptionalDependencies, null))); | ||
} | ||
catch (Exception e) | ||
{ | ||
Console.WriteLine(JsonConvert.SerializeObject(new VerificationResponse(false, module.Name, module.Description, module.Version, module.RequiredDependencies, module.OptionalDependencies, e.Message))); | ||
return; | ||
} | ||
} | ||
|
||
|
||
} | ||
|
||
internal class VerificationResponse | ||
{ | ||
public VerificationResponse(bool success, string name, string description, string version, string[] requiredDependencies, string[] optionalDependencies, string errors) | ||
{ | ||
this.Success = success; | ||
this.Name = name; | ||
this.Description = description; | ||
this.Version = version; | ||
this.RequiredDependencies = requiredDependencies; | ||
this.OptionalDependencies = optionalDependencies; | ||
this.Errors = errors; | ||
} | ||
|
||
public bool Success { get; set; } | ||
public string? Name { get; set; } | ||
public string? Description { get; set; } | ||
public string? Version { get; set; } | ||
public string[]? RequiredDependencies { get; set; } | ||
public string[]? OptionalDependencies { get; set; } | ||
public string? Errors { get; set; } | ||
} |
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,8 @@ | ||
{ | ||
"profiles": { | ||
"BBRAPIModuleVerification": { | ||
"commandName": "Project", | ||
"commandLineArgs": "E:\\Create\\Development\\Software\\C#\\BattleBit\\BattleBitBaseModules\\SpectateControl.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
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,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace BBRAPIModules; | ||
|
||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)] | ||
public class ModuleAttribute : Attribute | ||
{ | ||
public string Description { get; set; } | ||
public string Version { get; set; } | ||
|
||
public ModuleAttribute(string description, string version) | ||
{ | ||
this.Description = description; | ||
this.Version = version; | ||
} | ||
} |
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
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
Oops, something went wrong.