Deleting WIP files and fixing unit tests.
This commit is contained in:
Родитель
9c9ff4a225
Коммит
af2e9f6bbe
|
@ -10,11 +10,30 @@ namespace ReactNative.Tests.Bridge
|
|||
[TestMethod]
|
||||
public void NativeModuleBase_ArgumentChecks()
|
||||
{
|
||||
var fooCount = 0;
|
||||
var barSum = 0;
|
||||
var testModule = new TestNativeModule(() => fooCount++, x => barSum += x);
|
||||
|
||||
testModule.Initialize();
|
||||
|
||||
Assert.AreEqual(2, testModule.Methods.Count);
|
||||
foreach (var key in testModule.Methods.Keys)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
}
|
||||
|
||||
class TestNativeModule : NativeModuleBase
|
||||
{
|
||||
private readonly Action _onFoo;
|
||||
private readonly Action<int> _onBar;
|
||||
|
||||
public TestNativeModule(Action onFoo, Action<int> onBar)
|
||||
{
|
||||
_onFoo = onFoo;
|
||||
_onBar = onBar;
|
||||
}
|
||||
|
||||
public override string Name
|
||||
{
|
||||
get
|
||||
|
@ -22,6 +41,18 @@ namespace ReactNative.Tests.Bridge
|
|||
return "Foo";
|
||||
}
|
||||
}
|
||||
|
||||
[ReactMethod]
|
||||
public void Foo()
|
||||
{
|
||||
_onFoo();
|
||||
}
|
||||
|
||||
[ReactMethod]
|
||||
public void Bar(int x)
|
||||
{
|
||||
_onBar(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,8 +31,6 @@ namespace ReactNative.Tests.Bridge
|
|||
var builder = new NativeModuleRegistry.Builder();
|
||||
builder.Add(new OverrideAllowedModule());
|
||||
builder.Add(new OverrideAllowedModule());
|
||||
var registry = builder.Build();
|
||||
Assert.AreEqual(1, registry.Modules.Count);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
using System;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace ReactNative.Bridge
|
||||
{
|
||||
class ChakraReactBridge : IReactBridge
|
||||
{
|
||||
public void CallFunction(int moduleId, int methodId, JArray arguments)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void InvokeCallback(int callbackID, JArray arguments)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void SetGlobalVariable(string propertyName, string jsonEncodedArgument)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -101,11 +101,11 @@ namespace ReactNative.Bridge
|
|||
throw new ArgumentNullException(nameof(module));
|
||||
if (module.Name == null)
|
||||
throw new ArgumentException(
|
||||
nameof(module),
|
||||
string.Format(
|
||||
CultureInfo.InvariantCulture,
|
||||
"Native module '{0}' cannot have a null `Name`.",
|
||||
module.GetType()));
|
||||
module.GetType()),
|
||||
nameof(module));
|
||||
|
||||
var existing = default(INativeModule);
|
||||
if (_modules.TryGetValue(module.Name, out existing) && !module.CanOverrideExistingModule)
|
||||
|
@ -121,7 +121,7 @@ namespace ReactNative.Bridge
|
|||
|
||||
}
|
||||
|
||||
_modules.Add(module.Name, module);
|
||||
_modules[module.Name] = module;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -15,18 +15,6 @@ namespace ReactNative.Bridge.Queue
|
|||
/// <param name="action">The action.</param>
|
||||
void RunOnQueue(Action action);
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the given function on this thread.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The function will be submitted to the end of the event queue
|
||||
/// even if it is being submitted from the same queue Thread.
|
||||
/// </remarks>
|
||||
/// <typeparam name="T">The type of result expected.</typeparam>
|
||||
/// <param name="func">The function.</param>
|
||||
/// <returns>The result of the function.</returns>
|
||||
Task<T> CallOnQueue<T>(Func<T> func);
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the current thread is also the thread
|
||||
/// associated with this <see cref="IMessageQueueThread"/>.
|
||||
|
|
|
@ -29,10 +29,10 @@ namespace ReactNative.Bridge.Queue
|
|||
{
|
||||
switch (spec.Kind)
|
||||
{
|
||||
case MessageQueueThreadKind.MainUi:
|
||||
return new DispatcherMessageQueueThread(name, handler);
|
||||
case MessageQueueThreadKind.NewBackground:
|
||||
return new BackgroundMessageQueueThread(name, handler);
|
||||
//case MessageQueueThreadKind.MainUi:
|
||||
// return new DispatcherMessageQueueThread(name, handler);
|
||||
//case MessageQueueThreadKind.NewBackground:
|
||||
// return new BackgroundMessageQueueThread(name, handler);
|
||||
default:
|
||||
throw new InvalidOperationException(
|
||||
string.Format(
|
||||
|
@ -42,13 +42,5 @@ namespace ReactNative.Bridge.Queue
|
|||
spec.Name));
|
||||
}
|
||||
}
|
||||
|
||||
class DispatcherMessageQueueThread : MessageQueueThread
|
||||
{
|
||||
public DispatcherMessageQueueThread(string name, IQueueThreadExceptionHandler handler)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.System.Threading;
|
||||
|
||||
namespace ReactNative.Bridge.Queue
|
||||
{
|
||||
|
@ -20,14 +21,18 @@ namespace ReactNative.Bridge.Queue
|
|||
}
|
||||
}
|
||||
|
||||
public Task<T> CallOnQueue<T>(this IMessageQueueThread actionQueue, Func<T> func)
|
||||
public static Task<T> CallOnQueue<T>(this IMessageQueueThread actionQueue, Func<T> func)
|
||||
{
|
||||
var taskCompletionSource = new TaskCompletionSource<T>();
|
||||
|
||||
actionQueue.RunOnQueue(async () =>
|
||||
actionQueue.RunOnQueue(() =>
|
||||
{
|
||||
var result = func;
|
||||
await ThreadPool.RunAsync(taskCompletionSource.SetResult(result));
|
||||
var result = func();
|
||||
|
||||
// TaskCompletionSource<T>.SetResult can call continuations
|
||||
// on the awaiter of the task completion source.
|
||||
// TODO: Prevent such thread stealing.
|
||||
taskCompletionSource.SetResult(result);
|
||||
});
|
||||
|
||||
return taskCompletionSource.Task;
|
||||
|
|
|
@ -18,17 +18,11 @@ namespace ReactNative.Bridge.Queue
|
|||
|
||||
internal MessageQueueThreadKind Kind { get; }
|
||||
|
||||
public static MessageQueueThreadSpec MainUiThreadSpec { get; } = new MessageQueueThreadSpec(MessageQueueThreadKind.MainUi, "main_ui")
|
||||
public static MessageQueueThreadSpec MainUiThreadSpec { get; } = new MessageQueueThreadSpec(MessageQueueThreadKind.MainUi, "main_ui");
|
||||
|
||||
public static MessageQueueThreadSpec Create(string name)
|
||||
{
|
||||
return new MessageQueueThreadSpec(MessageQueueThreadKind.NewBackground, name);
|
||||
}
|
||||
|
||||
enum MessageQueueThreadKind
|
||||
{
|
||||
MainUi,
|
||||
NewBackground,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||
|
||||
namespace ReactNative.Bridge
|
||||
{
|
||||
class ReactApplicationContext
|
||||
class ReactContext
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace ReactNative.Bridge
|
||||
{
|
||||
interface IReactPackage
|
||||
{
|
||||
IList<INativeModule> CreateNativeModules(ReactApplicationContext context);
|
||||
|
||||
IList<IViewManager> CreateViewManagers(ReactApplicationContext context);
|
||||
}
|
||||
}
|
|
@ -1,12 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ReactNative
|
||||
{
|
||||
class IViewManager
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ReactNative
|
||||
{
|
||||
public abstract class ReactInstanceManager
|
||||
{
|
||||
public sealed class Builder
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -107,14 +107,20 @@
|
|||
<None Include="project.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Bridge\ChakraReactBridge.cs" />
|
||||
<Compile Include="Bridge\CatalystInstance.cs" />
|
||||
<Compile Include="Bridge\ICallback.cs" />
|
||||
<Compile Include="Bridge\ICatalystInstance.cs" />
|
||||
<Compile Include="Bridge\INativeMethod.cs" />
|
||||
<Compile Include="Bridge\IOnBatchCompleteListener.cs" />
|
||||
<Compile Include="Bridge\ModuleDefinition.cs" />
|
||||
<Compile Include="Bridge\NativeModuleBase.cs" />
|
||||
<Compile Include="Bridge\NativeModuleRegistry.cs" />
|
||||
<Compile Include="Bridge\Queue\IMessageQueueThread.cs" />
|
||||
<Compile Include="Bridge\Queue\IQueueThreadExceptionHandler.cs" />
|
||||
<Compile Include="Bridge\Queue\MessageQueueThread.cs" />
|
||||
<Compile Include="Bridge\Queue\MessageQueueThreadExtensions.cs" />
|
||||
<Compile Include="Bridge\Queue\MessageQueueThreadKind.cs" />
|
||||
<Compile Include="Bridge\Queue\MessageQueueThreadSpec.cs" />
|
||||
<Compile Include="Bridge\ReactContext.cs" />
|
||||
<Compile Include="Hosting\JavaScriptBackgroundWorkItemCallback.cs" />
|
||||
<Compile Include="Hosting\JavaScriptBeforeCollectCallback.cs" />
|
||||
<Compile Include="Hosting\JavaScriptContext.cs" />
|
||||
|
@ -139,10 +145,7 @@
|
|||
<Compile Include="Hosting\Native.cs" />
|
||||
<Compile Include="Imports.cs" />
|
||||
<Compile Include="Bridge\INativeModule.cs" />
|
||||
<Compile Include="IReactPackage.cs" />
|
||||
<Compile Include="IViewManager.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ReactApplicationContext.cs" />
|
||||
<Compile Include="Bridge\IReactBridge.cs" />
|
||||
<Compile Include="ReactMethodAttribute.cs" />
|
||||
<Compile Include="Reflection\MethodInfoHelpers.cs" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче