-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from roblox-csharp/feat/events
Basic events implementation
- Loading branch information
Showing
17 changed files
with
542 additions
and
89 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
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 |
---|---|---|
@@ -1,10 +1,8 @@ | ||
namespace RobloxCS.Luau | ||
{ | ||
/// <summary>Simply renders nothing.</summary> | ||
/// <summary>Simply renders a newline.</summary> | ||
public sealed class NoOp : Statement | ||
{ | ||
public override void Render(LuauWriter luau) | ||
{ | ||
} | ||
public override void Render(LuauWriter luau) => luau.WriteLine(); | ||
} | ||
} |
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,22 @@ | ||
using Microsoft.CodeAnalysis; | ||
|
||
namespace RobloxCS; | ||
|
||
public class SymbolMetadata | ||
{ | ||
public Luau.IdentifierName? EventConnectionName { get; set; } | ||
} | ||
|
||
public static class SymbolMetadataManager | ||
{ | ||
private static readonly Dictionary<ISymbol, SymbolMetadata> _metadata = []; | ||
|
||
public static SymbolMetadata Get(ISymbol symbol) | ||
{ | ||
var metadata = _metadata.GetValueOrDefault(symbol); | ||
if (metadata == null) | ||
_metadata.Add(symbol, metadata = new SymbolMetadata()); | ||
|
||
return metadata; | ||
} | ||
} |
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 @@ | ||
local CS = require("../../RobloxCS/Include/RuntimeLib") | ||
|
||
-- CS.is() | ||
assert(true, CS.is("abc", "string")) | ||
assert(true, CS.is(123, "number")) | ||
assert(true, CS.is(false, "boolean")) | ||
assert(true, CS.is(nil, "nil")) | ||
assert(true, CS.is(function() end, "function")) | ||
|
||
local MyClass: CS.Class = { __className = "MyClass" } | ||
local myClass = { __className = "MyClass" } | ||
assert(true, CS.is(myClass, MyClass)) | ||
|
||
local parent = {} | ||
parent.__index = parent | ||
local child = setmetatable({}, parent) | ||
assert(true, CS.is(child, parent)) | ||
|
||
-- CS.defineGlobal() / CS.getGlobal() | ||
CS.defineGlobal("MyValue", 69420) | ||
assert(69420, CS.getGlobal("MyValue")) | ||
|
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,54 @@ | ||
using System.Diagnostics; | ||
using System.Reflection; | ||
using System.Runtime.InteropServices; | ||
using Xunit.Abstractions; | ||
|
||
namespace RobloxCS.Tests; | ||
|
||
public class RuntimeLibTest(ITestOutputHelper testOutputHelper) | ||
{ | ||
private readonly string _cwd = | ||
Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location))))!; | ||
|
||
[Theory] | ||
[InlineData("RuntimeLibTest")] | ||
public void RuntimeLib_PassesTests(string scriptName) | ||
{ | ||
var lunePath = Path.GetFullPath("lune" + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : ""), _cwd); | ||
var runScriptArguments = $"run {scriptName}"; | ||
var process = new Process | ||
{ | ||
StartInfo = new ProcessStartInfo | ||
{ | ||
FileName = lunePath, | ||
Arguments = runScriptArguments, | ||
RedirectStandardOutput = true, | ||
RedirectStandardError = true, | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
WorkingDirectory = _cwd | ||
} | ||
}; | ||
|
||
try | ||
{ | ||
process.Start(); | ||
|
||
var output = process.StandardOutput.ReadToEnd(); | ||
var error = process.StandardError.ReadToEnd(); | ||
process.WaitForExit(); | ||
|
||
testOutputHelper.WriteLine($"{scriptName}.luau Errors:"); | ||
testOutputHelper.WriteLine(error); | ||
Assert.True(string.IsNullOrWhiteSpace(error)); | ||
testOutputHelper.WriteLine($"{scriptName}.luau Output:"); | ||
testOutputHelper.WriteLine(output); | ||
Assert.True(string.IsNullOrWhiteSpace(output)); | ||
Assert.Equal(0, process.ExitCode); | ||
} | ||
finally | ||
{ | ||
process.Dispose(); | ||
} | ||
} | ||
} |
Binary file not shown.
Binary file not shown.
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.