diff --git a/src/AnalyzerUser.targets b/src/AnalyzerUser.targets index 28260de2f..ee6d04fc0 100644 --- a/src/AnalyzerUser.targets +++ b/src/AnalyzerUser.targets @@ -1,6 +1,6 @@ - true + true diff --git a/src/StreamJsonRpc/StreamJsonRpc.csproj b/src/StreamJsonRpc/StreamJsonRpc.csproj index 9ade22ca9..d6c7463e3 100644 --- a/src/StreamJsonRpc/StreamJsonRpc.csproj +++ b/src/StreamJsonRpc/StreamJsonRpc.csproj @@ -11,6 +11,7 @@ $(NoWarn);SYSLIB0050 true + false diff --git a/test/StreamJsonRpc.Analyzer.Tests/ProxyGeneratorTests.cs b/test/StreamJsonRpc.Analyzer.Tests/ProxyGeneratorTests.cs index 51a2a0a48..bbf86ce30 100644 --- a/test/StreamJsonRpc.Analyzer.Tests/ProxyGeneratorTests.cs +++ b/test/StreamJsonRpc.Analyzer.Tests/ProxyGeneratorTests.cs @@ -587,6 +587,14 @@ void Foo(System.IO.Stream s) """); } + /// + /// Tracks the scenario of unknown types being passed to the Attach method. + /// + /// + /// Although the type is unknown, we still want to redirect the API call to + /// NativeAOT safe alternatives (that will fail at runtime if the proxy hasn't been generated). + /// Projects are required to opt-in to this behavior, so we consider it safe. + /// [Fact] public async Task Interceptor_UnknownTypes_Generic() { @@ -602,6 +610,14 @@ void Foo(System.IO.Stream s) where T: class """); } + /// + /// Tracks the scenario of unknown types being passed to the Attach method. + /// + /// + /// Although the type is unknown, we still want to redirect the API call to + /// NativeAOT safe alternatives (that will fail at runtime if the proxy hasn't been generated). + /// Projects are required to opt-in to this behavior, so we consider it safe. + /// [Fact] public async Task Interceptor_UnknownTypes_NonGeneric() { diff --git a/test/StreamJsonRpc.Tests/ArchitectureTests.cs b/test/StreamJsonRpc.Tests/ArchitectureTests.cs new file mode 100644 index 000000000..1e88cf3f6 --- /dev/null +++ b/test/StreamJsonRpc.Tests/ArchitectureTests.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +public class ArchitectureTests +{ + /// + /// Verifies that no interceptors are present in the StreamJsonRpc assembly. + /// + /// + /// Our own library intentionally has NativeAOT safe and unsafe APIs, and the unsafe ones should + /// not be rewritten to call the safe APIs, since that can cause runtime exceptions when + /// our callers are not prepared for NativeAOT safety's restrictions. + /// + [Fact] + public void NoInterceptors() + { + Assert.DoesNotContain(typeof(JsonRpc).Assembly.GetTypes(), t => t.Namespace == "StreamJsonRpc.Generated"); + } +}