-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for types derived from un-namespaced types. (#261)
- Loading branch information
1 parent
dbdbf87
commit 5d321c9
Showing
3 changed files
with
93 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using System.Collections; | ||
using System.Collections.Generic; | ||
|
||
#pragma warning disable IDE0060 // Remove unused parameter | ||
#pragma warning disable CA1050 // Declare types in namespaces | ||
#pragma warning disable CA1822 // Mark members as static | ||
|
||
public class NoNamespaceType | ||
{ | ||
} | ||
|
||
public interface INoNamespaceInterface | ||
{ | ||
} | ||
|
||
public class NoNamespaceCollection : ICollection<string> | ||
{ | ||
public IEnumerator<string> GetEnumerator() => throw new System.NotImplementedException(); | ||
|
||
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator(); | ||
|
||
public void Add(string item) => throw new System.NotImplementedException(); | ||
|
||
public void Clear() => throw new System.NotImplementedException(); | ||
|
||
public bool Contains(string item) => throw new System.NotImplementedException(); | ||
|
||
public void CopyTo(string[] array, int arrayIndex) => throw new System.NotImplementedException(); | ||
|
||
public bool Remove(string item) => throw new System.NotImplementedException(); | ||
|
||
public int Count { get; } | ||
public bool IsReadOnly { get; } | ||
} | ||
|
||
public delegate void NoNamespaceDelegate(); | ||
|
||
namespace Microsoft.JavaScript.NodeApi.TestCases | ||
{ | ||
public class NoNamespaceInterfaceImpl : INoNamespaceInterface | ||
{ | ||
} | ||
|
||
public class NoNamespaceTypeImpl : NoNamespaceType | ||
{ | ||
} | ||
|
||
public class NoNamespaceContainer | ||
{ | ||
public static NoNamespaceDelegate DelegateProperty { get; set; } | ||
Check warning on line 53 in test/TestCases/napi-dotnet/NoNamespaceTypes.cs GitHub Actions / Analyze (csharp)
|
||
|
||
public List<NoNamespaceType>? GetList(INoNamespaceInterface arg) | ||
{ | ||
return null; | ||
} | ||
|
||
public T GetList<T>() | ||
where T : List<NoNamespaceType>, INoNamespaceInterface | ||
{ | ||
return default!; | ||
} | ||
} | ||
} |
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,19 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
const assert = require('assert'); | ||
|
||
const dotnet = require('../common').dotnet; | ||
|
||
// Load the test module using dynamic binding `load()` instead of static binding `require()`. | ||
const assemblyPath = process.env.NODE_API_TEST_MODULE_PATH; | ||
dotnet.load(assemblyPath); | ||
|
||
// The unnamespaced type should be skipped. | ||
assert.strictEqual(dotnet.NoNamespaceType, undefined); | ||
|
||
assert.notStrictEqual(dotnet.Microsoft.JavaScript.NodeApi.TestCases.NoNamespaceInterfaceImpl, undefined) | ||
|
||
assert.notStrictEqual(dotnet.Microsoft.JavaScript.NodeApi.TestCases.NoNamespaceTypeImpl, undefined) | ||
|
||
assert.notStrictEqual(dotnet.Microsoft.JavaScript.NodeApi.TestCases.NoNamespaceContainer, undefined) |