From 172316c7c005d9151bfc6161fe6ef8c527c4067b Mon Sep 17 00:00:00 2001 From: Daniel Svensson Date: Wed, 12 Jun 2024 15:21:16 +0200 Subject: [PATCH] Obsolete and remove most usages of TargetPlatform (#511) --- .../Data/EnableClientAccessAttribute.cs | 3 +++ .../Framework/Data/OutputCacheAttribute.cs | 5 +++- .../ClientCodeGenerationOptionsBinder.cs | 5 +--- .../Program.cs | 4 +--- .../Framework/CreateOpenRiaClientFilesTask.cs | 24 +------------------ .../Framework/TargetPlatform.cs | 5 +++- src/OpenRiaServices.Tools/Test/TestHelper.cs | 3 +-- 7 files changed, 15 insertions(+), 34 deletions(-) diff --git a/src/OpenRiaServices.Server/Framework/Data/EnableClientAccessAttribute.cs b/src/OpenRiaServices.Server/Framework/Data/EnableClientAccessAttribute.cs index 0aeb21dee..9d5b6323f 100644 --- a/src/OpenRiaServices.Server/Framework/Data/EnableClientAccessAttribute.cs +++ b/src/OpenRiaServices.Server/Framework/Data/EnableClientAccessAttribute.cs @@ -24,6 +24,9 @@ public EnableClientAccessAttribute() { } /// Gets or sets a value indicating whether the /// may only be accessed using a secure endpoint. /// +#if NET + [Obsolete("RequiresSecureEndpoint is not enforced by AspNetCore Hosting, please enforce it using standard AspNetCore practices instead https://learn.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?")] +#endif public bool RequiresSecureEndpoint { get; set; } #endregion diff --git a/src/OpenRiaServices.Server/Framework/Data/OutputCacheAttribute.cs b/src/OpenRiaServices.Server/Framework/Data/OutputCacheAttribute.cs index a313c4207..f8b09ed49 100644 --- a/src/OpenRiaServices.Server/Framework/Data/OutputCacheAttribute.cs +++ b/src/OpenRiaServices.Server/Framework/Data/OutputCacheAttribute.cs @@ -8,6 +8,9 @@ namespace OpenRiaServices.Server [AttributeUsage( AttributeTargets.Field | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = true)] +#if NET + [Obsolete("OutputCacheAttribute is not applied by AspNetCore hosting, please se Readme of how caching can be achived.\nThe attribute will probably be removed in future releases")] +#endif public sealed class OutputCacheAttribute : Attribute { /// @@ -94,4 +97,4 @@ public OutputCacheAttribute(string cacheProfile) this.CacheProfile = cacheProfile; } } -} \ No newline at end of file +} diff --git a/src/OpenRiaServices.Tools.CodeGenTask/ClientCodeGenerationOptionsBinder.cs b/src/OpenRiaServices.Tools.CodeGenTask/ClientCodeGenerationOptionsBinder.cs index 7b79b532d..5219d3b0a 100644 --- a/src/OpenRiaServices.Tools.CodeGenTask/ClientCodeGenerationOptionsBinder.cs +++ b/src/OpenRiaServices.Tools.CodeGenTask/ClientCodeGenerationOptionsBinder.cs @@ -15,13 +15,12 @@ public class ClientCodeGenerationOptionsBinder : BinderBase _clientRootNamespace; private readonly Option _serverRootNamespace; private readonly Option _isApplicationContextGenerationEnabled; - private readonly Option _clientProjectTargetPlatform; private readonly Option _useFullTypeNames; /// /// Constructor that sets all arguments /// - public ClientCodeGenerationOptionsBinder(Option language, Option clientFrameworkPath, Option serverProjectPath, Option clientProjectPath, Option clientRootNamespace, Option serverRootNamespace, Option isApplicationContextGenerationEnabled, Option clientProjectTargetPlatform, Option useFullTypeNames) + public ClientCodeGenerationOptionsBinder(Option language, Option clientFrameworkPath, Option serverProjectPath, Option clientProjectPath, Option clientRootNamespace, Option serverRootNamespace, Option isApplicationContextGenerationEnabled, Option useFullTypeNames) { _language = language; _clientFrameworkPath = clientFrameworkPath; @@ -30,7 +29,6 @@ public ClientCodeGenerationOptionsBinder(Option language, Option _clientRootNamespace = clientRootNamespace; _serverRootNamespace = serverRootNamespace; _isApplicationContextGenerationEnabled = isApplicationContextGenerationEnabled; - _clientProjectTargetPlatform = clientProjectTargetPlatform; _useFullTypeNames = useFullTypeNames; } @@ -48,7 +46,6 @@ protected override ClientCodeGenerationOptions GetBoundValue(BindingContext bind ClientRootNamespace = bindingContext.ParseResult.GetValueForOption(_clientRootNamespace), ServerRootNamespace = bindingContext.ParseResult.GetValueForOption(_serverRootNamespace), IsApplicationContextGenerationEnabled = bindingContext.ParseResult.GetValueForOption(_isApplicationContextGenerationEnabled), - ClientProjectTargetPlatform = bindingContext.ParseResult.GetValueForOption(_clientProjectTargetPlatform), UseFullTypeNames = bindingContext.ParseResult.GetValueForOption(_useFullTypeNames), }; } diff --git a/src/OpenRiaServices.Tools.CodeGenTask/Program.cs b/src/OpenRiaServices.Tools.CodeGenTask/Program.cs index f0c3a04d8..ed0042e83 100644 --- a/src/OpenRiaServices.Tools.CodeGenTask/Program.cs +++ b/src/OpenRiaServices.Tools.CodeGenTask/Program.cs @@ -24,7 +24,6 @@ static int Main(string[] args) var clientRootNamespaceOption = new Option("--clientRootNamespace"); var serverRootNamespaceOption = new Option("--serverRootNamespace"); var isApplicationContextGenerationEnabledOption = new Option("--isApplicationContextGenerationEnabled"); - var clientProjectTargetPlatformsOption = new Option("--clientProjectTargetPlatform"); var useFullTypeNamesOption = new Option("--useFullTypeNames"); var sharedSourceFilesOption = new Option>("--sharedSourceFiles") { AllowMultipleArgumentsPerToken = true }; @@ -51,7 +50,6 @@ static int Main(string[] args) clientRootNamespaceOption, serverRootNamespaceOption, isApplicationContextGenerationEnabledOption, - clientProjectTargetPlatformsOption, useFullTypeNamesOption, sharedSourceFilesOption, symbolSearchPathsOption, @@ -69,7 +67,7 @@ static int Main(string[] args) => success = RunCodeGenForNet6(clientCodeGenerationOptionValue, sharedCodeServiceParametersValue, codeGeneratorName, generatedFileName, pipeName), new ClientCodeGenerationOptionsBinder( languageOption, clientFrameworkOption, serverProjectPathOption, clientProjectPathOption, clientRootNamespaceOption, serverRootNamespaceOption, - isApplicationContextGenerationEnabledOption, clientProjectTargetPlatformsOption, useFullTypeNamesOption), + isApplicationContextGenerationEnabledOption, useFullTypeNamesOption), new SharedCodeServiceParametersBinder(sharedSourceFilesOption, symbolSearchPathsOption, serverAssembliesOption, clientAssembliesOption, clientAssemblyPathsNormalizedOption), codeGeneratorName, generatedFileName, diff --git a/src/OpenRiaServices.Tools/Framework/CreateOpenRiaClientFilesTask.cs b/src/OpenRiaServices.Tools/Framework/CreateOpenRiaClientFilesTask.cs index cac92d12c..5a3bb9203 100644 --- a/src/OpenRiaServices.Tools/Framework/CreateOpenRiaClientFilesTask.cs +++ b/src/OpenRiaServices.Tools/Framework/CreateOpenRiaClientFilesTask.cs @@ -384,26 +384,6 @@ internal bool UseFullTypeNamesAsBool } } - internal TargetPlatform ClientTargetPlatform - { - get - { - if (string.IsNullOrEmpty(ClientFrameworkPath)) - return TargetPlatform.Unknown; - - if (ClientFrameworkPath.IndexOf("Silverlight", StringComparison.InvariantCultureIgnoreCase) != -1) - return TargetPlatform.Silverlight; - if (ClientFrameworkPath.IndexOf(".NETPortable", StringComparison.InvariantCultureIgnoreCase) != -1) - return TargetPlatform.Portable; - if (ClientFrameworkPath.IndexOf(".NETFramework", StringComparison.InvariantCultureIgnoreCase) != -1) - return TargetPlatform.Desktop; - if (ClientFrameworkPath.IndexOf(".NETCore", StringComparison.InvariantCultureIgnoreCase) != -1) - return TargetPlatform.Win8; - - return TargetPlatform.Unknown; - } - } - /// /// Gets a value indicating whether the server project file has been specified /// and exists on disk. @@ -705,8 +685,7 @@ internal void GenerateClientProxies() ClientProjectPath = this.ClientProjectPath, ServerProjectPath = this.ServerProjectPath, IsApplicationContextGenerationEnabled = this.IsClientApplicationAsBool, - UseFullTypeNames = this.UseFullTypeNamesAsBool, - ClientProjectTargetPlatform = this.ClientTargetPlatform, + UseFullTypeNames = this.UseFullTypeNamesAsBool }; // Compose the parameters we will pass to the other AppDomain to create the SharedCodeService @@ -1591,7 +1570,6 @@ static void AddParameter(List list, string parameter, string value) AddParameter(arguments, "--clientRootNamespace", options.ClientRootNamespace); AddParameter(arguments, "--serverRootNamespace", options.ServerRootNamespace); AddParameter(arguments, "--isApplicationContextGenerationEnabled", options.IsApplicationContextGenerationEnabled.ToString()); - AddParameter(arguments, "--clientProjectTargetPlatform", options.ClientProjectTargetPlatform.ToString()); AddParameter(arguments, "--useFullTypeNames", options.UseFullTypeNames.ToString()); //Arguments for SharedCodeServiceParameters diff --git a/src/OpenRiaServices.Tools/Framework/TargetPlatform.cs b/src/OpenRiaServices.Tools/Framework/TargetPlatform.cs index 31f3acdd0..297640540 100644 --- a/src/OpenRiaServices.Tools/Framework/TargetPlatform.cs +++ b/src/OpenRiaServices.Tools/Framework/TargetPlatform.cs @@ -1,8 +1,11 @@ -namespace OpenRiaServices.Tools +using System; + +namespace OpenRiaServices.Tools { /// /// Target platform /// + [Obsolete("This enum is not used and will be removed in a future version")] public enum TargetPlatform { /// diff --git a/src/OpenRiaServices.Tools/Test/TestHelper.cs b/src/OpenRiaServices.Tools/Test/TestHelper.cs index 77c337d33..c62b353f6 100644 --- a/src/OpenRiaServices.Tools/Test/TestHelper.cs +++ b/src/OpenRiaServices.Tools/Test/TestHelper.cs @@ -750,8 +750,7 @@ internal static string ValidateLanguageCodeGen(CodeGenValidationOptions codeGenO ClientRootNamespace = codeGenOptions.RootNamespace, ClientProjectPath = "MockProject.proj", IsApplicationContextGenerationEnabled = codeGenOptions.GenerateApplicationContexts, - UseFullTypeNames = codeGenOptions.UseFullTypeNames, - ClientProjectTargetPlatform = TargetPlatform.Silverlight + UseFullTypeNames = codeGenOptions.UseFullTypeNames }; MockCodeGenerationHost host = TestHelper.CreateMockCodeGenerationHost(codeGenOptions.Logger, codeGenOptions.SharedCodeService);