Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CSharpToJavaScript.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<GenerateDocumentationFile>False</GenerateDocumentationFile>
<Authors>TiLied</Authors>
<Description>A library for translating/converting cs into js, using Roslyn.</Description>
<PackageProjectUrl>https://tilied.github.io/CSTOJS_Pages/</PackageProjectUrl>
Expand Down
12 changes: 6 additions & 6 deletions CSharpToJavaScript/APIs/JS/GlobalObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public static bool InequalsStrict(dynamic left, dynamic right)
/// </remarks>
/// <param name="arg">object.property</param>
/// <returns>true for all cases except when the property is an own non-configurable property, in which case false is returned in non-strict mode.</returns>
[Unary("delete ")]
[Unary("delete")]
public static bool Delete(dynamic arg)
{
return true;
Expand All @@ -57,7 +57,7 @@ public static bool Delete(dynamic arg)
/// </remarks>
/// <param name="arg">expression</param>
/// <returns>Undefined</returns>
[Unary("void ")]
[Unary("void")]
public static Undefined Void(dynamic arg)
{
return new Undefined();
Expand All @@ -71,7 +71,7 @@ public static Undefined Void(dynamic arg)
/// </remarks>
/// <param name="operand">An expression representing the object or primitive whose type is to be returned.</param>
/// <returns>string</returns>
[Unary("typeof ")]
[Unary("typeof")]
public static string TypeOf(object operand)
{
return string.Empty;
Expand All @@ -84,7 +84,7 @@ public static string TypeOf(object operand)
/// </remarks>
/// <param name="operand">An expression representing the object or primitive whose type is to be returned.</param>
/// <returns>string</returns>
[Unary("typeof ")]
[Unary("typeof")]
public static string TypeOf(Func<dynamic> operand)
{
return string.Empty;
Expand All @@ -97,7 +97,7 @@ public static string TypeOf(Func<dynamic> operand)
/// </remarks>
/// <typeparam name="O">An expression representing the object or primitive whose type is to be returned.</typeparam>
/// <returns>string</returns>
[GenericUnary("typeof ")]
[GenericUnary("typeof")]
public static string TypeOf<O>()
{
return string.Empty;
Expand All @@ -112,7 +112,7 @@ public static string TypeOf<O>()
/// <typeparam name="C">Constructor to test against.</typeparam>
/// <param name="obj">The object to test.</param>
/// <returns>bool</returns>
[GenericBinary(" instanceof ")]
[GenericBinary("instanceof")]
public static bool InstanceOf<C>(dynamic obj)
{
return true;
Expand Down
23 changes: 18 additions & 5 deletions CSharpToJavaScript/CSTOJS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,10 @@ public static class CSTOJS
/// <returns></returns>
public static FileData Translate(FileData file, MetadataReference[]? references = null)
{
FileData[] files = Translate([file], references);
return files[0];
new Walker2(file);
return file;
//FileData[] files = Translate([file], references);
//return files[0];
}
/// <summary>
/// This method translates CSharp string into JavaScript with specified options.
Expand Down Expand Up @@ -122,7 +124,7 @@ public static FileData[] Translate(FileData[] files, MetadataReference[]? refere
return files;
}

private static MetadataReference[] GetReferences(CSTOJSOptions options)
public static MetadataReference[] GetReferences(CSTOJSOptions options)
{
HashSet<MetadataReference> assemblyMetadata = new();

Expand Down Expand Up @@ -222,7 +224,7 @@ private static MetadataReference[] GetReferences(CSTOJSOptions options)
return references;
}

private static SyntaxTree AddGlobalUsings(SyntaxTree tree)
public static SyntaxTree AddGlobalUsings(SyntaxTree tree)
{
CompilationUnitSyntax root = tree.GetCompilationUnitRoot();
UsingDirectiveSyntax[] oldUsing = root.Usings.ToArray();
Expand Down Expand Up @@ -402,4 +404,15 @@ public class FileData
/// JS translated string.
/// </summary>
public string TranslatedStr { get; set; } = string.Empty;
}


/// <summary>
/// Debug string.
/// </summary>
public string Debug_WithSemanticRewriter { get; set; } = string.Empty;

/// <summary>
/// Debug string.
/// </summary>
public string Debug_WithoutSemanticRewriter { get; set; } = string.Empty;
}
7 changes: 5 additions & 2 deletions CSharpToJavaScript/Utils/Attributes.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Microsoft.CodeAnalysis;
using System;

namespace CSharpToJavaScript.Utils;

Expand Down Expand Up @@ -76,6 +77,7 @@ public string Convert(string str)
[AttributeUsage(AttributeTargets.All)]
public class BinaryAttribute : Attribute
{
public static SyntaxAnnotation Annotation { get; } = new(nameof(BinaryAttribute));
public string Value { get; init; }
public BinaryAttribute(string value)
{
Expand All @@ -100,6 +102,7 @@ public GenericBinaryAttribute(string value)
[AttributeUsage(AttributeTargets.All)]
public class UnaryAttribute : Attribute
{
public static SyntaxAnnotation Annotation { get; } = new(nameof(UnaryAttribute));
public string Value { get; init; }
public UnaryAttribute(string value)
{
Expand All @@ -125,7 +128,7 @@ public GenericUnaryAttribute(string value)
[AttributeUsage(AttributeTargets.All)]
public class ToObjectAttribute : Attribute
{

public static SyntaxAnnotation Annotation { get; } = new(nameof(ToObjectAttribute));
}

[AttributeUsage(AttributeTargets.Method)]
Expand Down
Loading