diff --git a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs index 0f7673cc6..b08a43650 100644 --- a/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs +++ b/src/MagicOnion.Client.Unity/Assets/Scripts/MagicOnion/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs @@ -9,7 +9,7 @@ namespace MagicOnion { - internal class MarshallingAsyncStreamReader : IAsyncStreamReader, IDisposable + public class MarshallingAsyncStreamReader : IAsyncStreamReader, IDisposable { readonly IAsyncStreamReader inner; readonly MessagePackSerializerOptions options; @@ -41,7 +41,7 @@ public void Dispose() } } - internal class MarshallingClientStreamWriter : IClientStreamWriter + public class MarshallingClientStreamWriter : IClientStreamWriter { readonly IClientStreamWriter inner; readonly MessagePackSerializerOptions options; diff --git a/src/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs b/src/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs index 0f7673cc6..b08a43650 100644 --- a/src/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs +++ b/src/MagicOnion.Client/MarshallingAsyncStreamReaderWriter.cs @@ -9,7 +9,7 @@ namespace MagicOnion { - internal class MarshallingAsyncStreamReader : IAsyncStreamReader, IDisposable + public class MarshallingAsyncStreamReader : IAsyncStreamReader, IDisposable { readonly IAsyncStreamReader inner; readonly MessagePackSerializerOptions options; @@ -41,7 +41,7 @@ public void Dispose() } } - internal class MarshallingClientStreamWriter : IClientStreamWriter + public class MarshallingClientStreamWriter : IClientStreamWriter { readonly IClientStreamWriter inner; readonly MessagePackSerializerOptions options; diff --git a/tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs b/tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs new file mode 100644 index 000000000..a6ab84396 --- /dev/null +++ b/tests/MagicOnion.Generator.Tests/GenerateRawStreamingTest.cs @@ -0,0 +1,56 @@ +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using FluentAssertions; +using Microsoft.CodeAnalysis; +using Xunit; +using Xunit.Abstractions; + +namespace MagicOnion.Generator.Tests +{ + public class GenerateRawStreamingTest + { + private readonly ITestOutputHelper _testOutputHelper; + + public GenerateRawStreamingTest(ITestOutputHelper testOutputHelper) + { + _testOutputHelper = testOutputHelper; + } + + [Fact] + public async Task StreamingResult() + { + using var tempWorkspace = TemporaryProjectWorkarea.Create(); + tempWorkspace.AddFileToProject("IMyService.cs", @" +using System; +using MessagePack; +using MagicOnion; +using System.Threading.Tasks; + +namespace TempProject +{ + public interface IMyService : IService + { + Task> ClientStreamingAsync(); + Task> ServerStreamingAsync(); + Task> DuplexStreamingAsync(); + } +} + "); + + var compiler = new MagicOnionCompiler(_testOutputHelper.WriteLine, CancellationToken.None); + await compiler.GenerateFileAsync( + tempWorkspace.CsProjectPath, + Path.Combine(tempWorkspace.OutputDirectory, "Generated.cs"), + true, + "TempProject.Generated", + "", + "MessagePack.Formatters" + ); + + var compilation = tempWorkspace.GetOutputCompilation().Compilation; + compilation.GetDiagnostics().Where(x => x.Severity == DiagnosticSeverity.Error).Should().BeEmpty(); + } + } +} \ No newline at end of file diff --git a/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj b/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj index 011091fe3..26cba7379 100644 --- a/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj +++ b/tests/MagicOnion.Generator.Tests/MagicOnion.Generator.Tests.csproj @@ -16,6 +16,7 @@ + diff --git a/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs b/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs index 39f3be703..83bbb09da 100644 --- a/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs +++ b/tests/MagicOnion.Generator.Tests/TemporaryProjectWorkarea.cs @@ -73,17 +73,24 @@ public OutputCompilation GetOutputCompilation() Directory.EnumerateFiles(ProjectDirectory, "*.cs", SearchOption.AllDirectories) .Concat(Directory.EnumerateFiles(OutputDirectory, "*.cs", SearchOption.AllDirectories)) .Select(x => CSharpSyntaxTree.ParseText(File.ReadAllText(x), CSharpParseOptions.Default, x))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll"))) - .AddReferences(MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll"))) - .AddReferences(MetadataReference.CreateFromFile(typeof(object).Assembly.Location)) - //.AddReferences(MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location)) - //.AddReferences(MetadataReference.CreateFromFile(typeof(IMessagePackFormatter<>).Assembly.Location)) + .AddReferences( + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Private.CoreLib.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.Extensions.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Collections.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Linq.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Console.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Runtime.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "System.Memory.dll")), + MetadataReference.CreateFromFile(Path.Combine(refAsmDir, "netstandard.dll")), + MetadataReference.CreateFromFile(typeof(object).Assembly.Location), + + MetadataReference.CreateFromFile(typeof(Grpc.Core.AsyncUnaryCall<>).Assembly.Location), // Grpc.Core.Api + MetadataReference.CreateFromFile(typeof(MagicOnion.Client.MagicOnionClient).Assembly.Location), // MagicOnion.Client + MetadataReference.CreateFromFile(typeof(MagicOnion.MagicOnionMarshallers).Assembly.Location), // MagicOnion.Shared + MetadataReference.CreateFromFile(typeof(MagicOnion.IService<>).Assembly.Location), // MagicOnion.Abstractions + MetadataReference.CreateFromFile(typeof(MessagePack.IFormatterResolver).Assembly.Location), // MessagePack + MetadataReference.CreateFromFile(typeof(MessagePack.MessagePackObjectAttribute).Assembly.Location) // MessagePack.Annotations + ) .WithOptions(new CSharpCompilationOptions(OutputKind.DynamicallyLinkedLibrary)); return new OutputCompilation(compilation);