Skip to content

Commit 0dce45c

Browse files
committed
Added comments.
1 parent 347e557 commit 0dce45c

File tree

2 files changed

+110
-5
lines changed

2 files changed

+110
-5
lines changed

CSharpToJavaScript/APIs/JS/GlobalObject.cs

Lines changed: 81 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,120 @@ namespace CSharpToJavaScript.APIs.JS.Ecma;
44

55
public partial class GlobalObject
66
{
7+
/// <summary>
8+
/// Translates this method into the "===" operator.
9+
/// </summary>
10+
/// <remarks>
11+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_equality
12+
/// </remarks>
13+
/// <param name="left">x</param>
14+
/// <param name="right">y</param>
15+
/// <returns></returns>
716
[Binary("===")]
817
public static bool EqualsStrict(dynamic left, dynamic right)
918
{
1019
return left == right;
1120
}
21+
22+
/// <summary>
23+
/// Translates this method into the "!==" operator.
24+
/// </summary>
25+
/// <remarks>
26+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Strict_inequality
27+
/// </remarks>
28+
/// <param name="left">x</param>
29+
/// <param name="right">y</param>
30+
/// <returns></returns>
1231
[Binary("!==")]
1332
public static bool InequalsStrict(dynamic left, dynamic right)
1433
{
1534
return left != right;
1635
}
36+
37+
/// <summary>
38+
/// Translates this method into the "delete" operator.
39+
/// </summary>
40+
/// <remarks>
41+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/delete
42+
/// </remarks>
43+
/// <param name="arg">object.property</param>
44+
/// <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>
1745
[Unary("delete ")]
1846
public static bool Delete(dynamic arg)
1947
{
2048
return true;
2149
}
50+
51+
/// <summary>
52+
/// Translates this method into the "void" operator.
53+
/// </summary>
54+
/// <remarks>
55+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/void
56+
/// </remarks>
57+
/// <param name="arg">expression</param>
58+
/// <returns>Undefined</returns>
2259
[Unary("void ")]
2360
public static Undefined Void(dynamic arg)
2461
{
2562
return new Undefined();
2663
}
64+
65+
/// <summary>
66+
/// Translates this method into the "typeof" operator.
67+
/// </summary>
68+
/// <remarks>
69+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
70+
/// </remarks>
71+
/// <param name="operand">An expression representing the object or primitive whose type is to be returned.</param>
72+
/// <returns>string</returns>
2773
[Unary("typeof ")]
28-
public static string TypeOf(dynamic arg)
74+
public static string TypeOf(dynamic operand)
2975
{
3076
return string.Empty;
3177
}
78+
79+
/// <summary>
80+
/// Translates this method into the "instanceof" operator.
81+
/// </summary>
82+
/// <remarks>
83+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof
84+
/// </remarks>
85+
/// <param name="obj">The object to test.</param>
86+
/// <param name="constructor">Constructor to test against.</param>
87+
/// <returns>bool</returns>
3288
[Binary("instanceof")]
33-
public static bool InstanceOf(dynamic left, dynamic right)
89+
public static bool InstanceOf(dynamic obj, dynamic constructor)
3490
{
3591
return true;
3692
}
93+
94+
/// <summary>
95+
/// Translates this method into the "in" operator.
96+
/// </summary>
97+
/// <remarks>
98+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in
99+
/// </remarks>
100+
/// <param name="prop">A string or symbol representing a property name (non-symbols will be coerced to strings). Can also be a private element identifier.</param>
101+
/// <param name="obj">Object to check if it (or its prototype chain) contains the property with specified name (prop).</param>
102+
/// <returns>bool</returns>
37103
[Binary("in")]
38-
public static bool In(dynamic left, dynamic right)
104+
public static bool In(dynamic prop, dynamic obj)
39105
{
40106
return true;
41107
}
108+
109+
/// <summary>
110+
/// Translates this method into the "," operator. (As a binary)
111+
/// </summary>
112+
/// <remarks>
113+
/// See mdn: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Comma_operator
114+
/// </remarks>
115+
/// <param name="expr1">First expression.</param>
116+
/// <param name="expr2">Second expression.</param>
117+
/// <returns>dynamic</returns>
42118
[Binary(",")]
43-
public static dynamic Comma(dynamic left, dynamic right)
119+
public static dynamic Comma(dynamic expr1, dynamic expr2)
44120
{
45-
return right;
121+
return expr2;
46122
}
47123
}

CSharpToJavaScript/Utils/Attributes.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22

33
namespace CSharpToJavaScript.Utils;
44

5+
/// <summary>
6+
///
7+
/// </summary>
58
[AttributeUsage(AttributeTargets.Class)]
69
internal class IgnoreAttribute : Attribute
710
{
811
public IgnoreAttribute() { }
912
}
13+
14+
/// <summary>
15+
/// Translates class/method to a specified value.
16+
/// </summary>
1017
[AttributeUsage(AttributeTargets.All)]
1118
public class ValueAttribute : Attribute
1219
{
@@ -17,6 +24,17 @@ public ValueAttribute(string value)
1724
}
1825
}
1926

27+
/// <summary>
28+
/// Changes class/method based on options.
29+
/// </summary>
30+
/// <remarks>
31+
/// Default: do nothing.<br />
32+
/// ToLower: convert to lowercase.<br />
33+
/// FirstCharToLowerCase: convert the first char to lowercase.<br />
34+
/// None: convert to empty.<br />
35+
/// NoneWithLeadingDotRemoved: convert to empty with the leading dot removed.<br />
36+
/// NoneWithTailingDotRemoved: convert to empty with the trailing dot removed.<br />
37+
/// </remarks>
2038
[AttributeUsage(AttributeTargets.All)]
2139
public class ToAttribute : Attribute
2240
{
@@ -52,6 +70,9 @@ public string Convert(string str)
5270
}
5371
}
5472

73+
/// <summary>
74+
/// Translates a method into a binary operator.
75+
/// </summary>
5576
[AttributeUsage(AttributeTargets.All)]
5677
public class BinaryAttribute : Attribute
5778
{
@@ -61,6 +82,10 @@ public BinaryAttribute(string value)
6182
Value = value;
6283
}
6384
}
85+
86+
/// <summary>
87+
/// Translates a method into an unary operator.
88+
/// </summary>
6489
[AttributeUsage(AttributeTargets.All)]
6590
public class UnaryAttribute : Attribute
6691
{
@@ -70,6 +95,10 @@ public UnaryAttribute(string value)
7095
Value = value;
7196
}
7297
}
98+
99+
/// <summary>
100+
/// Translates a class into a JS object.
101+
/// </summary>
73102
[AttributeUsage(AttributeTargets.All)]
74103
public class ToObjectAttribute : Attribute
75104
{

0 commit comments

Comments
 (0)