diff --git a/src/Common/XSharpConstants.cs b/src/Common/XSharpConstants.cs index b46d736c90..0eb2d42d4a 100644 --- a/src/Common/XSharpConstants.cs +++ b/src/Common/XSharpConstants.cs @@ -63,6 +63,7 @@ internal static class XSharpConstants internal const string DialectPropertiesPage = "2652FCA6-1C45-4D25-942D-4C5D5EDE9539"; internal const string LanguagePropertiesPage = "0DFC7EF7-3F1A-4ACB-AFD8-DF56AEF9467A"; internal const string BuildEventsPropertiesPage = "49306259-9119-466E-8780-486CFBE2597D"; + internal const string GlobalUsingsPropertiesPage = "5BF73771-1E08-40D9-8A48-EC06552C138B"; internal const string DebuggerWorkareasPane = "B5B41BAB-62F9-48E0-80D8-947F2F14D1C5"; internal const string DebuggerSettingsPane = "F7ED7826-137A-462D-8757-37A02BEF4DCF"; internal const string DebuggerGlobalsPane = "53B7968B-251B-44E0-BDF5-A225BF0DBC77"; @@ -128,6 +129,7 @@ internal static class XSharpProjectFileConstants internal const string Fox1 = nameof(Fox1); internal const string Fox2 = nameof(Fox2); internal const string GetTargetPath = nameof(GetTargetPath); + internal const string ImplicitUsings = nameof(ImplicitUsings); internal const string IncludePaths = nameof(IncludePaths); internal const string IncludeSearchPaths = nameof(IncludeSearchPaths); internal const string InitLocals = nameof(InitLocals); diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/CommandLineBuilderExtensions.cs b/src/Compiler/src/Compiler/XSharpBuildTask/CommandLineBuilderExtensions.cs index 30d25f57a6..96f96dba29 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/CommandLineBuilderExtensions.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/CommandLineBuilderExtensions.cs @@ -174,7 +174,7 @@ internal void AppendSwitchWithSplitting(string switchName, string parameter, str } #if NOTUSED /// - /// Returns true if the parameter is empty in spirits, + /// Returns true if the parameter is empty in spirits, /// even if it contains the separators and white space only /// Split on the characters provided. /// @@ -199,7 +199,7 @@ internal static bool IsParameterEmpty(string parameter, params char[] splitOn) /// /// /embed[resource]:<filename>[,<name>[,Private]] /// /link[resource]:<filename>[,<name>[,Private]] - /// + /// /// Where the last flag--Private--is either present or not present /// depending on whether the ITaskItem has a Private="True" attribute. /// @@ -241,7 +241,7 @@ internal virtual void AppendSwitchIfNotNull // A boolean flag. bool flagSet = false; - flagSet = Utilities.TryConvertItemMetadataToBool(parameter, metadataNames[i]); + flagSet = parameter.GetBool(metadataNames[i]); if (flagSet) { diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/GenerateGlobalUsings.cs b/src/Compiler/src/Compiler/XSharpBuildTask/GenerateGlobalUsings.cs new file mode 100644 index 0000000000..69e32adc5c --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/GenerateGlobalUsings.cs @@ -0,0 +1,120 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +namespace XSharp.Build +{ + + public sealed class GenerateGlobalUsings : Task + { + [Required] + public ITaskItem[] Usings { get; set; } + + [Output] + public string[] Lines { get; set; } + + public override bool Execute() + { + if (Usings.Length == 0) + { + Lines = Array.Empty(); + return true; + } + + var usings = Usings.Select(UsingInfo.Read) + .OrderBy(static k => k, UsingInfoComparer.Instance) + .Distinct(UsingInfoComparer.Instance); + + var lines = new string[Usings.Length + 1]; + lines[0] = "// "; + + var index = 1; + var lineBuilder = new StringBuilder(); + foreach (var @using in usings) + { + lineBuilder.Clear(); + lineBuilder.Append("global using "); + + if (@using.Static) + { + lineBuilder.Append("static "); + } + + if (!string.IsNullOrEmpty(@using.Alias)) + { + lineBuilder.Append(@using.Alias) + .Append(" = "); + } + + lineBuilder.Append(@using.Namespace); + + lines[index++] = lineBuilder.ToString(); + } + + Lines = lines; + return true; + } + + private readonly struct UsingInfo + { + public static UsingInfo Read(ITaskItem taskItem) + { + return new UsingInfo( + taskItem.ItemSpec, + taskItem.GetBool("Static"), + taskItem.GetMetadata("Alias")); + } + + private UsingInfo(string @namespace, bool @static, string alias) + { + Namespace = @namespace; + Static = @static; + Alias = alias; + } + + public string Namespace { get; } + public bool Static { get; } + public string Alias { get; } + } + + private sealed class UsingInfoComparer : IComparer, IEqualityComparer + { + public static readonly UsingInfoComparer Instance = new(); + + public int Compare(UsingInfo x, UsingInfo y) + { + var @static = x.Static.CompareTo(y.Static); + if (@static != 0) + { + return @static; + } + + var alias = x.Alias.CompareTo(y.Alias); + if (alias != 0) + { + return alias; + } + + return StringComparer.Ordinal.Compare(x.Namespace, y.Namespace); + } + + public bool Equals(UsingInfo x, UsingInfo y) + { + return Compare(x, y) == 0; + } + + public int GetHashCode(UsingInfo obj) + { + return StringComparer.Ordinal.GetHashCode(obj.Namespace); + } + } + } +} diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AdditionalFiles.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AdditionalFiles.xaml deleted file mode 100644 index 1e4c7e0de6..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AdditionalFiles.xaml +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AnalyzerReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AnalyzerReference.xaml deleted file mode 100644 index f2cfeaf1b3..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AnalyzerReference.xaml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ApplicationPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ApplicationPropertyPage.xaml deleted file mode 100644 index 9cad396b8b..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ApplicationPropertyPage.xaml +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (not (has-evaluated-value "Application" "TargetMultipleFrameworks" true)) - - - - - - - - - - - - - (has-evaluated-value "Application" "TargetMultipleFrameworks" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (and - (has-net-core-app-version-or-greater "5.0") - (not (has-evaluated-value "Application" "TargetMultipleFrameworks" true))) - - - - - - - - - - - - - (and - (has-net-core-app-version-or-greater "5.0") - (and - (ne (unevaluated "Application" "TargetPlatformIdentifier") "") - (not (has-evaluated-value "Application" "TargetMultipleFrameworks" true)))) - - - - - - - - - - - - - - - (and - (has-net-core-app-version-or-greater "5.0") - (and - (ne (unevaluated "Application" "TargetPlatformIdentifier") "") - (not (has-evaluated-value "Application" "TargetMultipleFrameworks" true)))) - - - - - - - - - - - - - (and - (has-evaluated-value "Application" "OutputType" "WinExe") - (has-net-core-app-version-or-greater "3.0")) - - - - - - - - - - - (and - (has-evaluated-value "Application" "OutputType" "WinExe") - (has-net-core-app-version-or-greater "3.0")) - - - - - - - - - - (has-net-framework) - - - - - - - - - - (not (has-evaluated-value "Application" "OutputType" "Library")) - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Application" "ResourceSpecificationKind" "IconAndManifest") - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Application" "NuGetAudit" true) - - - - - - - - - - (has-evaluated-value "Application" "NuGetAudit" true) - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AssemblyReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AssemblyReference.xaml deleted file mode 100644 index 706e65e439..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/AssemblyReference.xaml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/BuildPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/BuildPropertyPage.xaml deleted file mode 100644 index d3d39a736f..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/BuildPropertyPage.xaml +++ /dev/null @@ -1,608 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-csharp-lang-version-or-greater "8.0") - - - - - - - - - - - - - - - - - - (and - (has-net-framework) - (has-evaluated-value "Build" "PlatformTarget" "Any CPU") - (or - (has-evaluated-value "Application" "OutputType" "Exe") - (has-evaluated-value "Application" "OutputType" "WinExe") - (has-evaluated-value "Application" "OutputType" "AppContainerExe"))) - - - - - - - - - - - - - (and - (has-net-framework) - (has-evaluated-value "Build" "PlatformTarget" "Any CPU") - (or - (has-evaluated-value "Application" "OutputType" "Exe") - (has-evaluated-value "Application" "OutputType" "WinExe") - (has-evaluated-value "Application" "OutputType" "AppContainerExe") - ) - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (and - (has-project-capability "NativeAOT") - (has-evaluated-value "Application" "OutputType" "Library")) - - - - - - - - - - - - - (and - (has-project-capability "NativeAOT") - (has-evaluated-value "Application" "OutputType" "Library")) - - - - - - - - - - - - - - - - (has-evaluated-value "Build" "WarningLevelOverridden" false) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Build" "TreatWarningsAsErrors" false) - - - - - - - - - - - (has-evaluated-value "Build" "TreatWarningsAsErrors" true) - - - - - - - - - - - - - - - - - - - - - - - - (has-project-capability "GenerateDocumentationFile") - - - - - - - - - - - - (has-evaluated-value "Build" "GenerateDocumentationFile" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (and - (has-project-capability "NativeAOT") - (not (has-evaluated-value "Application" "OutputType" "Library"))) - - - - - - - - - - - - - (and - (has-project-capability "NativeAOT") - (not (has-evaluated-value "Application" "OutputType" "Library"))) - - - - - - - - - - - - - - - (has-evaluated-value "Build" "SignAssembly" true) - - - - - - - - - - - (has-evaluated-value "Build" "SignAssembly" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/COMReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/COMReference.xaml deleted file mode 100644 index a1f3248e6c..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/COMReference.xaml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/CodeAnalysisPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/CodeAnalysisPropertyPage.xaml deleted file mode 100644 index a4657aced6..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/CodeAnalysisPropertyPage.xaml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Compile.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Compile.BrowseObject.xaml deleted file mode 100644 index 01b698f167..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Compile.BrowseObject.xaml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Compile.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Compile.xaml deleted file mode 100644 index 8c9b8a22a4..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Compile.xaml +++ /dev/null @@ -1,95 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ConfigurationGeneralPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ConfigurationGeneralPage.xaml deleted file mode 100644 index ac60bdf9ab..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ConfigurationGeneralPage.xaml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Content.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Content.BrowseObject.xaml deleted file mode 100644 index 1c8d652290..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Content.BrowseObject.xaml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Content.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Content.xaml deleted file mode 100644 index 632809e5ce..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Content.xaml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/DebugPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/DebugPropertyPage.xaml deleted file mode 100644 index 2904694712..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/DebugPropertyPage.xaml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - (has-project-capability "LaunchProfiles") - - - - - - - - - - - - (has-project-capability "LaunchProfiles") - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/DebuggerGeneral.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/DebuggerGeneral.xaml deleted file mode 100644 index 320a21c967..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/DebuggerGeneral.xaml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EditorConfigFiles.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EditorConfigFiles.BrowseObject.xaml deleted file mode 100644 index fd810a4ffa..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EditorConfigFiles.BrowseObject.xaml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EditorConfigFiles.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EditorConfigFiles.xaml deleted file mode 100644 index 3df3c6c6de..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EditorConfigFiles.xaml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EmbeddedResource.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EmbeddedResource.BrowseObject.xaml deleted file mode 100644 index 5723f49289..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EmbeddedResource.BrowseObject.xaml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EmbeddedResource.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EmbeddedResource.xaml deleted file mode 100644 index 32da5eb956..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/EmbeddedResource.xaml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ExecutableDebugPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ExecutableDebugPropertyPage.xaml deleted file mode 100644 index b1b2c62524..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ExecutableDebugPropertyPage.xaml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - Executable - - - AE27A6B0-E345-4288-96DF-5EAF394EE369 - - - 1173 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (ne (unevaluated "Executable" "StartArguments") "") - - - - - - - - - - - - (has-evaluated-value "Executable" "RemoteDebugEnabled" true) - - - - - - - - - (has-evaluated-value "Executable" "RemoteDebugEnabled" true) - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Folder.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Folder.xaml deleted file mode 100644 index 3a38f3adda..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Folder.xaml +++ /dev/null @@ -1,37 +0,0 @@ - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/FrameworkReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/FrameworkReference.xaml deleted file mode 100644 index 2bc3d241a4..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/FrameworkReference.xaml +++ /dev/null @@ -1,38 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/GeneralBrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/GeneralBrowseObject.xaml deleted file mode 100644 index 545d374077..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/GeneralBrowseObject.xaml +++ /dev/null @@ -1,476 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/GeneralConfiguredBrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/GeneralConfiguredBrowseObject.xaml deleted file mode 100644 index 3e7d8e944a..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/GeneralConfiguredBrowseObject.xaml +++ /dev/null @@ -1,262 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Microsoft.Managed.DesignTime.targets b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Microsoft.Managed.DesignTime.targets deleted file mode 100644 index 091c34c751..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Microsoft.Managed.DesignTime.targets +++ /dev/null @@ -1,626 +0,0 @@ - - - - - - - - false - false - false - - true - true - true - - - Exe;WinExe;Library - true - - - Pack - - - - - - - - - - - - - - 0 - - - TAB_ASSEMBLY_FRAMEWORK - - - - - - $(MSBuildThisFileDirectory) - - - - - - $(MSBuildThisFileDirectory)$(LangName) - - - $(MSBuildThisFileDirectory)zh-Hans - $(MSBuildThisFileDirectory)zh-Hant - - - $(MSBuildThisFileDirectory)$(LangName.Split('-')[0]) - - - $(ManagedXamlNeutralResourcesDirectory) - - - - $(ManagedXamlResourcesDirectory)\ - ProjectDebugger - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Project - - - - - File - - - - BrowseObject - - - - BrowseObject - - - - File - - - - BrowseObject - - - - File - - - - BrowseObject - - - - File;BrowseObject - - - - File - - - - File - - - - File - - - - BrowseObject - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - BrowseObject - - - - ConfiguredBrowseObject - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - Project - - - - - - - - Project;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - Project;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - Project;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - Project;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - Project;ProjectSubscriptionService;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - ProjectSubscriptionService;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - Project;ProjectSubscriptionService;BrowseObject - - - - ProjectSubscriptionService;BrowseObject - - - - - - - - - - - - - - <_GlobalJsonStartingDir Include="$(SolutionDir)" /> - <_PotentialContainingGlobalJsonDir Include="@(_GlobalJsonStartingDir->GetPathsOfAllDirectoriesAbove())" /> - - - - - - - false - - - - - - - - - - - - - - - - <_ProjectReferencesFromRAR2 Include="@(ReferencePath->WithMetadataValue('ReferenceSourceTarget', 'ProjectReference'))"> - %(ReferencePath.ProjectReferenceOriginalItemSpec) - - - <_ProjectReferencesWithoutOutputAssembly Include="@(ProjectReference->WithMetadataValue('ReferenceOutputAssembly', 'false'))"> - %(ProjectReference.Identity) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - CompileDesignTime - - $(CollectUpToDateCheckInputDesignTimeDependsOn);ResolveCodeAnalysisRuleSet - - - - - - - - - - - - - - CompileDesignTime - - - - - - - CompileDesignTime - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - <_CollectedCopyToOutputDirectoryItem Include="@(_ThisProjectItemsToCopyToOutputDirectory)"> - false - - - - - <_CollectedCopyToOutputDirectoryItem Include="$(TargetPath)"> - PreserveNewest - $([System.IO.Path]::GetFileName('$(TargetPath)')) - true - - - - - <_CollectedCopyToOutputDirectoryItem Include="@(_DebugSymbolsOutputPath->'%(FullPath)')" Condition="'$(_DebugSymbolsProduced)' == 'true' and '$(SkipCopyingSymbolsToOutputDirectory)' != 'true' and '$(CopyOutputSymbolsToOutputDirectory)' != 'false'"> - PreserveNewest - $([System.IO.Path]::GetFileName('%(Identity)')) - true - - - - - <_CollectedCopyToOutputDirectoryItem Include="@(ReferenceCopyLocalPaths->'%(Identity)')" Condition="'%(ReferenceCopyLocalPaths.ReferenceSourceTarget)' != 'ProjectReference' AND '%(ReferenceCopyLocalPaths.DestinationSubPath)' != ''"> - PreserveNewest - %(ReferenceCopyLocalPaths.DestinationSubPath) - true - - - <_CollectedCopyToOutputDirectoryItem Include="@(ReferenceCopyLocalPaths->'%(Identity)')" Condition="'%(ReferenceCopyLocalPaths.ReferenceSourceTarget)' != 'ProjectReference' AND '%(ReferenceCopyLocalPaths.DestinationSubPath)' == ''"> - PreserveNewest - $([System.IO.Path]::GetFileName('%(Identity)')) - true - - - - - <_CollectedCopyToOutputDirectoryItem Include="@(FinalDocFile->'%(FullPath)')" Condition="'$(_DocumentationFileProduced)' == 'true'"> - PreserveNewest - $([System.IO.Path]::GetFileName('%(Identity)')) - true - - - - - <_CollectedCopyToOutputDirectoryItem Include="@(IntermediateSatelliteAssembliesWithTargetPath->'$(TargetDir)%(Culture)\$(TargetName).resources.dll')" Condition="'@(IntermediateSatelliteAssembliesWithTargetPath)' != ''"> - PreserveNewest - %(IntermediateSatelliteAssembliesWithTargetPath.Culture)\$(TargetName).resources.dll - true - - - - - - \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/None.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/None.BrowseObject.xaml deleted file mode 100644 index ec027bfc4b..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/None.BrowseObject.xaml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/None.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/None.xaml deleted file mode 100644 index 1880be0dff..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/None.xaml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackagePropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackagePropertyPage.xaml deleted file mode 100644 index bf5cfd9dd1..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackagePropertyPage.xaml +++ /dev/null @@ -1,302 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Package" "PackAsTool" true) - - - - - - - - - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Package" "PackageLicenseKind" "Expression") - - - - - - - - - - - - - - - - - - - (has-evaluated-value "Package" "PackageLicenseKind" "Expression") - - - - - - - - - (has-evaluated-value "Package" "PackageLicenseKind" "File") - - - - - - - - - (not (has-evaluated-value "Package" "PackageLicenseKind" "None")) - - - - - - - - - - (has-evaluated-value "Package" "IncludeSymbols" true) - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackageReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackageReference.xaml deleted file mode 100644 index 186223611e..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackageReference.xaml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackageVersion.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackageVersion.xaml deleted file mode 100644 index 197e22c4d4..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/PackageVersion.xaml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectDebugPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectDebugPropertyPage.xaml deleted file mode 100644 index 4336805a4b..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectDebugPropertyPage.xaml +++ /dev/null @@ -1,130 +0,0 @@ - - - - - - Project - - - AE27A6B0-E345-4288-96DF-5EAF394EE369 - - - 165 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (ne (unevaluated "Project" "StartArguments") "") - - - - - - - - - - - - (has-evaluated-value "Project" "RemoteDebugEnabled" true) - - - - - - - - - (has-evaluated-value "Project" "RemoteDebugEnabled" true) - - - - - - - - - - - - - - - - (and - (has-project-capability "SupportsHotReload") - (not (has-evaluated-value "Project" "RemoteDebugEnabled" true))) - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectDebugger.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectDebugger.xaml deleted file mode 100644 index 5fbfa31357..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectDebugger.xaml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - 07530DC2-31D8-429D-8250-848AF494F007 - 0x100 - ActiveDebugProfile - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectItemsSchema.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectItemsSchema.xaml deleted file mode 100644 index 5f34ac631a..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectItemsSchema.xaml +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectReference.xaml deleted file mode 100644 index 5e1a3e1004..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ProjectReference.xaml +++ /dev/null @@ -1,152 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedAnalyzerReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedAnalyzerReference.xaml deleted file mode 100644 index 8e6fddf79a..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedAnalyzerReference.xaml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedAssemblyReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedAssemblyReference.xaml deleted file mode 100644 index b40875d099..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedAssemblyReference.xaml +++ /dev/null @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedCOMReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedCOMReference.xaml deleted file mode 100644 index aa96a21856..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedCOMReference.xaml +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedFrameworkReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedFrameworkReference.xaml deleted file mode 100644 index c60183d051..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedFrameworkReference.xaml +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedPackageReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedPackageReference.xaml deleted file mode 100644 index 18fbed0145..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedPackageReference.xaml +++ /dev/null @@ -1,138 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedProjectReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedProjectReference.xaml deleted file mode 100644 index c6c104fae5..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedProjectReference.xaml +++ /dev/null @@ -1,218 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedSdkReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedSdkReference.xaml deleted file mode 100644 index 18e2597752..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResolvedSdkReference.xaml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Resource.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Resource.BrowseObject.xaml deleted file mode 100644 index f53e54e08d..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Resource.BrowseObject.xaml +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Resource.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Resource.xaml deleted file mode 100644 index a311519074..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/Resource.xaml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResourcesPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResourcesPropertyPage.xaml deleted file mode 100644 index f5ec99f74b..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/ResourcesPropertyPage.xaml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/SdkReference.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/SdkReference.xaml deleted file mode 100644 index 9afea0582e..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/SdkReference.xaml +++ /dev/null @@ -1,71 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/SettingsPropertyPage.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/SettingsPropertyPage.xaml deleted file mode 100644 index 09dae75122..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Microsoft/SettingsPropertyPage.xaml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - (has-project-capability "AppSettings") - - - - - - - - - - - - - - - - (has-project-capability "AppSettings") - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectDebugger.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectDebugger.XSharp.xaml deleted file mode 100644 index 5fbfa31357..0000000000 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectDebugger.XSharp.xaml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - 07530DC2-31D8-429D-8250-848AF494F007 - 0x100 - ActiveDebugProfile - - - - - - - - - - - - - - - - - - - - diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Utilities.cs b/src/Compiler/src/Compiler/XSharpBuildTask/Utilities.cs index d83dc6d3fa..c6edf0cd8b 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Utilities.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Utilities.cs @@ -16,10 +16,78 @@ #nullable disable namespace XSharp.Build { + static class Extensions + { + internal static bool GetBool(this ITaskItem item, string itemMetadataName) + { + string metadataValue = item.GetMetadata(itemMetadataName); + if (metadataValue == null || metadataValue.Length == 0) + { + return false; + } + + try + { + return ConvertStringToBool(metadataValue); + } + catch (System.ArgumentException) + { + throw new Exception("Invalid metadata attribute: " + itemMetadataName + " " + metadataValue); + } + } + + /// + /// Converts a string to a bool. We consider "true/false", "on/off", and + /// "yes/no" to be valid boolean representations in the XML. + /// + /// The string to convert. + /// Boolean true or false, corresponding to the string. + internal static bool ConvertStringToBool(string parameterValue) + { + if (ValidBooleanTrue(parameterValue)) + { + return true; + } + else if (ValidBooleanFalse(parameterValue)) + { + return false; + } + else + { + // Unsupported boolean representation. + throw new Exception("Cannot convert string to bool: " + parameterValue); + } + } + + /// + /// Returns true if the string represents a valid MSBuild boolean true value, + /// such as "on", "!false", "yes" + /// + private static bool ValidBooleanTrue(string parameterValue) => + String.Compare(parameterValue, "true", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "on", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "yes", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "!false", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "!off", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "!no", StringComparison.OrdinalIgnoreCase) == 0; + + /// + /// Returns true if the string represents a valid MSBuild boolean false value, + /// such as "!on" "off" "no" "!true" + /// + private static bool ValidBooleanFalse(string parameterValue) => + String.Compare(parameterValue, "false", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "off", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "no", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "!true", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "!on", StringComparison.OrdinalIgnoreCase) == 0 || + String.Compare(parameterValue, "!yes", StringComparison.OrdinalIgnoreCase) == 0; + + + } class Utilities { - internal static string XSharpDir() { // If used after MSI Installer, value should be in the Registry @@ -83,77 +151,6 @@ internal static bool CopyFileSafe(string source, string target) } } - internal static bool TryConvertItemMetadataToBool(ITaskItem item, string itemMetadataName) - { - string metadataValue = item.GetMetadata(itemMetadataName); - if (metadataValue == null || metadataValue.Length == 0) - { - return false; - } - - try - { - return Utilities.ConvertStringToBool(metadataValue); - } - catch (System.ArgumentException) - { - throw new Exception("Invalid metadata attribute: " + itemMetadataName + " " + metadataValue); - } - } - - - /// - /// Converts a string to a bool. We consider "true/false", "on/off", and - /// "yes/no" to be valid boolean representations in the XML. - /// - /// The string to convert. - /// Boolean true or false, corresponding to the string. - internal static bool ConvertStringToBool(string parameterValue) - { - if (ValidBooleanTrue(parameterValue)) - { - return true; - } - else if (ValidBooleanFalse(parameterValue)) - { - return false; - } - else - { - // Unsupported boolean representation. - throw new Exception("Cannot convert string to bool: " + parameterValue); - } - } - /// - /// Returns true if the string can be successfully converted to a bool, - /// such as "on" or "yes" - /// - internal static bool CanConvertStringToBool(string parameterValue) => - ValidBooleanTrue(parameterValue) || ValidBooleanFalse(parameterValue); - - /// - /// Returns true if the string represents a valid MSBuild boolean true value, - /// such as "on", "!false", "yes" - /// - private static bool ValidBooleanTrue(string parameterValue) => - String.Compare(parameterValue, "true", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "on", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "yes", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "!false", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "!off", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "!no", StringComparison.OrdinalIgnoreCase) == 0; - - /// - /// Returns true if the string represents a valid MSBuild boolean false value, - /// such as "!on" "off" "no" "!true" - /// - private static bool ValidBooleanFalse(string parameterValue) => - String.Compare(parameterValue, "false", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "off", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "no", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "!true", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "!on", StringComparison.OrdinalIgnoreCase) == 0 || - String.Compare(parameterValue, "!yes", StringComparison.OrdinalIgnoreCase) == 0; internal static string GetFullPathNoThrow(string path) { diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Common.targets b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Common.targets index de1a458160..77c01d24ab 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Common.targets +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Common.targets @@ -41,6 +41,7 @@ inspired by Microsoft.CSharp.targets + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.GenerateGlobalUsings.targets b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.GenerateGlobalUsings.targets new file mode 100644 index 0000000000..d94749e2dd --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.GenerateGlobalUsings.targets @@ -0,0 +1,57 @@ + + + + + + + $(IntermediateOutputPath)$(MSBuildProjectName).GlobalUsings.g$(DefaultLanguageSourceExtension) + + + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.props b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.props index 6306025461..bc252db01a 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.props +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.props @@ -65,5 +65,15 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs b/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs index a18469532f..83a30df564 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs @@ -693,8 +693,8 @@ internal static void AddReferencesToCommandLine( string switchName = "/reference:"; if (!isInteractive) { - bool embed = Utilities.TryConvertItemMetadataToBool(reference, - "EmbedInteropTypes"); + + bool embed = reference.GetBool("EmbedInteropTypes"); if (embed) { diff --git a/src/CompilerTests/Applications/C949/Prg/C949.prg b/src/CompilerTests/Applications/C949/Prg/C949.prg new file mode 100644 index 0000000000..d6ebd970c9 --- /dev/null +++ b/src/CompilerTests/Applications/C949/Prg/C949.prg @@ -0,0 +1,32 @@ +// 949. ICE when calling method with default value in VO library from Core app +// https://github.com/X-Sharp/XSharpPublic/issues/1779 + +FUNCTION Start() AS VOID +LOCAL o := TestDefault{} AS TestDefault +o:TestDef() + +/* +error XS9999: An internal compiler error has occurred: 'Index was outside the bounds of the array.', at LanguageService.CodeAnalysis.XSharp.Symbols.ParameterSymbolExtensions.GetVODefaultParameter(ParameterSymbol param, SyntaxNode syntax, XSharpCompilation compilation, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Compiler\src\Compiler\XSharpCodeAnalysis\Symbols\ParameterSymbolExtensions.cs:line 67 + at LanguageService.CodeAnalysis.XSharp.Binder.XsDefaultValue(ParameterSymbol parameter, SyntaxNode syntax, XSharpCompilation compilation, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Compiler\src\Compiler\XSharpCodeAnalysis\Binder\Binder_Invocation.cs:line 70 + at LanguageService.CodeAnalysis.XSharp.Binder.g__bindDefaultArgument|701_1(SyntaxNode syntax, ParameterSymbol parameter, Symbol containingMember, Boolean enableCallerInfo, BindingDiagnosticBag diagnostics, ArrayBuilder`1 argumentsBuilder, Int32 argumentsCount, ImmutableArray`1 argsToParamsOpt) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Invocation.cs:line 1678 + at LanguageService.CodeAnalysis.XSharp.Binder.BindDefaultArguments(SyntaxNode node, ImmutableArray`1 parameters, ArrayBuilder`1 argumentsBuilder, ArrayBuilder`1 argumentRefKindsBuilder, ArrayBuilder`1 namesBuilder, ImmutableArray`1& argsToParamsOpt, BitVector& defaultArguments, Boolean expanded, Boolean enableCallerInfo, BindingDiagnosticBag diagnostics, Symbol attributedMember) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Invocation.cs:line 1593 + at LanguageService.CodeAnalysis.XSharp.Binder.BindInvocationExpressionContinued(SyntaxNode node, SyntaxNode expression, String methodName, OverloadResolutionResult`1 result, AnalyzedArguments analyzedArguments, MethodGroup methodGroup, NamedTypeSymbol delegateTypeOpt, BindingDiagnosticBag diagnostics, XSharpSyntaxNode queryClause) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Invocation.cs:line 1237 + at LanguageService.CodeAnalysis.XSharp.Binder.BindMethodGroupInvocation(SyntaxNode syntax, SyntaxNode expression, String methodName, BoundMethodGroup methodGroup, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, XSharpSyntaxNode queryClause, Boolean ignoreNormalFormIfHasValidParamsParameter, Boolean& anyApplicableCandidates, Boolean disallowExpandedNonArrayParams) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Invocation.cs:line 867 + at LanguageService.CodeAnalysis.XSharp.Binder.BindInvocationExpression(SyntaxNode node, SyntaxNode expression, String methodName, BoundExpression boundExpression, AnalyzedArguments analyzedArguments, BindingDiagnosticBag diagnostics, XSharpSyntaxNode queryClause, Boolean ignoreNormalFormIfHasValidParamsParameter, Boolean disallowExpandedNonArrayParams) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Invocation.cs:line 346 + at LanguageService.CodeAnalysis.XSharp.Binder.BindXsInvocationExpression(InvocationExpressionSyntax node, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Compiler\src\Compiler\XSharpCodeAnalysis\Binder\Binder_Invocation.cs:line 181 + at LanguageService.CodeAnalysis.XSharp.Binder.g__bindExpressionInternal|419_0(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 616 + at LanguageService.CodeAnalysis.XSharp.Binder.BindExpressionInternal(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 590 + at LanguageService.CodeAnalysis.XSharp.Binder.BindExpression(ExpressionSyntax node, BindingDiagnosticBag diagnostics, Boolean invoked, Boolean indexed) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Expressions.cs:line 540 + at LanguageService.CodeAnalysis.XSharp.Binder.BindExpressionStatement(XSharpSyntaxNode node, ExpressionSyntax syntax, Boolean allowsAnyExpression, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 651 + at LanguageService.CodeAnalysis.XSharp.Binder.BindExpressionStatement(ExpressionStatementSyntax node, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 644 + at LanguageService.CodeAnalysis.XSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 73 + at LanguageService.CodeAnalysis.XSharp.Binder.BindBlockParts(BlockSyntax node, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 1960 + at LanguageService.CodeAnalysis.XSharp.Binder.BindBlock(BlockSyntax node, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 1947 + at LanguageService.CodeAnalysis.XSharp.Binder.BindStatement(StatementSyntax node, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 64 + at LanguageService.CodeAnalysis.XSharp.Binder.BindMethodBody(XSharpSyntaxNode declaration, BlockSyntax blockBody, ArrowExpressionClauseSyntax expressionBody, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 4131 + at LanguageService.CodeAnalysis.XSharp.Binder.BindMethodBody(XSharpSyntaxNode syntax, BindingDiagnosticBag diagnostics) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Statements.cs:line 3732 + at LanguageService.CodeAnalysis.XSharp.Binder.BindWithLambdaBindingCountDiagnostics[TSyntax,TArg,TResult](TSyntax syntax, TArg arg, BindingDiagnosticBag diagnostics, Func`5 bind) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Binder\Binder_Lambda.cs:line 444 + at LanguageService.CodeAnalysis.XSharp.MethodCompiler.BindMethodBody(MethodSymbol method, TypeCompilationState compilationState, BindingDiagnosticBag diagnostics, Boolean includeInitializersInBody, BoundNode initializersBody, Boolean reportNullableDiagnostics, ImportChain& importChain, Boolean& originalBodyNested, Boolean& prependedDefaultValueTypeConstructorInitializer, InitialState& forSemanticModel) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 1811 + at LanguageService.CodeAnalysis.XSharp.MethodCompiler.CompileMethod(MethodSymbol methodSymbol, Int32 methodOrdinal, ProcessedFieldInitializers& processedInitializers, SynthesizedSubmissionFields previousSubmissionFields, TypeCompilationState compilationState) in D:\a\XSharpPublic\XSharpPublic\src\Roslyn\Src\Compilers\CSharp\Portable\Compiler\MethodCompiler.cs:line 1018 +*/ + diff --git a/src/CompilerTests/Applications/C949_helper/Prg/C949_helper.prg b/src/CompilerTests/Applications/C949_helper/Prg/C949_helper.prg new file mode 100644 index 0000000000..9b67072729 --- /dev/null +++ b/src/CompilerTests/Applications/C949_helper/Prg/C949_helper.prg @@ -0,0 +1,4 @@ +CLASS TestDefault +METHOD TestDef(c := "asd" AS STRING) AS VOID +END CLASS + diff --git a/src/CompilerTests/Applications/C950/Prg/C950.prg b/src/CompilerTests/Applications/C950/Prg/C950.prg new file mode 100644 index 0000000000..035391d396 --- /dev/null +++ b/src/CompilerTests/Applications/C950/Prg/C950.prg @@ -0,0 +1,44 @@ +// 950. Multiplication of numbers stored in a USUAL +// https://github.com/X-Sharp/XSharpPublic/issues/1764 + +FUNCTION Start( ) AS VOID + +? 18 *596 *735 *875 +xAssert(18 *596 *735 *875 == 6899445000) +xAssert(18U *596 *735 *875 == 6899445000) +xAssert(180 *596 *735 *875 == 68994450000) + +LOCAL u AS USUAL + +u := 18 +u := u * 596 *735 *875 +? u +xAssert(u == 6899445000) +u *= 10 +xAssert(u == 68994450000) + +LOCAL c AS STRING + +c := "18U *596 *735 *875" +? Str(&(c) , 20 , 2) +xAssert(&(c) == 6899445000) + +c := "18 *596 *735 *875" +? Str(&(c) , 20 , 2) +xAssert(&(c) == 6899445000) + + +u := Int32.MaxValue +xAssert( u * 2 == (INT64)Int32.MaxValue * 2) +xAssert( u - 2 == (INT64)Int32.MaxValue - 2) +xAssert( u + 2 == (INT64)Int32.MaxValue + 2) + + +PROC xAssert(l AS LOGIC) AS VOID + IF l + ? "Assertion passed" + ELSE + THROW Exception{"Incorrect result"} + END IF +RETURN + diff --git a/src/CompilerTests/Runtime/XSharp.RT.dll b/src/CompilerTests/Runtime/XSharp.RT.dll index 5e84932ad0..e41c0c1ca0 100644 Binary files a/src/CompilerTests/Runtime/XSharp.RT.dll and b/src/CompilerTests/Runtime/XSharp.RT.dll differ diff --git a/src/CompilerTests/xSharp Tests30.viproj b/src/CompilerTests/xSharp Tests30.viproj index 1a3aceac4c..19d7aaaa24 100644 --- a/src/CompilerTests/xSharp Tests30.viproj +++ b/src/CompilerTests/xSharp Tests30.viproj @@ -138771,6 +138771,368 @@ AppConfig = Release,22222222-2222-2222-2222-222222222222 ForceX86=0 Optimize=0 ENDApplication = C948 - "if x is not var y" not working + +ApplicationGroup = B9CFE839-D401-428D-94E9-E9D21E9F772D +; ************** APPLICATION C949 - ICE when calling method with default value in VO library from Core app ************* +Application = C949 - ICE when calling method with default value in VO library from Core app +IDEVersion = 1.06 +GalleryName = +GalleryPage = +GalleryDefaultName = +Target = 0 +Platform = AnyCPU +Language = XSharp +Runtime = CLR4 +Dialect = Core +Folder = %ProjectPath%\Applications\C949\ +PrgSubFolder = \Prg +ResourcesSubFolder = +Description = +NameSpace = +Assembly = C949 +Extension = +ApplicationIcon = +OutputFolder = +Frameworks = 1 +GUID = 8EC43411-B09B-4214-AA4A-1F78853E53F7 +IncludeInProjectBuild = 1 +IncludeInProjectSearch = 1 +IncludeInProjectExport = 1 +IncludePath = +StdDefsFile = +AppToRun = +SignAssembly = 0 +KeyFile = + +[ExportOptions] +ExportResources = 0 +ExportImages = 0 +[C949 - ICE when calling method with default value in VO library from Core app FileGroups] +[C949 - ICE when calling method with default value in VO library from Core app Files] +File = %AppPath%\Prg\C949.prg +FileGUID = E223671A-BA14-4DE8-BF30-265DF1707136 +FileType = Code +CopyToBin = 0 +[C949 - ICE when calling method with default value in VO library from Core app References] +ReferenceGAC = CLR4,System,1,0,4.0.0.0 +ReferenceGAC = CLR4,System.Core,1,0,4.0.0.0 +ReferenceProject = 373E049D-2D6E-4B3E-893F-E80EBECFE738,1,0,C949_helper +[C949 - ICE when calling method with default value in VO library from Core app Resources] +[C949 - ICE when calling method with default value in VO library from Core app Native Resources] +[C949 - ICE when calling method with default value in VO library from Core app License files] +[C949 - ICE when calling method with default value in VO library from Core app General Options] +Switches= +ZeroArrays=0 +CaseSensitive=0 +ImplicitNamespace=0 +VO1=0 +VO2=0 +VO3=0 +VO4=0 +VO5=0 +VO6=0 +VO7=0 +VO8=0 +VO9=0 +VO10=0 +VO11=0 +VO12=0 +VO13=0 +VO14=0 +VO15=0 +VO16=0 +VO17=0 +FOX1=0 +FOX2=0 +XPP1=0 +LateBound=0 +Unsafe=0 +Undeclared=0 +EnforceSelf=0 +EnforceOverride=0 +UseNativeVersion=0 +MemVar=0 +IgnoreStdDefs=0 +Ovf=0 +FOvf=0 +ModernSyntax=0 +NamedArgs=0 +InitLocals=0 +AllowOldStyleAssignments=0 +AllowDotOption=1 +ResponseOnly=0 +[C949 - ICE when calling method with default value in VO library from Core app Configurations] +AppConfig = Debug,11111111-1111-1111-1111-111111111111 + Switches= + SwitchesCF= + CommandLine= + CommandLineCF= + Debug=1 + DebugInit=1 + DefineDebug=1 + DefineTrace=0 + SyntaxOnly=0 + WarningsErrors=0 + ForceConsole=0 + ForceX86=0 + Optimize=0 +AppConfig = Release,22222222-2222-2222-2222-222222222222 + Switches= + SwitchesCF= + CommandLine= + CommandLineCF= + Debug=0 + DebugInit=0 + DefineDebug=0 + DefineTrace=0 + SyntaxOnly=0 + WarningsErrors=0 + ForceConsole=0 + ForceX86=0 + Optimize=0 +ENDApplication = C949 - ICE when calling method with default value in VO library from Core app + +ApplicationGroup = B9CFE839-D401-428D-94E9-E9D21E9F772D +; ************** APPLICATION C949_helper ************* +Application = C949_helper +IDEVersion = 1.06 +GalleryName = +GalleryPage = +GalleryDefaultName = +Target = 2 +Platform = AnyCPU +Language = XSharp +Runtime = CLR4 +Dialect = VO +Folder = %ProjectPath%\Applications\C949_helper\ +PrgSubFolder = \Prg +ResourcesSubFolder = +Description = +NameSpace = +Assembly = C949_helper +Extension = +ApplicationIcon = +OutputFolder = +Frameworks = 1 +GUID = 373E049D-2D6E-4B3E-893F-E80EBECFE738 +IncludeInProjectBuild = 1 +IncludeInProjectSearch = 1 +IncludeInProjectExport = 1 +IncludePath = +StdDefsFile = +AppToRun = +SignAssembly = 0 +KeyFile = + +[ExportOptions] +ExportResources = 0 +ExportImages = 0 +[C949_helper FileGroups] +[C949_helper Files] +File = %AppPath%\Prg\C949_helper.prg +FileGUID = 5400FFEA-2626-4157-9428-2FEE7622FBC1 +FileType = Code +CopyToBin = 0 +[C949_helper References] +ReferenceGAC = CLR4,System,1,0,4.0.0.0 +ReferenceGAC = CLR4,System.Core,1,0,4.0.0.0 +ReferenceGAC = CLR4,XSharp.Core,1,0,2.6.0.0 +ReferenceGAC = CLR4,XSharp.RT,1,0,2.6.0.0 +[C949_helper Resources] +[C949_helper Native Resources] +[C949_helper License files] +[C949_helper General Options] +Switches= +ZeroArrays=0 +CaseSensitive=0 +ImplicitNamespace=0 +VO1=0 +VO2=0 +VO3=0 +VO4=0 +VO5=0 +VO6=0 +VO7=0 +VO8=0 +VO9=0 +VO10=0 +VO11=0 +VO12=0 +VO13=0 +VO14=0 +VO15=0 +VO16=0 +VO17=0 +FOX1=0 +FOX2=0 +XPP1=0 +LateBound=0 +Unsafe=0 +Undeclared=0 +EnforceSelf=0 +EnforceOverride=0 +UseNativeVersion=0 +MemVar=0 +IgnoreStdDefs=0 +Ovf=0 +FOvf=0 +ModernSyntax=0 +NamedArgs=0 +InitLocals=0 +AllowOldStyleAssignments=0 +AllowDotOption=1 +ResponseOnly=0 +[C949_helper Configurations] +AppConfig = Debug,11111111-1111-1111-1111-111111111111 + Switches= + SwitchesCF= + CommandLine= + CommandLineCF= + Debug=1 + DebugInit=1 + DefineDebug=1 + DefineTrace=0 + SyntaxOnly=0 + WarningsErrors=0 + ForceConsole=0 + ForceX86=0 + Optimize=0 +AppConfig = Release,22222222-2222-2222-2222-222222222222 + Switches= + SwitchesCF= + CommandLine= + CommandLineCF= + Debug=0 + DebugInit=0 + DefineDebug=0 + DefineTrace=0 + SyntaxOnly=0 + WarningsErrors=0 + ForceConsole=0 + ForceX86=0 + Optimize=0 +ENDApplication = C949_helper + +ApplicationGroup = B9CFE839-D401-428D-94E9-E9D21E9F772D +; ************** APPLICATION C950 - Multiplication of numbers stored in a USUAL ************* +Application = C950 - Multiplication of numbers stored in a USUAL +IDEVersion = 1.06 +GalleryName = +GalleryPage = +GalleryDefaultName = +Target = 0 +Platform = x86 +Language = XSharp +Runtime = CLR4 +Dialect = VO +Folder = %ProjectPath%\Applications\C950\ +PrgSubFolder = \Prg +ResourcesSubFolder = +Description = +NameSpace = +Assembly = C950 +Extension = +ApplicationIcon = +OutputFolder = +Frameworks = 1 +GUID = D02E9AA5-9D5C-42DD-AFC7-97E8DA09B398 +IncludeInProjectBuild = 1 +IncludeInProjectSearch = 1 +IncludeInProjectExport = 1 +IncludePath = +StdDefsFile = +AppToRun = +SignAssembly = 0 +KeyFile = + +[ExportOptions] +ExportResources = 0 +ExportImages = 0 +[C950 - Multiplication of numbers stored in a USUAL FileGroups] +[C950 - Multiplication of numbers stored in a USUAL Files] +File = %AppPath%\Prg\C950.prg +FileGUID = 28BFBBBA-54EF-4954-B600-04E8E9FE37E4 +FileType = Code +CopyToBin = 0 +[C950 - Multiplication of numbers stored in a USUAL References] +ReferenceGAC = CLR4,System,1,0,4.0.0.0 +ReferenceGAC = CLR4,System.Core,1,0,4.0.0.0 +ReferenceGAC = CLR4,XSharp.Core,1,0,2.6.0.0 +ReferenceGAC = CLR4,XSharp.RT,1,0,2.6.0.0 +[C950 - Multiplication of numbers stored in a USUAL Resources] +[C950 - Multiplication of numbers stored in a USUAL Native Resources] +[C950 - Multiplication of numbers stored in a USUAL License files] +[C950 - Multiplication of numbers stored in a USUAL General Options] +Switches= +ZeroArrays=0 +CaseSensitive=0 +ImplicitNamespace=0 +VO1=0 +VO2=0 +VO3=0 +VO4=0 +VO5=0 +VO6=0 +VO7=0 +VO8=0 +VO9=0 +VO10=0 +VO11=0 +VO12=0 +VO13=0 +VO14=0 +VO15=0 +VO16=0 +VO17=0 +FOX1=0 +FOX2=0 +XPP1=0 +LateBound=0 +Unsafe=0 +Undeclared=0 +EnforceSelf=0 +EnforceOverride=0 +UseNativeVersion=0 +MemVar=0 +IgnoreStdDefs=0 +Ovf=0 +FOvf=0 +ModernSyntax=0 +NamedArgs=0 +InitLocals=0 +AllowOldStyleAssignments=0 +AllowDotOption=1 +ResponseOnly=0 +[C950 - Multiplication of numbers stored in a USUAL Configurations] +AppConfig = Debug,11111111-1111-1111-1111-111111111111 + Switches= + SwitchesCF= + CommandLine= + CommandLineCF= + Debug=1 + DebugInit=1 + DefineDebug=1 + DefineTrace=0 + SyntaxOnly=0 + WarningsErrors=0 + ForceConsole=0 + ForceX86=0 + Optimize=0 +AppConfig = Release,22222222-2222-2222-2222-222222222222 + Switches= + SwitchesCF= + CommandLine= + CommandLineCF= + Debug=0 + DebugInit=0 + DefineDebug=0 + DefineTrace=0 + SyntaxOnly=0 + WarningsErrors=0 + ForceConsole=0 + ForceX86=0 + Optimize=0 +ENDApplication = C950 - Multiplication of numbers stored in a USUAL [EndApplications] [Configurations] diff --git a/src/Runtime/MacroCompiler.Example/MacroCompiler.Example.xsproj b/src/Runtime/MacroCompiler.Example/MacroCompiler.Example.xsproj index d5fa8f02ff..f11ee469af 100644 --- a/src/Runtime/MacroCompiler.Example/MacroCompiler.Example.xsproj +++ b/src/Runtime/MacroCompiler.Example/MacroCompiler.Example.xsproj @@ -42,7 +42,6 @@ false true false - 2.11.0.0 false $(Solutiondir)common\xsharp.snk @@ -55,10 +54,10 @@ AnyCPU False - + DEBUG;TRACE - + TRACE @@ -120,5 +119,10 @@ {3a771f0e-9400-4a19-8663-c71567ebfa29} True + + XSharp.VO + {06099c3d-1697-4eb1-9f53-8a9a50b9eacd} + True + \ No newline at end of file diff --git a/src/Runtime/MacroCompiler.Example/VoTests.prg b/src/Runtime/MacroCompiler.Example/VoTests.prg index e50a90c8b7..14ee336228 100644 --- a/src/Runtime/MacroCompiler.Example/VoTests.prg +++ b/src/Runtime/MacroCompiler.Example/VoTests.prg @@ -687,7 +687,7 @@ BEGIN NAMESPACE MacroCompilerTest Testmacro(mc, e"{|str, x| PadL(str, x)}",Args("abc",2),"ab",typeof(STRING)) TestMacro(mc, e"{|o|o:Checked}", Args(CheckBox{}), FALSE, typeof(LOGIC)) TestMacro(mc, e"{|a,b|AltD(), a+b}", Args(1,2), 3, typeof(LONG)) - var tempGetInst := System.Runtime.InteropServices.Marshal.GetHINSTANCE(typeof(XSharp.Core.Functions):Module) + var tempGetInst := System.Runtime.InteropServices.Marshal.GetHINSTANCE(typeof(XSharp.VO.Functions):Module) TestMacro(mc, e"{||_GetInst()}", Args(), tempGetInst, typeof(IntPtr)) // Dynamic assembly load test (note: XSharp.VO needs to be compiled before this for it to work! This is ensured by the solution build order) diff --git a/src/Runtime/MacroCompiler/Binder/Binder.BinaryOp.cs b/src/Runtime/MacroCompiler/Binder/Binder.BinaryOp.cs index 631074db6e..ce6f63c74c 100644 --- a/src/Runtime/MacroCompiler/Binder/Binder.BinaryOp.cs +++ b/src/Runtime/MacroCompiler/Binder/Binder.BinaryOp.cs @@ -50,7 +50,17 @@ internal static BinaryOperatorSymbol BinaryOperation(BinaryOperatorKind kind, re Convert(ref left, Compilation.Get(NativeType.Usual), options); Convert(ref right, Compilation.Get(NativeType.Usual), options); } - var sym = BinaryOperatorEasyOut.ClassifyOperation(kind, left.Datatype, right.Datatype); + var lt = left.Datatype; + var rt = right.Datatype; + if (options.HasFlag(BindOptions.EnumAdd)) + { + // The binary operation of two Int32 values now returns an Int64. + // This breaks the enum addition since we cannot convert back to the enum type. + // Force one of the types to be not Int32 to make sure that we do not get the Int64 result + rt = Compilation.Get(NativeType.Int16); + } + + var sym = BinaryOperatorEasyOut.ClassifyOperation(kind, lt, rt); if (options.HasFlag(BindOptions.AllowInexactComparisons) && sym != null) { @@ -327,6 +337,8 @@ static BinaryOperatorSymbol EnumBinaryOperator(BinaryOperatorKind kind, ref Expr else return null; + if (kind == BinaryOperatorKind.Addition && dt.EnumUnderlyingType.NativeType == NativeType.Int32) + options |= BindOptions.EnumAdd; Convert(ref l, dt.EnumUnderlyingType, options); Convert(ref r, dt.EnumUnderlyingType, options); diff --git a/src/Runtime/MacroCompiler/Binder/Binder.cs b/src/Runtime/MacroCompiler/Binder/Binder.cs index f738b81dec..61f0e25e79 100644 --- a/src/Runtime/MacroCompiler/Binder/Binder.cs +++ b/src/Runtime/MacroCompiler/Binder/Binder.cs @@ -38,6 +38,7 @@ internal enum BindOptions Logic = 1024, Cast = 2048, ForceUsual = 4096, + EnumAdd = 8192, None = 0, Default = AllowDynamic | AllowInexactComparisons | AllowImplicitNarrowingConversions diff --git a/src/Runtime/MacroCompiler/Binder/Operator.Binary.cs b/src/Runtime/MacroCompiler/Binder/Operator.Binary.cs index 886923df79..efcaf529b9 100644 --- a/src/Runtime/MacroCompiler/Binder/Operator.Binary.cs +++ b/src/Runtime/MacroCompiler/Binder/Operator.Binary.cs @@ -412,7 +412,7 @@ static BinaryOperatorEasyOut() const OperandType DEC = OperandType.Decimal; const OperandType BOL = OperandType.Bool; - // Overload resolution for Y * / - % < > <= >= X + // Overload resolution for Y / - % < > <= >= X OperandType[,] arithmetic = { // bool chr i08 i16 i32 i64 u08 u16 u32 u64 r32 r64 dec @@ -431,15 +431,17 @@ static BinaryOperatorEasyOut() /* dec */{ ERR, DEC, DEC, DEC, DEC, DEC, DEC, DEC, DEC, DEC, ERR, ERR, DEC }, }; - // Overload resolution for Y + X - OperandType[,] addition = + // Note that the operation on two Int32 values now returns an Int64 to avoid overflow + // for Multiplication and Addition + // Overload resolution for Y * + X + OperandType[,] muladd = { // bool chr i08 i16 i32 i64 u08 u16 u32 u64 r32 r64 dec /* bool */{ ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR, ERR }, /* chr */{ ERR, INT, INT, INT, INT, LNG, INT, INT, UIN, ULG, FLT, DBL, DEC }, /* i08 */{ ERR, INT, INT, INT, INT, LNG, INT, INT, LNG, ERR, FLT, DBL, DEC }, /* i16 */{ ERR, INT, INT, INT, INT, LNG, INT, INT, LNG, ERR, FLT, DBL, DEC }, - /* i32 */{ ERR, INT, INT, INT, INT, LNG, INT, INT, LNG, ERR, FLT, DBL, DEC }, + /* i32 */{ ERR, INT, INT, INT, LNG, LNG, INT, INT, LNG, ERR, FLT, DBL, DEC }, /* i64 */{ ERR, LNG, LNG, LNG, LNG, LNG, LNG, LNG, LNG, ERR, FLT, DBL, DEC }, /* u08 */{ ERR, INT, INT, INT, INT, LNG, INT, INT, UIN, ULG, FLT, DBL, DEC }, /* u16 */{ ERR, INT, INT, INT, INT, LNG, INT, INT, UIN, ULG, FLT, DBL, DEC }, @@ -564,14 +566,14 @@ static BinaryOperatorEasyOut() return res; }; - var tables = new[] { arithmetic, addition, shift, equality, logical }; + var tables = new[] { arithmetic, muladd, shift, equality, logical }; Func tableIndex = k => { - if (k == BinaryOperatorKind.Multiplication || k == BinaryOperatorKind.Subtraction || k == BinaryOperatorKind.Division + if ( k == BinaryOperatorKind.Subtraction || k == BinaryOperatorKind.Division || k == BinaryOperatorKind.Remainder || k == BinaryOperatorKind.Exponent) return 0; - if (k == BinaryOperatorKind.Addition) + if (k == BinaryOperatorKind.Multiplication || k == BinaryOperatorKind.Addition) return 1; if (k == BinaryOperatorKind.LeftShift || k == BinaryOperatorKind.RightShift) return 2; diff --git a/src/Runtime/MacroCompiler/Compiler/MacroCodeblock.cs b/src/Runtime/MacroCompiler/Compiler/MacroCodeblock.cs index 203f798646..940dabd8de 100644 --- a/src/Runtime/MacroCompiler/Compiler/MacroCodeblock.cs +++ b/src/Runtime/MacroCompiler/Compiler/MacroCodeblock.cs @@ -16,7 +16,17 @@ internal MacroCodeblock(MacroCodeblockDelegate evalMethod, int pCount) public virtual object EvalBlock(params object[] args) { - return _eval(args); + var result = _eval(args); + if (result is long lng) + { + // All operations using 2 Int32 values now return an Int64 + // We want to convert back to Int32 if possible + if (lng >= int.MinValue && lng <= int.MaxValue) + { + result = (int)lng; + } + } + return result; } public int PCount() => _pcount; } @@ -55,8 +65,21 @@ class NestedCodeblock : ICodeblock internal class MacroCodeblock : _Codeblock { MacroCodeblockDelegate _eval; - public override __Usual Eval(params __Usual[] args) => _eval(args); - internal MacroCodeblock(MacroCodeblockDelegate evalMethod, int pCount, string source, bool isBlock) : + public override __Usual Eval(params __Usual[] args) + { + var result = _eval(args); + if (result.Value is long lng) + { + // All operations using 2 Int32 values now return an Int64 + // We want to convert back to Int32 if possible + if (lng >= int.MinValue && lng <= int.MaxValue) + { + result = new __Usual((int)lng); + } + } + return result; + } + internal MacroCodeblock(MacroCodeblockDelegate evalMethod, int pCount, string source, bool isBlock) : base(new NestedCodeblock(pCount), source, isBlock, false) { _eval = evalMethod; diff --git a/src/Runtime/XSharp.RT/Types/Usual.prg b/src/Runtime/XSharp.RT/Types/Usual.prg index adc7ca0ff7..9a9214b200 100644 --- a/src/Runtime/XSharp.RT/Types/Usual.prg +++ b/src/Runtime/XSharp.RT/Types/Usual.prg @@ -1459,7 +1459,16 @@ PUBLIC STRUCTURE __Usual IMPLEMENTS IConvertible, ; SWITCH lhs:_usualType CASE __UsualType.Long SWITCH rhs:_usualType - CASE __UsualType.Long ; RETURN (INT) (lhs:_intValue + rhs:_intValue) + CASE __UsualType.Long + local i1, i2 as Int64 + i1 := lhs:_intValue + i2 := rhs:_intValue + i1 := i1 + i2 + if i1 >= Int32.MinValue .and. i1 <= Int32.MaxValue + RETURN (INT) i1 + else + RETURN i1 + endif CASE __UsualType.Int64 ; RETURN (INT64) (lhs:_intValue + rhs:_i64Value) CASE __UsualType.Float ; RETURN FLOAT{Convert.ToDouble(lhs:_intValue) + rhs:_r8Value, rhs:_width, rhs:_decimals} CASE __UsualType.Currency ; RETURN (CURRENCY) (Convert.ToDecimal(lhs:_intValue) + rhs:_currencyValue) @@ -1570,7 +1579,16 @@ PUBLIC STRUCTURE __Usual IMPLEMENTS IConvertible, ; SWITCH lhs:_usualType CASE __UsualType.Long SWITCH rhs:_usualType - CASE __UsualType.Long ; RETURN (INT) (lhs:_intValue - rhs:_intValue) + CASE __UsualType.Long + local i1, i2 as Int64 + i1 := lhs:_intValue + i2 := rhs:_intValue + i1 := i1 - i2 + if i1 >= Int32.MinValue .and. i1 <= Int32.MaxValue + RETURN (INT) i1 + else + RETURN i1 + endif CASE __UsualType.Int64 ; RETURN (INT64) (lhs:_intValue - rhs:_i64Value) CASE __UsualType.Float ; RETURN FLOAT{Convert.ToDouble(lhs:_intValue) - rhs:_r8Value, rhs:_width, rhs:_decimals} CASE __UsualType.Currency ; RETURN (CURRENCY) (Convert.ToDecimal(lhs:_intValue) - rhs:_currencyValue) diff --git a/src/Runtime/XSharp.RT/Types/WinBool.prg b/src/Runtime/XSharp.RT/Types/WinBool.prg index a9fca47064..9c7c416b1d 100644 --- a/src/Runtime/XSharp.RT/Types/WinBool.prg +++ b/src/Runtime/XSharp.RT/Types/WinBool.prg @@ -21,12 +21,12 @@ PUBLIC STRUCT __WinBool IMPLEMENTS ISerializable [NOSHOW]; PRIVATE STATIC falseValue := __WinBool{0} AS __WinBool [NOSHOW]; - PRIVATE INITONLY _value AS BYTE // 0 = false, 1 = true + PRIVATE INITONLY _value AS INT // 0 = false, 1 = true /// Value as Logic PUBLIC PROPERTY @@Value AS LOGIC GET _value != 0 [NODEBUG] [INLINE]; - PRIVATE CONSTRUCTOR(@@value AS BYTE) + PRIVATE CONSTRUCTOR(@@value AS INT) _value := @@value /// This constructor is used in code generated by the compiler when needed. @@ -143,7 +143,7 @@ PUBLIC STRUCT __WinBool IMPLEMENTS ISerializable IF info == NULL THROW System.ArgumentException{"info"} ENDIF - _value := info:GetByte("Value") + _value := info:GetInt32("Value") #endregion END STRUCT diff --git a/src/VisualStudio/AppDesigner/AppDesigner2022.csproj b/src/VisualStudio/AppDesigner/AppDesigner2022.csproj index 0010432485..bcbff06e67 100644 --- a/src/VisualStudio/AppDesigner/AppDesigner2022.csproj +++ b/src/VisualStudio/AppDesigner/AppDesigner2022.csproj @@ -48,6 +48,13 @@ + + UserControl + + + XGlobalUsingsPropertyPagePanel.cs + + UserControl @@ -154,6 +161,9 @@ + + XGlobalUsingsPropertyPagePanel.cs + XDebugPropertyPagePanel.cs diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPage.cs b/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPage.cs index 1ddcfae101..9d870aa631 100644 --- a/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPage.cs +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPage.cs @@ -77,7 +77,7 @@ public override string GetProperty(string propertyName) { converterFramework = new SdkFrameWorkNameConverter(this.ProjectMgr.BuildProject); var p = this.PropertyPagePanel as XGeneralPropertyPagePanel; - p.FillFrameworkNames(converterFramework); + //p.FillFrameworkNames(converterFramework); } } @@ -184,7 +184,7 @@ public override void SetProperty(string propertyName, string value) if (!VS.MessageBox.ShowConfirm(message)) { var genPanel = PropertyPagePanel as XGeneralPropertyPagePanel; - genPanel.resetFramework(oldValue); + //genPanel.resetFramework(oldValue); return; } diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.Designer.cs b/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.Designer.cs index 8efd7fb89b..3aec5be8d5 100644 --- a/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.Designer.cs +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.Designer.cs @@ -43,7 +43,7 @@ private void InitializeComponent() this.lblDefaultNamespace = new System.Windows.Forms.Label(); this.lblApplicationName = new System.Windows.Forms.Label(); this.lblTargetFramework = new System.Windows.Forms.Label(); - this.comboTargetFramework = new System.Windows.Forms.ComboBox(); + //this.comboTargetFramework = new System.Windows.Forms.ComboBox(); this.tbTargetFrameworks = new System.Windows.Forms.TextBox(); this.lblOutputType = new System.Windows.Forms.Label(); this.tbAssemblyName = new System.Windows.Forms.TextBox(); @@ -73,7 +73,7 @@ private void InitializeComponent() this.tableLayoutPanel1.Controls.Add(this.lblDefaultNamespace, 1, 0); this.tableLayoutPanel1.Controls.Add(this.lblApplicationName, 0, 0); this.tableLayoutPanel1.Controls.Add(this.lblTargetFramework, 0, 2); - this.tableLayoutPanel1.Controls.Add(this.comboTargetFramework, 0, 3); + //this.tableLayoutPanel1.Controls.Add(this.comboTargetFramework, 0, 3); this.tableLayoutPanel1.Controls.Add(this.tbTargetFrameworks, 0, 3); this.tableLayoutPanel1.Controls.Add(this.lblOutputType, 1, 2); this.tableLayoutPanel1.Controls.Add(this.tbAssemblyName, 0, 1); @@ -197,17 +197,17 @@ private void InitializeComponent() // // comboTargetFramework // - this.comboTargetFramework.BackColor = System.Drawing.Color.WhiteSmoke; - this.comboTargetFramework.Dock = System.Windows.Forms.DockStyle.Fill; - this.comboTargetFramework.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; - this.comboTargetFramework.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); - this.comboTargetFramework.FormattingEnabled = true; - this.comboTargetFramework.Location = new System.Drawing.Point(321, 58); - this.comboTargetFramework.Margin = new System.Windows.Forms.Padding(5, 3, 3, 0); - this.comboTargetFramework.Name = "comboTargetFramework"; - this.comboTargetFramework.Size = new System.Drawing.Size(309, 21); - this.comboTargetFramework.TabIndex = 5; - this.comboTargetFramework.Visible = false; + //this.comboTargetFramework.BackColor = System.Drawing.Color.WhiteSmoke; + //this.comboTargetFramework.Dock = System.Windows.Forms.DockStyle.Fill; + //this.comboTargetFramework.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + //this.comboTargetFramework.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + //this.comboTargetFramework.FormattingEnabled = true; + //this.comboTargetFramework.Location = new System.Drawing.Point(321, 58); + //this.comboTargetFramework.Margin = new System.Windows.Forms.Padding(5, 3, 3, 0); + //this.comboTargetFramework.Name = "comboTargetFramework"; + //this.comboTargetFramework.Size = new System.Drawing.Size(309, 21); + //this.comboTargetFramework.TabIndex = 5; + //this.comboTargetFramework.Visible = false; // // tbTargetFrameworks // @@ -381,7 +381,7 @@ private void InitializeComponent() private System.Windows.Forms.TextBox tbDefaultNamespace; private System.Windows.Forms.TextBox tbAssemblyName; private System.Windows.Forms.ComboBox comboOutputType; - private System.Windows.Forms.ComboBox comboTargetFramework; + //private System.Windows.Forms.ComboBox comboTargetFramework; private System.Windows.Forms.TextBox tbTargetFrameworks; private System.Windows.Forms.CheckBox chkAutoGenerateBindingRedirects; private System.Windows.Forms.Label labelStartupObject; diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.cs b/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.cs index 62f8ac2f72..b18f8f4e00 100644 --- a/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.cs +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGeneralPropertyPagePanel.cs @@ -39,7 +39,7 @@ public XGeneralPropertyPagePanel(XPropertyPage parentPropertyPage) this.chkAutoGenerateBindingRedirects.Tag = XSharpProjectFileConstants.AutoGenerateBindingRedirects; this.comboDialect.Tag = XSharpProjectFileConstants.Dialect; this.comboOutputType.Tag = XSharpProjectFileConstants.OutputType; - this.comboTargetFramework.Tag = XSharpProjectFileConstants.TargetFrameworkVersion; + //this.comboTargetFramework.Tag = XSharpProjectFileConstants.TargetFrameworkVersion; this.tbTargetFrameworks.Tag = XSharpProjectFileConstants.XTargetFrameworks; lblDefaultNamespace.Text = GeneralPropertyPagePanel.captNamespace; @@ -74,9 +74,9 @@ public XGeneralPropertyPagePanel(XPropertyPage parentPropertyPage) FillCombo(new OutputTypeConverter(), comboOutputType); toolTip1.SetToolTip(lblOutputType, GeneralPropertyPagePanel.descOutputType); toolTip1.SetToolTip(comboOutputType, GeneralPropertyPagePanel.descOutputType); - FillFrameworkNames(new FrameworkNameConverter()); + //FillFrameworkNames(new FrameworkNameConverter()); toolTip1.SetToolTip(lblTargetFramework, GeneralPropertyPagePanel.descFramework); - toolTip1.SetToolTip(comboTargetFramework, GeneralPropertyPagePanel.descFramework); + //toolTip1.SetToolTip(comboTargetFramework, GeneralPropertyPagePanel.descFramework); // hook up the form to both editors @@ -87,7 +87,7 @@ public XGeneralPropertyPagePanel(XPropertyPage parentPropertyPage) public void FillFrameworkNames(FrameworkNameConverter converter) { - FillCombo(converter, comboTargetFramework); + //FillCombo(converter, comboTargetFramework); } void GetStartupClasses() { @@ -159,21 +159,21 @@ protected override void HandleControlValidated(object sender, EventArgs e) }); } - internal void resetFramework(string value) - { - int index = 0; - resetting = true; - foreach (string item in comboTargetFramework.Items) - { - if (String.Compare(item, value, true) == 0) - { - comboTargetFramework.SelectedIndex = index; - break; - } - index++; - } - resetting = false; - } + //internal void resetFramework(string value) + //{ + // int index = 0; + // resetting = true; + // foreach (string item in comboTargetFramework.Items) + // { + // if (String.Compare(item, value, true) == 0) + // { + // comboTargetFramework.SelectedIndex = index; + // break; + // } + // index++; + // } + // resetting = false; + //} private void btnIcon_Click(object sender, EventArgs e) { ThreadHelper.ThrowIfNotOnUIThread(); diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPage.cs b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPage.cs new file mode 100644 index 0000000000..4216bc3a65 --- /dev/null +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPage.cs @@ -0,0 +1,52 @@ +// +// Copyright (c) XSharp B.V. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. +// See License.txt in the project root for license information. +// + +namespace XSharp.Project +{ + using System; + using System.Globalization; + using System.Runtime.InteropServices; + using System.Windows.Forms; + using Microsoft.VisualStudio; + using Microsoft.VisualStudio.Package; + using Microsoft.VisualStudio.Project; + using Microsoft.VisualStudio.Shell; + + /// + /// Property page for the build events. + /// + [ComVisible(true)] + [Guid(XSharpConstants.GlobalUsingsPropertiesPage)] + [ProvideObject(typeof(XSharpGlobalUsingsPropertiesPage))] + public class XSharpGlobalUsingsPropertiesPage : XPropertyPage + { + // ========================================================================================= + // Constructors + // ========================================================================================= + /// + /// Initializes a new instance of the class. + /// + public XSharpGlobalUsingsPropertiesPage() + { + this.PageName = "Global Usings"; + this.PerConfig = false; + } + + // ========================================================================================= + // Methods + // ========================================================================================= + + + /// + /// Creates the controls that constitute the property page. This should be safe to re-entrancy. + /// + /// The newly created main control that hosts the property page. + protected override XPropertyPagePanel CreatePropertyPagePanel() + { + return new XGlobalUsingsPropertyPagePanel(this); + } + } +} diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.Designer.cs b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.Designer.cs new file mode 100644 index 0000000000..a555757573 --- /dev/null +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.Designer.cs @@ -0,0 +1,284 @@ +// +// Copyright (c) XSharp B.V. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. +// See License.txt in the project root for license information. +// + +namespace XSharp.Project +{ + partial class XGlobalUsingsPropertyPagePanel + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + this.chkImplicitUsings = new System.Windows.Forms.CheckBox(); + this.grpImpicitGlobalUsings = new System.Windows.Forms.GroupBox(); + this.grpManageImplicit = new System.Windows.Forms.GroupBox(); + this.gridUsings = new System.Windows.Forms.DataGridView(); + this.colNamespace = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colAlias = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.colStatic = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.colDelete = new System.Windows.Forms.DataGridViewButtonColumn(); + this.colImported = new System.Windows.Forms.DataGridViewCheckBoxColumn(); + this.btnAdd = new System.Windows.Forms.Button(); + this.chkStatic = new System.Windows.Forms.CheckBox(); + this.tbAlias = new System.Windows.Forms.TextBox(); + this.lblAlias = new System.Windows.Forms.Label(); + this.tbUsing = new System.Windows.Forms.TextBox(); + this.lblUsing = new System.Windows.Forms.Label(); + this.chkShowImported = new System.Windows.Forms.CheckBox(); + this.grpImpicitGlobalUsings.SuspendLayout(); + this.grpManageImplicit.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gridUsings)).BeginInit(); + this.SuspendLayout(); + // + // chkImplicitUsings + // + this.chkImplicitUsings.AutoSize = true; + this.chkImplicitUsings.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chkImplicitUsings.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.chkImplicitUsings.Location = new System.Drawing.Point(16, 19); + this.chkImplicitUsings.Name = "chkImplicitUsings"; + this.chkImplicitUsings.Size = new System.Drawing.Size(323, 17); + this.chkImplicitUsings.TabIndex = 0; + this.chkImplicitUsings.Text = "Enable implicit global usings to be declared by the project SDK."; + this.chkImplicitUsings.UseVisualStyleBackColor = true; + // + // grpImpicitGlobalUsings + // + this.grpImpicitGlobalUsings.Controls.Add(this.chkImplicitUsings); + this.grpImpicitGlobalUsings.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.grpImpicitGlobalUsings.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.grpImpicitGlobalUsings.Location = new System.Drawing.Point(17, 5); + this.grpImpicitGlobalUsings.Name = "grpImpicitGlobalUsings"; + this.grpImpicitGlobalUsings.Size = new System.Drawing.Size(454, 51); + this.grpImpicitGlobalUsings.TabIndex = 1; + this.grpImpicitGlobalUsings.TabStop = false; + this.grpImpicitGlobalUsings.Text = "Implicit Global Usings"; + // + // grpManageImplicit + // + this.grpManageImplicit.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.grpManageImplicit.Controls.Add(this.gridUsings); + this.grpManageImplicit.Controls.Add(this.btnAdd); + this.grpManageImplicit.Controls.Add(this.chkStatic); + this.grpManageImplicit.Controls.Add(this.tbAlias); + this.grpManageImplicit.Controls.Add(this.lblAlias); + this.grpManageImplicit.Controls.Add(this.tbUsing); + this.grpManageImplicit.Controls.Add(this.lblUsing); + this.grpManageImplicit.Controls.Add(this.chkShowImported); + this.grpManageImplicit.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.grpManageImplicit.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.grpManageImplicit.Location = new System.Drawing.Point(17, 73); + this.grpManageImplicit.Name = "grpManageImplicit"; + this.grpManageImplicit.Size = new System.Drawing.Size(521, 314); + this.grpManageImplicit.TabIndex = 2; + this.grpManageImplicit.TabStop = false; + this.grpManageImplicit.Text = "Manage Implicit Globals"; + // + // gridUsings + // + this.gridUsings.AllowUserToAddRows = false; + this.gridUsings.AllowUserToDeleteRows = false; + this.gridUsings.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.gridUsings.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.gridUsings.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.colNamespace, + this.colAlias, + this.colStatic, + this.colDelete, + this.colImported}); + this.gridUsings.Location = new System.Drawing.Point(19, 78); + this.gridUsings.Name = "gridUsings"; + dataGridViewCellStyle1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.gridUsings.RowsDefaultCellStyle = dataGridViewCellStyle1; + this.gridUsings.Size = new System.Drawing.Size(482, 230); + this.gridUsings.TabIndex = 8; + this.gridUsings.RowEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.gridUsings_RowEnter); + // + // colNamespace + // + this.colNamespace.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.colNamespace.DataPropertyName = "Namespace"; + this.colNamespace.HeaderText = "Namespace"; + this.colNamespace.Name = "colNamespace"; + this.colNamespace.Width = 98; + // + // colAlias + // + this.colAlias.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.AllCells; + this.colAlias.DataPropertyName = "Alias"; + this.colAlias.HeaderText = "Alias"; + this.colAlias.Name = "colAlias"; + this.colAlias.Width = 59; + // + // colStatic + // + this.colStatic.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.colStatic.DataPropertyName = "Static"; + this.colStatic.HeaderText = "Static"; + this.colStatic.Name = "colStatic"; + this.colStatic.Width = 46; + // + // colDelete + // + this.colDelete.DataPropertyName = "Delete"; + this.colDelete.HeaderText = "Delete"; + this.colDelete.Name = "colDelete"; + this.colDelete.Text = "Delete"; + // + // colImported + // + this.colImported.HeaderText = "Imported"; + this.colImported.Name = "colImported"; + this.colImported.Visible = false; + // + // btnAdd + // + this.btnAdd.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.btnAdd.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.btnAdd.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.btnAdd.Location = new System.Drawing.Point(422, 19); + this.btnAdd.Name = "btnAdd"; + this.btnAdd.Size = new System.Drawing.Size(79, 25); + this.btnAdd.TabIndex = 7; + this.btnAdd.Text = "Add Using"; + this.btnAdd.UseVisualStyleBackColor = true; + // + // chkStatic + // + this.chkStatic.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.chkStatic.AutoSize = true; + this.chkStatic.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chkStatic.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.chkStatic.Location = new System.Drawing.Point(359, 21); + this.chkStatic.Name = "chkStatic"; + this.chkStatic.Size = new System.Drawing.Size(53, 17); + this.chkStatic.TabIndex = 6; + this.chkStatic.Text = "Static"; + this.chkStatic.UseVisualStyleBackColor = true; + // + // tbAlias + // + this.tbAlias.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.tbAlias.BackColor = System.Drawing.Color.WhiteSmoke; + this.tbAlias.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbAlias.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.tbAlias.Location = new System.Drawing.Point(242, 18); + this.tbAlias.Name = "tbAlias"; + this.tbAlias.Size = new System.Drawing.Size(100, 20); + this.tbAlias.TabIndex = 5; + // + // lblAlias + // + this.lblAlias.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.lblAlias.AutoSize = true; + this.lblAlias.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblAlias.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.lblAlias.Location = new System.Drawing.Point(199, 21); + this.lblAlias.Name = "lblAlias"; + this.lblAlias.Size = new System.Drawing.Size(32, 13); + this.lblAlias.TabIndex = 4; + this.lblAlias.Text = "Alias:"; + // + // tbUsing + // + this.tbUsing.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.tbUsing.BackColor = System.Drawing.Color.WhiteSmoke; + this.tbUsing.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.tbUsing.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.tbUsing.Location = new System.Drawing.Point(59, 18); + this.tbUsing.Name = "tbUsing"; + this.tbUsing.Size = new System.Drawing.Size(134, 20); + this.tbUsing.TabIndex = 3; + // + // lblUsing + // + this.lblUsing.AutoSize = true; + this.lblUsing.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.lblUsing.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.lblUsing.Location = new System.Drawing.Point(16, 21); + this.lblUsing.Name = "lblUsing"; + this.lblUsing.Size = new System.Drawing.Size(37, 13); + this.lblUsing.TabIndex = 2; + this.lblUsing.Text = "Using:"; + // + // chkShowImported + // + this.chkShowImported.AutoSize = true; + this.chkShowImported.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.chkShowImported.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); + this.chkShowImported.Location = new System.Drawing.Point(19, 44); + this.chkShowImported.Name = "chkShowImported"; + this.chkShowImported.Size = new System.Drawing.Size(130, 17); + this.chkShowImported.TabIndex = 1; + this.chkShowImported.Text = "Show Imported usings"; + this.chkShowImported.UseVisualStyleBackColor = true; + this.chkShowImported.Click += new System.EventHandler(this.chkShowImported_Click); + // + // XGlobalUsingsPropertyPagePanel + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.grpManageImplicit); + this.Controls.Add(this.grpImpicitGlobalUsings); + this.Margin = new System.Windows.Forms.Padding(5); + this.Name = "XGlobalUsingsPropertyPagePanel"; + this.grpImpicitGlobalUsings.ResumeLayout(false); + this.grpImpicitGlobalUsings.PerformLayout(); + this.grpManageImplicit.ResumeLayout(false); + this.grpManageImplicit.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.gridUsings)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.CheckBox chkImplicitUsings; + private System.Windows.Forms.GroupBox grpImpicitGlobalUsings; + private System.Windows.Forms.GroupBox grpManageImplicit; + private System.Windows.Forms.CheckBox chkShowImported; + private System.Windows.Forms.TextBox tbAlias; + private System.Windows.Forms.Label lblAlias; + private System.Windows.Forms.TextBox tbUsing; + private System.Windows.Forms.Label lblUsing; + private System.Windows.Forms.Button btnAdd; + private System.Windows.Forms.CheckBox chkStatic; + private System.Windows.Forms.DataGridView gridUsings; + private System.Windows.Forms.DataGridViewTextBoxColumn colNamespace; + private System.Windows.Forms.DataGridViewTextBoxColumn colAlias; + private System.Windows.Forms.DataGridViewCheckBoxColumn colStatic; + private System.Windows.Forms.DataGridViewButtonColumn colDelete; + private System.Windows.Forms.DataGridViewCheckBoxColumn colImported; + } +} diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.cs b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.cs new file mode 100644 index 0000000000..3f005d3c0f --- /dev/null +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.cs @@ -0,0 +1,131 @@ +// +// Copyright (c) XSharp B.V. All Rights Reserved. +// Licensed under the Apache License, Version 2.0. +// See License.txt in the project root for license information. +// + +namespace XSharp.Project +{ + using Microsoft.VisualStudio.Project; + + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Drawing; + using System.Linq; + using System.Windows.Forms; + + using XSharp.Settings; + + + + /// + /// Property page contents for the Candle Settings page. + /// + internal partial class XGlobalUsingsPropertyPagePanel : XPropertyPagePanel + { + // ========================================================================================= + // Member Variables + // ========================================================================================= + + XProjectNode Project = null; + ObservableCollection usingList = new ObservableCollection(); + // ========================================================================================= + // Constructors + // ========================================================================================= + + /// + /// Initializes a new instance of the class. + /// + /// The parent property page to which this is bound. + public XGlobalUsingsPropertyPagePanel(XPropertyPage parentPropertyPage) + : base(parentPropertyPage) + { + this.InitializeComponent(); + this.grpImpicitGlobalUsings.Text = GlobalUsingsPropertyPagePanel.captImplicitUsings; + this.chkImplicitUsings.Tag = XSharpProjectFileConstants.ImplicitUsings; + this.chkImplicitUsings.Text = GlobalUsingsPropertyPagePanel.captEnableImplicitUsings; + Color defaultBackground = SystemColors.ButtonFace; + Color defaultForeground = SystemColors.WindowText; + UpdateWindowColors(this, defaultBackground, defaultForeground); + chkShowImported.Checked = true; + } + + protected void ShowItems() + { + Project = this.ParentPropertyPage.ProjectMgr; + if (Project == null) + { return; } + var items = Project.BuildProject.AllEvaluatedItems.Where(i => i.ItemType == "Using"); + usingList.Clear(); + foreach (var item in items) + { + if (item.IsImported && !chkShowImported.Checked) + { + continue; + } + var usingInfo = new UsingInfo(); + usingInfo.Namespace = item.EvaluatedInclude; + usingInfo.Alias = item.GetMetadataValue("Alias"); + var isStatic = item.GetMetadataValue("Static"); + usingInfo.Static = isStatic?.ToLower() == "true"; + usingInfo.Imported = item.IsImported; + usingList.Add(usingInfo); + } + gridUsings.DataSource = usingList; + + } + protected override void OnVisibleChanged(EventArgs e) + { + base.OnVisibleChanged(e); + ShowItems(); + } + + /// + /// Adjust the color values. Adjusts the text color and text + /// area background color + /// + /// The desired color for the background of the text area + /// The desired text color + static void UpdateWindowColors(Control control, Color clrBackground, Color clrForeground) + { + // Update the window background + if (control is TextBox) + control.BackColor = Color.White; + else + control.BackColor = clrBackground; + control.ForeColor = clrForeground; + + // Also update the label + foreach (Control child in control.Controls) + { + UpdateWindowColors(child, clrBackground, clrForeground); + } + } + + private void gridUsings_RowEnter(object sender, DataGridViewCellEventArgs e) + { + var row = gridUsings.Rows[e.RowIndex]; + var usingInfo = row.DataBoundItem as UsingInfo; + if (usingInfo != null) + { + row.ReadOnly = usingInfo.Imported; + } + } + + private void chkShowImported_Click(object sender, EventArgs e) + { + ShowItems(); + } + + } + public class UsingInfo + { + public string Namespace { get; set; } + public string Alias { get; set; } + public bool Static { get; set; } + public bool Imported { get; set; } + public string Delete => "Delete"; + } + +} diff --git a/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.resx b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.resx new file mode 100644 index 0000000000..b622103086 --- /dev/null +++ b/src/VisualStudio/AppDesigner/PropertyPages/XGlobalUsingsPropertyPagePanel.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + \ No newline at end of file diff --git a/src/VisualStudio/AppDesigner/XSharp.AppDesigner2022.pkgdef b/src/VisualStudio/AppDesigner/XSharp.AppDesigner2022.pkgdef index 37055969f3..47db42f0bb 100644 Binary files a/src/VisualStudio/AppDesigner/XSharp.AppDesigner2022.pkgdef and b/src/VisualStudio/AppDesigner/XSharp.AppDesigner2022.pkgdef differ diff --git a/src/VisualStudio/ProjectPackage/Nodes/XSharpProjectNode.cs b/src/VisualStudio/ProjectPackage/Nodes/XSharpProjectNode.cs index 424223757b..17f76c5c96 100644 --- a/src/VisualStudio/ProjectPackage/Nodes/XSharpProjectNode.cs +++ b/src/VisualStudio/ProjectPackage/Nodes/XSharpProjectNode.cs @@ -22,9 +22,7 @@ using System.IO; using System.Linq; using System.Runtime.InteropServices; -using System.Text; using System.Windows.Forms; -using System.Xml.Linq; using VSLangProj; @@ -616,6 +614,7 @@ protected override Guid[] GetPriorityProjectDesignerPages() typeof(XSharpGeneralPropertyPage).GUID, typeof(XSharpLanguagePropertyPage).GUID, typeof(XSharpDialectPropertyPage).GUID, + typeof(XSharpGlobalUsingsPropertiesPage).GUID, typeof(XSharpBuildPropertyPage).GUID, typeof(XSharpBuildEventsPropertyPage).GUID, typeof(XSharpDebugPropertyPage).GUID @@ -634,6 +633,7 @@ protected override Guid[] GetConfigurationIndependentPropertyPages() typeof(XSharpGeneralPropertyPage).GUID, typeof(XSharpLanguagePropertyPage).GUID, typeof(XSharpDialectPropertyPage).GUID, + typeof(XSharpGlobalUsingsPropertiesPage).GUID, }; return result; } @@ -1584,7 +1584,7 @@ public override void AddURL(string url, HierarchyNode node) { if (node is XSharpFileNode xNode && !xNode.IsNonMemberItem) { - if (File.Exists(url) ) + if (File.Exists(url)) { this.ProjectModel.AddFile(url, xNode.FileType); if (IsXamlFile(url)) diff --git a/src/VisualStudio/ProjectPackage/Nodes/XSharpSdkProjectNode.cs b/src/VisualStudio/ProjectPackage/Nodes/XSharpSdkProjectNode.cs index 68dcd86dd4..af21ec35bb 100644 --- a/src/VisualStudio/ProjectPackage/Nodes/XSharpSdkProjectNode.cs +++ b/src/VisualStudio/ProjectPackage/Nodes/XSharpSdkProjectNode.cs @@ -93,6 +93,7 @@ private void RestoreOriginalTargetFrameworks() SetProjectProperty(XSharpProjectFileConstants.TargetFrameworks, frameworks); RemoveProjectProperty(XSharpProjectFileConstants.TargetFramework); RemoveProjectProperty(XSharpProjectFileConstants.XTargetFrameworks); + this.BuildProject.Save(); } } private void SetSingleTargetFramework() @@ -109,6 +110,7 @@ private void SetSingleTargetFramework() RemoveProjectProperty(XSharpProjectFileConstants.TargetFrameworks); SetProjectProperty(XSharpProjectFileConstants.TargetFramework, _targetFrameworks[0]); } + this.BuildProject.Save(); } protected override int UnloadProject() diff --git a/src/VisualStudio/ProjectPackage/XSharpShellEvents.cs b/src/VisualStudio/ProjectPackage/XSharpShellEvents.cs index 97710b952d..7fdc422d53 100644 --- a/src/VisualStudio/ProjectPackage/XSharpShellEvents.cs +++ b/src/VisualStudio/ProjectPackage/XSharpShellEvents.cs @@ -33,13 +33,29 @@ internal XSharpShellEvents() { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); VS.Events.SolutionEvents.OnBeforeOpenProject += SolutionEvents_OnBeforeOpenProject; + VS.Events.SolutionEvents.OnBeforeCloseProject += SolutionEvents_OnBeforeCloseProject; }); } - + #region Project Events - + + private void SolutionEvents_OnBeforeCloseProject(Community.VisualStudio.Toolkit.Project project) + { + var node = XSharpProjectNode.FindProject(project.FullPath); + if (node != null) + { + var prop = node.GetProjectProperty(XSharpProjectFileConstants.XTargetFrameworks); + if (! String.IsNullOrEmpty(prop)) + { + node.RemoveProjectProperty(XSharpProjectFileConstants.XTargetFrameworks); + node.RemoveProjectProperty(XSharpProjectFileConstants.TargetFramework); + node.SetProjectProperty(XSharpProjectFileConstants.TargetFrameworks, prop); + node.BuildProject.Save(); + } + } + } private void SolutionEvents_OnBeforeOpenProject(string projectFileName) { if (IsXSharpProject(projectFileName)) diff --git a/src/VisualStudio/XSharpCodeModelXs/Settings/Strings.prg b/src/VisualStudio/XSharpCodeModelXs/Settings/Strings.prg index a9b456e082..9996f031d2 100644 --- a/src/VisualStudio/XSharpCodeModelXs/Settings/Strings.prg +++ b/src/VisualStudio/XSharpCodeModelXs/Settings/Strings.prg @@ -10,6 +10,13 @@ USING System.Collections.Generic USING System.Text BEGIN NAMESPACE XSharp.Settings + +class GlobalUsingsPropertyPagePanel + const captImplicitUsings := "Implicit Global Usings" as string + const captEnableImplicitUsings := "Enable implicit global usings to be declared by the project SDK." as string + + +end class class DebugPropertyPagePanel const catGeneral := "General" as string const catSpecial := "Special" as string