From 071697c6396a1f318f739497d87aa05ed34c1740 Mon Sep 17 00:00:00 2001 From: Adam Gritt Date: Tue, 31 Mar 2020 14:41:20 -0500 Subject: [PATCH 1/3] Added a unit test to show namespace overlap build failure --- Refit.Tests/NamespaceOverlapApi.cs | 34 +++++++++++++++++++++++++++++ Refit.Tests/RefitStubs.Net46.cs | 35 ++++++++++++++++++++++++++++++ Refit.Tests/RefitStubs.NetCore2.cs | 35 ++++++++++++++++++++++++++++++ Refit.Tests/RefitStubs.NetCore3.cs | 35 ++++++++++++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 Refit.Tests/NamespaceOverlapApi.cs diff --git a/Refit.Tests/NamespaceOverlapApi.cs b/Refit.Tests/NamespaceOverlapApi.cs new file mode 100644 index 000000000..e09fc2ae6 --- /dev/null +++ b/Refit.Tests/NamespaceOverlapApi.cs @@ -0,0 +1,34 @@ +using System; +using System.Threading.Tasks; +using Common.Helper; +using Refit.Tests.Common; +// InterfaceStubGenerator looks for this +using Refit; + +namespace Refit.Tests +{ + [SomeHelper] + public interface INamespaceOverlapApi + { + [Get("/")] + Task SomeRequest(); + } + + public static class NamespaceOverlapApi + { + public static INamespaceOverlapApi Create() + { + return RestService.For("http://somewhere.com"); + } + } +} + +namespace Common.Helper +{ + public class SomeHelperAttribute : Attribute { } +} + +namespace Refit.Tests.Common +{ + public class SomeOtherType { } +} diff --git a/Refit.Tests/RefitStubs.Net46.cs b/Refit.Tests/RefitStubs.Net46.cs index f40d928c6..c33a0b7d7 100644 --- a/Refit.Tests/RefitStubs.Net46.cs +++ b/Refit.Tests/RefitStubs.Net46.cs @@ -1824,6 +1824,41 @@ Task INamespaceCollisionApi.SomeRequest() } } +namespace Refit.Tests +{ + using System.Threading.Tasks; + using Common.Helper; + using Refit.Common; + using Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedINamespaceOverlapApi : INamespaceOverlapApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedINamespaceOverlapApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task INamespaceOverlapApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + namespace Refit.Tests { using System.Text; diff --git a/Refit.Tests/RefitStubs.NetCore2.cs b/Refit.Tests/RefitStubs.NetCore2.cs index f40d928c6..5ca72616b 100644 --- a/Refit.Tests/RefitStubs.NetCore2.cs +++ b/Refit.Tests/RefitStubs.NetCore2.cs @@ -1824,6 +1824,41 @@ Task INamespaceCollisionApi.SomeRequest() } } +namespace Refit.Tests +{ + using System.Threading.Tasks; + using Common.Helper; + using Refit.Tests.Common; + using Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedINamespaceOverlapApi : INamespaceOverlapApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedINamespaceOverlapApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task INamespaceOverlapApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + namespace Refit.Tests { using System.Text; diff --git a/Refit.Tests/RefitStubs.NetCore3.cs b/Refit.Tests/RefitStubs.NetCore3.cs index f40d928c6..5ca72616b 100644 --- a/Refit.Tests/RefitStubs.NetCore3.cs +++ b/Refit.Tests/RefitStubs.NetCore3.cs @@ -1824,6 +1824,41 @@ Task INamespaceCollisionApi.SomeRequest() } } +namespace Refit.Tests +{ + using System.Threading.Tasks; + using Common.Helper; + using Refit.Tests.Common; + using Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedINamespaceOverlapApi : INamespaceOverlapApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedINamespaceOverlapApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task INamespaceOverlapApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + namespace Refit.Tests { using System.Text; From 9441c6c543080a3404635cf3c882bf9e92ae83e6 Mon Sep 17 00:00:00 2001 From: Oleksandr Liakhevych Date: Wed, 1 Apr 2020 22:11:06 +0300 Subject: [PATCH 2/3] Qualify namespaces in usings globally --- .../InterfaceStubGenerator.cs | 18 +- Refit.Tests/InterfaceStubGenerator.cs | 20 +- Refit.Tests/ReducedUsingInsideNamespaceApi.cs | 18 + Refit.Tests/RefitStubs.Net46.cs | 677 +++++++++++------- Refit.Tests/RefitStubs.NetCore2.cs | 677 +++++++++++------- Refit.Tests/RefitStubs.NetCore3.cs | 677 +++++++++++------- 6 files changed, 1253 insertions(+), 834 deletions(-) create mode 100644 Refit.Tests/ReducedUsingInsideNamespaceApi.cs diff --git a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs index c4480d7b5..3525be357 100644 --- a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs @@ -119,9 +119,25 @@ public ClassTemplateInfo GenerateClassInfoForInterface(InterfaceDeclarationSynta var rootNode = interfaceTree.Parent; while (rootNode.Parent != null) rootNode = rootNode.Parent; - var usings = rootNode.DescendantNodes() + var usingsInsideNamespace = ns?.DescendantNodes() .OfType() .Select(x => $"{x.Alias} {x.StaticKeyword} {x.Name}".TrimStart()) + ?? Enumerable.Empty(); + + var usingsOutsideNamespace = rootNode.DescendantNodes(x => !x.IsKind(SyntaxKind.NamespaceDeclaration)) + .OfType() + .Select(x => + { + // Globally qualify namespace name to avoid conflicts when put inside namespace. + var name = x.Name.ToString(); + var globallyQualifiedName = name.StartsWith("global::") + ? name + : "global::" + name; + + return $"{x.Alias} {x.StaticKeyword} {globallyQualifiedName}".TrimStart(); + }); + + var usings = usingsInsideNamespace.Concat(usingsOutsideNamespace) .Distinct() .Where(x => x != "System" && x != "System.Net.Http" && x != "System.Collections.Generic" && x != "System.Linq") .Select(x => new UsingDeclaration { Item = x }); diff --git a/Refit.Tests/InterfaceStubGenerator.cs b/Refit.Tests/InterfaceStubGenerator.cs index 613b0149e..b36f2b14c 100644 --- a/Refit.Tests/InterfaceStubGenerator.cs +++ b/Refit.Tests/InterfaceStubGenerator.cs @@ -202,7 +202,7 @@ public void RetainsAliasesInUsings() var input = syntaxTree.GetRoot().DescendantNodes().OfType().ToList(); var result = fixture.GenerateTemplateInfoForInterfaceList(input); var classTemplate = result.ClassList[0]; - var usingList = classTemplate.UsingList.Select(x => x.Item).ToList(); + var usingList = classTemplate.UsingList.Select(x => x.Item.Replace("global::", "")).ToList(); Assert.Contains("SomeType = CollisionA.SomeType", usingList); Assert.Contains("CollisionB", usingList); } @@ -218,7 +218,7 @@ public void AvoidsTypeCollisions(string interfaceName, string usingCsv) var result = fixture.GenerateTemplateInfoForInterfaceList(input); var classItem = result.ClassList.Single(c => c.InterfaceName == interfaceName); - var usingList = classItem.UsingList.Select(x => x.Item); + var usingList = classItem.UsingList.Select(x => x.Item.Replace("global::", "")); var expected = usingCsv.Split(','); Assert.Equal(usingList, expected); @@ -229,6 +229,22 @@ IEnumerable getInterfaces(string fileName) } } + [Fact] + public void HandlesReducedUsingsInsideNamespace() + { + var fixture = new InterfaceStubGenerator(); + + var syntaxTree = CSharpSyntaxTree.ParseText(File.ReadAllText(IntegrationTestHelper.GetPath("ReducedUsingInsideNamespaceApi.cs"))); + var input = syntaxTree.GetRoot().DescendantNodes().OfType().ToList(); + var result = fixture.GenerateTemplateInfoForInterfaceList(input); + var classTemplate = result.ClassList[0]; + var usingList = classTemplate.UsingList.Select(x => x.Item).ToList(); + + Assert.Contains("ModelNamespace", usingList); + Assert.Contains("global::System.Threading.Tasks", usingList); + Assert.Contains("global::Refit", usingList); + } + [Fact] public void GenerateInterfaceStubsWithoutNamespaceSmokeTest() { diff --git a/Refit.Tests/ReducedUsingInsideNamespaceApi.cs b/Refit.Tests/ReducedUsingInsideNamespaceApi.cs new file mode 100644 index 000000000..0a5ba8fc1 --- /dev/null +++ b/Refit.Tests/ReducedUsingInsideNamespaceApi.cs @@ -0,0 +1,18 @@ +using System.Threading.Tasks; +using Refit; // InterfaceStubGenerator looks for this + +namespace Refit.Tests +{ + using ModelNamespace; + + public interface IReducedUsingInsideNamespaceApi + { + [Get("/")] + Task SomeRequest(); + } +} + +namespace Refit.Tests.ModelNamespace +{ + public class SomeType { } +} diff --git a/Refit.Tests/RefitStubs.Net46.cs b/Refit.Tests/RefitStubs.Net46.cs index c33a0b7d7..af3d8fb43 100644 --- a/Refit.Tests/RefitStubs.Net46.cs +++ b/Refit.Tests/RefitStubs.Net46.cs @@ -32,15 +32,17 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -102,16 +104,20 @@ Task IAmARefitInterfaceButNobodyUsesMe.ReservedWordsForParameterNames(int @int, namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -149,9 +155,9 @@ Task IAmHalfRefit.Get() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -207,9 +213,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -241,9 +247,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -283,9 +289,9 @@ Task IAmInterfaceD.Test() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -341,9 +347,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -375,16 +381,20 @@ Task IAmInterfaceD.Test() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -528,16 +538,20 @@ Task IApiBindPathToObject.PostFooBarStreamPart(PathBoundObj namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -569,16 +583,20 @@ Task IApiWithDecimal.GetWithDecimal(decimal value) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -626,15 +644,17 @@ Task IBodylessApi.Head() namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -701,16 +721,20 @@ Task IBoringCrudApi.Delete(TKey key) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -742,8 +766,8 @@ Task IBrokenWebApi.PostAValue(string derp) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -775,8 +799,8 @@ public AutoGeneratedICustomNullableReferenceService(HttpClient client, IRequestB namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -808,8 +832,8 @@ public AutoGeneratedICustomNullableValueService(HttpClient client, IRequestBuild namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -843,9 +867,10 @@ Task ICustomReferenceAndValueParametersService.Get(CustomReferenceType? referenc namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -925,9 +950,10 @@ Task IDataCrudApi.Delete(long key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -999,9 +1025,10 @@ Task IDataCrudApi.Delete(int key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1076,9 +1103,10 @@ Task IDataCrudApi.Delete(long key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1145,8 +1173,8 @@ Task IDataCrudApi.Delete(TKey key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1180,8 +1208,8 @@ Task IGenericNullableReferenceParameterService.Get(System.Collections.Generic.Li namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1213,8 +1241,8 @@ public AutoGeneratedIGenericNullableReferenceService(HttpClient client, IRequest namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1246,8 +1274,8 @@ public AutoGeneratedIGenericNullableValueService(HttpClient client, IRequestBuil namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1281,8 +1309,8 @@ Task IGenericNullableWithNullableReferenceParameterService.Get(System.Collection namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1314,8 +1342,8 @@ public AutoGeneratedIGenericNullableWithNullableReferenceService(HttpClient clie namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1347,8 +1375,8 @@ public AutoGeneratedIGenericNullableWithNullableValueService(HttpClient client, namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1380,8 +1408,8 @@ Task IGenericWithNullableReferenceParameterService.Get(System.Collections.Generi namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1413,8 +1441,8 @@ public AutoGeneratedIGenericWithNullableValueService(HttpClient client, IRequest namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1446,10 +1474,14 @@ public AutoGeneratedIGenericWithResultService(HttpClient client, IRequestBuilder namespace Refit.Tests { - using System.Text; - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1577,16 +1609,20 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1654,16 +1690,20 @@ Task IHttpBinApi.GetQuery1(TParam pa namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1703,18 +1743,21 @@ Task> IHttpContentApi.PostFileUploadWithMetadata(HttpCo namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Net.Http.Headers; - using System.Text; - using System.Text.Json; - using System.Threading.Tasks; - using Newtonsoft.Json; - using RichardSzalay.MockHttp; - using Refit; - using Refit.Buffers; - using Xunit; - using JsonSerializer = Newtonsoft.Json.JsonSerializer; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Net; + using global::System.Net.Http; + using global::System.Net.Http.Headers; + using global::System.Text; + using global::System.Text.Json; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::RichardSzalay.MockHttp; + using global::Refit; + using global::Refit.Buffers; + using global::Xunit; + using JsonSerializer = global::Newtonsoft.Json.JsonSerializer; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1746,12 +1789,15 @@ Task ResponseTests.IMyAliasService.GetTestObject() namespace Refit.Tests { - using System.Net; - using System.Text; - using System.Threading.Tasks; - using RichardSzalay.MockHttp; - using Refit; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.Net; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::RichardSzalay.MockHttp; + using global::Refit; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1791,10 +1837,10 @@ Task AuthenticatedClientHandlerTests.IMyAuthenticatedService.GetAuthenti namespace Refit.Tests { - using System.Threading.Tasks; - using SomeType = CollisionA.SomeType; - using CollisionB; - using Refit; + using global::System.Threading.Tasks; + using SomeType = global::CollisionA.SomeType; + using global::CollisionB; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1826,10 +1872,11 @@ Task INamespaceCollisionApi.SomeRequest() namespace Refit.Tests { - using System.Threading.Tasks; - using Common.Helper; - using Refit.Common; - using Refit; + using global::System; + using global::System.Threading.Tasks; + using global::Common.Helper; + using global::Refit.Tests.Common; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1861,10 +1908,14 @@ Task INamespaceOverlapApi.SomeRequest() namespace Refit.Tests { - using System.Text; - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1952,15 +2003,17 @@ Task TestNested.INestedGitHubApi.NothingToSeeHere() namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2000,16 +2053,20 @@ Task INonGenericInterfaceWithGenericMethod.PostMessage(T message, U par namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2041,8 +2098,8 @@ Task INpmJs.GetCongruence() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2074,8 +2131,8 @@ public AutoGeneratedINullableReferenceService(HttpClient client, IRequestBuilder namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2107,8 +2164,42 @@ public AutoGeneratedINullableValueService(HttpClient client, IRequestBuilder req namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using ModelNamespace; + using global::System.Threading.Tasks; + using global::Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIReducedUsingInsideNamespaceApi : IReducedUsingInsideNamespaceApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIReducedUsingInsideNamespaceApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IReducedUsingInsideNamespaceApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + +namespace Refit.Tests +{ + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2142,16 +2233,20 @@ Task IReferenceAndValueParametersService.Get(string? reference, int? value) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2183,16 +2278,20 @@ Task IRefitInterfaceWithStaticMethod.Get() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2256,16 +2355,20 @@ Task IRequestBin.PostGeneric(T param) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reflection; - using System.Threading.Tasks; - using Xunit; - using Refit; - using System.Threading; - using Newtonsoft.Json; - using System.Text; - using System.Net.Http.Headers; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reflection; + using global::System.Threading.Tasks; + using global::Xunit; + using global::Refit; + using global::System.Threading; + using global::Newtonsoft.Json; + using global::System.Text; + using global::System.Net.Http.Headers; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2393,9 +2496,11 @@ Task IRunscopeApi.UploadHttpContent(HttpContent content) namespace AutoGeneratedIServiceWithoutNamespace { - using System.Text; - using System.Threading.Tasks; - using Refit; + using global::System; + using global::System.Collections.Generic; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2435,16 +2540,20 @@ Task IServiceWithoutNamespace.PostRoot() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2484,16 +2593,20 @@ Task> IStreamApi.GetRemoteFileWithMetadata(string filename) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2525,9 +2638,9 @@ Task ITrimTrailingForwardSlashApi.Get() namespace Refit.Tests { - using System.Threading.Tasks; - using CollisionA; - using Refit; + using global::System.Threading.Tasks; + using global::CollisionA; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2559,9 +2672,9 @@ Task ITypeCollisionApiA.SomeARequest() namespace Refit.Tests { - using System.Threading.Tasks; - using CollisionB; - using Refit; + using global::System.Threading.Tasks; + using global::CollisionB; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2593,11 +2706,14 @@ Task ITypeCollisionApiB.SomeBRequest() namespace Refit.Tests { - using System.Net; - using System.Threading.Tasks; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.Net; + using global::System.Net.Http; + using global::System.Threading.Tasks; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2681,11 +2797,14 @@ Task IUseOverloadedGenericMethods.Get [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2725,16 +2844,20 @@ Task IUseOverloadedMethods.Get(int httpstatuscode) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] diff --git a/Refit.Tests/RefitStubs.NetCore2.cs b/Refit.Tests/RefitStubs.NetCore2.cs index 5ca72616b..af3d8fb43 100644 --- a/Refit.Tests/RefitStubs.NetCore2.cs +++ b/Refit.Tests/RefitStubs.NetCore2.cs @@ -32,15 +32,17 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -102,16 +104,20 @@ Task IAmARefitInterfaceButNobodyUsesMe.ReservedWordsForParameterNames(int @int, namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -149,9 +155,9 @@ Task IAmHalfRefit.Get() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -207,9 +213,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -241,9 +247,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -283,9 +289,9 @@ Task IAmInterfaceD.Test() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -341,9 +347,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -375,16 +381,20 @@ Task IAmInterfaceD.Test() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -528,16 +538,20 @@ Task IApiBindPathToObject.PostFooBarStreamPart(PathBoundObj namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -569,16 +583,20 @@ Task IApiWithDecimal.GetWithDecimal(decimal value) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -626,15 +644,17 @@ Task IBodylessApi.Head() namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -701,16 +721,20 @@ Task IBoringCrudApi.Delete(TKey key) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -742,8 +766,8 @@ Task IBrokenWebApi.PostAValue(string derp) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -775,8 +799,8 @@ public AutoGeneratedICustomNullableReferenceService(HttpClient client, IRequestB namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -808,8 +832,8 @@ public AutoGeneratedICustomNullableValueService(HttpClient client, IRequestBuild namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -843,9 +867,10 @@ Task ICustomReferenceAndValueParametersService.Get(CustomReferenceType? referenc namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -925,9 +950,10 @@ Task IDataCrudApi.Delete(long key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -999,9 +1025,10 @@ Task IDataCrudApi.Delete(int key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1076,9 +1103,10 @@ Task IDataCrudApi.Delete(long key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1145,8 +1173,8 @@ Task IDataCrudApi.Delete(TKey key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1180,8 +1208,8 @@ Task IGenericNullableReferenceParameterService.Get(System.Collections.Generic.Li namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1213,8 +1241,8 @@ public AutoGeneratedIGenericNullableReferenceService(HttpClient client, IRequest namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1246,8 +1274,8 @@ public AutoGeneratedIGenericNullableValueService(HttpClient client, IRequestBuil namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1281,8 +1309,8 @@ Task IGenericNullableWithNullableReferenceParameterService.Get(System.Collection namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1314,8 +1342,8 @@ public AutoGeneratedIGenericNullableWithNullableReferenceService(HttpClient clie namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1347,8 +1375,8 @@ public AutoGeneratedIGenericNullableWithNullableValueService(HttpClient client, namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1380,8 +1408,8 @@ Task IGenericWithNullableReferenceParameterService.Get(System.Collections.Generi namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1413,8 +1441,8 @@ public AutoGeneratedIGenericWithNullableValueService(HttpClient client, IRequest namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1446,10 +1474,14 @@ public AutoGeneratedIGenericWithResultService(HttpClient client, IRequestBuilder namespace Refit.Tests { - using System.Text; - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1577,16 +1609,20 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1654,16 +1690,20 @@ Task IHttpBinApi.GetQuery1(TParam pa namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1703,18 +1743,21 @@ Task> IHttpContentApi.PostFileUploadWithMetadata(HttpCo namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Net.Http.Headers; - using System.Text; - using System.Text.Json; - using System.Threading.Tasks; - using Newtonsoft.Json; - using RichardSzalay.MockHttp; - using Refit; - using Refit.Buffers; - using Xunit; - using JsonSerializer = Newtonsoft.Json.JsonSerializer; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Net; + using global::System.Net.Http; + using global::System.Net.Http.Headers; + using global::System.Text; + using global::System.Text.Json; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::RichardSzalay.MockHttp; + using global::Refit; + using global::Refit.Buffers; + using global::Xunit; + using JsonSerializer = global::Newtonsoft.Json.JsonSerializer; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1746,12 +1789,15 @@ Task ResponseTests.IMyAliasService.GetTestObject() namespace Refit.Tests { - using System.Net; - using System.Text; - using System.Threading.Tasks; - using RichardSzalay.MockHttp; - using Refit; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.Net; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::RichardSzalay.MockHttp; + using global::Refit; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1791,10 +1837,10 @@ Task AuthenticatedClientHandlerTests.IMyAuthenticatedService.GetAuthenti namespace Refit.Tests { - using System.Threading.Tasks; - using SomeType = CollisionA.SomeType; - using CollisionB; - using Refit; + using global::System.Threading.Tasks; + using SomeType = global::CollisionA.SomeType; + using global::CollisionB; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1826,10 +1872,11 @@ Task INamespaceCollisionApi.SomeRequest() namespace Refit.Tests { - using System.Threading.Tasks; - using Common.Helper; - using Refit.Tests.Common; - using Refit; + using global::System; + using global::System.Threading.Tasks; + using global::Common.Helper; + using global::Refit.Tests.Common; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1861,10 +1908,14 @@ Task INamespaceOverlapApi.SomeRequest() namespace Refit.Tests { - using System.Text; - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1952,15 +2003,17 @@ Task TestNested.INestedGitHubApi.NothingToSeeHere() namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2000,16 +2053,20 @@ Task INonGenericInterfaceWithGenericMethod.PostMessage(T message, U par namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2041,8 +2098,8 @@ Task INpmJs.GetCongruence() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2074,8 +2131,8 @@ public AutoGeneratedINullableReferenceService(HttpClient client, IRequestBuilder namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2107,8 +2164,42 @@ public AutoGeneratedINullableValueService(HttpClient client, IRequestBuilder req namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using ModelNamespace; + using global::System.Threading.Tasks; + using global::Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIReducedUsingInsideNamespaceApi : IReducedUsingInsideNamespaceApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIReducedUsingInsideNamespaceApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IReducedUsingInsideNamespaceApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + +namespace Refit.Tests +{ + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2142,16 +2233,20 @@ Task IReferenceAndValueParametersService.Get(string? reference, int? value) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2183,16 +2278,20 @@ Task IRefitInterfaceWithStaticMethod.Get() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2256,16 +2355,20 @@ Task IRequestBin.PostGeneric(T param) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reflection; - using System.Threading.Tasks; - using Xunit; - using Refit; - using System.Threading; - using Newtonsoft.Json; - using System.Text; - using System.Net.Http.Headers; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reflection; + using global::System.Threading.Tasks; + using global::Xunit; + using global::Refit; + using global::System.Threading; + using global::Newtonsoft.Json; + using global::System.Text; + using global::System.Net.Http.Headers; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2393,9 +2496,11 @@ Task IRunscopeApi.UploadHttpContent(HttpContent content) namespace AutoGeneratedIServiceWithoutNamespace { - using System.Text; - using System.Threading.Tasks; - using Refit; + using global::System; + using global::System.Collections.Generic; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2435,16 +2540,20 @@ Task IServiceWithoutNamespace.PostRoot() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2484,16 +2593,20 @@ Task> IStreamApi.GetRemoteFileWithMetadata(string filename) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2525,9 +2638,9 @@ Task ITrimTrailingForwardSlashApi.Get() namespace Refit.Tests { - using System.Threading.Tasks; - using CollisionA; - using Refit; + using global::System.Threading.Tasks; + using global::CollisionA; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2559,9 +2672,9 @@ Task ITypeCollisionApiA.SomeARequest() namespace Refit.Tests { - using System.Threading.Tasks; - using CollisionB; - using Refit; + using global::System.Threading.Tasks; + using global::CollisionB; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2593,11 +2706,14 @@ Task ITypeCollisionApiB.SomeBRequest() namespace Refit.Tests { - using System.Net; - using System.Threading.Tasks; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.Net; + using global::System.Net.Http; + using global::System.Threading.Tasks; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2681,11 +2797,14 @@ Task IUseOverloadedGenericMethods.Get [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2725,16 +2844,20 @@ Task IUseOverloadedMethods.Get(int httpstatuscode) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] diff --git a/Refit.Tests/RefitStubs.NetCore3.cs b/Refit.Tests/RefitStubs.NetCore3.cs index 5ca72616b..af3d8fb43 100644 --- a/Refit.Tests/RefitStubs.NetCore3.cs +++ b/Refit.Tests/RefitStubs.NetCore3.cs @@ -32,15 +32,17 @@ sealed class PreserveAttribute : Attribute #pragma warning disable CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -102,16 +104,20 @@ Task IAmARefitInterfaceButNobodyUsesMe.ReservedWordsForParameterNames(int @int, namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -149,9 +155,9 @@ Task IAmHalfRefit.Get() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -207,9 +213,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -241,9 +247,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -283,9 +289,9 @@ Task IAmInterfaceD.Test() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -341,9 +347,9 @@ Task IAmInterfaceA.Ping() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -375,16 +381,20 @@ Task IAmInterfaceD.Test() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -528,16 +538,20 @@ Task IApiBindPathToObject.PostFooBarStreamPart(PathBoundObj namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -569,16 +583,20 @@ Task IApiWithDecimal.GetWithDecimal(decimal value) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -626,15 +644,17 @@ Task IBodylessApi.Head() namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -701,16 +721,20 @@ Task IBoringCrudApi.Delete(TKey key) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -742,8 +766,8 @@ Task IBrokenWebApi.PostAValue(string derp) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -775,8 +799,8 @@ public AutoGeneratedICustomNullableReferenceService(HttpClient client, IRequestB namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -808,8 +832,8 @@ public AutoGeneratedICustomNullableValueService(HttpClient client, IRequestBuild namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -843,9 +867,10 @@ Task ICustomReferenceAndValueParametersService.Get(CustomReferenceType? referenc namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -925,9 +950,10 @@ Task IDataCrudApi.Delete(long key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -999,9 +1025,10 @@ Task IDataCrudApi.Delete(int key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1076,9 +1103,10 @@ Task IDataCrudApi.Delete(long key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System.Collections.Generic; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1145,8 +1173,8 @@ Task IDataCrudApi.Delete(TKey key) namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1180,8 +1208,8 @@ Task IGenericNullableReferenceParameterService.Get(System.Collections.Generic.Li namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1213,8 +1241,8 @@ public AutoGeneratedIGenericNullableReferenceService(HttpClient client, IRequest namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1246,8 +1274,8 @@ public AutoGeneratedIGenericNullableValueService(HttpClient client, IRequestBuil namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1281,8 +1309,8 @@ Task IGenericNullableWithNullableReferenceParameterService.Get(System.Collection namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1314,8 +1342,8 @@ public AutoGeneratedIGenericNullableWithNullableReferenceService(HttpClient clie namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1347,8 +1375,8 @@ public AutoGeneratedIGenericNullableWithNullableValueService(HttpClient client, namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1380,8 +1408,8 @@ Task IGenericWithNullableReferenceParameterService.Get(System.Collections.Generi namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1413,8 +1441,8 @@ public AutoGeneratedIGenericWithNullableValueService(HttpClient client, IRequest namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1446,10 +1474,14 @@ public AutoGeneratedIGenericWithResultService(HttpClient client, IRequestBuilder namespace Refit.Tests { - using System.Text; - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1577,16 +1609,20 @@ Task> IGitHubApi.CreateUserWithMetadata(User user) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1654,16 +1690,20 @@ Task IHttpBinApi.GetQuery1(TParam pa namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1703,18 +1743,21 @@ Task> IHttpContentApi.PostFileUploadWithMetadata(HttpCo namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Net.Http.Headers; - using System.Text; - using System.Text.Json; - using System.Threading.Tasks; - using Newtonsoft.Json; - using RichardSzalay.MockHttp; - using Refit; - using Refit.Buffers; - using Xunit; - using JsonSerializer = Newtonsoft.Json.JsonSerializer; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Net; + using global::System.Net.Http; + using global::System.Net.Http.Headers; + using global::System.Text; + using global::System.Text.Json; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::RichardSzalay.MockHttp; + using global::Refit; + using global::Refit.Buffers; + using global::Xunit; + using JsonSerializer = global::Newtonsoft.Json.JsonSerializer; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1746,12 +1789,15 @@ Task ResponseTests.IMyAliasService.GetTestObject() namespace Refit.Tests { - using System.Net; - using System.Text; - using System.Threading.Tasks; - using RichardSzalay.MockHttp; - using Refit; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.Net; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::RichardSzalay.MockHttp; + using global::Refit; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1791,10 +1837,10 @@ Task AuthenticatedClientHandlerTests.IMyAuthenticatedService.GetAuthenti namespace Refit.Tests { - using System.Threading.Tasks; - using SomeType = CollisionA.SomeType; - using CollisionB; - using Refit; + using global::System.Threading.Tasks; + using SomeType = global::CollisionA.SomeType; + using global::CollisionB; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1826,10 +1872,11 @@ Task INamespaceCollisionApi.SomeRequest() namespace Refit.Tests { - using System.Threading.Tasks; - using Common.Helper; - using Refit.Tests.Common; - using Refit; + using global::System; + using global::System.Threading.Tasks; + using global::Common.Helper; + using global::Refit.Tests.Common; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1861,10 +1908,14 @@ Task INamespaceOverlapApi.SomeRequest() namespace Refit.Tests { - using System.Text; - using System.Threading.Tasks; - using Refit; - using static System.Math; + using global::System; + using global::System.Collections.Generic; + using global::System.Linq; + using global::System.Net.Http; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; + using static global::System.Math; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -1952,15 +2003,17 @@ Task TestNested.INestedGitHubApi.NothingToSeeHere() namespace Refit.Tests { - using System.IO; - using System.Threading.Tasks; - using Microsoft.CodeAnalysis; - using Microsoft.CodeAnalysis.CSharp; - using Microsoft.CodeAnalysis.CSharp.Syntax; - using Refit; - using Refit.Generator; - using Xunit; - using Task = System.Threading.Tasks.Task; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Threading.Tasks; + using global::Microsoft.CodeAnalysis; + using global::Microsoft.CodeAnalysis.CSharp; + using global::Microsoft.CodeAnalysis.CSharp.Syntax; + using global::Refit; + using global::Refit.Generator; + using global::Xunit; + using Task = global::System.Threading.Tasks.Task; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2000,16 +2053,20 @@ Task INonGenericInterfaceWithGenericMethod.PostMessage(T message, U par namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2041,8 +2098,8 @@ Task INpmJs.GetCongruence() namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2074,8 +2131,8 @@ public AutoGeneratedINullableReferenceService(HttpClient client, IRequestBuilder namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2107,8 +2164,42 @@ public AutoGeneratedINullableValueService(HttpClient client, IRequestBuilder req namespace Refit.Tests { - using System.Threading.Tasks; - using Refit; + using ModelNamespace; + using global::System.Threading.Tasks; + using global::Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedIReducedUsingInsideNamespaceApi : IReducedUsingInsideNamespaceApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedIReducedUsingInsideNamespaceApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task IReducedUsingInsideNamespaceApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + +namespace Refit.Tests +{ + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2142,16 +2233,20 @@ Task IReferenceAndValueParametersService.Get(string? reference, int? value) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2183,16 +2278,20 @@ Task IRefitInterfaceWithStaticMethod.Get() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2256,16 +2355,20 @@ Task IRequestBin.PostGeneric(T param) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reflection; - using System.Threading.Tasks; - using Xunit; - using Refit; - using System.Threading; - using Newtonsoft.Json; - using System.Text; - using System.Net.Http.Headers; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reflection; + using global::System.Threading.Tasks; + using global::Xunit; + using global::Refit; + using global::System.Threading; + using global::Newtonsoft.Json; + using global::System.Text; + using global::System.Net.Http.Headers; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2393,9 +2496,11 @@ Task IRunscopeApi.UploadHttpContent(HttpContent content) namespace AutoGeneratedIServiceWithoutNamespace { - using System.Text; - using System.Threading.Tasks; - using Refit; + using global::System; + using global::System.Collections.Generic; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2435,16 +2540,20 @@ Task IServiceWithoutNamespace.PostRoot() namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2484,16 +2593,20 @@ Task> IStreamApi.GetRemoteFileWithMetadata(string filename) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2525,9 +2638,9 @@ Task ITrimTrailingForwardSlashApi.Get() namespace Refit.Tests { - using System.Threading.Tasks; - using CollisionA; - using Refit; + using global::System.Threading.Tasks; + using global::CollisionA; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2559,9 +2672,9 @@ Task ITypeCollisionApiA.SomeARequest() namespace Refit.Tests { - using System.Threading.Tasks; - using CollisionB; - using Refit; + using global::System.Threading.Tasks; + using global::CollisionB; + using global::Refit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2593,11 +2706,14 @@ Task ITypeCollisionApiB.SomeBRequest() namespace Refit.Tests { - using System.Net; - using System.Threading.Tasks; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.Net; + using global::System.Net.Http; + using global::System.Threading.Tasks; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2681,11 +2797,14 @@ Task IUseOverloadedGenericMethods.Get [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] @@ -2725,16 +2844,20 @@ Task IUseOverloadedMethods.Get(int httpstatuscode) namespace Refit.Tests { - using System.IO; - using System.Net; - using System.Reactive.Linq; - using System.Reflection; - using System.Text; - using System.Threading.Tasks; - using Newtonsoft.Json; - using Refit; - using RichardSzalay.MockHttp; - using Xunit; + using global::System; + using global::System.Collections.Generic; + using global::System.IO; + using global::System.Linq; + using global::System.Net; + using global::System.Net.Http; + using global::System.Reactive.Linq; + using global::System.Reflection; + using global::System.Text; + using global::System.Threading.Tasks; + using global::Newtonsoft.Json; + using global::Refit; + using global::RichardSzalay.MockHttp; + using global::Xunit; /// [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] From a9ee988f5b61948f8a953b404f58d2ead35ab973 Mon Sep 17 00:00:00 2001 From: Oleksandr Liakhevych Date: Wed, 1 Apr 2020 22:44:30 +0300 Subject: [PATCH 3/3] Add test file with global aliases --- .../InterfaceStubGenerator.cs | 2 +- Refit.Tests/NamespaceWithGlobalAliasApi.cs | 18 ++++++++++ Refit.Tests/RefitStubs.Net46.cs | 34 +++++++++++++++++++ Refit.Tests/RefitStubs.NetCore2.cs | 34 +++++++++++++++++++ Refit.Tests/RefitStubs.NetCore3.cs | 34 +++++++++++++++++++ 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 Refit.Tests/NamespaceWithGlobalAliasApi.cs diff --git a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs index 3525be357..a7f29c3c3 100644 --- a/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs +++ b/InterfaceStubGenerator.Core/InterfaceStubGenerator.cs @@ -130,7 +130,7 @@ public ClassTemplateInfo GenerateClassInfoForInterface(InterfaceDeclarationSynta { // Globally qualify namespace name to avoid conflicts when put inside namespace. var name = x.Name.ToString(); - var globallyQualifiedName = name.StartsWith("global::") + var globallyQualifiedName = name.Contains("::") ? name : "global::" + name; diff --git a/Refit.Tests/NamespaceWithGlobalAliasApi.cs b/Refit.Tests/NamespaceWithGlobalAliasApi.cs new file mode 100644 index 000000000..235a6d4a8 --- /dev/null +++ b/Refit.Tests/NamespaceWithGlobalAliasApi.cs @@ -0,0 +1,18 @@ +using global::System.Threading.Tasks; +using Refit; // InterfaceStubGenerator looks for this + +namespace Refit.Tests +{ + using global::Refit.Tests.SomeNamespace; + + public interface NamespaceWithGlobalAliasApi + { + [Get("/")] + Task SomeRequest(); + } +} + +namespace Refit.Tests.SomeNamespace +{ + public class SomeType { } +} diff --git a/Refit.Tests/RefitStubs.Net46.cs b/Refit.Tests/RefitStubs.Net46.cs index af3d8fb43..98320e1d0 100644 --- a/Refit.Tests/RefitStubs.Net46.cs +++ b/Refit.Tests/RefitStubs.Net46.cs @@ -2887,5 +2887,39 @@ Task IValidApi.Get() } } +namespace Refit.Tests +{ + using global::Refit.Tests.SomeNamespace; + using global::System.Threading.Tasks; + using global::Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedNamespaceWithGlobalAliasApi : NamespaceWithGlobalAliasApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedNamespaceWithGlobalAliasApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task NamespaceWithGlobalAliasApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. #pragma warning restore CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. diff --git a/Refit.Tests/RefitStubs.NetCore2.cs b/Refit.Tests/RefitStubs.NetCore2.cs index af3d8fb43..98320e1d0 100644 --- a/Refit.Tests/RefitStubs.NetCore2.cs +++ b/Refit.Tests/RefitStubs.NetCore2.cs @@ -2887,5 +2887,39 @@ Task IValidApi.Get() } } +namespace Refit.Tests +{ + using global::Refit.Tests.SomeNamespace; + using global::System.Threading.Tasks; + using global::Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedNamespaceWithGlobalAliasApi : NamespaceWithGlobalAliasApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedNamespaceWithGlobalAliasApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task NamespaceWithGlobalAliasApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. #pragma warning restore CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. diff --git a/Refit.Tests/RefitStubs.NetCore3.cs b/Refit.Tests/RefitStubs.NetCore3.cs index af3d8fb43..98320e1d0 100644 --- a/Refit.Tests/RefitStubs.NetCore3.cs +++ b/Refit.Tests/RefitStubs.NetCore3.cs @@ -2887,5 +2887,39 @@ Task IValidApi.Get() } } +namespace Refit.Tests +{ + using global::Refit.Tests.SomeNamespace; + using global::System.Threading.Tasks; + using global::Refit; + + /// + [global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] + [global::System.Diagnostics.DebuggerNonUserCode] + [Preserve] + [global::System.Reflection.Obfuscation(Exclude=true)] + partial class AutoGeneratedNamespaceWithGlobalAliasApi : NamespaceWithGlobalAliasApi + { + /// + public HttpClient Client { get; protected set; } + readonly IRequestBuilder requestBuilder; + + /// + public AutoGeneratedNamespaceWithGlobalAliasApi(HttpClient client, IRequestBuilder requestBuilder) + { + Client = client; + this.requestBuilder = requestBuilder; + } + + /// + Task NamespaceWithGlobalAliasApi.SomeRequest() + { + var arguments = new object[] { }; + var func = requestBuilder.BuildRestResultFuncForMethod("SomeRequest", new Type[] { }); + return (Task)func(Client, arguments); + } + } +} + #pragma warning restore CS8632 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. #pragma warning restore CS8669 // The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.