public void SerializableExtractor5Test() { var source = @" namespace NS1 { public interface IA{} public interface IB{ Regulus.Remote.Property<IA> Property1 {get;} } } "; var tree = CSharpSyntaxTree.ParseText(source); Compilation compilation = tree.Compilation(); bool exc = false; try { var symbols = new SerializableExtractor(compilation).Symbols.ToArray(); } catch (Regulus.Remote.Tools.Protocol.Sources.Exceptions.UnserializableException ex) { exc = true; } NUnit.Framework.Assert.IsTrue(exc); }
public void SerializableExtractor4Test() { var source = @" namespace NS1 { public interface IB{ Regulus.Remote.Property<int> Property1 {get;} } } "; var tree = CSharpSyntaxTree.ParseText(source); Compilation compilation = tree.Compilation(); var cSymbols = new[] { compilation.GetSpecialType(SpecialType.System_Int32) }; var symbols = new SerializableExtractor(compilation).Symbols; var count = cSymbols.Except(symbols).Count(); NUnit.Framework.Assert.AreEqual(0, count); }
public void SerializableExtractor6Test() { var source = @" namespace Regulus.Remote.Tools.Protocol.Sources.TestCommon { public static partial class ProtocolProvider { public static Regulus.Remote.IProtocol CreateCase1() { Regulus.Remote.IProtocol protocol = null; _CreateCase1(ref protocol); return protocol; } [Remote.Protocol.Creator] static partial void _CreateCase1(ref Regulus.Remote.IProtocol protocol); public static IProtocol CreateCase2() { IProtocol protocol = null; _CreateCase2(ref protocol); return protocol; } [Remote.Protocol.Creator] static partial void _CreateCase2(ref IProtocol protocol); } } "; var tree = CSharpSyntaxTree.ParseText(source); Compilation compilation = tree.Compilation(); var symbols = new SerializableExtractor(compilation).Symbols; NUnit.Framework.Assert.AreEqual(0, symbols.Count); }
public async Task SerializableExtractor1Test() { var source = @" namespace NS1 { public struct C2 { public int F1; public string F2; public float F3; } public class C1 { public C2; } public interface IB{ Regulus.Remote.Property<C1> Property1 {get;} } public interface IA { Regulus.Remote.Value<C2> Method(C2 a1 , C1 a2); Regulus.Remote.Notifier<IB> Property1 {get;} } } "; var tree = CSharpSyntaxTree.ParseText(source); Compilation compilation = tree.Compilation(); var symbols = new SerializableExtractor(compilation).Symbols; var cSymbols = new[] { compilation.GetTypeByMetadataName("NS1.C2"), compilation.GetTypeByMetadataName("NS1.C1") }; var count = cSymbols.Except(symbols).Count(); NUnit.Framework.Assert.AreEqual(0, count); }
public async Task SerializableExtractor3Test() { var source = @" namespace NS1 { public class CReturn { public CReturn Field1; } public class CUseless { public CArg1 Field1; } public enum ENUM1 { ITEM1, } public struct CArg3 { public ENUM1 Field2; public string Field1; } public struct CArg2 { public CArg2 Field3; public ENUM1 Field2; public string Field1; } public class CArg1 { public CArg2 Field1; } public interface IB { event System.Action<float , CArg1,CArg3[][]> Event1; Regulus.Remote.Property<string> Property1 {get;} } public interface IA { Regulus.Remote.Value<CReturn> Method(CArg1 a1,int a2,System.Guid id); Regulus.Remote.Notifier<IB> Property1 {get;} } } "; var tree = CSharpSyntaxTree.ParseText(source); Compilation compilation = tree.Compilation(); var symbols = new SerializableExtractor(compilation).Symbols.Select(s => s.ToDisplayString()); var cSymbols = new[] { "NS1.CReturn", "NS1.CArg1", "NS1.CArg2", "NS1.CArg3", "NS1.CArg3[]", "NS1.CArg3[][]", "int", "string", "System.Guid", "float", "NS1.ENUM1", }; var count = symbols.Except(cSymbols).Count(); NUnit.Framework.Assert.AreEqual(0, count); }