From 2a598ecc147bff89839a1399a4fc4292bd444956 Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Thu, 6 Jun 2024 18:25:37 +0200 Subject: [PATCH] fix some more tests, default to WCF uri's since we use same baseline for .NET and .NET FRAMEWORK --- .../Framework/ClientCodeGenerationDispatcher.cs | 2 +- .../Framework/ClientCodeGenerationOptions.cs | 10 +++++++--- .../Framework/EndpointRoutePattern.cs | 8 +++++--- src/OpenRiaServices.Tools/Test/TestHelper.cs | 2 ++ src/Test/AspNetCoreWebsite/Program.cs | 2 +- 5 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationDispatcher.cs b/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationDispatcher.cs index 3d743a55..0c77a23f 100644 --- a/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationDispatcher.cs +++ b/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationDispatcher.cs @@ -85,7 +85,7 @@ internal string GenerateCode(ClientCodeGenerationOptions options, SharedCodeServ #if NET // If the server assembly has a DomainServiceEndpointRoutePatternAttribute, we use it to set the default EndpointRoutePattern Assembly linkedServerAssembly = AssemblyUtilities.LoadAssembly(parameters.ServerAssemblies.First() + ".dll", loggingService); - if (linkedServerAssembly.GetCustomAttribute() is { } routeAttribute) + if (linkedServerAssembly?.GetCustomAttribute() is { } routeAttribute) { options.DefaultEndpointRoutePattern = (EndpointRoutePattern)(int)routeAttribute.EndpointRoutePattern; } diff --git a/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationOptions.cs b/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationOptions.cs index 46d081f4..78754428 100644 --- a/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationOptions.cs +++ b/src/OpenRiaServices.Tools/Framework/ClientCodeGenerationOptions.cs @@ -92,11 +92,15 @@ public string Language /// public bool UseFullTypeNames { get; set; } -#if NET + /// - /// determining how default Uri's for accessing DomainServices are generated. + /// See "Server.EndpointRoutePattern" determining how default Uri's for accessing DomainServices are generated. /// - public EndpointRoutePattern DefaultEndpointRoutePattern { get; set; } = EndpointRoutePattern.FullName; + public EndpointRoutePattern DefaultEndpointRoutePattern { get; set; } +#if NET + = EndpointRoutePattern.FullName; +#else + = EndpointRoutePattern.WCF; #endif } diff --git a/src/OpenRiaServices.Tools/Framework/EndpointRoutePattern.cs b/src/OpenRiaServices.Tools/Framework/EndpointRoutePattern.cs index 47565af0..7b2fd491 100644 --- a/src/OpenRiaServices.Tools/Framework/EndpointRoutePattern.cs +++ b/src/OpenRiaServices.Tools/Framework/EndpointRoutePattern.cs @@ -1,6 +1,9 @@ -namespace OpenRiaServices.Tools +#if NETFRAMEWORK +#pragma warning disable 1574 // Server.EndpointRoutePattern is not available +#endif + +namespace OpenRiaServices.Tools { -#if NET /// /// IMPORTANT: THIS IS AN EXACT copy of where all values are identical. /// We don't use the server version in the options because we don't want to load in the Server assembly until a bit later @@ -23,5 +26,4 @@ public enum EndpointRoutePattern /// WCF } -#endif } diff --git a/src/OpenRiaServices.Tools/Test/TestHelper.cs b/src/OpenRiaServices.Tools/Test/TestHelper.cs index 0ee941e5..6ba91fdc 100644 --- a/src/OpenRiaServices.Tools/Test/TestHelper.cs +++ b/src/OpenRiaServices.Tools/Test/TestHelper.cs @@ -750,6 +750,8 @@ internal static string ValidateLanguageCodeGen(CodeGenValidationOptions codeGenO ClientRootNamespace = codeGenOptions.RootNamespace, ClientProjectPath = "MockProject.proj", IsApplicationContextGenerationEnabled = codeGenOptions.GenerateApplicationContexts, + // Since we use the same baseline for NETFRAMEWORK and NET we need to set the same endpoint pattern for both + DefaultEndpointRoutePattern = EndpointRoutePattern.WCF, UseFullTypeNames = codeGenOptions.UseFullTypeNames, ClientProjectTargetPlatform = TargetPlatform.Silverlight }; diff --git a/src/Test/AspNetCoreWebsite/Program.cs b/src/Test/AspNetCoreWebsite/Program.cs index 60f6a52d..2d3f08a8 100644 --- a/src/Test/AspNetCoreWebsite/Program.cs +++ b/src/Test/AspNetCoreWebsite/Program.cs @@ -12,7 +12,7 @@ using RootNamespace.TestNamespace; using TestDomainServices.Testing; -//[assembly: DomainServiceEndpointRoutePattern(EndpointRoutePattern.FullName)] +[assembly: DomainServiceEndpointRoutePattern(EndpointRoutePattern.FullName)] var builder = WebApplication.CreateBuilder(args); builder.Services.AddOpenRiaServices();