Skip to content

Commit

Permalink
fix #419
Browse files Browse the repository at this point in the history
  • Loading branch information
yanghuan committed Feb 23, 2023
2 parents f1de1f6 + 26cc191 commit 69c0e4c
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CSharp.lua/LuaSyntaxNodeTransform.Helper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -812,6 +812,15 @@ private bool MayBeNullOrFalse(ExpressionSyntax conditionalWhenTrue) {

case SyntaxKind.ParenthesizedLambdaExpression:
return false;

case SyntaxKind.IdentifierName:
var symbol = semanticModel_.GetSymbolInfo(conditionalWhenTrue).Symbol;
if (symbol != null) {
if (symbol.Kind == SymbolKind.Method) {
return false;
}
}
break;
}

var type = semanticModel_.GetTypeInfo(conditionalWhenTrue!).Type;
Expand Down
10 changes: 7 additions & 3 deletions CSharp.lua/XmlDocumentationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,23 @@ limitations under the License.
namespace CSharpLua {
internal class XmlDocumentationProvider : DocumentationProvider {
private readonly string path_;
private Dictionary<string, string> comments_;
private readonly Dictionary<string, string> comments_ = new();

internal XmlDocumentationProvider(string path) {
path_ = path;
Load();
}

private void Load() {
comments_ = XElement.Load(path_).Descendants("member").Select(e => {
var comments = XElement.Load(path_).Descendants("member").Select(e => {
var name = e.Attribute("name");
var comment = e.Element("summary")?.Value;
return new { name, comment };
}).Where(i => i.name != null && !string.IsNullOrEmpty(i.comment)).ToDictionary(i => i.name.Value, i => i.comment);
}).Where(i => i.name != null && !string.IsNullOrEmpty(i.comment));

foreach (var i in comments) {
comments_[i.name.Value] = i.comment;
}
}

public override bool Equals(object obj) {
Expand Down
9 changes: 9 additions & 0 deletions test/BridgeNetTests/Batch1/src/BasicCSharp/TestFromIssue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ public static void TestOf410() {
Assert.AreEqual("System.Collections.Generic.IEnumerable`1[System.Collections.Generic.IEnumerable`1[System.Int32]]", genericType1[0].FullName);
}

[Test]
public static void TestOf418() {
static void OnKickTeamMemberClick() {
}
bool isLeader = true;
Action kickAction = isLeader ? OnKickTeamMemberClick : null;
Assert.AreEqual(kickAction, OnKickTeamMemberClick);
}

[Test]
public static void TestOf419() {
static string GetStr() {
Expand Down

0 comments on commit 69c0e4c

Please sign in to comment.