diff --git a/Storage/Storage.Test/CloudFunctionTest.cs b/Storage/Storage.Test/CloudFunctionTest.cs new file mode 100644 index 0000000..6b48a6a --- /dev/null +++ b/Storage/Storage.Test/CloudFunctionTest.cs @@ -0,0 +1,22 @@ +using NUnit.Framework; +using LeanCloud; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace LeanCloudTests { + public class CloudFunctionTest { + [SetUp] + public void SetUp() { + Utils.InitNorthChina(); + } + + [Test] + public async Task Hello() { + AVClient.UseProduction = true; + string result = await AVCloud.CallFunctionAsync("hello", new Dictionary { + { "word", "world" } + }); + TestContext.Out.WriteLine($"resutlt: {result}"); + } + } +} diff --git a/Storage/Storage.Test/Utils.cs b/Storage/Storage.Test/Utils.cs index caecb3e..2a111d9 100644 --- a/Storage/Storage.Test/Utils.cs +++ b/Storage/Storage.Test/Utils.cs @@ -6,34 +6,35 @@ namespace LeanCloudTests { public static class Utils { public static void InitNorthChina(bool master = false) { if (master) { - Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com", "qKH9ryRagHKvXeRRVkiUiHeb"); + Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com", "https://avoscloud.com", "qKH9ryRagHKvXeRRVkiUiHeb"); } else { - Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com"); + Init("BMYV4RKSTwo8WSqt8q9ezcWF-gzGzoHsz", "pbf6Nk5seyjilexdpyrPwjSp", "https://avoscloud.com", "https://avoscloud.com"); } } public static void InitEastChina(bool master = false) { if (master) { - Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com", "eqEp4n89h4zanWFskDDpIwL4"); + Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com", "https://4eTwHdYh.engine.lncldapi.com", "eqEp4n89h4zanWFskDDpIwL4"); } else { - Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com"); + Init("4eTwHdYhMaNBUpl1SrTr7GLC-9Nh9j0Va", "GSD6DtdgGWlWolivN4qhWtlE", "https://4eTwHdYh.api.lncldapi.com", "https://4eTwHdYh.engine.lncldapi.com"); } } public static void InitUS(bool master = false) { if (master) { - Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com", "Ahb1wdFLwMgKwEaEicHRXbCY"); + Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com", "https://MFAS1GnO.engine.lncldglobal.com", "Ahb1wdFLwMgKwEaEicHRXbCY"); } else { - Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com"); + Init("MFAS1GnOyomRLSQYRaxdgdPz-MdYXbMMI", "p42JUxdxb95K5G8187t5ba3l", "https://MFAS1GnO.api.lncldglobal.com", "https://MFAS1GnO.engine.lncldglobal.com"); } } - static void Init(string appId, string appKey, string apiServer, string masterKey = null) { + static void Init(string appId, string appKey, string apiServer, string engineServer, string masterKey = null) { AVClient.Initialize(new AVClient.Configuration { ApplicationId = appId, ApplicationKey = appKey, MasterKey = masterKey, - ApiServer = apiServer + ApiServer = apiServer, + EngineServer = engineServer, }); AVClient.UseMasterKey = !string.IsNullOrEmpty(masterKey); AVClient.HttpLog(TestContext.Out.WriteLine); diff --git a/Storage/Storage/Internal/Object/Subclassing/ObjectSubclassingController.cs b/Storage/Storage/Internal/Object/Subclassing/ObjectSubclassingController.cs index d1bd092..919f053 100644 --- a/Storage/Storage/Internal/Object/Subclassing/ObjectSubclassingController.cs +++ b/Storage/Storage/Internal/Object/Subclassing/ObjectSubclassingController.cs @@ -126,9 +126,8 @@ namespace LeanCloud.Storage.Internal { public IDictionary GetPropertyMappings(string className) { mutex.EnterReadLock(); - registeredSubclasses.TryGetValue(className, out info); - if (info == null) { - registeredSubclasses.TryGetValue(avObjectClassName, out info); + if (!registeredSubclasses.TryGetValue(className, out ObjectSubclassInfo info)) { + _ = registeredSubclasses.TryGetValue(avObjectClassName, out info); } mutex.ExitReadLock(); diff --git a/Storage/Storage/Public/AVObject.cs b/Storage/Storage/Public/AVObject.cs index ffe29d7..05e77b2 100644 --- a/Storage/Storage/Public/AVObject.cs +++ b/Storage/Storage/Public/AVObject.cs @@ -210,7 +210,7 @@ namespace LeanCloud { } private static string GetFieldForPropertyName(string className, string propertyName) { - SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out fieldName); + SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out string fieldName); return fieldName; }