From 1ab110bb62953141961b131f495c3313a1ed8a7d Mon Sep 17 00:00:00 2001 From: Fabrice Foray Date: Fri, 4 Sep 2026 12:29:20 +0200 Subject: [PATCH 001/180] [VSIntegration] Check existing *.resx files in the ShadowProject, related to the current opened Form; then copy back them to the original X# project. --- .../Commands/CommandSyncDesignerChanges.cs | 7 +- .../Commands/CommandSyncEventHandlers.cs | 11 +- .../ProjectPackage/ProjectPackage2022.csproj | 1 + .../ShadowDesigner/CompanionResourceSync.cs | 130 ++++++++++++++++++ .../ShadowDesigner/CompanionSaveWatcher.cs | 78 ++++++++++- .../ShadowDesigner/ShadowDesignerBridge.cs | 6 +- 6 files changed, 226 insertions(+), 7 deletions(-) create mode 100644 src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionResourceSync.cs diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs b/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs index e03c6133ba..b4dc165d20 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs @@ -73,9 +73,11 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) } DesignerChangesSync.SyncResult result; + CompanionResourceSync.SyncResult resxResult; try { result = DesignerChangesSync.Sync(location); + resxResult = CompanionResourceSync.Sync(location); } catch (Exception ex) { @@ -89,8 +91,11 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) ? $" ({result.SkippedStatements.Count} statement(s) skipped -- unsupported shape, check manually: " + string.Join("; ", result.SkippedStatements) + ")" : ""; + string resxText = resxResult.CopiedFileNames.Count > 0 + ? $" Synced {resxResult.CopiedFileNames.Count} resource file(s)." + : ""; await VS.StatusBar.ShowMessageAsync( - $"Regenerated Form1.Designer.prg: {result.FieldCount} field(s), {result.StatementCount} statement(s).{skippedText}"); + $"Regenerated Form1.Designer.prg: {result.FieldCount} field(s), {result.StatementCount} statement(s).{skippedText}{resxText}"); } } } diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs b/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs index da28fd8c2d..b3c4e13479 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs @@ -74,9 +74,11 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) } EventHandlerSync.SyncResult result; + CompanionResourceSync.SyncResult resxResult; try { result = EventHandlerSync.Sync(location); + resxResult = CompanionResourceSync.Sync(location); } catch (Exception ex) { @@ -84,15 +86,18 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) return; } - if (!result.HasChanges) + if (!result.HasChanges && resxResult.CopiedFileNames.Count == 0) { - await VS.StatusBar.ShowMessageAsync("Nothing new to sync -- no new handler stubs or event wiring found."); + await VS.StatusBar.ShowMessageAsync("Nothing new to sync -- no new handler stubs, event wiring, or resource files found."); return; } await VS.Commands.ExecuteAsync(KnownCommands.File_OpenFile, location.MainPrgPath); + string resxText = resxResult.CopiedFileNames.Count > 0 + ? $", {resxResult.CopiedFileNames.Count} resource file(s)" + : ""; await VS.StatusBar.ShowMessageAsync( - $"Synced {result.NewHandlerNames.Count} handler stub(s) and {result.NewWiringDescriptions.Count} event wiring statement(s)."); + $"Synced {result.NewHandlerNames.Count} handler stub(s) and {result.NewWiringDescriptions.Count} event wiring statement(s){resxText}."); } } } diff --git a/src/VisualStudio/ProjectPackage/ProjectPackage2022.csproj b/src/VisualStudio/ProjectPackage/ProjectPackage2022.csproj index af5dc2a527..e8d996c877 100644 --- a/src/VisualStudio/ProjectPackage/ProjectPackage2022.csproj +++ b/src/VisualStudio/ProjectPackage/ProjectPackage2022.csproj @@ -484,6 +484,7 @@ + diff --git a/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionResourceSync.cs b/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionResourceSync.cs new file mode 100644 index 0000000000..4def2a8bd2 --- /dev/null +++ b/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionResourceSync.cs @@ -0,0 +1,130 @@ +// +// 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. +// +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace XSharp.Project.ShadowDesigner +{ + /// + /// Copies a form's .resx file(s) -- the neutral Form1.resx and any culture-specific + /// siblings the Designer creates when a form's Language property is changed, e.g. + /// Form1.nl.resx -- from the companion project's folder back to the real project's + /// folder, next to the real .prg. Unlike Form1.Designer.cs, nothing else in the bridge + /// ever copies these over: EventHandlerSync/DesignerChangesSync only look at C# source, + /// so a resx the Designer writes into the companion project is otherwise silently + /// stranded there. + /// + /// Assumes the real .xsproj's SDK-style default item globbing already picks up a .resx + /// file dropped into its folder as an EmbeddedResource (the same implicit-globbing + /// behavior already relied on for .prg Compile items elsewhere in this bridge) -- no + /// project-file edit is made here, only a file copy. + /// + /// What about other external files (Images, ??? ); Time will tell. + /// + /// + internal static class CompanionResourceSync + { + public sealed class SyncResult + { + public List CopiedFileNames { get; } = new List(); + } + + public static SyncResult Sync(ShadowDesignerBridge.CompanionLocation location) + { + var result = new SyncResult(); + + string companionDir = Path.GetDirectoryName(location.CompanionDesignerCsPath); + string realDir = Path.GetDirectoryName(location.MainPrgPath); + string className = Path.GetFileNameWithoutExtension(location.MainPrgPath); + if (string.IsNullOrEmpty(companionDir) || string.IsNullOrEmpty(realDir) || !Directory.Exists(companionDir)) + { + return result; + } + + foreach (string companionResxPath in Directory.EnumerateFiles(companionDir, className + "*.resx")) + { + string fileName = Path.GetFileName(companionResxPath); + if (!IsResxForClass(fileName, className)) + { + continue; + } + + string realResxPath = Path.Combine(realDir, fileName); + if (FilesDiffer(companionResxPath, realResxPath)) + { + File.Copy(companionResxPath, realResxPath, overwrite: true); + result.CopiedFileNames.Add(fileName); + } + } + + return result; + } + + /// + /// Bootstraps the companion folder from any .resx already sitting next to the real + /// .prg (e.g. an icon on a form carried over before the bridge ever ran) -- called + /// once, right after the companion project/files are (re)written, so the Designer + /// doesn't open against a blank resource set the first time. Deliberately one-way and + /// non-destructive: only copies a file the companion side doesn't have yet, never + /// overwrites an existing companion .resx -- the real project is otherwise always the + /// source of truth once has run at least once (companion -> real). + /// + public static void PrimeFromReal(ShadowDesignerBridge.CompanionLocation location) + { + string companionDir = Path.GetDirectoryName(location.CompanionDesignerCsPath); + string realDir = Path.GetDirectoryName(location.MainPrgPath); + string className = Path.GetFileNameWithoutExtension(location.MainPrgPath); + if (string.IsNullOrEmpty(companionDir) || string.IsNullOrEmpty(realDir) || !Directory.Exists(realDir)) + { + return; + } + Directory.CreateDirectory(companionDir); + + foreach (string realResxPath in Directory.EnumerateFiles(realDir, className + "*.resx")) + { + string fileName = Path.GetFileName(realResxPath); + if (!IsResxForClass(fileName, className)) + { + continue; + } + + string companionResxPath = Path.Combine(companionDir, fileName); + if (!File.Exists(companionResxPath)) + { + File.Copy(realResxPath, companionResxPath); + } + } + } + + /// + /// Matches "Form1.resx" and culture-qualified siblings like "Form1.nl.resx" / + /// "Form1.de-DE.resx", but not an unrelated form sharing the same companion folder + /// whose name merely starts with the same characters (e.g. "Form10.resx" must NOT + /// match className "Form1"). + /// + private static bool IsResxForClass(string fileName, string className) + { + if (!fileName.EndsWith(".resx", StringComparison.OrdinalIgnoreCase)) + { + return false; + } + string stem = fileName.Substring(0, fileName.Length - ".resx".Length); + return stem.Equals(className, StringComparison.OrdinalIgnoreCase) + || stem.StartsWith(className + ".", StringComparison.OrdinalIgnoreCase); + } + + private static bool FilesDiffer(string companionPath, string realPath) + { + if (!File.Exists(realPath)) + { + return true; + } + return !File.ReadAllBytes(companionPath).SequenceEqual(File.ReadAllBytes(realPath)); + } + } +} diff --git a/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionSaveWatcher.cs b/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionSaveWatcher.cs index e2ecb91a21..64f9561889 100644 --- a/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionSaveWatcher.cs +++ b/src/VisualStudio/ProjectPackage/ShadowDesigner/CompanionSaveWatcher.cs @@ -51,6 +51,15 @@ internal sealed class CompanionSaveWatcher : IVsRunningDocTableEvents private static readonly Dictionary _watched = new Dictionary(StringComparer.OrdinalIgnoreCase); + // Keyed by the companion project's folder -> every form's location known to live + // there. A .resx the Designer writes (e.g. a newly added Form1.nl.resx from changing + // the form's Language property) doesn't necessarily touch Form1.cs/Form1.Designer.cs + // at all, so it's never a key in _watched above -- this lets OnAfterSave still + // recognize "a resx under a known companion folder was just saved" and resolve which + // form it belongs to by filename prefix, via CompanionResourceSync. + private static readonly Dictionary> _companionDirs = + new Dictionary>(StringComparer.OrdinalIgnoreCase); + private readonly IVsRunningDocumentTable _rdt; private readonly DTE2 _dte; private bool _syncing; @@ -89,6 +98,18 @@ public static void Watch(ProjectNode projectMgr, ShadowDesignerBridge.CompanionL } _watched[location.CompanionFormCsPath] = location; _watched[location.CompanionDesignerCsPath] = location; + + string companionDir = Path.GetDirectoryName(location.CompanionDesignerCsPath); + if (!string.IsNullOrEmpty(companionDir)) + { + if (!_companionDirs.TryGetValue(companionDir, out var locations)) + { + locations = new List(); + _companionDirs[companionDir] = locations; + } + locations.RemoveAll(l => string.Equals(l.MainPrgPath, location.MainPrgPath, StringComparison.OrdinalIgnoreCase)); + locations.Add(location); + } } public int OnAfterSave(uint docCookie) @@ -103,8 +124,18 @@ public int OnAfterSave(uint docCookie) } string path = GetDocumentMoniker(docCookie); - if (string.IsNullOrEmpty(path) || !_watched.TryGetValue(path, out var location)) + if (string.IsNullOrEmpty(path)) + { + return VSConstants.S_OK; + } + + if (!_watched.TryGetValue(path, out var location)) { + // Not Form1.cs/Form1.Designer.cs -- still worth checking whether this is a + // .resx living directly in a known companion folder (e.g. a new + // Form1.nl.resx from changing the form's Language property), since that can + // be saved without either code file ever becoming dirty. + TryHandleResxOnlySave(path); return VSConstants.S_OK; } @@ -119,6 +150,7 @@ public int OnAfterSave(uint docCookie) _dte.ExecuteCommand("File.SaveAll"); EventHandlerSync.Sync(location); DesignerChangesSync.Sync(location); + CompanionResourceSync.Sync(location); } catch (Exception ex) { @@ -133,6 +165,49 @@ public int OnAfterSave(uint docCookie) return VSConstants.S_OK; } + /// + /// Handles a save of a .resx file that isn't Form1.cs/Form1.Designer.cs itself -- + /// resolves which form it belongs to (by companion folder + filename prefix) and + /// copies it to the real project, without running the code-sync steps that only + /// apply to Form1.cs/Form1.Designer.cs saves. + /// + private void TryHandleResxOnlySave(string path) + { + if (!path.EndsWith(".resx", StringComparison.OrdinalIgnoreCase)) + { + return; + } + string dir = Path.GetDirectoryName(path); + if (string.IsNullOrEmpty(dir) || !_companionDirs.TryGetValue(dir, out var locations)) + { + return; + } + string fileName = Path.GetFileName(path); + var location = locations.FirstOrDefault(l => + { + string className = Path.GetFileNameWithoutExtension(l.MainPrgPath); + return fileName.StartsWith(className, StringComparison.OrdinalIgnoreCase); + }); + if (location == null) + { + return; + } + + _syncing = true; + try + { + CompanionResourceSync.Sync(location); + } + catch (Exception ex) + { + Logger.Exception(ex, "CompanionSaveWatcher.TryHandleResxOnlySave: resx sync failed"); + } + finally + { + _syncing = false; + } + } + private string GetDocumentMoniker(uint docCookie) { int hr = _rdt.GetDocumentInfo(docCookie, out _, out _, out _, out string moniker, out _, out _, out _); @@ -180,6 +255,7 @@ public int OnBeforeDocumentWindowShow(uint docCookie, int fFirstShow, IVsWindowF // companion buffer without that being on disk yet. _dte.ExecuteCommand("File.SaveAll"); result = EventHandlerSync.Sync(location); + CompanionResourceSync.Sync(location); } catch (Exception ex) { diff --git a/src/VisualStudio/ProjectPackage/ShadowDesigner/ShadowDesignerBridge.cs b/src/VisualStudio/ProjectPackage/ShadowDesigner/ShadowDesignerBridge.cs index 91164882df..8b18401cd8 100644 --- a/src/VisualStudio/ProjectPackage/ShadowDesigner/ShadowDesignerBridge.cs +++ b/src/VisualStudio/ProjectPackage/ShadowDesigner/ShadowDesignerBridge.cs @@ -141,14 +141,16 @@ public static bool TryOpen(XSharpFileNode fileNode, out string error) var companion = CompanionProjectWriter.EnsureCompanionProject( xProject.FileName, referencePaths, shadowCSharp, namespaceName, className); - CompanionSaveWatcher.Watch(fileNode.ProjectMgr, new CompanionLocation + var location = new CompanionLocation { MainPrgPath = mainPrgPath, DesignerPrgPath = designerPrgPath, CompanionCsprojPath = companion.CsprojPath, CompanionFormCsPath = CompanionProjectWriter.ComputeFormCsPath(xProject.FileName, className), CompanionDesignerCsPath = companion.DesignerCsPath, - }); + }; + CompanionResourceSync.PrimeFromReal(location); + CompanionSaveWatcher.Watch(fileNode.ProjectMgr, location); ShadowDesignerCleanup.Track(companion.CsprojPath); SolutionWiring.EnsureProjectInSolution(dte, companion.CsprojPath); From 0b73ddccc2b220be104aa3c5528882a5a20f6d44 Mon Sep 17 00:00:00 2001 From: Robert van der Hulst Date: Tue, 29 Sep 2026 16:00:01 +0200 Subject: [PATCH 002/180] [Runtime] Changed dialect from VO to XBaseNet for several projects. Only XSharp.VO has the VO dialect. --- .../XSharp.Harbour/XSharp.Harbour.Next.xsproj | 2 +- .../XSharp.Harbour/XSharp.Harbour.xsproj | 2 +- src/Runtime/XSharp.RT/XSharp.RT.xsproj | 4 +- src/Runtime/XSharp.VFP/ArrayFunctions.prg | 10 +- src/Runtime/XSharp.VFP/BitFunctions.prg | 50 +++--- src/Runtime/XSharp.VFP/ClassFunctions.prg | 8 +- .../XSharp.VFP/Cursors/DbFunctions.prg | 6 +- .../XSharp.VFP/Database/DbFunctions.prg | 10 +- src/Runtime/XSharp.VFP/DateFunctions.prg | 4 +- src/Runtime/XSharp.VFP/DebugFunctions.prg | 12 +- src/Runtime/XSharp.VFP/Defines.prg | 138 +++++++------- src/Runtime/XSharp.VFP/FileFunctions.prg | 62 +++---- src/Runtime/XSharp.VFP/FoxCompilerSupport.prg | 10 +- src/Runtime/XSharp.VFP/GatherScatter.prg | 22 +-- src/Runtime/XSharp.VFP/GetWord.prg | 170 +++++++++--------- src/Runtime/XSharp.VFP/Keyboard.prg | 24 +-- src/Runtime/XSharp.VFP/MiscFunctions.prg | 8 +- src/Runtime/XSharp.VFP/PrinterFunctions.prg | 2 +- .../XSharp.VFP/RuntimeCoreWrappers.prg | 2 +- src/Runtime/XSharp.VFP/SQL/EmbeddedSql.prg | 14 +- src/Runtime/XSharp.VFP/StringFunctions.prg | 48 ++--- src/Runtime/XSharp.VFP/SystemFunctions.prg | 29 +-- src/Runtime/XSharp.VFP/Types/Attributes.prg | 4 +- src/Runtime/XSharp.VFP/UI/VfpUIService.prg | 2 +- src/Runtime/XSharp.VFP/WindowFunctions.prg | 4 +- src/Runtime/XSharp.VFP/XSharp.VFP.Next.xsproj | 11 +- src/Runtime/XSharp.VFP/XSharp.VFP.xsproj | 11 +- src/Runtime/XSharp.XPP/XSharp.XPP.Next.xsproj | 2 +- src/Runtime/XSharp.XPP/XSharp.XPP.xsproj | 2 +- 29 files changed, 336 insertions(+), 337 deletions(-) diff --git a/src/Runtime/XSharp.Harbour/XSharp.Harbour.Next.xsproj b/src/Runtime/XSharp.Harbour/XSharp.Harbour.Next.xsproj index e327da440a..87fae009ff 100644 --- a/src/Runtime/XSharp.Harbour/XSharp.Harbour.Next.xsproj +++ b/src/Runtime/XSharp.Harbour/XSharp.Harbour.Next.xsproj @@ -3,7 +3,7 @@ XSharp.Harbour XSharp.Harbour - VO + XBaseNet true true true diff --git a/src/Runtime/XSharp.Harbour/XSharp.Harbour.xsproj b/src/Runtime/XSharp.Harbour/XSharp.Harbour.xsproj index c2e9c14f4f..6458235e58 100644 --- a/src/Runtime/XSharp.Harbour/XSharp.Harbour.xsproj +++ b/src/Runtime/XSharp.Harbour/XSharp.Harbour.xsproj @@ -7,7 +7,7 @@ XSharp.Harbour XSharp.Harbour XSharp.Harbour - VO + XBaseNet XSharp.Harbour true true diff --git a/src/Runtime/XSharp.RT/XSharp.RT.xsproj b/src/Runtime/XSharp.RT/XSharp.RT.xsproj index f353a9e9d9..4c49a50cba 100644 --- a/src/Runtime/XSharp.RT/XSharp.RT.xsproj +++ b/src/Runtime/XSharp.RT/XSharp.RT.xsproj @@ -7,7 +7,7 @@ XSharp.RT XSharp.RT XSharp.RT - VO + XBaseNet XSharp.RT true true @@ -24,6 +24,8 @@ 4 False AnyCPU + true + false DEBUG;TRACE;RUNTIME;DOCUMENTATION diff --git a/src/Runtime/XSharp.VFP/ArrayFunctions.prg b/src/Runtime/XSharp.VFP/ArrayFunctions.prg index 8673e88aba..8de9d003ec 100644 --- a/src/Runtime/XSharp.VFP/ArrayFunctions.prg +++ b/src/Runtime/XSharp.VFP/ArrayFunctions.prg @@ -257,7 +257,7 @@ FUNCTION ALines ( ArrayName AS USUAL, cExpression AS STRING, nFlags := 0 AS INT, VAR separators := List{} - IF cParseChars == NULL OR cParseChars:Length == 0 + IF cParseChars == NULL .OR. cParseChars:Length == 0 separators:Add(e"\r\n") separators:Add(e"\r") separators:Add(e"\n") @@ -303,11 +303,11 @@ FUNCTION ALines ( ArrayName AS USUAL, cExpression AS STRING, nFlags := 0 AS INT, lIsSeparator := (nIndex % 2) == 1 ENDIF - IF lTrim AND !lIsSeparator + IF lTrim .AND. !lIsSeparator sTemp := sTemp:Trim() ENDIF - IF lNoEmpty AND String.IsNullOrEmpty(sTemp) AND !lIsSeparator + IF lNoEmpty .AND. String.IsNullOrEmpty(sTemp) .AND. !lIsSeparator nIndex++ LOOP ENDIF @@ -316,7 +316,7 @@ FUNCTION ALines ( ArrayName AS USUAL, cExpression AS STRING, nFlags := 0 AS INT, nIndex++ NEXT - IF !lIncludeLast AND !lNoEmpty AND finalLines:Count > 0 + IF !lIncludeLast .AND. !lNoEmpty .AND. finalLines:Count > 0 VAR nLastIdx := finalLines:Count - 1 IF String.IsNullOrEmpty(finalLines[nLastIdx]) finalLines:RemoveAt(nLastIdx) @@ -325,7 +325,7 @@ FUNCTION ALines ( ArrayName AS USUAL, cExpression AS STRING, nFlags := 0 AS INT, VAR nRows := (DWORD)finalLines:Count - IF nRows == 0 AND !lNoEmpty + IF nRows == 0 .AND. !lNoEmpty nRows := 1 finalLines:Add("") ENDIF diff --git a/src/Runtime/XSharp.VFP/BitFunctions.prg b/src/Runtime/XSharp.VFP/BitFunctions.prg index 9aa944ee2a..86267fcf0e 100644 --- a/src/Runtime/XSharp.VFP/BitFunctions.prg +++ b/src/Runtime/XSharp.VFP/BitFunctions.prg @@ -41,7 +41,7 @@ FUNCTION BitClear (Arg1 AS USUAL, Bit AS USUAL) AS USUAL ENDIF IF IsBinary(Arg1) VAR binValue := (BINARY) Arg1 - RETURN IIF(binValue.Length == 0, 0h, BitClear(binValue, (INT)Bit, 1)) + RETURN IIF(binValue:Length == 0, 0h, BitClear(binValue, (INT)Bit, 1)) ELSEIF IsNumeric(Arg1) RETURN BitClear((INT)Arg1, (INT)Bit) ELSE @@ -69,13 +69,13 @@ END FUNC /// FUNCTION BitClear (BinString AS BINARY) AS BINARY - RETURN IIF(BinString.Length == 0, 0h, BitClear(BinString, 0, BinString.Length * 8)) + RETURN IIF(BinString:Length == 0, 0h, BitClear(BinString, 0, BinString:Length * 8)) END FUNC /// FUNCTION BitClear (BinString AS BINARY, StartBit AS INT) AS BINARY - RETURN IIF(BinString.Length == 0, 0h, BitClear(BinString, StartBit, 1)) + RETURN IIF(BinString:Length == 0, 0h, BitClear(BinString, StartBit, 1)) END FUNC /// @@ -89,7 +89,7 @@ FUNCTION BitClear (BinString AS BINARY, StartBit AS INT, BitCount AS INT) AS BIN FOR BitCounter := 1 TO BitCount ByteIndex := BitIndex / 8 + 1 - IF BETWEEN(ByteIndex, 1, Result.Length) + IF BETWEEN(ByteIndex, 1, Result:Length) Result[ByteIndex] := (BYTE) _AND(Result[ByteIndex],_NOT(1 << BitIndex % 8)) BitIndex++ ELSE @@ -137,7 +137,7 @@ END FUNC /// FUNCTION BitNot (BinString AS BINARY) AS BINARY - RETURN BitNot(BinString, 0, BinString.Length * 8) + RETURN BitNot(BinString, 0, BinString:Length * 8) END FUNC /// @@ -150,7 +150,7 @@ FUNCTION BitNot (BinString AS BINARY, StartBit AS INT, BitCount := 1 AS INT) AS FOR BitCounter := 1 TO BitCount ByteIndex := BitIndex / 8 + 1 - IF BETWEEN(ByteIndex, 1, Result.Length) + IF BETWEEN(ByteIndex, 1, Result:Length) Result[ByteIndex] := (BYTE) _XOR(Result[ByteIndex], 1 << BitIndex % 8) BitIndex++ ELSE @@ -239,12 +239,12 @@ END FUNC /// FUNCTION BitSet (BinString AS BINARY) AS BINARY - RETURN IIF(BinString.Length == 0, 0h, BitSet(BinString, 0, BinString.Length * 8)) + RETURN IIF(BinString:Length == 0, 0h, BitSet(BinString, 0, BinString:Length * 8)) END FUNC /// FUNCTION BitSet (BinString AS BINARY, StartBit AS INT) AS BINARY - RETURN IIF(BinString.Length == 0, 0h, BitSet(BinString, StartBit, 1)) + RETURN IIF(BinString:Length == 0, 0h, BitSet(BinString, StartBit, 1)) END FUNC /// @@ -258,7 +258,7 @@ FUNCTION BitSet (BinString AS BINARY, StartBit AS INT, BitCount AS INT) AS BINAR FOR BitCounter := 1 TO BitCount ByteIndex := BitIndex / 8 + 1 - IF BETWEEN(ByteIndex, 1, Result.Length) + IF BETWEEN(ByteIndex, 1, Result:Length) Result[ByteIndex] := (BYTE) _OR(Result[ByteIndex], 1 << BitIndex % 8) BitIndex++ ELSE @@ -299,7 +299,7 @@ FUNCTION BitTest (BinString AS BINARY, BitNumber AS INT) AS LOGIC LOCAL Buff := BinString AS BYTE[] - IF BETWEEN(BitNumber, 0, Buff.Length * 8 - 1) + IF BETWEEN(BitNumber, 0, Buff:Length * 8 - 1) RETURN _AND(Buff[BitNumber / 8 + 1], 1 << BitNumber % 8) != 0 ELSE THROW Error.ArgumentError(__FUNCTION__, nameof(BitNumber),2) @@ -327,19 +327,19 @@ INTERNAL STATIC CLASS BitHelpers STATIC METHOD _BITANDORX (LogicalOp AS BitOperation, Arg1 AS USUAL, Arg2 PARAMS USUAL[]) AS USUAL IF IsBinary(Arg1) - VAR Args = BINARY[]{Arg2.Length} + VAR Args := BINARY[]{Arg2:Length} LOCAL ArgIndex AS INT - FOR ArgIndex := 1 TO Args.Length + FOR ArgIndex := 1 TO Args:Length Args[ArgIndex] := (BINARY)Arg2[ArgIndex] NEXT RETURN _BITANDORX(LogicalOp, (BINARY)Arg1, Args) ELSEIF IsLong(Arg1) - VAR Args = INT[]{Arg2.Length} + VAR Args := INT[]{Arg2:Length} LOCAL ArgIndex AS INT - FOR ArgIndex := 1 TO Args.Length + FOR ArgIndex := 1 TO Args:Length Args[ArgIndex] := (INT)Arg2[ArgIndex] NEXT @@ -356,15 +356,15 @@ STATIC METHOD _BITANDORX (LogicalOp AS BitOperation, Arg1 AS INT, Arg2 PARAMS IN SWITCH LogicalOp CASE BitOperation.And - FOR ArgIndex := 1 TO Arg2.Length + FOR ArgIndex := 1 TO Arg2:Length Result := _AND(Result, Arg2[ArgIndex]) NEXT CASE BitOperation.Or - FOR ArgIndex := 1 TO Arg2.Length + FOR ArgIndex := 1 TO Arg2:Length Result := _OR(Result, Arg2[ArgIndex]) NEXT CASE BitOperation.Xor - FOR ArgIndex := 1 TO Arg2.Length + FOR ArgIndex := 1 TO Arg2:Length Result := _XOR(Result, Arg2[ArgIndex]) NEXT END @@ -378,27 +378,27 @@ STATIC METHOD _BITANDORX (LogicalOp AS BitOperation, Arg1 AS BINARY, Arg2 PARAMS LOCAL Result := 0h + Arg1 AS BYTE[] LOCAL ArgIndex AS INT - FOR ArgIndex := 1 TO Arg2.Length + FOR ArgIndex := 1 TO Arg2:Length LOCAL Arg := 0h + Arg2[ArgIndex] AS BYTE[] - IF Result.Length < Arg.Length - Array.Resize(REF Result, Arg.Length) + IF Result:Length < Arg:Length + Array.Resize(REF Result, Arg:Length) ELSE - IF Result.Length > Arg.Length - Array.Resize(REF Arg, Result.Length) + IF Result:Length > Arg:Length + Array.Resize(REF Arg, Result:Length) ENDIF ENDIF LOCAL ByteIndex AS INT SWITCH LogicalOp CASE BitOperation.And - FOR ByteIndex := 1 TO Result.Length + FOR ByteIndex := 1 TO Result:Length Result[ByteIndex] := _AND(Result[ByteIndex], Arg[ByteIndex]) NEXT CASE BitOperation.Or - FOR ByteIndex := 1 TO Result.Length + FOR ByteIndex := 1 TO Result:Length Result[ByteIndex] := _OR(Result[ByteIndex], Arg[ByteIndex]) NEXT CASE BitOperation.Xor - FOR ByteIndex := 1 TO Result.Length + FOR ByteIndex := 1 TO Result:Length Result[ByteIndex] := _XOR(Result[ByteIndex], Arg[ByteIndex]) NEXT END diff --git a/src/Runtime/XSharp.VFP/ClassFunctions.prg b/src/Runtime/XSharp.VFP/ClassFunctions.prg index c19fca395b..fb4e536f98 100644 --- a/src/Runtime/XSharp.VFP/ClassFunctions.prg +++ b/src/Runtime/XSharp.VFP/ClassFunctions.prg @@ -16,7 +16,7 @@ FUNCTION AddProperty (oObjectName AS OBJECT, cPropertyName AS STRING, eNewValue oDynamic:_AddProperty(cPropertyName, eNewValue,1,"") else Send(oObjectName,#AddProperty,cPropertyName, eNewValue) - endi + endif return true @@ -120,7 +120,7 @@ FUNCTION AClass(ArrayName AS USUAL, oExpression AS USUAL) AS DWORD ENDIF IF IsObject(oExpression) - oType = ((OBJECT)oExpression):GetType() + oType := ((OBJECT)oExpression):GetType() ELSEIF IsString(oExpression) VAR cName := (STRING)oExpression oType := Type.GetType(cName, FALSE, TRUE) @@ -175,8 +175,8 @@ FUNCTION ASessions (ArrayName AS USUAL) AS DWORD LOCAL nIdx := 0 AS DWORD FOREACH VAR oSession IN sessions VAR nBase := (INT)(nIdx * 2) - aFoxArray.__SetElement(oSession:Id, nBase) - aFoxArray.__SetElement(oSession:Name, nBase + 1) + aFoxArray:__SetElement(oSession:Id, nBase) + aFoxArray:__SetElement(oSession:Name, nBase + 1) nIdx += 1 NEXT diff --git a/src/Runtime/XSharp.VFP/Cursors/DbFunctions.prg b/src/Runtime/XSharp.VFP/Cursors/DbFunctions.prg index 4dc7229322..b95c89b336 100644 --- a/src/Runtime/XSharp.VFP/Cursors/DbFunctions.prg +++ b/src/Runtime/XSharp.VFP/Cursors/DbFunctions.prg @@ -48,7 +48,7 @@ FUNCTION Descending( uIndex, uArea) AS USUAL CLIPPER [FoxProFunction("FIELD", FoxFunctionCategory.CursorAndTable, FoxEngine.WorkArea, FoxFunctionStatus.Full, FoxCriticality.High)]; FUNCTION Field( uField , uArea, nFlag) AS STRING CLIPPER LOCAL nInfo as LONG - @@Default(@nFlag, 0) + Default( REF nFlag, 0) IF nFlag == 1 nInfo := DBS_CAPTION ELSE @@ -288,7 +288,7 @@ FUNCTION SetFldState(uField, nFieldState, uArea) AS LOGIC CLIPPER /// [FoxProFunction("INDEXSEEK", FoxFunctionCategory.Database, FoxEngine.WorkArea, FoxFunctionStatus.Full, FoxCriticality.High)]; FUNCTION IndexSeek( eExpression , lMovePointer , uArea, uIndex) AS LOGIC CLIPPER - @@Default(@lMovePointer, FALSE) + Default(REF lMovePointer, FALSE) LOCAL nArea := _AreaFromParam(uArea) AS DWORD IF nArea == 0 @@ -349,7 +349,7 @@ INTERNAL FUNCTION _AreaFromParam(uArea AS USUAL) AS DWORD IF IsNil(uArea) RETURN RuntimeState.CurrentWorkarea ELSEIF IsString(uArea) - RETURN RuntimeState.Workareas.FindAlias((STRING) uArea) + RETURN RuntimeState.Workareas:FindAlias((STRING) uArea) ELSEIF IsNumeric(uArea) RETURN (DWORD) uArea ENDIF diff --git a/src/Runtime/XSharp.VFP/Database/DbFunctions.prg b/src/Runtime/XSharp.VFP/Database/DbFunctions.prg index b075c37fcd..cf8ec239b9 100644 --- a/src/Runtime/XSharp.VFP/Database/DbFunctions.prg +++ b/src/Runtime/XSharp.VFP/Database/DbFunctions.prg @@ -152,9 +152,9 @@ INTERNAL FUNCTION __DbFieldListHelper(aFieldList AS ARRAY, cIncludedFields AS ST next ENDIF lAll := ALen(aFieldList) == 0 .and. String.IsNullOrEmpty(cIncludedFields) - LOCAL fCount as DWORD - fCount := FCount() - FOR VAR nFld := 1u to fCount + LOCAL ffCount as DWORD + ffCount := FCount() + FOR VAR nFld := 1u to ffCount LOCAL lInclude AS LOGIC LOCAL oVar := NULL AS OBJECT VoDb.FieldInfo( DBS_STRUCT, nFld, REF oVar) @@ -507,7 +507,7 @@ FUNCTION DbUseAreaFox(uArea, cDataFile, cAlias, lShared, lReadOnly, ; endif // locate the area with the same filename for var i := 1u to Workareas.MaxWorkareas - var area := RuntimeState.DataSession.GetRDD(i) + var area := RuntimeState.DataSession:GetRDD(i) if area is Workarea var wa .and. String.Compare(wa:FileName, cDataFile, TRUE) == 0 lShared := wa:Shared lReadOnly := wa:ReadOnly @@ -518,7 +518,7 @@ FUNCTION DbUseAreaFox(uArea, cDataFile, cAlias, lShared, lReadOnly, ; if IsNil(cAlias) cAlias := System.IO.Path.GetFileNameWithoutExtension( cDataFile ):ToUpper() if VoDbGetSelect(cAlias) > 0 - cAlias := Chr(64+RuntimeState.DataSession.CurrentWorkareaNO) + cAlias := Chr(64+RuntimeState.DataSession:CurrentWorkareaNO) DO WHILE VoDbGetSelect(cAlias) > 0 cAlias := Chr(Asc(cAlias)+1) ENDDO diff --git a/src/Runtime/XSharp.VFP/DateFunctions.prg b/src/Runtime/XSharp.VFP/DateFunctions.prg index a6dc015ccd..dfb121dc26 100644 --- a/src/Runtime/XSharp.VFP/DateFunctions.prg +++ b/src/Runtime/XSharp.VFP/DateFunctions.prg @@ -210,7 +210,7 @@ FUNCTION CToT(cCharacterExpression AS STRING) AS System.DateTime ENDIF RETURN DateTime.MinValue -ENDFUNC +END FUNCTION /// [FoxProFunction("TTOC", FoxFunctionCategory.DateAndTime, FoxEngine.LanguageCore, FoxFunctionStatus.Full, FoxCriticality.High)]; @@ -246,7 +246,7 @@ FUNCTION TToC(tdExpression AS System.DateTime, nParam := 0 AS LONG) AS STRING END SWITCH RETURN lcResult -ENDFUNC +END FUNCTION /// /// diff --git a/src/Runtime/XSharp.VFP/DebugFunctions.prg b/src/Runtime/XSharp.VFP/DebugFunctions.prg index ef0a2bb627..9e4386cc3f 100644 --- a/src/Runtime/XSharp.VFP/DebugFunctions.prg +++ b/src/Runtime/XSharp.VFP/DebugFunctions.prg @@ -90,10 +90,10 @@ FUNCTION AStackInfo (ArrayName AS USUAL) AS DWORD VAR oMethod := oFrame:GetMethod() VAR nBase := (INT)(nIdx * 6) - aFoxArray.__SetElement(nIdx + 1, nBase) // Col 1: Stack Level + aFoxArray:__SetElement(nIdx + 1, nBase) // Col 1: Stack Level VAR cFile := oFrame:GetFileName() - aFoxArray.__SetElement(IIF(cFile != NULL, cFile, ""), nBase + 1) // Col 2: File + aFoxArray:__SetElement(IIF(cFile != NULL, cFile, ""), nBase + 1) // Col 2: File VAR cModule := "" IF oMethod:DeclaringType != NULL @@ -102,10 +102,10 @@ FUNCTION AStackInfo (ArrayName AS USUAL) AS DWORD cModule := oMethod:Name ENDIF - aFoxArray.__SetElement(cModule, nBase + 2) // Col 3: Module/Object - aFoxArray.__SetElement(IIF(cFile != NULL, cFile, ""), nBase + 3) // Col 4: Source file - aFoxArray.__SetElement(oFrame:GetFileLineNumber(), nBase + 4) // Col 5: Line - aFoxArray.__SetElement("", nBase + 5) // Col 6: Source content (n/a) + aFoxArray:__SetElement(cModule, nBase + 2) // Col 3: Module/Object + aFoxArray:__SetElement(IIF(cFile != NULL, cFile, ""), nBase + 3) // Col 4: Source file + aFoxArray:__SetElement(oFrame:GetFileLineNumber(), nBase + 4) // Col 5: Line + aFoxArray:__SetElement("", nBase + 5) // Col 6: Source content (n/a) nIdx += 1 NEXT diff --git a/src/Runtime/XSharp.VFP/Defines.prg b/src/Runtime/XSharp.VFP/Defines.prg index d6201e54e7..050992b9e8 100644 --- a/src/Runtime/XSharp.VFP/Defines.prg +++ b/src/Runtime/XSharp.VFP/Defines.prg @@ -5,7 +5,7 @@ // // The defines below are imported from FoxPro.h -************************************************************************************ +/*********************************************************************************** ************************************************************************************ ** ** ** ================ =========== ** @@ -30,16 +30,16 @@ ** This file contains named constants for most Visual FoxPro functions ** ** ** ************************************************************************************ -************************************************************************************ +***********************************************************************************/ -*-- General -*--ZOrder Method +//-- General +//--ZOrder Method /// DEFINE ZORDER_BRINGTOFRONT := 0 /// DEFINE ZORDER_SENDTOBACK := 1 -*-- TYPE() tags +//-- TYPE() tags /// DEFINE T_CHARACTER := "C" /// @@ -73,7 +73,7 @@ DEFINE T_VARBINARY := "Q" /// DEFINE T_BLOB := "W" -*-- QueryUnload +//-- QueryUnload /// DEFINE FORM_CONTROLMENU := 0 /// @@ -86,7 +86,7 @@ DEFINE APP_TASKMANAGER := 3 DEFINE FORM_MDIFORM := 4 /// -*-- Columns in array returned by AVCXCLASSES() +//-- Columns in array returned by AVCXCLASSES() /// DEFINE AVCX_CLASS := 1 // OBJNAME field /// @@ -111,8 +111,8 @@ DEFINE AVCX_USERINFO := 10 // USER field DEFINE AVCX_OLEPUBLIC := 11 // RESERVED2 field -*-- Active Document -*-- CommandTargetQuery Command Options +//-- Active Document +//-- CommandTargetQuery Command Options /// DEFINE CMDF_NOTSUPPORTED := 0 // The command is not supported by this object /// @@ -124,7 +124,7 @@ DEFINE CMDF_LATCHED := 4 // The command is an on-off toggle and /// DEFINE CMDF_NINCHED := 8 // The command state is indeterminate -*-- CommandTargetQuery CommandTextFlag values +//-- CommandTargetQuery CommandTextFlag values /// DEFINE CMDTEXTF_NONE := 0 // No extra information is requested /// @@ -132,7 +132,7 @@ DEFINE CMDTEXTF_NAME := 1 // Object should provide the localized /// DEFINE CMDTEXTF_STATUS := 2 // Object should provide a localized status string for the command -*-- CommandTarget Command IDs +//-- CommandTarget Command IDs /// DEFINE CMDID_OPEN := 1 // File menu, Open command /// @@ -201,7 +201,7 @@ DEFINE CMDID_ENABLE_INTERACTION := 36 // Asks the Active Document to either pa DEFINE CMDID_ONUNLOAD := 37 // Sent by the Active Document host before navigation to another // site is initiated or the host is closed -*-- CommantTargetExec nExecOption parameter +//-- CommantTargetExec nExecOption parameter /// DEFINE CMDEXECOPT_DODEFAULT := 0 // Use the default behavior /// @@ -212,7 +212,7 @@ DEFINE CMDEXECOPT_DONTPROMPTUSER := 2 // Execute the command without prompting DEFINE CMDEXECOPT_SHOWHELP := 3 // Show help for the corresponding command /// -*-- CommandTargetExec Return Values +//-- CommandTargetExec Return Values /// DEFINE CMD_OK := 0 // Command handled okay by the Active Document /// @@ -225,8 +225,8 @@ DEFINE CMD_NOHELP := 3 // No help is available for the command DEFINE CMD_CANCELED := 4 // The user canceled the execution of the command -*-- Project Hooks -*-- Build Actions +//-- Project Hooks +//-- Build Actions /// DEFINE BUILDACTION_REBUILD := 1 // Rebuild Project /// @@ -238,7 +238,7 @@ DEFINE BUILDACTION_BUILDDLL := 4 // Build DLL /// DEFINE BUILDACTION_BUILDMTDLL := 5 // Build MTDLL -*-- File Object SCCStatus Property +//-- File Object SCCStatus Property /// DEFINE SCCFILE_NOTCONTROLLED := 0 // File is not source controlled /// @@ -254,7 +254,7 @@ DEFINE SCCFILE_MERGE := 5 // File has been merged without conflic /// DEFINE SCCFILE_CHECKEDOUTMU := 6 // File is checked out to multiple users -*-- File Object Type Property +//-- File Object Type Property /// DEFINE FILETYPE_DATABASE := "d" // Database (.DBC) /// @@ -282,7 +282,7 @@ DEFINE FILETYPE_TEXT := "T" // Text (.TXT, .H., etc.) /// DEFINE FILETYPE_OTHER := "x" // Other file types not enumerated above -*-- Server Object Instancing Property +//-- Server Object Instancing Property /// DEFINE SERVERINSTANCE_NOTCREATABLE := 0 // Instances creatable only inside Visual FoxPro /// @@ -291,8 +291,8 @@ DEFINE SERVERINSTANCE_SINGLEUSE := 1 // Single use server DEFINE SERVERINSTANCE_MULTIUSE := 2 // Multi-use server -*-- Drag and Drop -*-- OLE Drag and Drop: Drop Effects +//-- Drag and Drop +//-- OLE Drag and Drop: Drop Effects /// DEFINE DROPEFFECT_NONE := 0 /// @@ -302,7 +302,7 @@ DEFINE DROPEFFECT_MOVE := 2 /// DEFINE DROPEFFECT_LINK := 4 -*-- OLE Drag and Drop: Drop Modes +//-- OLE Drag and Drop: Drop Modes /// DEFINE DROP_DISABLED :=0 /// @@ -310,7 +310,7 @@ DEFINE DROP_ENABLED :=1 /// DEFINE DROP_PASSTOCONTAINER :=2 -*-- OLE Drag and Drop: OLEDropHasData settings +//-- OLE Drag and Drop: OLEDropHasData settings /// DEFINE DROPHASDATA_VFPDETERMINE := -1 /// @@ -319,7 +319,7 @@ DEFINE DROPHASDATA_NOTUSEFUL := 0 DEFINE DROPHASDATA_USEFUL := 1 /// -*-- Clipboard formats (Global) +//-- Clipboard formats (Global) /// DEFINE CF_TEXT := 1 // Text /// @@ -357,7 +357,7 @@ DEFINE CF_LOCALE := 16 // A handle to the locale identifier /// DEFINE CF_MAX := 17 -*-- Other Miscellaneous Clipboard formats +//-- Other Miscellaneous Clipboard formats /// DEFINE CFSTR_HYPERLINK := "Hyperlink" // A Hyperlink /// @@ -388,7 +388,7 @@ DEFINE CFSTR_RTFNOOBJS := "Rich Text Format Without Objects" /// DEFINE CFSTR_RETEXTOBJ := "RichEdit Text and Objects" -*-- Clipboard formats (Private to VFP) +//-- Clipboard formats (Private to VFP) /// DEFINE CFSTR_OLEVARIANTARRAY :="OLE Variant Array" // VFP array /// @@ -396,13 +396,13 @@ DEFINE CFSTR_OLEVARIANT :="OLE Variant" // Data in variant form /// DEFINE CFSTR_VFPSOURCEOBJECT :="VFP Source Object" // A reference to the VFP source object -*-- DragMode +//-- DragMode /// DEFINE DRAG_MANUAL := 0 // 0 - Manual /// DEFINE DRAG_AUTOMATIC := 1 // 1 - Automatic -*-- DragOver +//-- DragOver /// DEFINE DRAG_ENTER := 0 /// @@ -410,7 +410,7 @@ DEFINE DRAG_LEAVE := 1 /// DEFINE DRAG_OVER := 2 -*-- Drag (controls) +//-- Drag (controls) /// DEFINE DRAG_CANCEL := 0 /// @@ -419,8 +419,8 @@ DEFINE DRAG_BEGIN := 1 DEFINE DRAG_END := 2 -*-- Properties -*-- Colors +//-- Properties +//-- Colors /// DEFINE COLOR_WHITE :=16777215 /// @@ -455,7 +455,7 @@ DEFINE COLOR_MAGENTA :=16711935 DEFINE COLOR_DARK_MAGENTA:= 8388736 /// -*-- MousePointer +//-- MousePointer /// DEFINE MOUSE_DEFAULT := 0 // 0 - Default /// @@ -489,7 +489,7 @@ DEFINE MOUSE_ARROW2 := 14 // 14 - Arrow /// DEFINE MOUSE_CUSTOM := 99 // 99 - Custom -*-- ScrollBars +//-- ScrollBars /// DEFINE SCROLLBARS_NONE := 0 // 0 - None (Default) /// @@ -499,7 +499,7 @@ DEFINE SCROLLBARS_VERTICAL := 2 // 2 - Vertical /// DEFINE SCROLLBARS_BOTH := 3 // 3 - Both -*-- DrawMode +//-- DrawMode /// DEFINE DRAWMODE_BLACKNESS := 1 // 1 - Blackness /// @@ -533,7 +533,7 @@ DEFINE DRAWMODE_MERGE_PEN := 15 // 15 - Merge Pen /// DEFINE DRAWMODE_WHITENESS := 16 // 16 - Whiteness -*-- DrawStyle +//-- DrawStyle /// DEFINE DRAWSTYLE_SOLID := 0 // 0 - Solid /// @@ -549,7 +549,7 @@ DEFINE DRAWSTYLE_INVISIBLE := 5 // 5 - Invisible /// DEFINE DRAWSTYLE_INSIDE_SOLID := 6 // 6 - Inside Solid -*-- FillStyle +//-- FillStyle /// DEFINE FILLSTYLE_SOLID := 0 // 0 - Solid /// @@ -567,13 +567,13 @@ DEFINE FILLSTYLE_CROSS := 6 // 6 - Cross /// DEFINE FILLSTYLE_DIAGONAL_CROSS := 7 // 7 - Diagonal Cross -*-- ScaleMode +//-- ScaleMode /// DEFINE SCALEMODE_PIXELS := 3 // 3 - Pixel /// DEFINE SCALEMODE_FOXELS := 0 // 0 - Foxels -*-- WindowState +//-- WindowState /// DEFINE WINDOWSTATE_NORMAL := 0 // 0 - Normal /// @@ -581,7 +581,7 @@ DEFINE WINDOWSTATE_MINIMIZED := 1 // 1 - Minimized /// DEFINE WINDOWSTATE_MAXIMIZED := 2 // 2 - Maximized -*-- Window Borders +//-- Window Borders /// DEFINE BORDER_NONE := 0 /// @@ -591,7 +591,7 @@ DEFINE BORDER_DOUBLE := 2 /// DEFINE BORDER_SYSTEM := 3 -*-- Toolbar and Form Docking Positions +//-- Toolbar and Form Docking Positions /// DEFINE TOOL_NOTDOCKED:= -1 /// @@ -607,7 +607,7 @@ DEFINE TOOL_TAB := 4 /// DEFINE TOOL_LINK := 5 -*-- Button parameter masks +//-- Button parameter masks /// DEFINE BUTTON_LEFT :=1 /// @@ -615,8 +615,8 @@ DEFINE BUTTON_RIGHT :=2 /// DEFINE BUTTON_MIDDLE :=4 -*-- Function Parameters -*-- MessageBox parameters +//-- Function Parameters +//-- MessageBox parameters /// DEFINE MB_OK := 0 // OK button only /// @@ -653,7 +653,7 @@ DEFINE MB_DEFBUTTON3 := 512 // Third button is default DEFINE MB_SYSTEMMODAL := 4096 // System Modal /// -*-- MsgBox return values +//-- MsgBox return values /// DEFINE IDOK :=1 // OK button pressed /// @@ -673,7 +673,7 @@ DEFINE IDTIMEOUT :=-1 // Timeout occurs /// -*-- Low Level File Constants +//-- Low Level File Constants /// DEFINE F_READONLY := 0 /// @@ -687,8 +687,8 @@ DEFINE F_WRITEONLY_UNBUFF := 11 /// DEFINE F_READWRITE_UNBUFF := 12 -*-- PRTINFO() Constants -*-- PRTINFO() Valid types to pass +//-- PRTINFO() Constants +//-- PRTINFO() Valid types to pass /// DEFINE PRT_ORIENTATION := 1 /// @@ -716,8 +716,8 @@ DEFINE PRT_TTOPTION := 12 /// DEFINE PRT_COLLATE := 13 -*--PRTINFO() Return types -*-- Paper sizes +//--PRTINFO() Return types +//-- Paper sizes /// DEFINE PRTPAPER_LETTER := 1 // Letter 8 1/2 x 11 in /// @@ -801,7 +801,7 @@ DEFINE PRTPAPER_FANFOLD_STD_GERMAN := 40 // German Std Fanfold 8 1/2 x 12 in /// DEFINE PRTPAPER_FANFOLD_LGL_GERMAN := 41 // German Legal Fanfold 8 1/2 x 13 in -*-- Paper bins +//-- Paper bins /// DEFINE PRTBIN_UPPER :=1 /// @@ -832,7 +832,7 @@ DEFINE PRTBIN_CASSETTE :=14 DEFINE PRTBIN_AUTOSELECT :=15 /// -*-- Print qualities +//-- Print qualities /// DEFINE PRTRES_DRAFT := -1 /// @@ -842,13 +842,13 @@ DEFINE PRTRES_MEDIUM := -3 /// DEFINE PRTRES_HIGH := -4 -*-- Color printer +//-- Color printer /// DEFINE PRTCOLOR_MONOCHROME := 1 /// DEFINE PRTCOLOR_COLOR := 2 -*-- Duplexing +//-- Duplexing /// DEFINE PRTDUP_SIMPLEX :=1 /// @@ -856,7 +856,7 @@ DEFINE PRTDUP_VERTICAL :=2 /// DEFINE PRTDUP_HORIZONTAL:=3 -*-- True Type fonts +//-- True Type fonts /// DEFINE PRTTT_BITMAP := 1 // Print True Type fonts as graphics /// @@ -864,7 +864,7 @@ DEFINE PRTTT_DOWNLOAD := 2 // Download True Type fonts as soft fonts /// DEFINE PRTTT_SUBDEV := 3 // Substitute device fonts for True Type -*-- FontMetric() +//-- FontMetric() /// DEFINE TM_HEIGHT := 1 /// @@ -907,7 +907,7 @@ DEFINE TM_ASPECTX :=19 DEFINE TM_ASPECTY :=20 /// -*-- Sysmetric() parameter values +//-- Sysmetric() parameter values /// DEFINE SYSMETRIC_SCREENWIDTH := 1 // Screen width /// @@ -981,7 +981,7 @@ DEFINE SYSMETRIC_HALFHEIGHTBUTTONWIDTH := 33 // Width of a button in a half-heig DEFINE SYSMETRIC_HALFHEIGHTBUTTONHEIGHT:= 34 // Height of a button in a half-height title bar /// -*-- Windows GetSysMetric() defines +//-- Windows GetSysMetric() defines /// DEFINE SM_CXSCREEN := 0 /// @@ -1059,7 +1059,7 @@ DEFINE SM_CMETRICS := 36 /// /// -*-- Cursor buffering modes +//-- Cursor buffering modes /// DEFINE DB_BUFOFF := 1 /// @@ -1072,13 +1072,13 @@ DEFINE DB_BUFLOCKTABLE := 4 DEFINE DB_BUFOPTTABLE := 5 /// -*-- Update types for views/cursors +//-- Update types for views/cursors /// DEFINE DB_UPDATE := 1 /// DEFINE DB_DELETEINSERT := 2 -*-- WHERE clause types for views/cursors +//-- WHERE clause types for views/cursors /// DEFINE DB_KEY := 1 /// @@ -1091,7 +1091,7 @@ DEFINE DB_KEYANDTIMESTAMP := 4 -*-- Source Types for CursorGetProp() +//-- Source Types for CursorGetProp() /// DEFINE DB_SRCLOCALVIEW := 1 /// @@ -1099,8 +1099,8 @@ DEFINE DB_SRCREMOTEVIEW := 2 /// DEFINE DB_SRCTABLE := 3 -*-- Language IDs. -* +//-- Language IDs. +/* * A language ID is a 16 bit value which is the combination of a * primary language ID and a secondary language ID. The bits are * allocated as follows: @@ -1123,7 +1123,7 @@ DEFINE DB_SRCTABLE := 3 * * Primary language IDs. -* +*/ /// DEFINE LANG_NEUTRAL := 0x00 @@ -1215,13 +1215,13 @@ DEFINE LANG_UKRAINIAN := 0x22 DEFINE LANG_VIETNAMESE := 0x2a /// -* +/* * Sublanguage IDs. * * The name immediately following SUBLANG_ dictates which primary * language ID that sublanguage ID can be combined with to form a * valid language ID. -* +*/ /// DEFINE SUBLANG_NEUTRAL := 0x0000 // language neutral @@ -1381,7 +1381,7 @@ DEFINE SUBLANG_SWEDISH := 0x0400 // Swedish /// DEFINE SUBLANG_SWEDISH_FINLAND := 0x0800 // Swedish (Finland) -*-- DBC Events constants +//-- DBC Events constants /// DEFINE DBCEVENTS_NULLTYPE:=0 /// @@ -1406,7 +1406,7 @@ DEFINE DBCEVENTS_LASTTYPE :=8 DEFINE DBCEVENTS_STPROCS := 9 /// -*-- AFields() Constants +//-- AFields() Constants /// DEFINE AFIELDS_NAME := 1 /// @@ -1444,14 +1444,14 @@ DEFINE AFIELDS_AUTOINC_NEXT_VALUE := 17 /// DEFINE AFIELDS_AUTOINC_STEP := 18 -* UCS Transformation Format byte order marks. +// UCS Transformation Format byte order marks. /// DEFINE ENCODE_UTF16 := e"\uFFFE" /// DEFINE ENCODE_UTF8 :="" /// -* COM_Attrib flag settings for Type Library attributes support +// COM_Attrib flag settings for Type Library attributes support /// DEFINE COMATTRIB_RESTRICTED :=0x1 // The property/method should not be accessible from macro languages. /// diff --git a/src/Runtime/XSharp.VFP/FileFunctions.prg b/src/Runtime/XSharp.VFP/FileFunctions.prg index fb0ee750e2..de940a921e 100644 --- a/src/Runtime/XSharp.VFP/FileFunctions.prg +++ b/src/Runtime/XSharp.VFP/FileFunctions.prg @@ -7,14 +7,14 @@ USING System.IO // VFP standard flags -DEFINE S2F_FLAG_OVERWRITE = 0x0000 -DEFINE S2F_FLAG_APPEND = 0x0001 -DEFINE S2F_FLAG_UNICODE_LE = 0x0002 -DEFINE S2F_FLAG_UTF8 = 0x0004 +DEFINE S2F_FLAG_OVERWRITE := 0x0000 +DEFINE S2F_FLAG_APPEND := 0x0001 +DEFINE S2F_FLAG_UNICODE_LE := 0x0002 +DEFINE S2F_FLAG_UTF8 := 0x0004 // X# extension flags -DEFINE S2F_FLAG_UNICODE_BE = 0x0008 -DEFINE S2F_FLAG_UNICODE_FORMATS = S2F_FLAG_UNICODE_LE | S2F_FLAG_UTF8 | S2F_FLAG_UNICODE_BE -DEFINE S2F_FLAG_UNICODE_TEXT = 0x0100 +DEFINE S2F_FLAG_UNICODE_BE := 0x0008 +DEFINE S2F_FLAG_UNICODE_FORMATS := S2F_FLAG_UNICODE_LE | S2F_FLAG_UTF8 | S2F_FLAG_UNICODE_BE +DEFINE S2F_FLAG_UNICODE_TEXT := 0x0100 /// FUNCTION MkDir(cPath AS STRING) AS INT @@ -99,27 +99,27 @@ FUNCTION StrToFile (cExpression AS STRING, cFileName AS STRING, nFlags AS INT) A ENDIF END SWITCH - * append mode? + //* append mode? IF Additive IF VFPBehavior - * open an existing file, or create if it does not exists + // open an existing file, or create if it does not exists FHandle := FOpen(cFileName, FO_READWRITE + FO_SHARED) IF FHandle != F_ERROR - * try to move to the end of the file + //try to move to the end of the file FSeek3(FHandle, 0, FS_END) - * and write the contents of the buffer + // and write the contents of the buffer IF FError() == 0 Result := FWrite(FHandle, cExpression, (DWORD) cExpression:Length) ENDIF - * if everything went ok, close the file handle + // if everything went ok, close the file handle IF FError() == 0 FClose(FHandle) IF FError() != 0 THROW FException() ENDIF - * if not, before throwing the exception... + // if not, before throwing the exception... ELSE IOError := FException() FClose(FHandle) // ... try to close the handle, anyway @@ -129,7 +129,7 @@ FUNCTION StrToFile (cExpression AS STRING, cFileName AS STRING, nFlags AS INT) A THROW FException() ENDIF ELSE - * in non-VFP behavior, just append the Unicode string to an existing file + // in non-VFP behavior, just append the Unicode string to an existing file TRY File.AppendAllText(cFileName, cExpression, UnicodeEncoding) CATCH @@ -142,31 +142,31 @@ FUNCTION StrToFile (cExpression AS STRING, cFileName AS STRING, nFlags AS INT) A ELSE - * TO-DO: check on SET("Safety") + // TODO: check on SET("Safety") - * create a new file + // create a new file IF VFPBehavior - * get an handle for a new file + // get an handle for a new file FHandle := FCreate(cFileName) IF FHandle != F_ERROR - * start with the BOM of the file + // start with the BOM of the file IF !String.IsNullOrEmpty(BOM) - Result = FWrite(FHandle, BOM, (DWORD) BOM:Length) + Result := FWrite(FHandle, BOM, (DWORD) BOM:Length) ENDIF - * try to write the contents from the buffer + // try to write the contents from the buffer IF FError() == 0 Result += FWrite(FHandle, cExpression, (DWORD) cExpression:Length) ENDIF - * and close the file + // and close the file IF FError() == 0 FClose(FHandle) IF FError() != 0 THROW FException() ENDIF - * if an error occurred... + // if an error occurred... ELSE - IOError = FException() + IOError := FException() FClose(FHandle) // ... try to not leave the handle open, in any case THROW IOError ENDIF @@ -176,7 +176,7 @@ FUNCTION StrToFile (cExpression AS STRING, cFileName AS STRING, nFlags AS INT) A ELSE - * write the Unicode string to a text file + // write the Unicode string to a text file TRY File.WriteAllText(cFileName, cExpression, UnicodeEncoding) CATCH @@ -187,7 +187,7 @@ FUNCTION StrToFile (cExpression AS STRING, cFileName AS STRING, nFlags AS INT) A ENDIF - * return the length of bytes / characters + // return the length of bytes / characters RETURN (INT) Result END FUNCTION @@ -211,18 +211,18 @@ FUNCTION FileToStr (cFileName AS STRING, Flags AS INT) AS STRING ENDIF FHandle := FOpen(cFileName, FO_READ + FO_SHARED) IF FHandle != F_ERROR - * success opening the file, get its size... + // success opening the file, get its size... StrLen := (DWORD) FSize(FHandle) IF StrLen > 0 - * ...and allocate a buffer for it + // ...and allocate a buffer for it Result := Space(StrLen) - IF FRead(FHandle, @Result, StrLen) != StrLen + IF FRead(FHandle, REF Result, StrLen) != StrLen Result := "" ENDIF ELSE Result := "" ENDIF - * any IO error will throw an exception + // any IO error will throw an exception IF FError() != 0 IOError := FException() FClose(FHandle) @@ -236,7 +236,7 @@ FUNCTION FileToStr (cFileName AS STRING, Flags AS INT) AS STRING ELSE - * for a Unicode text file, just read it into a string + // for a Unicode text file, just read it into a string TRY Result := File.ReadAllText(cFileName) // read a text file CATCH @@ -245,7 +245,7 @@ FUNCTION FileToStr (cFileName AS STRING, Flags AS INT) AS STRING ENDIF - * return the contents of the file + // return the contents of the file RETURN Result END FUNCTION diff --git a/src/Runtime/XSharp.VFP/FoxCompilerSupport.prg b/src/Runtime/XSharp.VFP/FoxCompilerSupport.prg index 6855ca363a..a07852a527 100644 --- a/src/Runtime/XSharp.VFP/FoxCompilerSupport.prg +++ b/src/Runtime/XSharp.VFP/FoxCompilerSupport.prg @@ -32,17 +32,17 @@ INTERNAL FUNCTION InitFoxState() AS VOID XSharp.RuntimeState.AutoLock := __FoxAutoLock XSharp.RuntimeState.AutoUnLock := __FoxAutoUnLock - XSharp.__Array.FoxArrayHelpers.ADel := XSharp.VFP.Functions.ADel - XSharp.__Array.FoxArrayHelpers.ALen := XSharp.VFP.Functions.FoxALen - XSharp.__Array.FoxArrayHelpers.AIns := XSharp.VFP.Functions.FoxAIns - XSharp.__Array.FoxArrayHelpers.ShowArray := XSharp.VFP.Functions.ShowFoxArray + XSharp.__Array.FoxArrayHelpers:ADel := XSharp.VFP.Functions.ADel + XSharp.__Array.FoxArrayHelpers:ALen := XSharp.VFP.Functions.FoxALen + XSharp.__Array.FoxArrayHelpers:AIns := XSharp.VFP.Functions.FoxAIns + XSharp.__Array.FoxArrayHelpers:ShowArray := XSharp.VFP.Functions.ShowFoxArray RETURN INTERNAL FUNCTION ClearFoxState as VOID XSharp.MemVar.Initialize() XSharp.RuntimeState.AutoLock := NULL XSharp.RuntimeState.AutoUnLock := NULL - XSharp.__Array.FoxArrayHelpers.Reset() + XSharp.__Array.FoxArrayHelpers:Reset() diff --git a/src/Runtime/XSharp.VFP/GatherScatter.prg b/src/Runtime/XSharp.VFP/GatherScatter.prg index ab830f22ea..0c25c82052 100644 --- a/src/Runtime/XSharp.VFP/GatherScatter.prg +++ b/src/Runtime/XSharp.VFP/GatherScatter.prg @@ -41,12 +41,12 @@ INTERNAL FUNCTION __BuildFieldList(aFieldList IN USUAL, lIncludeMemo as LOGIC) A RETURN selected ENDIF ENDIF - LOCAL fCount as DWORD - fCount := FCount() - FOR VAR nFld := 1u to fCount + LOCAL ffCount as DWORD + ffCount := FCount() + FOR VAR nFld := 1u to ffCount LOCAL lInclude AS LOGIC LOCAL cType := NIL as USUAL - VoDb.FieldInfo(DBS_TYPE, nFld,@cType) + VoDb.FieldInfo(DBS_TYPE, nFld,REF cType) SWITCH (STRING) cType CASE "M" CASE "G" @@ -71,8 +71,8 @@ INTERNAL FUNCTION __BuildFieldList(aFieldList IN USUAL, lIncludeMemo as LOGIC) A FUNCTION __ScatterMemVar(aFieldList, lBlank,lMemo) AS LOGIC CLIPPER - EnforceType(@lBlank, __UsualType.Logic) - EnforceType(@lMemo, __UsualType.Logic) + EnforceType(REF lBlank, __UsualType.Logic) + EnforceType(REF lMemo, __UsualType.Logic) VAR aFields := __GetFieldValues(aFieldList, lMemo, lBlank) FOREACH var oField in aFields @@ -92,8 +92,8 @@ FUNCTION __GatherMemVar(aFieldList, lMemo) AS LOGIC CLIPPER [FoxArrayInputParameter(1)]; FUNCTION __ScatterArray(uSource, aFieldList, lBlank, lMemo) AS ARRAY CLIPPER - EnforceType(@lBlank, __UsualType.Logic) - EnforceType(@lMemo, __UsualType.Logic) + EnforceType(REF lBlank, __UsualType.Logic) + EnforceType(REF lMemo, __UsualType.Logic) VAR aFields := __GetFieldValues(aFieldList, lMemo, lBlank) VAR nLen := (DWORD) aFields:Length @@ -141,9 +141,9 @@ FUNCTION __GatherArray(uSource, aFieldList, lMemo) AS LOGIC CLIPPER [NeedsAccessToLocals(FALSE)]; FUNCTION __ScatterObject(aFieldList, lBlank, cObject, lAdditive, lMemo) AS OBJECT CLIPPER LOCAL oResult := NULL_OBJECT as OBJECT - EnforceType(@lBlank, __UsualType.Logic) - EnforceType(@lBlank, __UsualType.Logic) - EnforceType(@lMemo, __UsualType.Logic) + EnforceType(REF lBlank, __UsualType.Logic) + EnforceType(REF lBlank, __UsualType.Logic) + EnforceType(REF lMemo, __UsualType.Logic) VAR aFields := __GetFieldValues(aFieldList, lMemo, lBlank) IF IsArray(aFieldList) aFields := aFieldList diff --git a/src/Runtime/XSharp.VFP/GetWord.prg b/src/Runtime/XSharp.VFP/GetWord.prg index f94da2a5b7..0eaa9d5ce8 100644 --- a/src/Runtime/XSharp.VFP/GetWord.prg +++ b/src/Runtime/XSharp.VFP/GetWord.prg @@ -21,7 +21,7 @@ BEGIN NAMESPACE XSharp.VFP INTERNAL CONST _cSpace := c' ' AS Char // _Chr(ASC_BLANK) Chr(032)[0] INTERNAL CONST _c_LinF := c'\n' AS Char // _Chr(ASC_LF) Chr(010)[0] INTERNAL CONST _c__Tab := c'\t' AS Char // _Chr(ASC_Tab) Chr(009)[0] - * public const _c_CRet := c'\r' as Char // _Chr(ASC_CR) Chr(013)[0] + //* public const _c_CRet := c'\r' as Char // _Chr(ASC_CR) Chr(013)[0] INTERNAL oParent AS GetWordHandler @@ -35,7 +35,7 @@ BEGIN NAMESPACE XSharp.VFP DO WHILE lnI < lnSLast lnI := lnI + 1 IF !SELF:IsDelimiter(tcString[lnI]) - *-- we have next normal chars considered "in word" + //-- we have next normal chars considered "in word" lnCount := lnCount+1 EXIT ENDIF @@ -45,29 +45,29 @@ BEGIN NAMESPACE XSharp.VFP RETURN lnCount VIRTUAL METHOD GetWordNum(tcString AS STRING, tnWordNum AS INT) AS STRING - *-- Checked: throws on .Null. - *-- undocumented and differing vom vfp: if tnIndex is 0, return "" (as in vfp9) - *-- but set WordCount as out Parameter to use in GetWordNum - *-- pure stringdancing, stay with those methods - * ? tcRefString, tnRefIndex, tcDelimiters:Length, tcDelimiters + //-- Checked: throws on .Null. + //-- undocumented and differing vom vfp: if tnIndex is 0, return "" (as in vfp9) + //-- but set WordCount as out Parameter to use in GetWordNum + //pure stringdancing, stay with those methods + // ? tcRefString, tnRefIndex, tcDelimiters:Length, tcDelimiters // Start with a Word? LOCAL lnCount := iif(SELF:IsDelimiter(tcString[0]), 0, 1) AS INT LOCAL lnSLast := tcString:Length-1 AS INT LOCAL lnStart := 0 AS INT, lnStop AS INT FOR LOCAL lnI := 0 AS INT TO lnSLast - * ? tcRefString:Substring(lnI,1), tcDelimiters:Contains( tcRefString:Substring(lnI,1)) + // ? tcRefString:Substring(lnI,1), tcDelimiters:Contains( tcRefString:Substring(lnI,1)) IF SELF:IsDelimiter(tcString[lnI]) // Skip all other delimiters until next Word is found DO WHILE lnI < lnSLast lnI := lnI+1 IF !SELF:IsDelimiter(tcString[lnI]) - *-- gets interesting... found a word + //-- gets interesting... found a word IF tnWordNum=lnCount - *-- if we start at a word and RefIndex is 1 we reach this here + //-- if we start at a word and RefIndex is 1 we reach this here lnStop := lnI-1 ELSE lnCount := lnCount + 1 - lnStart = lnI + lnStart := lnI FOR lnStop := lnI+1 TO lnSLast IF SELF:IsDelimiter(tcString[lnStop]) EXIT @@ -75,10 +75,10 @@ BEGIN NAMESPACE XSharp.VFP NEXT ENDIF IF tnWordNum=lnCount - *-- here we HAVE correct word on both starts if tnIndex>0 and will RETURN + //-- here we HAVE correct word on both starts if tnIndex>0 and will RETURN RETURN tcString:Substring(lnStart, lnStop-lnStart) ELSE - *-- Add already found non-White + //-- Add already found non-White lnI := lnStop - 1 EXIT ENDIF @@ -86,7 +86,7 @@ BEGIN NAMESPACE XSharp.VFP ENDDO ENDIF NEXT - *-- return empty as in vfp, as real payload takes inner exit + //-- return empty as in vfp, as real payload takes inner exit RETURN "" VIRTUAL METHOD IsDelimiter(tc2Check AS Char) AS LOGIC @@ -120,7 +120,7 @@ BEGIN NAMESPACE XSharp.VFP END CLASS INTERNAL CLASS GetSingle INHERIT GetVfpDefault - *-- Single delimiter Comparison options + //-- Single delimiter Comparison options PUBLIC cCmp AS Char OVERRIDE METHOD IsDelimiter(tc2Check AS Char) AS LOGIC @@ -146,7 +146,7 @@ BEGIN NAMESPACE XSharp.VFP DO WHILE lnI < lnSLast lnI := lnI + 1 IF !SELF:cCmp:Equals(tcString[lnI]) - *-- we have next normal chars considered "in word" + //-- we have next normal chars considered "in word" lnCount := lnCount+1 EXIT ENDIF @@ -156,29 +156,29 @@ BEGIN NAMESPACE XSharp.VFP RETURN lnCount OVERRIDE METHOD GetWordNum(tcString AS STRING, tnWordNum AS INT) AS STRING - *-- Checked: throws on .Null. - *-- undocumented and differing vom vfp: if tnIndex is 0, return "" (as in vfp9) - *-- but set WordCount as out Parameter to use in GetWordNum - *-- pure stringdancing, stay with those methods - * ? tcRefString, tnRefIndex, tcDelimiters:Length, tcDelimiters + //-- Checked: throws on .Null. + //-- undocumented and differing vom vfp: if tnIndex is 0, return "" (as in vfp9) + //-- but set WordCount as out Parameter to use in GetWordNum + //-- pure stringdancing, stay with those methods + // ? tcRefString, tnRefIndex, tcDelimiters:Length, tcDelimiters // Start with a Word? LOCAL lnCount := iif(SELF:cCmp:Equals(tcString[0]), 0, 1) AS INT LOCAL lnSLast := tcString:Length-1 AS INT LOCAL lnStart := 0 AS INT, lnStop AS INT FOR LOCAL lnI := 0 AS INT TO lnSLast - * ? tcRefString:Substring(lnI,1), tcDelimiters:Contains( tcRefString:Substring(lnI,1)) + // ? tcRefString:Substring(lnI,1), tcDelimiters:Contains( tcRefString:Substring(lnI,1)) IF SELF:cCmp:Equals(tcString[lnI]) // Skip all other delimiters until next Word is found DO WHILE lnI < lnSLast lnI := lnI+1 IF !SELF:cCmp:Equals(tcString[lnI]) - *-- gets interesting... found a word + //-- gets interesting... found a word IF tnWordNum=lnCount - *-- if we start at a word and RefIndex is 1 we reach this here + //-- if we start at a word and RefIndex is 1 we reach this here lnStop := lnI-1 ELSE lnCount := lnCount + 1 - lnStart = lnI + lnStart := lnI FOR lnStop := lnI+1 TO lnSLast IF SELF:IsDelimiter(tcString[lnStop]) EXIT @@ -186,10 +186,10 @@ BEGIN NAMESPACE XSharp.VFP NEXT ENDIF IF tnWordNum=lnCount - *-- here we HAVE correct word on both starts if tnIndex>0 and will RETURN + //-- here we HAVE correct word on both starts if tnIndex>0 and will RETURN RETURN tcString:Substring(lnStart, lnStop-lnStart) ELSE - *-- Add already found non-White + //-- Add already found non-White lnI := lnStop - 1 EXIT ENDIF @@ -197,7 +197,7 @@ BEGIN NAMESPACE XSharp.VFP ENDDO ENDIF NEXT - *-- return empty as in vfp, as real payload takes inner exit + //-- return empty as in vfp, as real payload takes inner exit RETURN "" CONSTRUCTOR(toParent AS GetWordHandler) AS VOID @@ -206,7 +206,7 @@ BEGIN NAMESPACE XSharp.VFP END CLASS INTERNAL CLASS GetMultiple INHERIT GetVfpDefault - *-- if not single char, DotNetWhite or VfpWhite: + //-- if not single char, DotNetWhite or VfpWhite: PRIVATE CONST _c_A126 := (Char) 126 AS Char // _Chr(ASC_Z_Low) Chr(126)[0], cut off ~ TO be safe on 1 off PRIVATE CONST _i_ArSz := 135 AS INT PRIVATE CONST _i_ArOf := _i_ArSz - 2 AS INT @@ -221,43 +221,43 @@ BEGIN NAMESPACE XSharp.VFP /// can create index error LOCAL lnI := tc2Check:CompareTo(_c_A126) AS INT IF lnI<0 - *-- it is GUARANTEED OBJECT below Ascii 126 - *-- make certain, no index Error can slip in + //-- it is GUARANTEED OBJECT below Ascii 126 + //-- make certain, no index Error can slip in RETURN SELF:alFlg[_i_ArOf + lnI] ELSEIF SELF:nInDict>0 - *-- guard for other alphabets + //-- guard for other alphabets RETURN SELF:hcCmp:ContainsKey(tc2Check) ENDIF RETURN .f. OVERRIDE METHOD SetStru() AS VOID - *-- chk different version of setdict in 2. run of timings - *-- when often calling routine for short takes, many rows in table + //-- chk different version of setdict in 2. run of timings + //-- when often calling routine for short takes, many rows in table SELF:nInDict := 0 SELF:hcCmp := Dictionary{} SELF:alFlg := LOGIC[]{_i_ArSz} - *-- ? instead try timing - * Self:hcCmp:Clear() - * self:alFlg:Clear() + //-- ? instead try timing + // Self:hcCmp:Clear() + // self:alFlg:Clear() LOCAL lcAdd AS Char LOCAL lnI AS INT FOR LOCAL lnRun := 0 AS INT TO SELF:oParent:cRawStr:Length-1 // Att: ARRAY base 1, STRING Base 0!!! lcAdd := SELF:oParent:cRawStr[lnRun] - *-- Alternative coding with Try/Catch faster?? usually the Catch part incurs runtime hit? - *-- but feels less clean, as source of problem (duplicate keys in string) known + //-- Alternative coding with Try/Catch faster?? usually the Catch part incurs runtime hit? + //-- but feels less clean, as source of problem (duplicate keys in string) known lnI := lcAdd:CompareTo(_c_A126) IF lnI<0 - *-- it is GUARANTEED OBJECT below Ascii 126 - *-- make certain, no index Error can slip in + //-- it is GUARANTEED OBJECT below Ascii 126 + //-- make certain, no index Error can slip in SELF:alFlg[_i_ArOf + lnI] := .t. ELSEIF !SELF:hcCmp:ContainsKey(lcAdd) - *-- Do NOT add lcAdds already in earlier structure(s) - *-- to enable total block of dict access if zero delimiters outside checked range given - *-- but checked text consists mostly of unicode chars outside Latin: - *-- Greek, Cyrillic, Hirigana, Katagana, whatever + //-- Do NOT add lcAdds already in earlier structure(s) + //-- to enable total block of dict access if zero delimiters outside checked range given + //-- but checked text consists mostly of unicode chars outside Latin: + //-- Greek, Cyrillic, Hirigana, Katagana, whatever SELF:hcCmp:Add(lcAdd,0) - Self.nInDict := Self.nInDict + 1 + Self:nInDict := SELF:nInDict + 1 ENDIF NEXT @@ -266,17 +266,17 @@ BEGIN NAMESPACE XSharp.VFP END CLASS // INTERNAL CLASS GetMoreLanguage INHERIT GetMultiple -// *-- exchange with Range for Greek or Cyrillic alphabet +// //-- exchange with Range for Greek or Cyrillic alphabet // PRIVATE CONST _c_Up_A := c'A' AS Char // _Chr(ASC_A) Chr(065)[0] // PRIVATE CONST _c_Up_Z := c'Z' AS Char // _Chr(ASC_Z) Chr(090)[0] // PRIVATE CONST _c_Lw_a := c'a' AS Char // _Chr(ASC_A_Low) Chr(097)[0] // PRIVATE CONST _c_Lw_z := c'z' AS Char // _Chr(ASC_Z_Low) Chr(122)[0] // // OVERRIDE METHOD IsDelimiter(tc2Check AS Char) AS LOGIC -// *-- even better would be 1 Compare, then checking against known numeric range, -// *-- or checking several ranges, perhaps even adding DotNet.IsWhiteSpace into the fray -// *-- generating+compiling "specific" IsDelimiter() on the fly -// *-- either generating whole class dynamic only predicate delegate IsDelimiter +// //-- even better would be 1 Compare, then checking against known numeric range, +// //-- or checking several ranges, perhaps even adding DotNet.IsWhiteSpace into the fray +// //-- generating+compiling "specific" IsDelimiter() on the fly +// //-- either generating whole class dynamic only predicate delegate IsDelimiter // * local liCompared2BigAlpha := // IF tc2Check:CompareTo(_c_Lw_a)>=0 .and. tc2Check:CompareTo(_c_Lw_z)<=0 // lower letters first, AS ocurring more often // RETURN .f. @@ -296,7 +296,7 @@ BEGIN NAMESPACE XSharp.VFP /// Single /// lMany: /// todo: Check new dict+array vs. :clear - *-- gets faster runtime if declared immutable? Not really... + //-- gets faster runtime if declared immutable? Not really... PUBLIC cRawStr AS STRING PUBLIC iMethod := 0 AS INT PUBLIC lAuto := .t. AS LOGIC @@ -312,30 +312,30 @@ BEGIN NAMESPACE XSharp.VFP PRIVATE STATIC oMultipleCs := NULL AS GetMultiple INTERNAL oActiveObjc := NULL AS IGetWord // IGetWord AS common INTERFACE would be cleaner - *-- plus a few special methods to set different delimiters, - *-- causing the object to "reoptimize" the code used to analyze/extract the string ( + //-- plus a few special methods to set different delimiters, + //-- causing the object to "reoptimize" the code used to analyze/extract the string ( PUBLIC METHOD SetDelimiter(tcDelimiter AS STRING) AS VOID - *-- Somewhat ugly: here no option to set DotNetWhite or VfpDefault via "best" mode - *-- of course setting :iMethod directly works, and "special" values - *-- like "" for vfpFeault and .Null. for DotNetWhite have their own messy code smell - *-- what is missing for alines() ? Perhaps implement alines(taArr, tcString, tnFlags, tcCHAR_List as Char[]) overload? - *-- List of STRING Parameters, Flags: in own code Chr(13)+Chr(10) most often used "String" + //-- Somewhat ugly: here no option to set DotNetWhite or VfpDefault via "best" mode + //-- of course setting :iMethod directly works, and "special" values + //-- like "" for vfpFeault and .Null. for DotNetWhite have their own messy code smell + //-- what is missing for alines() ? Perhaps implement alines(taArr, tcString, tnFlags, tcCHAR_List as Char[]) overload? + //-- List of STRING Parameters, Flags: in own code Chr(13)+Chr(10) most often used "String" SELF:cRawStr := tcDelimiter IF tcDelimiter:Length=1 IF SELF:iMethod <0 - *-- guard for manual sets + //-- guard for manual sets SELF:iMethod := -SELF:iMethod ELSE SELF:iMethod := 1 ENDIF - ELSEIF tcDelimiter:Length=3 and tcDelimiter:IndexOf(GetVfpDefault._cSpace)>=0 ; - and tcDelimiter:IndexOf(GetVfpDefault._c_LinF)>=0 ; - and tcDelimiter:IndexOf(GetVfpDefault._c__Tab)>=0 - *-- ToDo: find most efficient check for Permutations of Tab, LF, Space(1) - *-- Will switcg over to correct subobject - *-- min() taking usuals not an option + ELSEIF tcDelimiter:Length=3 .and. tcDelimiter:IndexOf(GetVfpDefault._cSpace)>=0 ; + .and. tcDelimiter:IndexOf(GetVfpDefault._c_LinF)>=0 ; + .and. tcDelimiter:IndexOf(GetVfpDefault._c__Tab)>=0 + //-- ToDo: find most efficient check for Permutations of Tab, LF, Space(1) + //-- Will switcg over to correct subobject + //-- min() taking usuals not an option IF SELF:iMethod <0 - *-- guard for manual sets + //-- guard for manual sets SELF:iMethod := -SELF:iMethod ELSE SELF:iMethod := 22 @@ -359,8 +359,8 @@ BEGIN NAMESPACE XSharp.VFP ENDIF SELF:oActiveObjc := oDotWhiteSp CASE 1 - *if !Self:oSingle_Opt != null - *if Self:oSingle_Opt is null + //if !Self:oSingle_Opt != null + //if Self:oSingle_Opt is null IF oSingle_Opt == NULL oSingle_Opt := GetSingleOpt{SELF} ENDIF @@ -376,9 +376,9 @@ BEGIN NAMESPACE XSharp.VFP oVfpDefault := GetVfpDefault{SELF} ENDIF SELF:oActiveObjc := oVfpDefault // - * case 34 - * Hook for additional Char sets like Greek, Cyrillic... - * self:IsDelimiter := Self:isViaDictGuarded + // case 34 + // Hook for additional Char sets like Greek, Cyrillic... + // self:IsDelimiter := Self:isViaDictGuarded OTHERWISE IF oMultipleCs == NULL oMultipleCs := GetMultiple{SELF} @@ -386,9 +386,9 @@ BEGIN NAMESPACE XSharp.VFP SELF:oActiveObjc := oMultipleCs END SWITCH IF SELF:lAuto - *-- better imp via additional interface for 3(1)&37, 22/4 don't need empty method - *-- no additional code as 1 inherits 3, but - *-- then have to guard via call "as" plus check for returned null + //-- better imp via additional interface for 3(1)&37, 22/4 don't need empty method + //-- no additional code as 1 inherits 3, but + //-- then have to guard via call "as" plus check for returned null SELF:SetStru() ENDIF RETURN @@ -401,9 +401,9 @@ BEGIN NAMESPACE XSharp.VFP CONSTRUCTOR() - *self:GetWordCount := self:GetWordCountMeth - *self:GetWordNum := self:GetWordNumMeth - *self:IsDelimiter := Self:isVia1Char + //self:GetWordCount := self:GetWordCountMeth + //self:GetWordNum := self:GetWordNumMeth + //self:IsDelimiter := Self:isVia1Char RETURN END CLASS @@ -432,15 +432,15 @@ FUNCTION GetWordCount( cString AS STRING, cDelimiters AS STRING) AS LONG RETURN GetWordCount( cString , cDelimiters, REF lnRefSwitch, REF lcTrack) INTERNAL FUNCTION GetWordCount( cString AS STRING, cDelimiters AS STRING, tnSwitch REF INT, tcTrack REF STRING) AS LONG - *-- Checked: throws on .Null. - *-- when moving class based optimized, presearch optimization times are avoided - *-- so no systematic error to do up front when checking efficiency + //-- Checked: throws on .Null. + //-- when moving class based optimized, presearch optimization times are avoided + //-- so no systematic error to do up front when checking efficiency LOCAL lnReturn AS INT LOCAL loSrch := GetWordHandler{} AS GetWordHandler IF tnSwitch<0 loSrch:iMethod := tnSwitch ENDIF - = loSrch:SetDelimiter(cDelimiters) + loSrch:SetDelimiter(cDelimiters) tnSwitch := loSrch:iMethod tnSwitch := loSrch:iMethod tcTrack := loSrch:oActiveObjc:GetType():Name @@ -455,17 +455,17 @@ FUNCTION GetWordNum( cString AS STRING, nIndex AS INT) AS STRING /// FUNCTION GetWordNum( cString AS STRING, nIndex AS INT, cDelimiters AS STRING) AS STRING - *-- Checked: throws on .Null. + //-- Checked: throws on .Null. LOCAL lnRefSwitch := 0 AS INT LOCAL lcTrack := "" AS STRING RETURN GetWordNum( cString, nIndex, cDelimiters, REF lnRefSwitch, REF lcTrack) INTERNAL FUNCTION GetWordNum( cString AS STRING, nIndex AS INT, cDelimiters AS STRING, tnSwitch REF INT, tcTrack REF STRING) AS STRING - *-- Checked: throws on .Null., lcReturn still here to debug + //-- Checked: throws on .Null., lcReturn still here to debug LOCAL lcReturn AS STRING LOCAL loSrch AS GetWordHandler loSrch := GetWordHandler {} - = loSrch:SetDelimiter(cDelimiters) + loSrch:SetDelimiter(cDelimiters) tnSwitch := loSrch:iMethod tcTrack := loSrch:oActiveObjc:GetType():Name lcReturn := loSrch:oActiveObjc:GetWordNum(cString, nIndex) diff --git a/src/Runtime/XSharp.VFP/Keyboard.prg b/src/Runtime/XSharp.VFP/Keyboard.prg index 0ec74e0d10..ce9ec88d67 100644 --- a/src/Runtime/XSharp.VFP/Keyboard.prg +++ b/src/Runtime/XSharp.VFP/Keyboard.prg @@ -123,21 +123,21 @@ BEGIN NAMESPACE XSharp.VFP // Press the key - ip[1].Type := 1 // 1 for keyboard - ip[1].Input.wScan := 0 - ip[1].Input.time := 0 - ip[1].Input.dwExtraInfo := IntPtr.Zero - ip[1].Input.wVk := (WORD) nKey - ip[1].Input.dwFlags := 0 // 0 for key press + ip[1]:Type := 1 // 1 for keyboard + ip[1]:Input:wScan := 0 + ip[1]:Input:time := 0 + ip[1]:Input:dwExtraInfo := IntPtr.Zero + ip[1]:Input:wVk := (WORD) nKey + ip[1]:Input:dwFlags := 0 // 0 for key press // Release the key - ip[2].Type := 1 // 1 for keyboard - ip[2].Input.wScan := 0 - ip[2].Input.time := 0 - ip[2].Input.dwExtraInfo := IntPtr.Zero - ip[2].Input.wVk := (WORD) nKey - ip[2].Input.dwFlags := 2 // 2 for key release + ip[2]:Type := 1 // 1 for keyboard + ip[2]:Input:wScan := 0 + ip[2]:Input:time := 0 + ip[2]:Input:dwExtraInfo := IntPtr.Zero + ip[2]:Input:wVk := (WORD) nKey + ip[2]:Input:dwFlags := 2 // 2 for key release RETURN Win32.SendInput( 2 , ip, Marshal.SizeOf ( TypeOf ( Win32.winInputXS ) ) ) == 2 diff --git a/src/Runtime/XSharp.VFP/MiscFunctions.prg b/src/Runtime/XSharp.VFP/MiscFunctions.prg index 0780c8dfac..107c0043c5 100644 --- a/src/Runtime/XSharp.VFP/MiscFunctions.prg +++ b/src/Runtime/XSharp.VFP/MiscFunctions.prg @@ -231,7 +231,7 @@ FUNCTION __FoxCast(expr AS USUAL, targetType AS STRING, nLen AS LONG, nDec AS LO END SWITCH RETURN FALSE - ENDFUNC + END FUNCTION /// [FoxProFunction("ISNULL", FoxFunctionCategory.General, FoxEngine.LanguageCore, FoxFunctionStatus.Full, FoxCriticality.High)]; @@ -241,19 +241,19 @@ FUNCTION IsNull(eExpression AS USUAL) AS LOGIC ENDIF RETURN System.Convert.IsDBNull(eExpression) -ENDFUNC +END FUNCTION /// [FoxProFunction("IMESTATUS", FoxFunctionCategory.UIAndWindow, FoxEngine.UI, FoxFunctionStatus.Full, FoxCriticality.Low)]; FUNCTION ImeStatus(nExpression := 0 AS LONG) AS LONG RETURN 0 -ENDFUNC +END FUNCTION /// [FoxProFunction("ISPEN", FoxFunctionCategory.EnvironmentAndSystem, FoxEngine.UI, FoxFunctionStatus.Full, FoxCriticality.Low)]; FUNCTION IsPen() AS LOGIC RETURN FALSE -ENDFUNC +END FUNCTION /// FUNCTION __VfpUnsupported(cCommand AS STRING) AS VOID diff --git a/src/Runtime/XSharp.VFP/PrinterFunctions.prg b/src/Runtime/XSharp.VFP/PrinterFunctions.prg index 5da88d81e1..4bf148eccc 100644 --- a/src/Runtime/XSharp.VFP/PrinterFunctions.prg +++ b/src/Runtime/XSharp.VFP/PrinterFunctions.prg @@ -42,7 +42,7 @@ FUNCTION APrinters( ArrayName AS USUAL, nValue := 0 AS INT ) AS INT ENDIF RETURN (INT)nRows -ENDFUNC +END FUNCTION /// [FoxProFunction("PCOL", FoxFunctionCategory.EnvironmentAndSystem, FoxEngine.RuntimeCore, FoxFunctionStatus.Full, FoxCriticality.Low)]; diff --git a/src/Runtime/XSharp.VFP/RuntimeCoreWrappers.prg b/src/Runtime/XSharp.VFP/RuntimeCoreWrappers.prg index c269d1e2c0..1240700d3c 100644 --- a/src/Runtime/XSharp.VFP/RuntimeCoreWrappers.prg +++ b/src/Runtime/XSharp.VFP/RuntimeCoreWrappers.prg @@ -158,7 +158,7 @@ FUNCTION FSize(cFieldName AS STRING, eWorkArea := NIL AS USUAL) AS INT IF XSharp.RuntimeState.Compatible .AND. IsNil(eWorkArea) VAR cSearchFile := cFieldName - IF String.IsNullOrEmpty(System.IO.Path.GetExtension(cSearchFile)) AND XSharp.Core.Functions.File(cSearchFile + ".dbf") + IF String.IsNullOrEmpty(System.IO.Path.GetExtension(cSearchFile)) .AND. XSharp.Core.Functions.File(cSearchFile + ".dbf") cSearchFile += ".dbf" ENDIF diff --git a/src/Runtime/XSharp.VFP/SQL/EmbeddedSql.prg b/src/Runtime/XSharp.VFP/SQL/EmbeddedSql.prg index 864615ccd5..a725eecd6f 100644 --- a/src/Runtime/XSharp.VFP/SQL/EmbeddedSql.prg +++ b/src/Runtime/XSharp.VFP/SQL/EmbeddedSql.prg @@ -143,7 +143,7 @@ STATIC CLASS FoxEmbeddedSQL cTable := Path.GetTempFileName() cAlias := oTable:Name ENDIF - if RuntimeState.Workareas.FindAlias(cAlias) != 0 + if RuntimeState.Workareas:FindAlias(cAlias) != 0 DbCloseArea(cAlias) endif DbCreate(cTable, aStruct, "DBFVFP", TRUE, cAlias) @@ -191,11 +191,11 @@ STATIC CLASS FoxEmbeddedSQL local table as FoxCreateTableContext IF lCursor IF ! parser:ParseCreateCursor(out table) - THROW Error{"Syntax error in command: "+parser.Error+CRLF+sCommand} + THROW Error{"Syntax error in command: "+parser:Error+CRLF+sCommand} ENDIF ELSE IF ! parser:ParseCreateTable(out table) - THROW Error{"Syntax error in command: "+parser.Error+CRLF+sCommand} + THROW Error{"Syntax error in command: "+parser:Error+CRLF+sCommand} ENDIF endif return table @@ -248,11 +248,11 @@ STATIC METHOD SqlAlterTable(table as FoxAlterTableContext) AS LOGIC IF ! FoxEmbeddedSQL.OpenArea(table:Name) RETURN FALSE ENDIF - var area := RuntimeState.Workareas.FindAlias(table:Name) + var area := RuntimeState.Workareas:FindAlias(table:Name) if area == 0 Throw Error{"Table "+table:Name+" not found"} ENDIF - var oRdd := RuntimeState.Workareas.GetRDD(area) + var oRdd := RuntimeState.Workareas:GetRDD(area) local fields := NULL as RddFieldInfo[] if oRdd is XSharp.RDD.Workarea var oWA fields := oWA:_Fields @@ -312,8 +312,8 @@ STATIC METHOD SqlAlterTable(table as FoxAlterTableContext) AS LOGIC FRename(newMemo, oldMemo) ENDIF DbUseArea(TRUE, "DBFVFP", oldFile, table:Name, FALSE, FALSE) - area := RuntimeState.Workareas.FindAlias(table:Name) - oRdd := RuntimeState.Workareas.GetRDD(area) + area := RuntimeState.Workareas:FindAlias(table:Name) + oRdd := RuntimeState.Workareas:GetRDD(area) if fields != NULL .and. oRdd is XSharp.RDD.Workarea var oWANew foreach var fld in oWANew:_Fields var oldFld := fields:FirstOrDefault({f => f:Name == fld:Name}) diff --git a/src/Runtime/XSharp.VFP/StringFunctions.prg b/src/Runtime/XSharp.VFP/StringFunctions.prg index fa2425b3c2..a04df336ea 100644 --- a/src/Runtime/XSharp.VFP/StringFunctions.prg +++ b/src/Runtime/XSharp.VFP/StringFunctions.prg @@ -34,7 +34,7 @@ FUNCTION AddBs (cPath AS STRING) AS STRING RETURN "" ENDIF cPath := cPath:TrimEnd() - IF ! cPath.EndsWith(PathHelpers.PathChar) + IF ! cPath:EndsWith(PathHelpers.PathChar) cPath += PathHelpers.PathChar ENDIF RETURN cPath @@ -51,16 +51,16 @@ FUNCTION ForceExt( cFileName AS STRING, cExtension AS STRING) AS STRING /// FUNCTION ForceExt( cFileName AS STRING, cExtension AS STRING, tlOptAsVfp9 AS LOGIC) AS STRING - *-- current take on matters is that the Dotnet-Version should be Default behaviour - *-- as vfp9 version behaviour in edge cases could be seen as erroneous - *-- work in progress and not tested, as existing code should only call 2-parameter overload should be safe + //-- current take on matters is that the Dotnet-Version should be Default behaviour + //-- as vfp9 version behaviour in edge cases could be seen as erroneous + //-- work in progress and not tested, as existing code should only call 2-parameter overload should be safe IF tlOptAsVfp9 == .f. RETURN ForceExt( cFileName, cExtension) ENDIF cFileName := JustFName(cFileName) IF cFileName:EndsWith(".") - *-- if filename ends with dot, cut that - *-- but only rightmost one, ending in several dots cuts still only 1 + //-- if filename ends with dot, cut that + //-- but only rightmost one, ending in several dots cuts still only 1 cFileName := cFileName:Substring(0 , cFileName:Length-1) ENDIF IF cExtension:StartsWith(".") @@ -77,7 +77,7 @@ FUNCTION ForceExt( cFileName AS STRING, cExtension AS STRING, tlOptAsVfp9 AS LOG /// [FoxProFunction("FORCEPATH", FoxFunctionCategory.FileAndIO, FoxEngine.RuntimeCore, FoxFunctionStatus.Full, FoxCriticality.Medium)]; FUNCTION ForcePath( cFileName AS STRING, cPath AS STRING) AS STRING - *-- check if path needs also check... + //-- check if path needs also check... IF String.IsNullOrEmpty(cFileName) RETURN "" ENDIF @@ -102,8 +102,8 @@ FUNCTION JustDrive(cPath AS STRING) AS STRING /// [FoxProFunction("JUSTEXT", FoxFunctionCategory.FileAndIO, FoxEngine.RuntimeCore, FoxFunctionStatus.Full, FoxCriticality.High)]; FUNCTION JustExt(cPath AS STRING) AS STRING - *-- Default for new parameter lOptWithLeadingDot ist .f. - *-- As returning all extensions with leading dot could lead to breaking changes + //-- Default for new parameter lOptWithLeadingDot ist .f. + //-- As returning all extensions with leading dot could lead to breaking changes RETURN JustExt(cPath, .f.) @@ -114,7 +114,7 @@ FUNCTION JustExt(cPath AS STRING, lOptWithLeadingDot AS LOGIC) AS STRING RETURN "" ENDIF VAR result := Path.GetExtension(cPath) - IF lOptWithLeadingDot == .f. AND result:StartsWith(".") + IF lOptWithLeadingDot == .f. .AND. result:StartsWith(".") result := result:Substring(1) ENDIF RETURN result @@ -365,9 +365,9 @@ FUNCTION Trim(Expression AS STRING, Flags AS INT, TrimChars PARAMS STRING[]) AS STATIC FUNCTION Trim_helper(TrimLeft AS Boolean, TrimRight AS Boolean, Expression AS STRING, Flags AS INT, TrimChars PARAMS STRING[]) AS STRING STRICT LOCAL parmNdx AS INT - LOCAL Trimmed = .T. AS Boolean + LOCAL Trimmed := .T. AS Boolean LOCAL LRTrimmed AS INT - LOCAL comparison = StringComparison.Ordinal AS System.StringComparison + LOCAL comparison := StringComparison.Ordinal AS System.StringComparison LOCAL compared AS STRING IF Expression = NULL @@ -375,38 +375,38 @@ STATIC FUNCTION Trim_helper(TrimLeft AS Boolean, TrimRight AS Boolean, Expressio END IF IF Flags = 1 - comparison = StringComparison.OrdinalIgnoreCase + comparison := StringComparison.OrdinalIgnoreCase END IF DO WHILE Trimmed - Trimmed = .F. + Trimmed := .F. - FOR parmNdx = 1 TO TrimChars:Length + FOR parmNdx := 1 TO TrimChars:Length - compared = TrimChars[parmNdx] + compared := TrimChars[parmNdx] IF TrimLeft - LRTrimmed = 0 + LRTrimmed := 0 DO WHILE String.Compare(Expression, LRTrimmed, compared, 0, compared:Length, comparison) = 0 LRTrimmed += compared:Length END DO IF LRTrimmed > 0 - Expression = Expression:Substring(LRTrimmed) - Trimmed = .T. + Expression := Expression:Substring(LRTrimmed) + Trimmed := .T. END IF END IF IF TrimRight - LRTrimmed = Expression:Length - compared:Length + LRTrimmed := Expression:Length - compared:Length - DO WHILE LRTrimmed >= 0 AND String.Compare(Expression, LRTrimmed, compared, 0, compared:Length, comparison) = 0 + DO WHILE LRTrimmed >= 0 .AND. String.Compare(Expression, LRTrimmed, compared, 0, compared:Length, comparison) = 0 LRTrimmed -= compared:Length END DO IF LRTrimmed < (Expression:Length - compared:Length) - Expression = Expression:Substring(0, LRTrimmed + compared:Length) - Trimmed = .T. + Expression := Expression:Substring(0, LRTrimmed + compared:Length) + Trimmed := .T. END IF END IF @@ -471,7 +471,7 @@ FUNCTION StrExtract(cSearchExpression as string, cBeginDelim as string, cEndDeli return "" endif - if lIncludeDelims and (i == nOccurrence) + if lIncludeDelims .and. (i == nOccurrence) nStart := nAt else nStart := nAt + cBeginDelim:Length diff --git a/src/Runtime/XSharp.VFP/SystemFunctions.prg b/src/Runtime/XSharp.VFP/SystemFunctions.prg index c846737669..53667e93ae 100644 --- a/src/Runtime/XSharp.VFP/SystemFunctions.prg +++ b/src/Runtime/XSharp.VFP/SystemFunctions.prg @@ -22,17 +22,18 @@ FUNCTION Sys(nSetting, uNewValue, uContextParam3) AS USUAL CLIPPER CASE 3 // Legal File Name - VAR tempFileName = System.Guid.NewGuid():ToString() - retVal := tempFileName:Replace("-", "") - retVal := Left(retVal,8) + VAR tempFileName := System.Guid.NewGuid():ToString() + tempFileName := tempFileName:Replace("-", "") + retVal := Left(tempFileName,8) CASE 5 // Default drive or volume. - retVal := GetDefault() - IF ( String.IsNullOrEmpty(retVal)) + var strRet := GetDefault() + retVal := strRet + IF ( String.IsNullOrEmpty(strRet )) retVal := CurDrive() + ":" ELSE // "SET DEFAULT TO" can contain a Path, get the Drive - retVal := ((string) retVal):Substring(0,1) + ":" + retVal := ( strRet ):Substring(0,1) + ":" ENDIF CASE 16 // Executing program file name. @@ -42,17 +43,17 @@ FUNCTION Sys(nSetting, uNewValue, uContextParam3) AS USUAL CLIPPER // retVal := path VAR level := 1 // Add one, due to Issue #1704 - VAR calling = ProcName(level + 1) + VAR calling := ProcName(level + 1) // Change Colon to Dot, to provide a VFP-Compatible result - calling = calling:Replace(":", ".") + calling := calling:Replace(":", ".") // Remove the static FUNCTIONS class from X# IF calling:StartsWith("FUNCTIONS.") - calling = calling:Substring(10) + calling := calling:Substring(10) ENDIF // Where ? - VAR file = ProcFile(level) - retVal := "PROCEDURE " + calling + " " + file - retVal := ((string) retVal):ToUpper() + VAR file := ProcFile(level) + file := "PROCEDURE " + calling + " " + file + retVal := file:ToUpper() CASE 987 // Map Remote Data to ANSI. RETURN FALSE @@ -65,8 +66,8 @@ FUNCTION Sys(nSetting, uNewValue, uContextParam3) AS USUAL CLIPPER retVal := strRetVal CASE 2015 // Returns a unique 10-character procedure name that begins with an underscore followed by a combination of letters and numbers. - VAR str := "_" + Sys(3) - retVal := Left(str,10) + VAR strRet := "_" + Sys(3) + retVal := Left(strRet,10) CASE 2023 // Temporary Path. retVal := __GetEnv("TEMP") diff --git a/src/Runtime/XSharp.VFP/Types/Attributes.prg b/src/Runtime/XSharp.VFP/Types/Attributes.prg index 818fed52be..62bc79f8f6 100644 --- a/src/Runtime/XSharp.VFP/Types/Attributes.prg +++ b/src/Runtime/XSharp.VFP/Types/Attributes.prg @@ -27,7 +27,7 @@ BEGIN NAMESPACE XSharp.VFP /// PUBLIC ENUM FoxFunctionStatus Full := 0 // Fully supported (same as VFP) - Partial := 1 // Partially supported (edge cases missed, flags or optional params) + @@Partial := 1 // Partially supported (edge cases missed, flags or optional params) Changed := 2 // Supported with changes (eg: requires .NET type or behavior differs by design) Stub := 3 // Compiles but not functionally implemented Obsolete := 4 // Obsolete (exists for retrocompatibility but it's usage is not recommended) @@ -36,7 +36,7 @@ BEGIN NAMESPACE XSharp.VFP /// PUBLIC ENUM FoxFunctionCategory - Array := 0 + @@Array := 0 Bitwise := 1 ClassAndObject := 2 CursorAndTable := 3 diff --git a/src/Runtime/XSharp.VFP/UI/VfpUIService.prg b/src/Runtime/XSharp.VFP/UI/VfpUIService.prg index ab4cd2f217..2c6cbe81ee 100644 --- a/src/Runtime/XSharp.VFP/UI/VfpUIService.prg +++ b/src/Runtime/XSharp.VFP/UI/VfpUIService.prg @@ -55,7 +55,7 @@ BEGIN NAMESPACE XSharp.VFP IF oAsm != NULL VAR oType := oAsm:GetType("XSharp.VFP.UI.VfpUIProvider", FALSE, TRUE) - IF oType != NULL AND typeof(IVfpUIProvider):IsAssignableFrom(oType) + IF oType != NULL .AND. typeof(IVfpUIProvider):IsAssignableFrom(oType) _provider := (IVfpUIProvider) Activator.CreateInstance(oType) ENDIF ENDIF diff --git a/src/Runtime/XSharp.VFP/WindowFunctions.prg b/src/Runtime/XSharp.VFP/WindowFunctions.prg index 01ae90d76f..b0e98e78e0 100644 --- a/src/Runtime/XSharp.VFP/WindowFunctions.prg +++ b/src/Runtime/XSharp.VFP/WindowFunctions.prg @@ -4,8 +4,8 @@ USING System USING System.Collections.Generic USING System.Text -INTERNAL _DLL FUNCTION FindWindow(lpClassName AS STRING , lpWindowName AS STRING ) AS PTR PASCAL:USER32.FindWindowA -INTERNAL _DLL FUNCTION IsWindowVisible(hwnd AS PTR) AS LOGIC PASCAL:USER32.IsWindowVisible +INTERNAL _DLL FUNCTION FindWindow(lpClassName AS STRING , lpWindowName AS STRING ) AS IntPtr PASCAL:USER32.FindWindowA +INTERNAL _DLL FUNCTION IsWindowVisible(hwnd AS IntPtr) AS LOGIC PASCAL:USER32.IsWindowVisible DEFINE SW_HIDE := 0 DEFINE SW_NORMAL := 1 diff --git a/src/Runtime/XSharp.VFP/XSharp.VFP.Next.xsproj b/src/Runtime/XSharp.VFP/XSharp.VFP.Next.xsproj index 555e155475..8e444e35d8 100644 --- a/src/Runtime/XSharp.VFP/XSharp.VFP.Next.xsproj +++ b/src/Runtime/XSharp.VFP/XSharp.VFP.Next.xsproj @@ -3,20 +3,19 @@ XSharp.VFP XSharp.VFP - FoxPro + XBaseNet true - True + false true False + true + $(ProjectDir) true - True - True - True + true true net8.0 - $(ProjectDir) diff --git a/src/Runtime/XSharp.VFP/XSharp.VFP.xsproj b/src/Runtime/XSharp.VFP/XSharp.VFP.xsproj index d48b4dfb3e..662eb5c715 100644 --- a/src/Runtime/XSharp.VFP/XSharp.VFP.xsproj +++ b/src/Runtime/XSharp.VFP/XSharp.VFP.xsproj @@ -1,4 +1,4 @@ - + @@ -7,10 +7,10 @@ XSharp.VFP XSharp.VFP XSharp.VFP - FoxPro + XBaseNet XSharp.VFP true - true + False true False True @@ -18,10 +18,7 @@ true - True - True - True - + diff --git a/src/Runtime/XSharp.XPP/XSharp.XPP.Next.xsproj b/src/Runtime/XSharp.XPP/XSharp.XPP.Next.xsproj index 82dffff461..7017edf300 100644 --- a/src/Runtime/XSharp.XPP/XSharp.XPP.Next.xsproj +++ b/src/Runtime/XSharp.XPP/XSharp.XPP.Next.xsproj @@ -3,7 +3,7 @@ XSharp.XPP XSharp.XPP - XPP + XBaseNet true True true diff --git a/src/Runtime/XSharp.XPP/XSharp.XPP.xsproj b/src/Runtime/XSharp.XPP/XSharp.XPP.xsproj index 5498136fbc..af5c79e0a1 100644 --- a/src/Runtime/XSharp.XPP/XSharp.XPP.xsproj +++ b/src/Runtime/XSharp.XPP/XSharp.XPP.xsproj @@ -7,7 +7,7 @@ XSharp.XPP XSharp.XPP XSharp.XPP - XPP + XBaseNet XSharp.XPP true true From fc2ca68afc14fa7890d6677726ebae9df05b4c18 Mon Sep 17 00:00:00 2001 From: Robert van der Hulst Date: Tue, 29 Sep 2026 16:01:35 +0200 Subject: [PATCH 003/180] [Vsintegration] Fixed typo in View and added XbaseNet as dialect to the combobox. --- src/VisualStudio/AppDesigner/PropertyPages/Enums.cs | 2 +- src/VisualStudio/XSharpCodeModelXs/Database/XDatabase.prg | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/VisualStudio/AppDesigner/PropertyPages/Enums.cs b/src/VisualStudio/AppDesigner/PropertyPages/Enums.cs index 3679e44141..33ce3ed6a2 100644 --- a/src/VisualStudio/AppDesigner/PropertyPages/Enums.cs +++ b/src/VisualStudio/AppDesigner/PropertyPages/Enums.cs @@ -196,7 +196,7 @@ public override bool GetStandardValuesSupported(System.ComponentModel.ITypeDescr public override StandardValuesCollection GetStandardValues(System.ComponentModel.ITypeDescriptorContext context) { - return new StandardValuesCollection(new Dialect[] { Dialect.Core, Dialect.VO, Dialect.Vulcan, Dialect.Harbour,Dialect.XPP, Dialect.FoxPro}); + return new StandardValuesCollection(new Dialect[] { Dialect.Core, Dialect.VO, Dialect.Vulcan, Dialect.Harbour,Dialect.XPP, Dialect.FoxPro, Dialect.XBaseNet}); } } diff --git a/src/VisualStudio/XSharpCodeModelXs/Database/XDatabase.prg b/src/VisualStudio/XSharpCodeModelXs/Database/XDatabase.prg index 374a46c587..31db3ce108 100644 --- a/src/VisualStudio/XSharpCodeModelXs/Database/XDatabase.prg +++ b/src/VisualStudio/XSharpCodeModelXs/Database/XDatabase.prg @@ -28,7 +28,9 @@ STATIC CLASS XDatabase STATIC PRIVATE currentFile AS STRING STATIC PROPERTY FileName as STRING GET currentFile STATIC PROPERTY DeleteOnClose as LOGIC AUTO - PRIVATE CONST CurrentDbVersion := 3.9 AS System.Double // 3.9: added Types_File / Types_Project indexes + // 3.9: added Types_File / Types_Project indexes + // 3.10: fixed typo in view ProjectExtensionMethods + PRIVATE CONST CurrentDbVersion := 3.10 AS System.Double STATIC METHOD LogDbClosed() AS VOID Log("Database is not open") RETURN @@ -561,7 +563,7 @@ STATIC METHOD CreateSchema(Connection AS DbConnection) AS VOID cmd:CommandText := stmt cmd:ExecuteNonQuery() - stmt := " CREATE VIEW ProjectExtensionMethods as SELECT em.FullName, m.* FROM ExtensionMethods em" + ; + stmt := " CREATE VIEW ProjectExtensionMethods as SELECT em.FullName, pm.* FROM ExtensionMethods em" + ; " JOIN ProjectMembers pm ON em.IdMember = pm.Id" cmd:CommandText := stmt cmd:ExecuteNonQuery() From 8b4c35468d7d49154a443721e5f6c01d4c5ceed8 Mon Sep 17 00:00:00 2001 From: Robert van der Hulst Date: Tue, 29 Sep 2026 16:04:38 +0200 Subject: [PATCH 004/180] [Compiler] Several small changes to prevent using ToLower() and ToUpper() for string comparisons. And using OrdinalIgnoreCase or Ordinal comparisons for strings --- .../CreateManagedResourceName.cs | 6 +- .../CreateXSharpManifestResourceName.cs | 6 +- .../XSharpBuildTask/NativeResourceGen.cs | 6 +- .../src/Compiler/XSharpBuildTask/Xsc.cs | 6 +- .../Binder/Binder_Expressions.cs | 2 +- .../Binder/Binder_Lookup.cs | 6 +- .../Binder/TypeExtensions.cs | 3 +- .../CommandLine/XSharpCommandLineParser.cs | 6 +- .../XSharpSpecificCompilationOptions.cs | 11 ++-- .../LocalRewriter/LocalRewriter_Call.cs | 4 +- .../Parser/XSharpParseErrorAnalysis.cs | 9 +-- .../Parser/XSharpParserCode.cs | 13 ++-- .../Parser/XSharpTreeTransformationCore.cs | 46 +++++++------- .../Parser/XSharpTreeTransformationFox.cs | 8 +-- .../Parser/XSharpTreeTransformationRT.cs | 62 ++++++++++--------- .../Parser/XSharpTreeTransformationXPP.cs | 15 ++--- .../Preprocessor/XSharpPPRule.cs | 25 ++++---- .../Preprocessor/XSharpPreprocessor.cs | 24 +++---- .../Symbols/TypeNameHelpers.cs | 4 +- .../Symbols/TypeSymbolExtensions.cs | 2 +- .../XSharpCodeAnalysis/VsParser/Stubs.cs | 4 +- 21 files changed, 133 insertions(+), 135 deletions(-) diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/CreateManagedResourceName.cs b/src/Compiler/src/Compiler/XSharpBuildTask/CreateManagedResourceName.cs index ad864fe696..868654efb8 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/CreateManagedResourceName.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/CreateManagedResourceName.cs @@ -69,15 +69,15 @@ internal bool Execute(CreateFileStream createFileStream) string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(itemSpec); string dependentUpOn = taskItem.GetMetadata("DependentUpon"); string type = taskItem.GetMetadata("Type"); - bool isResx = !string.IsNullOrEmpty(type) && type.ToLower() == "resx"; + bool isResx = !string.IsNullOrEmpty(type) && type.ToLowerInvariant() == "resx"; if (string.IsNullOrEmpty(dependentUpOn)) { - isResx = Path.GetExtension(itemSpec).ToLower() == ".resx"; + isResx = Path.GetExtension(itemSpec).ToLowerInvariant() == ".resx"; } if (isResx && UseDependentUponConvention && string.IsNullOrEmpty(dependentUpOn)) { var temp = Path.ChangeExtension(Path.GetFileName(itemSpec), Constants.SourceFileExtension); - if (taskItem.GetMetadata("WithCulture").ToLower() == "true") + if (taskItem.GetMetadata("WithCulture").ToLowerInvariant() == "true") { string culture = taskItem.GetMetadata("Culture"); if (!string.IsNullOrEmpty(culture)) diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/CreateXSharpManifestResourceName.cs b/src/Compiler/src/Compiler/XSharpBuildTask/CreateXSharpManifestResourceName.cs index 0a3fb764f3..3a3a669bcf 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/CreateXSharpManifestResourceName.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/CreateXSharpManifestResourceName.cs @@ -231,7 +231,7 @@ private static string stripComments(string line) private static string stripMultiLineComments(string contents) { var sb = new StringBuilder(); - int index = contents.IndexOf("/*"); + int index = contents.IndexOf("/*", StringComparison.OrdinalIgnoreCase); while (index >= 0 && contents.Length > 0) { if (index > 0) @@ -239,12 +239,12 @@ private static string stripMultiLineComments(string contents) sb.Append(contents.Substring(0, index - 1)); } contents = contents.Substring(index + 2); - index = contents.IndexOf("*/"); + index = contents.IndexOf("*/", StringComparison.OrdinalIgnoreCase); if (index >= 0) { contents = contents.Substring(index + 2); } - index = contents.IndexOf("/*"); + index = contents.IndexOf("/*", StringComparison.OrdinalIgnoreCase); } return sb.ToString(); } diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/NativeResourceGen.cs b/src/Compiler/src/Compiler/XSharpBuildTask/NativeResourceGen.cs index 249d6c3a2a..1bb3227fa0 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/NativeResourceGen.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/NativeResourceGen.cs @@ -279,7 +279,7 @@ protected bool FilesAreNewer(List fileNames, string outputFileName) } if (found) { - if (!alreadychecked.Contains(foundfile.ToLower())) + if (!alreadychecked.Contains(foundfile.ToLowerInvariant())) { DateTime includeTime = File.GetLastWriteTime(foundfile); base.Log.LogMessage("Input file: \"{0}\" depends on include file \"{1}\"", fileName, foundfile); @@ -288,7 +288,7 @@ protected bool FilesAreNewer(List fileNames, string outputFileName) base.Log.LogMessage("Include file: \"{0}\" is newer than output file \"{1}\" as was last updated on {2:f}", foundfile, outputFileName, includeTime); return true; } - alreadychecked.Add(foundfile.ToLower()); + alreadychecked.Add(foundfile.ToLowerInvariant()); } } else @@ -438,7 +438,7 @@ protected string NativeResourceInclude protected override void LogEventsFromTextOutput(string singleLine, MessageImportance messageImportance) { - bool isWarning = singleLine.IndexOf(" warning RC4005") != -1; + bool isWarning = singleLine.IndexOf(" warning RC4005", StringComparison.OrdinalIgnoreCase) != -1; if (SuppressRCWarnings && isWarning) { ; // do nothing diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs b/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs index dc8d72c77f..a0dbd9d1db 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Xsc.cs @@ -861,7 +861,7 @@ internal void AddVOCompatibilityCommands(XSharpCommandLineBuilder commandline) commandline.AppendPlusOrMinusSwitchAlways("/ins", _store, nameof(INS)); commandline.AppendPlusOrMinusSwitchAlways("/lb", _store, nameof(LB)); commandline.AppendPlusOrMinusSwitchAlways("/namedarguments", _store, nameof(NamedArgs)); - if (Dialect.ToLower() != "core" && Dialect.ToLower() != "vulcan") + if (Dialect.ToLowerInvariant() != "core" && Dialect.ToLowerInvariant() != "vulcan") { commandline.AppendPlusOrMinusSwitchAlways("/memvar", _store, nameof(MemVar)); commandline.AppendPlusOrMinusSwitchAlways("/undeclared", _store, nameof(Undeclared)); @@ -889,11 +889,11 @@ internal void AddVOCompatibilityCommands(XSharpCommandLineBuilder commandline) commandline.AppendPlusOrMinusSwitchAlways("/vo15", _store, nameof(VO15)); commandline.AppendPlusOrMinusSwitchAlways("/vo16", _store, nameof(VO16)); commandline.AppendPlusOrMinusSwitchAlways("/vo17", _store, nameof(VO17)); - if (Dialect.ToLower() == "xpp") + if (Dialect.ToLowerInvariant() == "xpp") { commandline.AppendPlusOrMinusSwitchAlways("/xpp1", _store, nameof(XPP1)); } - if (Dialect.ToLower() == "foxpro") + if (Dialect.ToLowerInvariant() == "foxpro") { commandline.AppendPlusOrMinusSwitchAlways("/fox1", _store, nameof(FOX1)); commandline.AppendPlusOrMinusSwitchAlways("/fox2", _store, nameof(FOX2)); diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Expressions.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Expressions.cs index c1f1a12bd0..fecc676214 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Expressions.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Expressions.cs @@ -1029,7 +1029,7 @@ private BoundExpression BindXSIdentifier( } var name = node.Identifier.ValueText; var useSiteInfo = GetNewCompoundUseSiteInfo(diagnostics); - var memvarorfield = name.IndexOf("->") > 0; + var memvarorfield = name.IndexOf("->", StringComparison.Ordinal) > 0; // no need to look for our special names if (!memvarorfield) { diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Lookup.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Lookup.cs index 5a2672be58..0c048dd32b 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Lookup.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/Binder_Lookup.cs @@ -4,6 +4,7 @@ // See License.txt in the project root for license information. // #nullable disable +using System; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; @@ -151,7 +152,8 @@ private Binder XSLookupSymbolsInternal( if (!Compilation.Options.HasOption(CompilerOption.EnforceSelf, syntax)) { // Static method generate the error elsewhere - bool ignore = name.ToLower() == XSharpSpecialNames.funcToIgnore1 || name.ToLower() == XSharpSpecialNames.funcToIgnore2; + bool ignore = string.Equals(name, XSharpSpecialNames.funcToIgnore1, StringComparison.OrdinalIgnoreCase) + || string.Equals(name, XSharpSpecialNames.funcToIgnore2, StringComparison.OrdinalIgnoreCase); if (!ignore) { var args = new object[] { name, func, meth }; @@ -168,7 +170,7 @@ private Binder XSLookupSymbolsInternal( // function first and then the methods LookupResult mergedResults = LookupResult.GetInstance(); mergedResults.MergeEqual(functionResults); - // now add the symbols from result that do not exist + // now add the symbols from result that do not exist for (int j = 0; j < result.Symbols.Count; j++) { var sym = result.Symbols[j]; diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/TypeExtensions.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/TypeExtensions.cs index 480a08a543..fd5bb6f8e8 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/TypeExtensions.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Binder/TypeExtensions.cs @@ -103,7 +103,8 @@ internal static bool IsXsCompilerGenerated(this Symbol symbol) { if (symbol.Kind == SymbolKind.Local || symbol.Kind == SymbolKind.Parameter) { - if (symbol.Name != null && symbol.Name.StartsWith("Xs$") ) + if (symbol.Name != null && symbol.Name.StartsWith("Xs$", + System.StringComparison.OrdinalIgnoreCase)) { return true; } diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpCommandLineParser.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpCommandLineParser.cs index 1041404f3c..c85c0ce2ec 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpCommandLineParser.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpCommandLineParser.cs @@ -54,7 +54,7 @@ internal bool ParseXSharpArgument(ref string name, ref string value, string arg, { name = name.Substring(0, name.Length - 1); } - switch (name.ToLower()) + switch (name.ToLowerInvariant()) { case "allowoldstyleassignments": options.AllowOldStyleAssignments = positive; @@ -211,7 +211,7 @@ internal bool ParseXSharpArgument(ref string name, ref string value, string arg, value = value.Trim(); if (value.StartsWith("\"") && value.EndsWith("\"")) value = value.Substring(1, value.Length - 2); - string fn = System.IO.Path.GetFileName(value).ToLower(); + string fn = System.IO.Path.GetFileName(value).ToLowerInvariant(); fn = System.IO.Path.GetFileNameWithoutExtension(fn); switch (fn) { @@ -302,7 +302,7 @@ internal bool ParseXSharpArgument(ref string name, ref string value, string arg, value = value.Substring(1, value.Length - 2); } string filename = value; - if (value.IndexOf(";") != -1) + if (value.IndexOf(';') != -1) { foreach (var fname in ParseSeparatedPaths(value).Where((path) => !string.IsNullOrWhiteSpace(path))) { diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpSpecificCompilationOptions.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpSpecificCompilationOptions.cs index 44c6cca369..b511970aa7 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpSpecificCompilationOptions.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/CommandLine/XSharpSpecificCompilationOptions.cs @@ -250,7 +250,7 @@ public void SetOption(CompilerOption option, bool value) public void SetOptionFromReference(string filename) { - switch (System.IO.Path.GetFileNameWithoutExtension(filename).ToLower()) + switch (System.IO.Path.GetFileNameWithoutExtension(filename).ToLowerInvariant()) { case XSharpAssemblyNames.SdkDefines: this.RuntimeAssemblies |= RuntimeAssemblies.SdkDefines; @@ -304,17 +304,18 @@ public void SetOptionFromReference(string filename) case "system": if (!this.ExplicitOptions.HasFlag(CompilerOption.ClrVersion)) { - if (filename.ToLower().Contains("\\v2") || filename.ToLower().Contains("\\2.")) + var filenameLower = filename.ToLowerInvariant(); + if (filenameLower.Contains("\\v2") || filenameLower.Contains("\\2.")) { this.ExplicitOptions |= CompilerOption.ClrVersion; this.ClrVersion = 2; } - else if (filename.ToLower().Contains("\\v3") || filename.ToLower().Contains("\\3.")) + else if (filenameLower.Contains("\\v3") || filenameLower.Contains("\\3.")) { this.ExplicitOptions |= CompilerOption.ClrVersion; this.ClrVersion = 2; } - else if (filename.ToLower().Contains("\\v4") || filename.ToLower().Contains("\\4.")) + else if (filenameLower.Contains("\\v4") || filenameLower.Contains("\\4.")) { this.ExplicitOptions |= CompilerOption.ClrVersion; this.ClrVersion = 4; @@ -586,7 +587,7 @@ internal static string Description(this CompilerOption option) internal static CompilerOption Decode(string option) { // options sorted in alphabetical order - switch (option.ToLower()) + switch (option.ToLowerInvariant()) { case "allowoldstyleassignments": return CompilerOption.AllowOldStyleAssignments; diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/LocalRewriter/LocalRewriter_Call.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/LocalRewriter/LocalRewriter_Call.cs index f3ccf1976b..13126873d2 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/LocalRewriter/LocalRewriter_Call.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/LocalRewriter/LocalRewriter_Call.cs @@ -123,7 +123,7 @@ private BoundExpression XsAdjustBoundCall(BoundExpression expression) int count = 0; foreach (var sym in localsymbols) { - if (sym.Name.IndexOf("$") == -1) + if (sym.Name.IndexOf('$') == -1) count++; } if (count == 0 && isStatic) @@ -156,7 +156,7 @@ private BoundExpression XsAdjustBoundCall(BoundExpression expression) foreach (var symbol in localsymbols) { var name = symbol.Name; - if (name.IndexOf("$") >= 0) + if (name.IndexOf('$') >= 0) continue; BoundExpression? localvar = null; if (symbol is LocalSymbol ls) diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParseErrorAnalysis.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParseErrorAnalysis.cs index a2a3e122c4..951f267883 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParseErrorAnalysis.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParseErrorAnalysis.cs @@ -490,7 +490,7 @@ public override void EnterFoxfield([NotNull] XSharpParser.FoxfieldContext contex public override void ExitXFunctionExpression([NotNull] XSharpParser.XFunctionExpressionContext context) { - NotInCore(context, context.XFunc.GetText().ToUpper() + " function"); + NotInCore(context, context.XFunc.GetText().ToUpperInvariant() + " function"); } public override void ExitFoxclsctor([NotNull] XSharpParser.FoxclsctorContext context) @@ -615,7 +615,7 @@ public override void ExitVodll([NotNull] XSharpParser.VodllContext context) } if (context.CharSet != null) { - var text = context.CharSet.Text.ToUpper(); + var text = context.CharSet.Text.ToUpperInvariant(); if (text != "AUTO" && text != "ANSI" && text != "UNICODE") { _parseErrors.Add(new ParseErrorData(context, ErrorCode.ERR_UnExpectedExpected, context.CharSet.Text, "AUTO', 'ANSI' or 'UNICODE")); @@ -727,8 +727,9 @@ public override void ExitMethod([NotNull] XSharpParser.MethodContext context) //} if (isInInterface && _options.VoInitAxitMethods) { - var name = context.Sig.Id.GetText().ToLower(); - if (name == "init" || name == "axit") + var name = context.Sig.Id.GetText(); + if (string.Equals(name, "init", System.StringComparison.OrdinalIgnoreCase) || + string.Equals(name, "axit", System.StringComparison.OrdinalIgnoreCase)) { _parseErrors.Add(new ParseErrorData(context.Start, ErrorCode.ERR_InterfacesCantContainConstructors)); } diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParserCode.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParserCode.cs index 4611018077..f534e227b6 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParserCode.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpParserCode.cs @@ -598,11 +598,6 @@ internal MemVarFieldInfo AddField(string name, string Alias, XSharpParserRuleCon info = new MemVarFieldInfo(name, Alias, context); Fields.Add(info); } - if (!info.IsMacroMemvar) - { - if (info.Name != info.FullName && !Fields.ContainsKey(info.FullName)) - Fields.Add(info.FullName, info); - } return info; } internal MemVarFieldInfo GetField(string name) @@ -1288,8 +1283,8 @@ public partial class AccessMemberContext internal FoxFlags foxFlags = FoxFlags.None; internal bool IsFox => foxFlags != FoxFlags.None; internal bool HasMPrefix => foxFlags.HasFlag(FoxFlags.MPrefix); - internal string AreaName => Expr == null ? "" : Expr.GetText().ToUpper(); - internal string FieldName => Name.GetText().ToUpper(); + internal string AreaName => Expr == null ? "" : Expr.GetText().ToUpperInvariant(); + internal string FieldName => Name.GetText().ToUpperInvariant(); internal bool HasThisReference => Op.Type == XSharpLexer.DOT && Expr != null && this.Expr.Start == this.Expr.Stop && (this.Expr.Start.Type == XSharpParser.SELF); @@ -1554,7 +1549,7 @@ public string FullName { if (_fieldType == MemvarType.MacroMemvar) { - var name = Name.Substring(0, Name.IndexOf(":")); + var name = Name.Substring(0, Name.IndexOf(':')); return Alias + "->" + name; } if (Alias != null) @@ -1615,7 +1610,7 @@ internal MemVarFieldInfo(string name, string alias, XSharpParserRuleContext cont { if (alias.StartsWith("@@")) alias = alias.Substring(2); - switch (alias.ToUpper()) + switch (alias.ToUpperInvariant()) { case "&": _fieldType = MemvarType.MacroMemvar; diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationCore.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationCore.cs index 619cc63541..3e6fe328e8 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationCore.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationCore.cs @@ -608,7 +608,7 @@ protected string GetEntityName(Boolean Full, Boolean funcNameOnly = false) } else { - name = name.ToUpper() + suffix; + name = name.ToUpperInvariant() + suffix; } } return name; @@ -1271,7 +1271,7 @@ protected internal NameSyntax GenerateQualifiedName(string name) string[] ids = name.Split('.'); string idName = ids[0]; string alias = null; - int cc = idName.IndexOf("::"); + int cc = idName.IndexOf("::", StringComparison.Ordinal); if (cc >= 0) { alias = idName.Substring(0, cc); @@ -1306,7 +1306,7 @@ internal static Syntax.NameSyntax ExtGenerateQualifiedName(string name) string[] ids = name.Split('.'); string idName = ids[0]; string alias = null; - int cc = idName.IndexOf("::"); + int cc = idName.IndexOf("::", StringComparison.Ordinal); if (cc >= 0) { alias = idName.Substring(0, cc); @@ -2662,7 +2662,7 @@ internal void SetPragmas(IList pragmas) } else { - var id = _syntaxFactory.IdentifierName(SyntaxFactory.MakeIdentifier(token.Text.ToUpper())); + var id = _syntaxFactory.IdentifierName(SyntaxFactory.MakeIdentifier(token.Text.ToUpperInvariant())); list.Add(id); } } @@ -3858,8 +3858,9 @@ protected virtual ExpressionSyntax GenerateInitializer(XP.DatatypeContext dataty && pts.Keyword.Kind == SyntaxKind.StringKeyword; if (!isString) { - var typeText = datatype.GetText().ToLower(); - isString = typeText == "string" || typeText == "system.string"; + var typeText = datatype.GetText(); + isString = typeText.Equals("string", StringComparison.OrdinalIgnoreCase) || + typeText.Equals("system.string", StringComparison.OrdinalIgnoreCase); } if (isString) { @@ -4848,7 +4849,7 @@ public override void ExitAttributeBlock([NotNull] XP.AttributeBlockContext conte walker.Walk(this, attblock); var list = attblock.CsNode as AttributeListSyntax; context.Put(list); - if (list.Attributes.Count == 0) + if (list?.Attributes.Count == 0) { ParseErrors.Add(new ParseErrorData(context, ErrorCode.ERR_BadAttributeArgument, source)); } @@ -4876,7 +4877,7 @@ public override void ExitAttributeBlock([NotNull] XP.AttributeBlockContext conte public override void ExitAttributeTarget([NotNull] XP.AttributeTargetContext context) { - string target = context.Token.Text.ToLower(); + string target = context.Token.Text.ToLowerInvariant(); switch (target) { // numeric values in the switch are the values of the AttributeTargets enum @@ -4960,7 +4961,7 @@ public override void ExitGlobalAttributes([NotNull] XP.GlobalAttributesContext c // we leave the handling of '*' inside AssemblyVersion to the roslyn code // if the version does not have a '*' character then we use the string that was passed by the user. // this also allows for non numeric versions for InformationalVersion - if (context.Target.Token.Text.ToLower() == "assembly") + if (context.Target.Token.Text.Equals("assembly", StringComparison.CurrentCultureIgnoreCase)) { string[] names = { "AssemblyFileVersionAttribute","AssemblyFileVersion", "AssemblyInformationalVersionAttribute","AssemblyInformationalVersion"}; @@ -5010,7 +5011,7 @@ public override void ExitGlobalAttributes([NotNull] XP.GlobalAttributesContext c public override void ExitGlobalAttributeTarget([NotNull] XP.GlobalAttributeTargetContext context) { - var text = context.Token.Text.ToLower(); + var text = context.Token.Text.ToLowerInvariant(); if (text != "assembly" && text != "module") { ParseErrors.Add(new ParseErrorData(context, ErrorCode.ERR_UnexpectedToken, context.Token.Text)); @@ -5547,7 +5548,7 @@ public override void ExitFuncproc([NotNull] XP.FuncprocContext context) { if (_options.Dialect != XSharpDialect.FoxPro) { - if (context.ReturnType != null && context.ReturnType.GetText().ToLower() != "void") + if (context.ReturnType != null && context.ReturnType.GetText().ToLowerInvariant() != "void") { returntype = NotInDialect(returntype, "Procedure with non VOID return type"); } @@ -5777,7 +5778,7 @@ private AttributeSyntax _dllImportAttribute(XP.VodllContext context, ExpressionS { // convert to 1 Upper char and lower chars string cs = context.CharSet.Text; - cs = cs.Substring(0, 1).ToUpper() + cs.Substring(1).ToLower(); + cs = cs.Substring(0, 1).ToUpperInvariant() + cs.Substring(1).ToLowerInvariant(); id = SyntaxFactory.Identifier(cs); } else @@ -5972,7 +5973,7 @@ protected static bool hasDllImport(SyntaxList attributes) for (int i = 0; i < ats.Count; i++) { var at = ats[i] as AttributeSyntax; - if (at.ToString().ToLower().Contains("dllimport")) + if (at.ToString().Contains("dllimport", StringComparison.OrdinalIgnoreCase)) { return true; } @@ -7740,8 +7741,7 @@ public override void ExitAccessMember([NotNull] XP.AccessMemberContext context) { var left = context.Expr.Get(); var cb = GetCodeBlock(context); - var mem = CurrentMember; - if (mem != null && cb != null && context.HasThisReference && mem.Data.HasThisInCodeBlock) + if (CurrentMember != null && cb != null && context.HasThisReference && CurrentMember.Data.HasThisInCodeBlock) { left = GenerateSimpleName(XSharpSpecialNames.This); } @@ -8094,11 +8094,11 @@ public override void ExitMethodCall([NotNull] XP.MethodCallContext context) string name = String.Empty; if (expr is IdentifierNameSyntax ins) { - name = ins.Identifier.Text.ToUpper(); + name = ins.Identifier.Text.ToUpperInvariant(); } else if (expr is GenericNameSyntax gns) { - name = gns.Identifier.Text.ToUpper(); + name = gns.Identifier.Text.ToUpperInvariant(); } switch (name) { @@ -9069,7 +9069,7 @@ public override void ExitIdentifier([NotNull] XP.IdentifierContext context) if (String.Compare(context.Start.Text, "value", true) == 0) { var token = context.Start as XSharpToken; - token.Text = token.Text.ToLower(); + token.Text = token.Text.ToLowerInvariant(); } } } @@ -9393,7 +9393,7 @@ protected ExpressionSyntax CreateInterPolatedStringExpression(IToken token, XSha string expr = e; bool singleColon = false; // Format character? - int pos = expr.IndexOf("::"); + int pos = expr.IndexOf("::", StringComparison.Ordinal); if (pos < 0 && allowDot) { pos = expr.IndexOf(':'); @@ -9498,7 +9498,7 @@ protected static int[] DecodeDateTimeConst(string dateliteral) { if (args.Length == 7) { - var suffix = args[6].Trim().ToLower(); + var suffix = args[6].Trim().ToLowerInvariant(); if (suffix == "am" || suffix == "pm") { bool pm = suffix == "pm"; @@ -9592,7 +9592,7 @@ public override void ExitLiteralValue([NotNull] XP.LiteralValueContext context) { try { - var dt = new DateTime(elements[0], elements[1], elements[2], 0, 0, 0); + var _ = new DateTime(elements[0], elements[1], elements[2], 0, 0, 0); } catch (Exception e) { @@ -9616,7 +9616,7 @@ public override void ExitLiteralValue([NotNull] XP.LiteralValueContext context) { try { - var dt = new DateTime(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]); + var _ = new DateTime(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]); } catch (Exception e) { @@ -9700,7 +9700,7 @@ public override void ExitParserLiteralValue([NotNull] XP.ParserLiteralValueConte { try { - var dt = new DateTime(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]); + var _ = new DateTime(elements[0], elements[1], elements[2], elements[3], elements[4], elements[5]); } catch (Exception e) { diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs index 2ebac7a8e5..e93d5517eb 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationFox.cs @@ -707,7 +707,7 @@ public override void ExitMethodCall([NotNull] XP.MethodCallContext context) { // Intrinsic functions that depend on Vulcan types IdentifierNameSyntax ins = expr as IdentifierNameSyntax; - name = ins.Identifier.Text.ToUpper(); + name = ins.Identifier.Text.ToUpperInvariant(); if (name == XSharpIntrinsicNames.DoDefault) { var entity = CurrentMember; @@ -824,7 +824,7 @@ public override void ExitFoxclassvars([NotNull] XP.FoxclassvarsContext context) public override void EnterFoxmethod([NotNull] XP.FoxmethodContext context) { Check4ClipperCC(context, context.Sig.ParamList?._Params, context.Sig.CallingConvention?.Convention, context.Sig.Type); - var name = context.Id.GetText().ToUpper(); + var name = context.Id.GetText().ToUpperInvariant(); if (name == "INIT" && (context.Params == null || context.Params._Params.Count == 0)) { context.Data.HasClipperCallingConvention = true; @@ -997,7 +997,7 @@ public override void ExitFoxclass([NotNull] XP.FoxclassContext context) var mem = fcfc.Member; foreach (var v in mem._Vars) { - fieldNames.Add(v.GetText().ToLower()); + fieldNames.Add(v.GetText().ToLowerInvariant()); } if (mem.CsNode is List list) { @@ -1211,7 +1211,7 @@ private ConstructorDeclarationSyntax createConstructor(XP.FoxclassContext contex { // fetch parameters from procedure/function init, so they can be copied to the generated constructor var method = fm.Member; - if (method.Id.GetText().ToLower() == "init") + if (string.Equals(method.Id.GetText(), "init", StringComparison.OrdinalIgnoreCase)) { var syntax = method.Get(); initparams = syntax.ParameterList; diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationRT.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationRT.cs index 3b862f7a41..740e660c1d 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationRT.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationRT.cs @@ -281,7 +281,7 @@ protected ExpressionSyntax MakePublicInitializer(string name) { // Assign FALSE to PUBLIC variables or TRUE when the name is CLIPPER bool publicValue; - switch (name.ToUpper()) + switch (name.ToUpperInvariant()) { case "FOX": case "FOXPRO": @@ -928,7 +928,7 @@ internal ExpressionSyntax GenerateFieldGet(XSharpParserRuleContext context, stri } else { - if (alias.ToUpper() == "M") + if (alias.ToUpperInvariant() == "M") { return GenerateMemVarGet(context, field); } @@ -980,26 +980,29 @@ public override void ExitNameExpression([NotNull] XP.NameExpressionContext conte // Check to see if the name is a field or Memvar, registered with the FIELD or MemVar statement string Name = context.Name.GetText(); ExpressionSyntax expr = context.Name.Get(); - // For expressions such as String.IsNullOrEmpty() - // we do not want String to be seen as a memvar. - // in this case the Parent of name is SimpleName and the parent of that is a Primary - var amc = context.XParent.XParent as XP.AccessMemberContext; - var staticCall = false; - var usesColon = false; - if (amc != null) - { - staticCall = amc.IsStaticMethodCall || amc.IsDotColonExpression; - usesColon = amc.IsColonExpression; - } // SomeVar(1,2) Can also be a FoxPro array access - if (!usesColon) + + if (context.Parent.Parent is not XP.MethodCallContext || + (_options.HasOption(CompilerOption.FoxArraySupport, context, PragmaOptions))) { - if (!staticCall || - (_options.HasOption(CompilerOption.FoxArraySupport, context, PragmaOptions))) + MemVarFieldInfo fieldInfo = findVar(Name); + var amc = context.Parent.Parent as XP.AccessMemberContext; + var staticCall = amc?.Op.Type == XP.DOTCOLON; + var methodCall = amc?.Parent is MethodCallContext; + if (fieldInfo != null && !staticCall && !methodCall && !context.IsInLambdaOrCodeBlock()) { - MemVarFieldInfo fieldInfo = null; - if (!staticCall) - fieldInfo = findVar(Name); + // for code that looks like this we do not want to change the expression + // Foo(1,2) + // even when Foo is a private because this can never be a assignment + if (!fieldInfo.IsField) + { + if (context.Parent is XP.PrimaryExpressionContext pec && + pec.Parent is XP.MethodCallContext mcc && + mcc.Parent is XP.ExpressionStmtContext) + { + fieldInfo = null; + } + } if (fieldInfo != null) { expr = MakeMemVarField(fieldInfo); @@ -2811,7 +2814,7 @@ private AttributeSyntax EncodeDefaultParameter([NotNull] XP.ParameterContext con bool Ok; Ok = datatype is XP.SimpleDatatypeContext sdtc1 && sdtc1.TypeName.Start.Type == XP.USUAL; var typename = datatype.GetText(); - Ok = Ok || typename.ToLower().EndsWith(OurTypeNames.UsualType.ToLower()); + Ok = Ok || typename.ToLowerInvariant().EndsWith(OurTypeNames.UsualType.ToLowerInvariant()); if (!Ok) { _parseErrors.Add(new ParseErrorData(initexpr, ErrorCode.WRN_ConversionFromNilNotSupported, typename)); @@ -3171,10 +3174,10 @@ private ExpressionSyntax GenerateLiteralSymbol(string symbol) { //remove the # from the string symbol = symbol.Substring(1); - var expr = CreateObject(SymbolType, MakeArgumentList(MakeArgument(GenerateLiteral(symbol.ToUpper())))); + var expr = CreateObject(SymbolType, MakeArgumentList(MakeArgument(GenerateLiteral(symbol.ToUpperInvariant())))); if (_options.MacroScript || _options.Kind == SourceCodeKind.Script) return expr; - var lsym = "_" + symbol.ToLower(); + var lsym = "_" + symbol.ToLowerInvariant(); if (!_literalSymbols.ContainsKey(lsym)) { // create field declarator with inline assignment @@ -3295,7 +3298,7 @@ public override void ExitMethodCall([NotNull] XP.MethodCallContext context) if (expr is IdentifierNameSyntax ins) { // Intrinsic functions that depend on X# types - name = ins.Identifier.Text.ToUpper(); + name = ins.Identifier.Text.ToUpperInvariant(); switch (name) { case "MEXEC": @@ -3368,7 +3371,7 @@ public override void ExitMethodCall([NotNull] XP.MethodCallContext context) else if (expr is GenericNameSyntax) { var gns = expr as GenericNameSyntax; - name = gns.Identifier.Text.ToUpper(); + name = gns.Identifier.Text.ToUpperInvariant(); switch (name) { case XSharpIntrinsicNames.PCallNative: @@ -3396,7 +3399,7 @@ public override void ExitMethodCall([NotNull] XP.MethodCallContext context) } else if (expr is MemberAccessExpressionSyntax maes) { - var memname = maes.Name.Identifier.Text.ToUpper(); + var memname = maes.Name.Identifier.Text.ToUpperInvariant(); if (memname == "EVAL" && _options.HasOption(CompilerOption.MemVars, context, PragmaOptions) && CurrentMember != null) { CurrentMember.Data.HasMemVars = true; @@ -3508,15 +3511,16 @@ protected void Check4ClipperCC(XP.IMemberContext context, IList 0) + if (_options.HasOption(CompilerOption.MemVars, context, PragmaOptions) && context.Name.GetText().IndexOf('.') > 0) { var id = getMacroNameExpression(context.Name); var expr = GenerateMemVarGet(context, id); diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationXPP.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationXPP.cs index 03ba3c1d96..9f7a52d3a2 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationXPP.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Parser/XSharpTreeTransformationXPP.cs @@ -23,7 +23,7 @@ namespace Microsoft.CodeAnalysis.CSharp.Syntax.InternalSyntax public class XppClassInfo { internal IList Methods { get; set; } - private IList Properties { get; set; } + private HashSet Properties { get; set; } internal IList ExternalMethods { get; set; } internal string Name { get; set; } internal string BaseClassName { get; set; } @@ -34,7 +34,7 @@ internal XppClassInfo(string name) Name = name; Methods = new List(); ExternalMethods = new List(); - Properties = new List(); + Properties = new HashSet(StringComparer.OrdinalIgnoreCase); BaseClassName = string.Empty; CurrentVisibility = XP.HIDDEN; } @@ -56,15 +56,10 @@ internal XppDeclaredMethodInfo FindMethod(string name) } internal void AddProperty(string name) { - name = name.ToLower(); - if (!Properties.Contains(name)) - { - Properties.Add(name); - } + Properties.Add(name); } internal bool HasProperty(string name) { - name = name.ToLower(); return Properties.Contains(name); } } @@ -1205,7 +1200,7 @@ public override void ExitMethodCall([NotNull] XP.MethodCallContext context) // convert ClassName():New(...) to ClassName{...} if (context.Expr is XP.AccessMemberContext lhs) { - if (lhs.Name.GetText().ToLower() == "new") + if (string.Equals(lhs.Name.GetText(), "new", StringComparison.OrdinalIgnoreCase)) { if (lhs.Op.Type == XP.COLONCOLON) { @@ -1299,7 +1294,7 @@ public override void ExitAccessMember([NotNull] XP.AccessMemberContext context) var parent = info.Parent; var parentName = GenerateSimpleName(parent.Name); var name = context.Name.Get(); - if (context.Name.GetText().ToLower() != "new") + if (!string.Equals(context.Name.GetText(), "new", StringComparison.OrdinalIgnoreCase)) { context.Put(MakeSimpleMemberAccess(parentName, name)); } diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPPRule.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPPRule.cs index 44c635e3cf..58acd79d30 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPPRule.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPPRule.cs @@ -49,17 +49,17 @@ internal PPRule(XSharpToken udc, IList tokens, out PPErrorMessages switch (udc.Type) { case XSharpLexer.PP_COMMAND: - if (udc.Text.ToLower() == "#command") + if (udc.Text.StartsWith("#co", StringComparison.OrdinalIgnoreCase)) _type = PPUDCType.Command; - else if (udc.Text.ToLower() == "#xcommand") + else if (udc.Text.StartsWith("#xc", StringComparison.OrdinalIgnoreCase)) _type = PPUDCType.XCommand; else _type = PPUDCType.YCommand; break; case XSharpLexer.PP_TRANSLATE: - if (udc.Text.ToLower().StartsWith("#trans")) + if (udc.Text.StartsWith("#t", StringComparison.OrdinalIgnoreCase)) _type = PPUDCType.Translate; - else if (udc.Text.ToLower() == "#xtranslate") + else if (udc.Text.StartsWith("#xt", StringComparison.OrdinalIgnoreCase)) _type = PPUDCType.XTranslate; else _type = PPUDCType.YTranslate; @@ -268,7 +268,7 @@ bool parseRuleTokens(XSharpToken udc, XSharpToken[] tokens) } void checkForRepeat(XSharpToken udc) { - var keys = new List(); + var keys = new HashSet(StringComparer.OrdinalIgnoreCase); var flattened = new List(); foreach (var restoken in _resulttokens) { @@ -279,27 +279,24 @@ void checkForRepeat(XSharpToken udc) if (!child.IsToken && !child.IsOptional) { flattened.Add(child); - if (!keys.Contains(child.Token.Text.ToLower())) - { - keys.Add(child.Token.Text.ToLower()); - } + keys.Add(child.Token.Text); } } } if (!restoken.IsToken && !restoken.IsOptional) { flattened.Add(restoken); - if (!keys.Contains(restoken.Token.Text.ToLower())) - keys.Add(restoken.Token.Text.ToLower()); + keys.Add(restoken.Token.Text); } } foreach (var restoken in flattened) { - var tokenName = restoken.Token.Text.ToLower(); + var tokenName = restoken.Token.Text.ToLowerInvariant(); foreach (string name in keys) { - if (tokenName != name && isRepeatToken(tokenName, name)) + if (String.Compare(tokenName, name, StringComparison.OrdinalIgnoreCase) != 0 + && isRepeatToken(tokenName, name)) { if (tokenName.EndsWith("n", StringComparison.OrdinalIgnoreCase)) { @@ -428,7 +425,7 @@ void addToDict(Dictionary markers, PPMatchToken element) { if (element.Token.IsName() || element.Token.Type == XSharpLexer.SYMBOL_CONST || element.IsWholeUDC) { - string name = element.Key.ToLower(); + string name = element.Key.ToLowerInvariant(); if (name == "udc" && !element.IsWholeUDC) { addErrorMessage(element.Token, $"The Match marker name '{element.Key}' is reserved"); diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPreprocessor.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPreprocessor.cs index 99a4491d55..23e16b3c7a 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPreprocessor.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Preprocessor/XSharpPreprocessor.cs @@ -286,9 +286,9 @@ private void initStdDefines(string fileName) if (_options.PreprocessorSymbolsUpper.Contains("NDEBUG")) debug = false; #else - if (_options.PreprocessorSymbolNames.Contains((name) => name.ToUpper() == "DEBUG")) + if (_options.PreprocessorSymbolNames.Contains((name) => name.Equals("DEBUG",StringComparison.OrdinalIgnoreCase))) debug = true; - if (_options.PreprocessorSymbolNames.Contains((name) => name.ToUpper() == "NDEBUG")) + if (_options.PreprocessorSymbolNames.Contains((name) => name.Equals("NDEBUG",StringComparison.OrdinalIgnoreCase))) debug = false; #endif #endif @@ -547,7 +547,7 @@ internal XSharpPreprocessor(XSharpLexer lexer, ITokenStream lexerStream, CSharpP { _ppoWriter = null; _preprocessorOutput = _options.PreprocessorOutput; - if (FileNameUtilities.GetExtension(fileName).ToLower() == ".ppo") + if (FileNameUtilities.GetExtension(fileName).ToLowerInvariant() == ".ppo") { _preprocessorOutput = false; } @@ -795,7 +795,7 @@ IList ProcessLine(IList line, bool write2ppo) } } var sLine = sb.ToString().Trim(); - if (sLine.ToUpper().StartsWith("ENDTEXT")) + if (sLine.StartsWith("ENDTEXT", StringComparison.OrdinalIgnoreCase)) { var temp = stripWs(line); line = doNormalLine(temp, write2ppo); @@ -1153,7 +1153,7 @@ private Exception readFileContents(string fp, out string nfp, out SourceText tex #endif private bool isObsoleteIncludeFile(string includeFileName, XSharpToken token) { - string file = Path.GetFileName(includeFileName).ToLower(); + string file = Path.GetFileName(includeFileName).ToLowerInvariant(); bool obsolete = false; string assemblyName = ""; bool sdkdefs = _options.RuntimeAssemblies.HasFlag(RuntimeAssemblies.SdkDefines); @@ -1303,7 +1303,7 @@ private bool ProcessIncludeFile(string includeFileName, XSharpToken fileNameToke if (resolvedIncludeFileName == null) { loadResources(); - var baseName = Path.GetFileNameWithoutExtension(includeFileName).ToLower(); + var baseName = Path.GetFileNameWithoutExtension(includeFileName).ToLowerInvariant(); if (embeddedHeaders.TryGetValue(baseName, out var source)) { text = SourceText.From(source); @@ -2106,7 +2106,7 @@ private void doNullableDirective(IList originalTokens, bool isIfDef } // #nullable Pragmastate state; - switch (tokens[1].Text.ToLower()) + switch (tokens[1].Text.ToLowerInvariant()) { case "enable": state = Pragmastate.On; @@ -2127,7 +2127,7 @@ private void doNullableDirective(IList originalTokens, bool isIfDef if (tokens.Count == 3) { optionToken = tokens[2]; - switch (optionToken.Text.ToLower()) + switch (optionToken.Text.ToLowerInvariant()) { case "warnings": kind = SyntaxKind.WarningsKeyword; @@ -2220,7 +2220,7 @@ private void doPragmaDirective(IList originalTokens, bool isIfDef) if (error == ErrorCode.Unknown) { - switch (i1.Text.ToLower()) + switch (i1.Text.ToLowerInvariant()) { case "options": isWarning = false; @@ -2239,7 +2239,7 @@ private void doPragmaDirective(IList originalTokens, bool isIfDef) { if (i2 != null) { - switch (i2.Text.ToLower()) + switch (i2.Text.ToLowerInvariant()) { case "enable": case "true": @@ -2278,7 +2278,7 @@ private void doPragmaDirective(IList originalTokens, bool isIfDef) else if (numbers.Count == 0) { // options pop - if (i2.Text.ToLower() == "pop") + if (i2.Text.ToLowerInvariant() == "pop") { pragma = new PragmaOption(start, Pragmastate.Default, CompilerOption.All); } @@ -2291,7 +2291,7 @@ private void doPragmaDirective(IList originalTokens, bool isIfDef) else { var token = numbers[0]; - var opt = token.Text.ToLower(); + var opt = token.Text.ToLowerInvariant(); if (token.Type == XSharpParser.STRING_CONST && opt.StartsWith("\"") && opt.EndsWith("\"") && opt.Length > 2) { opt = opt.Substring(1, opt.Length - 2); diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeNameHelpers.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeNameHelpers.cs index b05ec10bcf..ccb48e705b 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeNameHelpers.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeNameHelpers.cs @@ -5,6 +5,8 @@ // #nullable disable +using System; + namespace Microsoft.CodeAnalysis { internal static class XsHelpers @@ -12,7 +14,7 @@ internal static class XsHelpers internal static string ReplaceTypeNames(string result) { result = result.Replace("void*", "ptr"); - if (result.IndexOf("XSharp.") >= 0) + if (result.IndexOf("XSharp.", StringComparison.OrdinalIgnoreCase) >= 0) { result = result.Replace("XSharp.__Usual", "usual"); result = result.Replace("XSharp.__Date", "date"); diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeSymbolExtensions.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeSymbolExtensions.cs index 35abafee35..b144a6f047 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeSymbolExtensions.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/Symbols/TypeSymbolExtensions.cs @@ -518,7 +518,7 @@ public static bool TypesChanged(this TypeSymbol type) public static string GetDisplayName(this TypeSymbol type) { string strType = type.ToString(); - switch (strType.ToLower()) + switch (strType.ToLowerInvariant()) { case "xsharp.__date": strType = "date"; diff --git a/src/Compiler/src/Compiler/XSharpCodeAnalysis/VsParser/Stubs.cs b/src/Compiler/src/Compiler/XSharpCodeAnalysis/VsParser/Stubs.cs index c13f634be9..9f255d4a37 100644 --- a/src/Compiler/src/Compiler/XSharpCodeAnalysis/VsParser/Stubs.cs +++ b/src/Compiler/src/Compiler/XSharpCodeAnalysis/VsParser/Stubs.cs @@ -205,7 +205,7 @@ public static CSharpParseOptions FromVsValues(IList options) foreach (var opt in options) { string name, value; - var pos = opt.IndexOf(":"); + var pos = opt.IndexOf(':'); if (pos > 0) { @@ -217,7 +217,7 @@ public static CSharpParseOptions FromVsValues(IList options) name = opt; value = ""; } - name = name.ToLower(); + name = name.ToLowerInvariant(); if (name == "d") { var defs = value.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); From 243efc6755bc38b2aab6c5a08c19b9d344558524 Mon Sep 17 00:00:00 2001 From: hpetriffer Date: Tue, 29 Sep 2026 16:34:48 +0200 Subject: [PATCH 005/180] [VsIntegration] CPS project system for SDK-style X# projects (#2094) * [VsIntegration] CPS project system: new ProjectSystemCPS project and WP-1 skeleton First step of the MPFproj -> CPS migration (WP-1: project type registration & skeleton). - New SDK-style project src/VisualStudio/ProjectSystemCPS (net48, XSharp.ProjectSystemCPS.dll), references only XSharpCodeModelXs (never ProjectBase/ProjectPackage). Part of VSIntegration2022.sln and Master.slnx. - XSharpProjectSystemPackage registers a CPS project type for .xsproj with the reserved guidCpsProjectType {AB494DCE-...}, template language "XSharpCps" and the initial capability "XSharpCps". Only compiled with XSHARPCPS (Debug), so the Release VSIX does not register it and MPFproj stays the default project system (side by side via the project type GUID). - XSharpCpsGlobalPropertiesProvider sets XSharpCpsProjectSystem=true for projects loaded by the CPS project type. - X# MSBuild: XSharp.DesignTime.targets revived; it imports VS' Microsoft.Managed.DesignTime.targets (managed project system: Dependencies tree, PackageReference, launch profiles, property pages) and removes the LanguageService/ReferencesFolder capabilities (no Roslyn workspace for X#). It is only imported when XSharpCpsProjectSystem is true, so MPFproj and command line builds are unchanged. New Rules/ProjectItemsSchema.XSharp.xaml (.prg/.prgx/.xs -> Compile, headers -> None). - ProjectPackage2022 ships XSharp.ProjectSystemCPS.dll + pkgdef in its VSIX. - Test bed src/VisualStudio/ProjectSystemCPS.TestBed: SDK-style CpsTestBed.xsproj, CpsTestBed.sln with the CPS project type GUID, StartExp.cmd (starts the VS 2022 experimental instance with the repository X# MSBuild files, without changing the installed X#). Verified from the command line: normal builds unchanged; with the CPS property the managed capabilities and rules are present and the design-time build returns the compiler switches and resolved references. Acceptance test in the VS experimental instance still pending. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system WP-5: XSharpProjectAdapter feeds the code model XSharpProjectAdapter (IProjectDynamicLoadComponent + IXSharpProject, one per UnconfiguredProject, active configuration) creates the unchanged XProject and feeds it from CPS instead of MPFproj hierarchy walking and .rsp parsing: - source items (evaluation) -> XProject.AddFile/RemoveFile, ModelWalker.AddProject - XSharpProjectProperties + EvaluatedProjectReference (evaluation) -> RootNamespace, output paths, NS, provisional dialect, X# project references (AddProjectReference/RemoveProjectReference) - XSharpCompilerCommandLineArgs (design-time build, CompileDesignTime without running xsc) -> XParseOptions.FromVsValues/ResetParseOptions and RefreshReferences/ResolveReferences, so parse options and references are correct before the first real build. XSharpCommandLine maps the Xsc switches to the FromVsValues format (as XSharpProjectOptions does for MPFproj). IntellisenseErrorStore keeps the code model errors per file (no Error List yet). If the X# solution model is not open yet, the adapter loads the X# project package by GUID. New rules Rules/XSharpCompilerCommandLineArgs.xaml and Rules/XSharpProjectProperties.xaml (Context ProjectSubscriptionService), registered in XSharp.DesignTime.targets. Verified from the command line with the design-time output of a VO dialect project (dialect, /ns, defines, include path, references). Acceptance test in VS pending. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system WP-2: project capabilities and X# icons - Initial capabilities of the CPS project type (ProjectTypeRegistration.Capabilities), modelled on the managed C# project type: XSharpCps; AppDesigner; HandlesOwnReload; OpenProjectFile; PreserveFormatting; ProjectConfigurationsDeclaredDimensions; .NET; UseProjectEvaluationCache (without LanguageService, CSharp, SharedImports and EditAndContinue). - XSharp.DesignTime.targets adds ProjectPropertiesEditor (new property editor for the XAML property pages of WP-4) to the managed capability set. - The managed project system only provides project icons for C#/VB/F# (internal IProjectImageProvider): XSharpProjectTreePropertiesProvider sets the X# project icon and the X# document icon for .prg/.prgx/.xs files via IProjectTreePropertiesProvider. New XSharp.ProjectSystemCPS.imagemanifest (images as WPF resources in the assembly), shipped as ImageManifest asset in the ProjectPackage2022 VSIX. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system WP-3: X# item types and item templates - ProjectItemsSchema.XSharp.xaml maps .rc to NativeResource and the VO binaries (.xsfrm/.vnfrm/.xsdbs/.vndbs/.xsmnu/.vnmnu/.xsfs/.vnfs/.xssql/.xsrep) to VOBinary. - NativeResource/VOBinary File and BrowseObject rules restored from 58cca0eaeb^ and registered in XSharp.DesignTime.targets; fixed CustomTool/SubType data sources that still used ItemType None. - AddItemTemplatesGuid, GeneratorsTypeGuid and CmdUIContextGuid now use the X# project factory GUID {AA6C8D78-...} instead of the C# values, so CPS projects get the X# item templates and single file generators that the X# project package already registers there. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system WP-4: X# property pages as XAML rules Property pages for the new property editor (capability ProjectPropertiesEditor), restored from 58cca0eaeb^ and registered with Context Project in XSharp.DesignTime.targets: - LanguagePage.XSharp.xaml (Language) and DialectPage.XSharp.xaml (Dialect) - BuildPropertyPage.XSharp.xaml and ApplicationPropertyPage.XSharp.xaml extend the managed Build/Application pages (OverrideMode="Extend") - ReferencesPage.XSharp.xaml (Global Usings) Corrected against the property names read by the Xsc task and persisted by MPFproj: Stddefs -> StandardDefs, OtherFlags -> CommandLineOption, UseShared -> UseSharedCompilation, INS as bool; added the missing VO17 and FOX3 dialect options. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system WP-6: commands side by side, Error List and Task List MPFproj commands (ProjectPackage) with X# projects loaded by CPS, where XProject.ProjectNode is the XSharpProjectAdapter instead of an XSharpProjectNode: - CommandGenerateWinForm: hard cast replaced by a type check (would throw InvalidCastException) - CommandAddDesignerFile: only visible for MPFproj projects (needs the MPFproj file node) - CommandEditProjectFile: only visible for MPFproj projects (CPS has its own Edit Project File) - new helper Commands.ProjectIsMpfProjectAsync() ProjectSystemCPS replacements for the MPFproj ErrorListManager/TaskListManager: - IntellisenseErrorList shows the code model errors of the project in the Error List - CommentTaskList shows the comment tasks after project/file walks in the Task List Both refresh coalesced on the UI thread. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system WP-7: VO designers through the adapter The VO editor panes hold the IXSharpProject of the file's XProject, which is the XSharpProjectAdapter for CPS projects, so the VO designers are served through the adapter. The designers (XSharpVoEditors Functions.EnsureFileNodeExists/DeleteFile) write generated files to disk and then call HasFileNode/AddFileNode/DeleteFileNode. The adapter now registers and unregisters these files with the code model immediately instead of ignoring the calls; in SDK-style projects the XSharp.SDK.Props globs include them (with DependentUpon), so the project file does not change and CPS confirms the item with the next evaluation. HasFileNode compares full paths. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: make the project properties UI available X# CPS projects had no project properties UI: CPS only offers the project designer when at least one IVsProjectDesignerPageProvider applies (VsProjectDesignerPageService.IsProjectDesignerSupported), and the managed project system only has providers for C#, VB and F#. - New XSharpProjectDesignerPageProvider ([AppliesTo("XSharpCps & AppDesigner")]). It lists no classic COM pages: with the ProjectPropertiesEditor capability the AppDesigner editor factory opens the new property editor, which shows the XAML rules (managed pages + X# pages). - ProjectPropertiesEditor is now also an initial capability of the project type, so the new editor does not depend on the X# targets that declare it in XSharp.DesignTime.targets. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: project selector for SDK-style and legacy projects Two X# project systems side by side, like the legacy and SDK project systems of C#/VB/F#: legacy .xsproj stay on MPFproj ({AA6C8D78-...}), SDK-style .xsproj are loaded by CPS ({AB494DCE-...}). - XSharpProjectSelector (IVsProjectSelector, the reserved guidProjectSelectorString) is registered for the MPFproj project type and sends projects with , or to the CPS project type. Existing solution files keep their project type GUID. Unreadable project files and errors fall back to MPFproj. - ProvideProjectSelectorAttribute writes Projects\{AA6C8D78}\ProjectSelector and ProjectSelectors\{selector}\Package; the package registers the selector with IVsRegisterProjectSelector during initialization and unregisters it on dispose. - Tools > Options > X# > Project System: "Load SDK-style projects with the new project system (CPS)" (default on) switches the routing off without uninstalling anything. - Still only registered with XSHARPCPS (Debug builds). - Test bed: Legacy/LegacyTestBed.xsproj and SelectorTestBed.sln (both projects with the MPFproj GUID); StartExp.cmd takes the solution as optional parameter. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: open the X# solution model for CPS-only solutions Found in the log of the first VS test: "XSharpProjectAdapter: X# solution model is not open, no code model". XSolution.Open is called by the X# project package in OnBeforeOpenSolution. For solutions with the MPFproj project type VS loads that package before the solution opens (it provides the project factory); for the CPS project type it is only autoloaded later, misses OnBeforeOpenSolution and does not see the solution yet while it is still opening, so the database was never opened and the CPS project got no code model. - XSharpProjectAdapter: after loading the X# project package, open the solution model for the solution file reported by IVsSolution.GetSolutionInfo, instead of waiting 10s and giving up. - XSharpShellLink.OnAfterOpenSolution: open the solution model before XSolution.AfterOpen() when it is still closed (safety net for any late package load). Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: fix source item subscription, first VS test results Found in the experimental instance: the CPS code model got parse options and references from the design-time build, but never any source files. LinkTo without rule names subscribes to an empty rule set, so the SourceItemsRuleSource link delivered nothing. The source item rules are dynamic (one per item type): link with SourceItemRuleNamesSource as the rule names block, as dotnet/project-system does. Added a log line with the evaluated project properties. Verified in VS (SelectorTestBed.sln): the selector loads CpsTestBed through CPS and LegacyTestBed through MPFproj; the adapter opens the solution model, adds Program.prg, the walker parses it, the design-time build delivers 58 options and 10 references; editing the project file removes files live. Test bed: CpsTestBed.xsproj excludes the Legacy subfolder from its globs (it compiled the legacy project's Start.prg as well). Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS test bed: refresh the image library cache of the experimental instance The X# project icon was not shown in the experimental instance: its ImageLibrary.cache dated from 2024 and did not contain XSharp.ProjectSystemCPS.imagemanifest, because the Debug build deploys the VSIX without refreshing that cache. StartExp.cmd now deletes the cache of the experimental instance before starting; VS rebuilds it (verified: the manifest is in the rebuilt cache). Normal VSIX installations refresh the cache themselves. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: register the CPS project type in Release builds The CPS project type, the project selector and the Tools > Options page were only registered with XSHARPCPS (Debug builds). The define and the conditional code are removed, so the Release VSIX registers them as well. Safety net for the shipped product: the selector only sends SDK-style projects to CPS when the installed X# MSBuild support files contain the CPS design-time import (XSharpCpsProjectSystem in XSharp.CurrentVersion.targets) and the XAML rules (new XSharpMsBuildSupport; folder from XSharpMsBuildDir, the registry or Program Files (x86)\XSharp\MsBuild, like XSharp.BeforeCommon.Props). With an older X# installation SDK-style projects stay on MPFproj instead of loading in CPS without rules. Verified: installed X# -> false, repository overlay (StartExp.cmd) -> true. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Port the shadow WinForms designer to the CPS project system Prerequisite for removing the MPFproj SDK path (WP-8): the shadow designer (WinForms designer for SDK-style X# projects via a hidden companion C# project) was built on the MPFproj SDK project node, so SDK projects loaded by CPS had no WinForms designer. - ShadowDesigner moved from ProjectPackage to ProjectSystemCPS (namespace XSharp.ProjectSystem.ShadowDesigner) and made project system independent: ShadowDesignerBridge.TryOpen/TryResolveCompanionPaths take the .prg path and the XProject instead of an XSharpFileNode; services from the global service provider instead of the MPFproj node/package; ShadowDesignerCleanup implements IVsSolutionEvents instead of deriving from the MPFproj SolutionListener; no Community Toolkit dependency. Public helpers IsCpsProject and HasDesignerFile. - XSharpCodeDomHelper (BuildDesignerFileName, MergeCodeCompileUnit, ...) moved from ProjectPackage to the shared CodeDomProvider project, so both project systems can use it. - CPS entry points: XSharpShadowDesignerDefaultActionCommand (double click / Enter) and XSharpShadowDesignerViewFormCommand (View Designer) open the shadow designer for a .prg with a matching .Designer.prg; otherwise CPS falls back to its default action. - MPFproj keeps working: XSharpFileNode calls the new API; the Sync Designer Changes / Sync Event Handlers commands now work for SDK projects in MPFproj and in CPS. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS test bed: SDK-style WinForms project for the shadow designer WinForms/WinFormsTestBed.xsproj (net8.0-windows, UseWindowsForms, Core dialect, from the CoreWinFormApp template) with Form1.prg/Form1.designer.prg, added to SelectorTestBed.sln with the classic X# project type GUID, so it is loaded by CPS through the project selector. Double click or View Designer on Form1.prg must open the shadow WinForms designer. CpsTestBed.xsproj excludes the WinForms subfolder from its globs. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Keep XSharpCodeDomHelper out of the GAC'd XSharp.CodeDomProvider VS test: "Could not load type 'XSharp.CodeDom.XSharpCodeDomHelper' from assembly 'XSharp.CodeDomProvider, Version=3.0.2.0'". The X# installation puts XSharp.CodeDomProvider (and XSharp.VSParser, XSharp.Evaluator) in the GAC with the same assembly version, and the GAC copy wins over the one in the VSIX, so the class moved there in the shadow designer port was not found. - XSharpCodeDomHelper back in ProjectPackage/CodeDomProvider; CodeDomProvider.csproj and the VS 2019 ProjectPackage.csproj are unchanged compared to before the port again. - ProjectSystemCPS links the same source file as an internal copy (define XSHARP_PROJECTSYSTEMCPS), so the shadow designer does not depend on a GAC'd assembly version. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Keep shadow designer companion projects out of X# SDK globs VS test: the shadow designer opened the first time, the second time the WinForms designer reported that Form1.Designer.cs "is not contained within a project that supports code". The companion C# project ({Project}.ShadowDesigner) is generated next to the X# project folder, so the X# project's own globs never see it -- but an SDK-style X# project in a parent folder does (here CpsTestBed, which contains the WinForms test project). After the first open the generated .cs files were None items of that X# project, VS used it as the owning hierarchy of Form1.Designer.cs and the designer refused it. XSharp.SDK.Props excludes **/*.ShadowDesigner/** from the default items of every X# SDK project (before XSharpDefaultItemExcludes captures DefaultItemExcludes, so the X# specific globs skip it too). Verified with a dummy companion folder: installed props -> None item, fixed props -> excluded. StartExp.cmd copies XSharp.SDK.Props into the overlay. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: form, user control and VO binary icons VS test: X# forms showed the X# document icon in CPS projects. XSharpProjectTreePropertiesProvider now mirrors XSharpFileNode (MPFproj): a .prg is a form/user control when its SubType says so, or when it has a matching .Designer.prg and its class inherits from Form/UserControl (same inference as the MPFproj SDK node, cached per file timestamp) -> KnownImageIds.WindowsForm / UserControl. VO binaries get the MPFproj icons (FormInstance, Database, MainMenuControl, ValidationRule, Report). The item path comes from the FullPath metadata (ItemName is only the file name). Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: remove the empty companion solution folder on close VS test: after closing, the saved .sln still contained the "Shadow Designer (generated)" Solution Folder. ShadowDesignerCleanup removed the companion projects in OnQueryCloseSolution, but not the folder they were nested in (behaviour inherited from the MPFproj implementation). It now also removes that folder when it is empty (IVsSolution.CloseSolutionElement, like the companion projects), so the .sln stays unchanged. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: register the project selector for the CPS project type GUID too When VS saves a solution it writes the GUID of the factory that loaded the project, so an SDK project's .sln entry flips from {AA6C8D78} (MPFproj) to {AB494DCE} (CPS). C# SDK projects flip the same way ({FAE04EC0} -> {9A19103F}), and VS offers no way to keep the original GUID. Routing the CPS GUID through the same selector means those entries still load with MPFproj when the routing option is off, the project is not SDK-style, or the installed X# MSBuild files are too old for CPS. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: make the empty solution folder cleanup work The first version never found the "Shadow Designer (generated)" folder: solution folders are virtual projects, so GetProjectEnum needs EPF_ALLPROJECTS rather than EPF_ALLINSOLUTION. Right after the companion project is removed the folder can still list it as a child without a name and without a nested project, so such children, and *.ShadowDesigner projects, no longer count as content. Each step is logged. Verified in the Exp instance: the folder is removed and is no longer in the saved .sln. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: resolve assembly references before parsing the form Opening a form shortly after the solution loaded failed with an ArgumentNullException ("e") in CSharpCodeGenerator. The project's assembly references were still queued (XProject.ResolveReferences runs at most every 15 seconds), so System.Windows.Forms.Form could not be resolved and the parser dropped the right-hand side of assignments. TryOpen already forced the queued references to load, but only after parsing; it now does so before. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] WP-8: remove the SDK-style project path from MPFproj SDK-style X# projects are loaded by the CPS project system (XSharp.ProjectSystemCPS) since the project selector routes them there and the shadow WinForms designer was ported. MPFproj keeps the legacy projects. Removed from ProjectPackage (VS 2022 only; VS 2019 never had it): - NodesSDK (XSharpSdkProjectNode, SDK reference/dependency/folder nodes) - the debug target "Framework" menu (commandDebuggerFramework.cs), the Publish/Pack commands with PublishDialog, and the priority command target that intercepted VS's own Publish/Pack. That interception also hid or broke Publish/Pack for X# projects loaded by CPS. - the SDK-only parts of the file node (shadow designer redirect), project node (SDK project reference completion), configuration provider and shell events, and the matching Menus.vsct/Menus.cs symbols. The MPFproj factory now rejects an SDK-style project with a clear message instead of creating the removed node. That only happens when the selector cannot use CPS (X# MSBuild support files too old). ProjectSystemCPS: the Tools > Options switch is gone, because MPFproj can no longer load SDK-style projects. The SDK project file check moved to the public SdkProjectFile class, which the MPFproj factory uses as well. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] WP-8: remove the dead SDK-style branches from MPFproj After the removal of XSharpSdkProjectNode, ProjectNode.IsSdkProject was always false. Removed the property and every branch that depended on it or on the project file's Sdk attribute, in ProjectBase and ProjectPackage: - ProjectFactory.CreateSdkProject (MPFproj rejects SDK-style projects in XSharpProjectFactory.CreateProject) - target framework update, rename and file refresh special cases (ProjectNode, FileNode, ProjectElement), project reference guid handling - XSharpFileNode: handling on include, designer inference from a .Designer.prg (the CPS tree provider does this now), MarkDirty on remove - XSharpProjectNode reload/upgrade checks, CommandConvertXsRuntime visibility The legacy code paths are unchanged. ProjectBase (VS 2019) builds. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: fix the UseNativeVersion and NoWin32Manifest property names The Application page extension declared "usenativeversion " and "nowin32manifest " (with trailing spaces) as property and persisted names. That is not a valid MSBuild property name: the checkboxes always showed unchecked and saving wrote nothing usable. Use the names that the Xsc task reads and MPFproj writes. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: hide the Win32 resource file option The Application page offered the C# choice between "Icon and manifest" and "Resource file". X# gets its Win32 resources from the Win32Resource item (compiled from the .rc files); the $(Win32Resource) property is never read. Choosing "Resource file" made the managed interceptor remove ApplicationIcon and ApplicationManifest and write a property the build ignores. Hide ResourceSpecificationKind and Win32Resource; Icon and Manifest stay visible because the interceptor still evaluates the kind to IconAndManifest. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: error squiggles for build errors In MPFproj the build logger fills the ErrorListManager, and GetIntellisenseErrors returns those build errors and warnings to XSharpErrorColorizer, which draws the squiggles. Under CPS the build errors only reached the VS Error List, and GetIntellisenseErrors stayed empty (the code model's own AddIntellisenseError is not called anymore), so the editor showed no squiggles at all. BuildErrorLoggerProvider (IBuildLoggerProviderAsync) attaches an MSBuild logger to real builds (Build/Rebuild/Clean, not design-time builds) and hands the errors and warnings to the adapter. Each build of a configuration replaces its previous errors; the store merges them with the code model errors per file. They are not added to the Error List, VS shows them there. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: remove the C# global usings editor "Manage Implicit Global Usings" (ImplicitUsingsEditor) only works through ImplicitUsingsValueProvider of the managed project system, which maps the value to items and applies to CSharp projects only. For X# the editor read and wrote a meaningless ImplicitUsingsEditor property. The interceptor contract lives in the private Microsoft.VisualStudio.ProjectSystem.Managed.dll, so an X# version would tie the VSIX to one VS build. The "Implicit global usings" switch stays; items are edited in the project file. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: open the X# solution model before the solution file is saved The adapter only opened the X# solution model (database) when the .sln existed on disk, and did not try again. A project opened without a solution (devenv project.xsproj, File > Open > Project) or a new project lives in a solution that VS writes only when it is saved, so these projects got no code model and no IntelliSense. XSolution.Open only needs the folder and the name, so open it for the (future) solution file, or for the project name when VS reports no solution file. Also load the X# project package with IVsShell7.LoadPackageAsync instead of blocking the UI thread. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: do not pass XSharpCpsProjectSystem to referenced projects The CPS project type sets XSharpCpsProjectSystem as a global property, and the MSBuild task calls for project references inherit global properties. Referenced C# and legacy X# projects were evaluated and built a second time with different global properties (overbuild, file locks), and referenced X# projects imported the design-time targets in a normal build. Add it to _GlobalPropertiesToRemoveFromProjectReferences (verified: a referenced project now sees an empty value, before it saw 'true'). Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: fix a dispose race in the Error List and Task List Dispose ran on the unloading thread and cleared the provider field while a refresh could be running on the UI thread past its disposed check. That refresh then created a new provider that was never disposed, and its entries stayed in the list after the project was unloaded. Dispose now only sets the (volatile) flag and removes the provider on the UI thread, where the refresh runs as well. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: keep the companions when the solution close is already cancelled OnQueryCloseSolution removed the companion projects and the "Shadow Designer (generated)" Solution Folder even when another listener had already cancelled the close. It now returns right away in that case. OnQueryCloseSolution is not final: the close can still be cancelled later (e.g. Cancel in the save prompt). That leaves the solution open without the companion projects, which is harmless: their paths stay tracked, the next View Designer adds the project back (SolutionWiring.EnsureProjectInSolution), and the folders are only deleted after a real close. Documented in the class remarks. Tested in VS: close, Cancel in the save prompt, View Designer works. Also removes the stale remark that the class subclasses the MPFproj SolutionListener; it implements IVsSolutionEvents directly. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: cancel the pending folder deletion when a companion is used again After a solution close the companion folders are deleted in the background, retrying for up to 20 s because the out-of-process designer host still locks the folder. When the solution was reopened in that time and the designer opened again, the retry could delete the freshly written companion folder while the designer used it. Each background deletion now has a CancellationTokenSource per folder. ShadowDesignerBridge calls ShadowDesignerCleanup.CancelPendingDelete before it writes the companion project (new CompanionProjectWriter.ComputeCompanionDir). Every delete attempt runs under a lock and checks the cancellation first, so after CancelPendingDelete returns no deletion is running or will start; the wait between attempts ends early on cancellation. Tested in VS with the folder locked by a process (cmd working directory): close, reopen, View Designer within 20 s -> "cancelled the pending deletion", folder and designer intact after the lock was released. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: companion stub with the real base class The companion's Form1.cs-equivalent stub always declared ": System.Windows.Forms.Form", while the generated .Designer.cs carries the real base type. For a user control the two partial declarations named different base classes (CS0263). ShadowDesignerBridge.BuildStubCSharp now generates the stub with the same CSharpCodeProvider, the same base type references and the same namespace imports as the designer code, so both parts always agree. The stub is where the designer puts new members (event handler stubs, see EventHandlerSync), so it is only rewritten while it is still an empty generated stub (CompanionProjectWriter.IsEmptyStub), e.g. one with an outdated base class. Verified outside VS: a user control gives ": UserControl" with its using, a stub with a handler is kept, old and new stub formats are recognized. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: companion target framework from the loaded project The companion project took its target framework only from in the .xsproj XML, so multi-targeting projects () and a TargetFramework from Directory.Build.props made the designer fail. The bridge now passes the active target framework of the loaded project (VSHPROPID_TargetFrameworkMoniker of its hierarchy, converted to the short form: net8.0, net48, netcoreapp3.1, ...). Without it the writer falls back to the project file, now including the first entry of . The "-windows" suffix is still appended as before. Verified: moniker conversion for .NETCoreApp 8.0/3.1 and .NETFramework 4.8/4.7.2; the test bed companion gets net8.0-windows. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: wait for the project load instead of a blocking build When the package references of the X# project were not resolved yet, the bridge built the project with EnvDTE BuildProject(WaitForBuildToFinish: true) -- a nested message pump inside the async CPS command handler. Under CPS a build does not even refresh the code model's references: they come from the design-time build (XSharpProjectAdapter), which runs after the NuGet restore. ShadowDesignerBridge.EnsureReferencesAsync (called by the CPS commands before TryOpen) now first waits asynchronously for the IntelliSense stage of the project load (IVsOperationProgressStatusService, up to 60 s) and briefly for the adapter to process the result. Only when the references are still missing it offers a build as before, which now runs through IVsSolutionBuildManager2.StartSimpleUpdateProjectConfiguration and completes through IVsUpdateSolutionEvents. A second double click during the wait is swallowed. TryOpen loses its refreshReferences parameter (the MPFproj .rsp re-read); the class docs no longer mention the removed MPFproj SDK caller. Not tested in VS: the path only runs for a project with NuGet references before its restore has finished. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: add new form files to an already loaded companion project When the companion project was already loaded (another form of the project was opened before), the bridge wrote the new form's .cs/.Designer.cs into its folder and opened the designer immediately. The companion includes its files through the SDK globs, but it did not pick them up in time -- verified in VS, not even after 10 s -- so the designer failed with "... is not contained within a project that supports code" and only worked on a second attempt. TryOpen is split into TryPrepareCompanion (parse, write, add to the solution) and TryOpenAsync: missing files are added with ProjectItems.AddFromFile, then it waits (up to 10 s) until IVsProject.IsDocumentInProject finds them, and only then opens the designer. For files covered by a glob CPS writes no explicit item into the companion .csproj (verified: the .csproj stays unchanged). Tested in VS: open a user control (loads the companion), then Form1 -> the designer opens on the first attempt. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Shadow designer: open forms added with "Add New Item" in the designer The item template wizard opens the new .prg itself, with the default editor for .prg (the X# code editor), so a new form or user control did not open in the designer. MPFproj redirected this in XSharpFileNode, which was removed with the MPFproj SDK path. CPS' own mechanism (IProjectSpecificEditorProvider with IsDefaultEditor) is not usable: it routes every open of the file to the project specific editor, also debugger and navigation opens (LOGVIEWID_Debugging/TextView), which the shadow designer cannot serve. New NewFormDesignerRedirect (IVsRunningDocTableEvents, advised when the first X# CPS project loads): on the first window of a document of a CPS X# project that belongs to a form .prg (a .Designer.prg exists) created within the last 30 s, it waits until the code model knows the file, opens the shadow designer and, only when that succeeded, closes the code window. Each file is redirected once per session, so a later View Code is not affected; Add Existing Item opens no window. XSharpShadowDesignerCommands.TryOpenAsync gets an overload without IProjectThreadingService for it. Tested in VS: Add New Item > UserControl in the CPS WinForms project opens the designer and closes the code editor (about 1.4 s); in the legacy (MPFproj) project the MPFproj designer opens as before, no redirect. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: create the code model on the UI thread The projects of a solution load in parallel, and the adapters created their XProjects at the same time on background threads. That raced in the code model: with a new X# database the lazily created OrphanedFiles project was added twice and XDatabase.Read failed with SQLite "FOREIGN KEY constraint failed" (seen in the VS log after deleting the .vs folder). MPFproj creates its XProjects one after the other on the UI thread; the adapter now switches to the UI thread before it creates the model as well. Verified in VS with a fresh database: OrphanedFiles is added once, both models are created on the UI thread, no SQLite error. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: refresh the Task List when a file is saved The comment tasks (TODO etc.) of a CPS project only showed up after the next project walk, e.g. after a design-time build, not when the file was saved. MPFproj walks a changed file again in XSharpProjectNode.OnFileChanged (WalkFile(file, notify: true)), whose FileWalkComplete event refreshes the Task List; the CPS adapter had no counterpart. New ProjectFileSaveWatcher (IVsRunningDocTableEvents, advised when the first X# CPS project loads): after a save of a source file of an X# CPS project it walks the file again on a background thread, so the adapter's FileWalkComplete handler refreshes the Task List. It also passes the Task List comment tokens (Tools > Options) to the code model when nobody did yet: the X# project package only sets them when an MPFproj project opens or after the options dialog, so a solution with only CPS projects had no comment tasks at all. Verified in VS: the TODO entry appears right after saving (the save walk runs on a background thread); "4 comment tokens set" with a fresh database. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: make the image manifest assembly findable at startup The project and .prg icons of CPS projects were often empty. The image manifest refers to its PNGs with pack URIs that name XSharp.ProjectSystemCPS by its short name. The image library resolves them when it builds its cache at startup, usually before a CPS project has loaded the assembly; no X# package registered a binding path, so the lookup failed and the whole manifest was missing from ImageLibrary.cache (no GUID, no images, while e.g. the IntelliCode manifest was there). The icons only worked when a CPS project happened to load the assembly first. - [ProvideBindingPath] on XSharpProjectSystemPackage: the extension folder is probed for loads by name, the image library finds the assembly. - [assembly: ProvideCodeBase(AssemblyName = "XSharp.ProjectSystemCPS")] next to the sibling assemblies in ProjectPackage/ExternalAssemblies.cs: loads with the full identity work too, e.g. when ProjectPackage2022 uses ShadowDesignerBridge before a CPS project has loaded the assembly. Verified in VS: after StartExp (fresh cache) the cache contains the manifest GUID and both images, the project and document icons show. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: check the overridable managed design-time targets path XSharp.DesignTime.targets imports $(XSharpManagedDesignTimeTargetsPath), but the import gates in XSharp.CurrentVersion.targets and XSharp.CrossTargeting.targets checked the hard-coded path of Microsoft.Managed.DesignTime.targets. With the property overridden to a file that does not exist, the gate passed and the project failed to load (MSB4019). The property is now defined next to XSharpDesignTimeTargetsPath and the gate checks it. Verified from the command line: default -> design-time targets imported; override to a missing file -> not imported, no error (before: MSB4019); without XSharpCpsProjectSystem -> unchanged. Project loads in VS. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: hide the property page of the NativeResource and VOBinary rules The File rules of the X# item types were copied from the managed None rule without PropertyPagesHidden="true" and without the TargetPath property. Without PropertyPagesHidden the file property dialog shows an extra, empty page for .rc files and VO binaries. Both are added as in None.xaml. Tested in VS: Test.rc shows its properties (Build Action Native Resource), no empty extra page. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: map .vnsqs and .vnrep to VOBinary The X# code model treats .vnsqs as a VO SQL table and .vnrep as a VO report, like .xssql and .xsrep (FileTypeHelpers), and the icon provider already maps them, but ProjectItemsSchema.XSharp.xaml did not: such files got no X# item type when added to a CPS project. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: SuppressRCWarnings on the Build page The MPFproj Build page has "Suppress Resource Compiler warnings" (SuppressRCWarnings, passed to the NativeResourceCompiler task, default true in XSharp.props); the CPS Build page had no rule for it. Added as a bool property in the "Errors and warnings" category with the MPFproj texts. Tested in VS: the checkbox shows ticked by default, unticking writes the property to the project file. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: do not hold the adapter lock during code model I/O The adapter's single lock protected both its file/reference sets and the calls into the code model. XProject.AddFile/RemoveFile do database I/O and ResolveReferences loads the referenced assemblies, so HasFileNode, which the VO designers call on the UI thread, could wait for that I/O. Two locks now, always taken in the same order: modelGate serializes the changes of the code model (the three subscriptions, AddFileNode/DeleteFileNode, load/unload) as before; gate only protects the file set and the model field, briefly, and HasFileNode only takes gate. ResolveReferences runs outside both locks: XProject guards it itself (_resolvingReferences), and the ModelWalker and the type lookups call it without these locks as well. Tested in VS: projects load, design-time builds apply, files added through Add New Item reach the code model, completion works. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: less file system access in the tree properties provider XSharpProjectTreePropertiesProvider runs synchronously on the CPS tree thread for every node on every tree update. It called File.Exists for every .prg (is there a .Designer.prg?), read form files completely (File.ReadAllText) to infer Form/UserControl from the base class, and its cache grew without limit. - The designer file check uses a listing of the *.Designer.prg files per folder, reused for 250 ms and read again when the folder's timestamp changes (on NTFS: a file was created, deleted or renamed). 250 ms covers the burst of one tree update; longer could miss a .Designer.prg created by Add New Item. ShadowDesignerBridge.HasDesignerFile stays uncached (the commands and NewFormDesignerRedirect need the current state). - The base class check reads the file in 4 KB blocks only until the first CLASS ... INHERIT declaration, at most 64 KB. - Both caches are cleared when they exceed 1000 entries. Verified outside VS (reflection): Form1.prg -> Form, a UserControl whose declaration follows after ~6 KB -> UserControl, a new .Designer.prg is found after 0.3 s. Tested in VS: project, document, form and user control icons, also for a user control added with Add New Item. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: do not copy all intellisense errors on every Add IntellisenseErrorStore built the complete error list of the project on every Add and handed it to IntellisenseErrorList, which only applies the last one per (coalesced) UI refresh. The store now only reports the change; the Error List fetches the errors with IntellisenseErrorStore.GetAll once per refresh (after resetting its scheduled flag, so a later change schedules the next one). The code model does not report intellisense errors at the moment (see the CPS migration spec, WP-6), so this matters once it does again. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS test bed: SDK-style VO project for the VO designers New VO\VOTestBed.xsproj in SelectorTestBed.sln (classic X# project type GUID, the project selector sends it to CPS), made from the VO SDI Application template (ProjectPackage/Templates/Projects/Windows/VOSdiApp): a VO window (Help About.HELPABOUT.xsfrm), two menus (SDI Menus.*.xsmnu), their .prg/.rc files, the VO designer templates in Properties\ and the resources. Differences from the template: SDK-style (net48, x86, VO dialect and the template's compiler options), no AssemblyInfo.prg (the SDK generates the attributes), no explicit items (the X# SDK globs add .prg/.rc/VO binaries with DependentUpon), and the X# runtime and VO SDK assemblies referenced with a HintPath into the X# installation (XSharpPath from the registry). CpsTestBed.xsproj keeps VO\** out of its globs, including the NativeResource and VOBinary items. StartExp.cmd describes the test projects. Verified: builds from the command line; in VS the selector loads it with CPS, the code model gets all 23 files, the VO window editor opens the window and saving regenerates the .xsfrm and .rc without changing the project file. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: walk source files that change on disk Under CPS nobody re-read a source file that changed on disk outside the VS editor. The VO designers write the generated .prg directly to disk when it is not open in an editor (menu editor: SDI Menus.prg with the new menu IDs, window editor: Help About.prg with the new control), and the code model kept the old types until the next project walk (found in the VS test with VO/VOTestBed). MPFproj covers this in XSharpProjectNode.OnFileChanged (WalkFile(file, notify: true)). New SourceFileWatcher (one per project, created by the adapter): a FileSystemWatcher on the project folder including subfolders. Changes to source files of the project (adapter: in the file set and XFile.IsSource) are collected and walked after 500 ms, one walk per file for a burst of writes; notify: true refreshes the Task List. After a buffer overflow the whole project is walked again. Files outside the project folder (links) are not watched. The watcher also sees saves from the VS editor, so the editor save walk of ProjectFileSaveWatcher (IVsRunningDocTableEvents.OnAfterSave, 1803b79e2a) is removed to avoid a second walk per save. What remains of that file, setting the comment tokens for pure CPS solutions, is now CommentTokens.EnsureSet. Verified outside VS: 5 quick writes -> one callback 500 ms after the last, temp file + rename (editor save) -> callback, non-source file -> none, none after Dispose. Tested in VS: menu editor and window editor saves with the .prg closed -> "changed on disk, walking it again" 0.5 s later, new menu item and control in the code model and in completion; TODO saved in the editor -> Task List entry. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS test bed: DBServer and FieldSpec for the VO designers VO\VOTestBed gets a DBServer (Customer.prg + Customer.Customer.xsdbs, class Customer on Customer.dbf) and FieldSpecs (Fieldspecs.prg + Fieldspecs.FieldSpecs.xsfs), created from the X# item templates VODBServer and VOFieldSpec (ProjectPackage/Templates/ProjectItems/VO) with $safeitemrootname$ replaced; Fieldspecs.prg is the template's empty stub, the FieldSpec editor fills it. The X# SDK globs add the VO binaries as VOBinary with DependentUpon. Tested in VS: the FieldSpec editor regenerates Fieldspecs.prg, the DBServer editor regenerates Customer.prg and creates Customer.FieldSpecs.xsfs (added to the code model through AddFileNode and the glob); SourceFileWatcher walks the .prg files 0.5 s after the save; the generated code compiles; the project file stays unchanged. The committed files are the template state. Co-Authored-By: Claude Opus 5.5 * [CodeDomProvider] Write static field references on parsed types with '.' GenerateFieldReferenceExpression used the static selector only when the target was exactly a CodeTypeReferenceExpression. The X# CodeDOM parser creates the subclass XCodeTypeReferenceExpression, so code that was parsed and generated again got a colon: "Add .designer file" wrote "System.Windows.Forms.AutoScaleMode:Font", which the compiler rejects (XS9114) and the shadow designer cannot convert. GeneratePropertyReference- Expression already tested with "is"; now both do. Checked outside VS with the dev build (DEVPATH, the GAC copy of 3.0.2 still writes the colon): an XCodeTypeReferenceExpression target gives "AutoScaleMode.Font", SELF:button1 keeps the colon. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: form icon for generated form files The tree properties provider found the base class of a form with "CLASS name INHERIT base" on one line. The X# CodeDOM generator writes the declaration with a line continuation ("CLASS Form1 ;" and "INHERIT ..." on the next line), so a form lost its icon as soon as the generator wrote its main file: "Add .designer file", or the shadow designer adding an event handler. The regex now allows the continuation. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: update the form icon when a designer file is added CPS calls the tree properties providers only for the nodes that changed in a tree update. "Add .designer file" adds a .Designer.prg below an existing .prg: that adds a child node but leaves the node of the .prg unchanged, so its form icon only appeared after the project was loaded again. When the list of properties providers changes, CPS calculates the properties of all nodes again (PhysicalProjectTreeProvider.OnProjectTreePropertiesProviders- Changed, providers compared by instance). New XSharpProjectTreePropertiesProviderSource (IProjectTreePropertiesProvider- DataSource, the pattern of the managed project system's TreeItemOrder- PropertyProviderSource) supplies the provider, which is no longer a MEF export itself. It follows the source items and publishes a new provider only when a .Designer.prg was added or removed. Its values carry their own version, not the versions of the source items subscription: the tree input synchronizes its sources by their data source versions, and with the source item versions the tree was never published and VS hung while restoring the open documents (seen in the experimental instance, stacks read with cdb). The first provider is published right away. Tested in VS: the icon changes right after "Add .designer file" and after deleting the designer file; the solution loads normally. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Add .designer file for X# projects loaded by CPS The command was hidden for CPS projects: it generated the designer file from the MPFproj file node (XSharpFileNode) and cast the project node to XSharpProjectNode. - Visible for .prg files of X# projects only (before, the MPFproj check also kept it away from C# forms). SDK-style projects rarely have a SubType, so for CPS projects the base classes of the first class in the file are followed through the code model, the same rule as XSharpFileNode.DetermineSubType (TypeNameToSubtype is now internal). Also hidden when a .designer.prg exists next to the file without being nested below it; the command would have overwritten it. - VSXSharpCodeDomProvider has a second constructor with the code model project and the file path; without a file node it writes into an open editor buffer by path. The CPS project system needs no AddFileNode: the SDK globs include the new file and XSharp.SDK.Props nests it. - The form is parsed first; the files are only created when the form class with InitializeComponent was found. Right after the solution was opened the references are not loaded yet and the parser cannot recognize it (the command left an empty designer file behind and failed silently). Now a message says to try again later. Exceptions are shown instead of only going to the activity log. Tested in VS with a single-file form in the WinForms test project: the designer file is created and nested, the form keeps its icon, the designer opens it (after correcting "AutoScaleMode:Font", written by the GAC copy of the CodeDOM generator without 5ec34de0f2), and the project builds. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] Add .designer file: do not write the form file in lower case The generated form source was lowered for the "#endregion without #region" check and only restored when that check applied. For a form without a #region the whole form file was written back in lower case. Only the check is case insensitive now. The bug is also on dev. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS shadow designer: do not wait for the references on the blocked UI thread CPS waits synchronously on the UI thread for the task of a command handler (ProjectNode.ExecCommand), without pumping messages. When a form was opened while the package references were still missing, EnsureReferencesAsync waited for the project load inside that wait: the NuGet restore and the design-time build after it could not finish, the wait gave up after 3 s (the IntelliSense stage was already complete, the first design-time build had run without the packages), the build prompt came, and after OK VS hung for good (seen in the experimental instance, stacks read with cdb). - Double click / Enter and View Designer report the command as handled right away when package references are missing, and open the designer in the background. When it cannot be opened, the form opens in the code editor, the default action CPS would have taken. With the references present nothing changes. - After the load stage the references are awaited for up to 20 s instead of 3 s, with a status bar message. Tested in VS with a WebView2 PackageReference restored from a local feed: double click right after the solution opened -> no prompt, the designer opened 1.4 s later, after the design-time build with the packages; with a failing restore -> VS stays responsive, prompt after the wait, the build runs, the designer opens. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS shadow designer: wait only briefly for the references after a build After the build offered by EnsureReferencesAsync, the references were awaited for the same 20 s as during the project load. A build restores, and the design-time build with the references follows right after it (0.2 s in VS), so 3 s are enough. Also for a failed build: it can have restored and failed on compile errors, then the references still come; when the restore failed, the Designer used to open only after the full 20 s. Tested in VS with a restore that fails (local feed renamed): prompt, OK, the build fails, the Designer opens 3.8 s later (before: 21 s). Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: conditional compilation symbols keep DEBUG and TRACE The "Conditional compilation symbols" field of the managed Build page edits DefineConstants with a MultiStringSelector, whose value is a list of name/value pairs. For C# the managed DefineConstantsValueProvider (persistence ProjectFileWithInterception, AppliesTo CSharp | FSharp) converts it. For X# nothing did: adding MYSYM wrote MYSYM=False into the project file, the implicit DEBUG and TRACE were lost and MYSYM was not defined either (verified in VS). That value provider cannot be used for X#: its interfaces are in Microsoft.VisualStudio.ProjectSystem.Managed.dll, which has no usable package and a version per VS release (the part would be rejected on older VS). So: - BuildPropertyPage.XSharp.xaml defines DefineConstants like the managed page, with the persistence "XSharpDefineConstants". - XSharpDefineConstantsPropertiesProvider (public CPS API only) wraps the project file provider and converts DefineConstants: the list shows the symbols of the project file after "$(DefineConstants);" (a value without the prefix is shown as a whole), a change is written as "$(DefineConstants);SYMBOL;...", an empty list deletes the property. Exported named and unnamed: the property pages import the unnamed contract and select by the "Name" metadata. - KeyValuePairListEncoding: the editors' list format, internal in the managed project system. Tested in VS: MYSYM added for Debug -> "$(DefineConstants);MYSYM", the program reports DEBUG, TRACE and MYSYM; the page shows MYSYM again after reopening; removing it deletes the property. Co-Authored-By: Claude Opus 5.5 * [VsIntegration] CPS project system: documentation README.md in src/VisualStudio/ProjectSystemCPS: what the CPS project system for SDK-style X# projects offers, the supported Visual Studio versions, the installation (VSIX plus matching X# MSBuild support files and rules), how it works (project selection, capabilities, MSBuild integration, feeding the code model, errors and Task List, property pages, icons, VO designers, shadow WinForms designer, commands, multi-targeting), the source layout, building, testing and debugging, troubleshooting and the known limitations. Co-Authored-By: Claude Opus 5.5 --------- Co-authored-by: Claude Opus 5.5 --- src/Common/XSharpConstants.cs | 1 + .../Rules/ApplicationPropertyPage.XSharp.xaml | 143 +++ .../Rules/BuildPropertyPage.XSharp.xaml | 83 ++ .../Rules/DialectPage.XSharp.xaml | 152 +++ .../Rules/LanguagePage.XSharp.xaml | 88 ++ .../Rules/NativeResource.BrowseObject.xaml | 162 +++ .../XSharpBuildTask/Rules/NativeResource.xaml | 106 ++ .../Rules/ProjectItemsSchema.XSharp.xaml | 60 + .../Rules/ReferencesPage.XSharp.xaml | 46 + .../Rules/VOBinary.BrowseObject.xaml | 162 +++ .../XSharpBuildTask/Rules/VOBinary.xaml | 107 ++ .../Rules/XSharpCompilerCommandLineArgs.xaml | 24 + .../Rules/XSharpProjectProperties.xaml | 19 + .../XSharpBuildTask/XSharp.Build.csproj | 36 + .../XSharp.CrossTargeting.targets | 7 + .../XSharp.CurrentVersion.targets | 7 + .../XSharpBuildTask/XSharp.DesignTime.targets | 82 +- .../Compiler/XSharpBuildTask/XSharp.SDK.Props | 4 + src/Master.slnx | 1 + src/VSIntegration2022.sln | 15 + .../CodeDomProvider/XSharpCodeGenerator.cs | 3 +- src/VisualStudio/ProjectBase/FileNode.cs | 31 +- .../ProjectBase/ProjectElement.cs | 18 +- .../ProjectBase/ProjectFactory.cs | 14 +- src/VisualStudio/ProjectBase/ProjectNode.cs | 11 - .../ProjectBase/ProjectReferenceNode.cs | 7 +- .../VSXsharpCodeDomProvider.cs | 43 +- .../CodeDomProvider/XSharpCodeDomHelper.cs | 7 + .../Commands/CommandAddDesignerFile.cs | 118 +- .../ProjectPackage/Commands/CommandBuild.cs | 227 ---- .../Commands/CommandConvertXsRuntime.cs | 2 +- .../Commands/CommandEditProjectFile.cs | 6 +- .../Commands/CommandGenerateWinForm.cs | 21 +- .../ProjectPackage/Commands/CommandPack.cs | 71 -- .../ProjectPackage/Commands/CommandPublish.cs | 244 ---- .../Commands/CommandSyncDesignerChanges.cs | 25 +- .../Commands/CommandSyncEventHandlers.cs | 25 +- .../Commands/PublishDialog.xaml | 100 -- .../Commands/PublishDialog.xaml.cs | 104 -- .../Commands/XSharpBaseCommand.cs | 9 +- .../Commands/commandDebuggerFramework.cs | 191 --- .../Editors/XSharpProjectFactory.cs | 41 +- .../ProjectPackage/ExternalAssemblies.cs | 3 + src/VisualStudio/ProjectPackage/Menus.cs | 13 - src/VisualStudio/ProjectPackage/Menus.vsct | 94 -- .../ProjectPackage/Nodes/XSharpFileNode.cs | 156 +-- .../ProjectPackage/Nodes/XSharpProjectNode.cs | 106 +- .../Nodes/XSharpReferenceContainerNode.cs | 43 +- .../NodesSDK/SdkDependenciesContainer.cs | 172 --- .../ProjectPackage/NodesSDK/SdkFolderNodes.cs | 118 -- .../ProjectPackage/NodesSDK/SdkProjectNode.cs | 1049 ----------------- .../NodesSDK/SdkReferenceNodes.cs | 214 ---- .../ProjectPackage/ProjectPackage.csproj | 1 - .../ProjectPackage/ProjectPackage2022.csproj | 34 +- .../ShadowDesigner/ShadowDesignerBridge.cs | 399 ------- .../ShadowDesigner/ShadowDesignerCleanup.cs | 203 ---- .../ProjectPackage/XSharpConfigprovider.cs | 27 - .../ProjectPackage/XSharpProjectPackage.cs | 8 - .../ProjectPackage/XSharpShellEvents.cs | 37 - .../source.extension.2022.vsixmanifest | 4 + .../ProjectSystemCPS.TestBed/CpsTestBed.sln | 21 + .../CpsTestBed.xsproj | 24 + .../Legacy/LegacyTestBed.xsproj | 44 + .../ProjectSystemCPS.TestBed/Legacy/Start.prg | 5 + .../ProjectSystemCPS.TestBed/Program.prg | 5 + .../SelectorTestBed.sln | 39 + .../ProjectSystemCPS.TestBed/StartExp.cmd | 48 + .../VO/Customer.Customer.xsdbs | 21 + .../ProjectSystemCPS.TestBed/VO/Customer.prg | 211 ++++ .../VO/Fieldspecs.FieldSpecs.xsfs | 5 + .../VO/Fieldspecs.prg | 1 + .../VO/Help About.HELPABOUT.xsfrm | 89 ++ .../VO/Help About.HelpAbout.rc | 37 + .../VO/Help About.POWXSHARPBMP.rc | 2 + .../VO/Help About.prg | 89 ++ .../VO/Properties/cavoded.tpl | 225 ++++ .../VO/Properties/cavofed.tpl | 33 + .../VO/Properties/cavowed.inf | 955 +++++++++++++++ .../VO/Properties/cavowed.tpl | 464 ++++++++ .../VO/Resources/HelpAbt.BMP | Bin 0 -> 48654 bytes .../VO/Resources/XSharp.ICO | Bin 0 -> 9662 bytes .../VO/Resources/cctl6.man | 23 + .../VO/SDI Menus.EmptySDIMenu.rc | 40 + .../VO/SDI Menus.EmptySDIMenu.xsmnu | 226 ++++ .../VO/SDI Menus.EmptySDIMenu_Accelerator.rc | 27 + .../VO/SDI Menus.StandardSDIMenu.rc | 76 ++ .../VO/SDI Menus.StandardSDIMenu.xsmnu | 515 ++++++++ .../SDI Menus.StandardSDIMenu_Accelerator.rc | 50 + .../VO/SDI Menus.VS_VERSION_INFO.rc | 31 + .../ProjectSystemCPS.TestBed/VO/SDI Menus.prg | 240 ++++ .../VO/Standard SDI.IDI_STANDARDICON.rc | 1 + .../VO/Standard SDI.Manifest.rc | 4 + .../VO/Standard SDI.prg | 118 ++ .../ProjectSystemCPS.TestBed/VO/Start.prg | 24 + .../VO/VOTestBed.xsproj | 52 + .../WinForms/Form1.designer.prg | 36 + .../WinForms/Form1.prg | 13 + .../WinForms/Program.prg | 10 + .../WinForms/WinFormsTestBed.xsproj | 16 + .../XSharpCpsGlobalPropertiesProvider.cs | 48 + .../ProjectSystemCPS/Imaging/XSharpImages.cs | 22 + .../XSharpProjectTreePropertiesProvider.cs | 243 ++++ ...harpProjectTreePropertiesProviderSource.cs | 103 ++ .../BuildErrorLoggerProvider.cs | 166 +++ .../LanguageService/CommentTaskList.cs | 115 ++ .../LanguageService/CommentTokens.cs | 60 + .../LanguageService/IntellisenseErrorList.cs | 132 +++ .../LanguageService/IntellisenseErrorStore.cs | 158 +++ .../LanguageService/SourceFileWatcher.cs | 136 +++ .../LanguageService/XSharpCommandLine.cs | 133 +++ .../LanguageService/XSharpProjectAdapter.cs | 549 +++++++++ .../ProjectSystemCPS/ProjectSystemCPS.csproj | 77 ++ .../Properties/AssemblyInfo.cs | 8 + .../PropertyPages/KeyValuePairListEncoding.cs | 72 ++ ...XSharpDefineConstantsPropertiesProvider.cs | 180 +++ .../XSharpProjectDesignerPageProvider.cs | 41 + src/VisualStudio/ProjectSystemCPS/README.md | 519 ++++++++ .../Resources/XSharpDocument.png | Bin 0 -> 1597 bytes .../Resources/XSharpProject.png | Bin 0 -> 1082 bytes .../ProvideProjectSelectorAttribute.cs | 64 + .../Selection/SdkProjectFile.cs | 54 + .../Selection/XSharpMsBuildSupport.cs | 76 ++ .../Selection/XSharpProjectSelector.cs | 54 + .../ShadowDesigner/CompanionProjectWriter.cs | 101 +- .../ShadowDesigner/CompanionSaveWatcher.cs | 28 +- .../ShadowDesigner/DesignerChangesSync.cs | 7 +- .../ShadowDesigner/EventHandlerSync.cs | 7 +- .../ProjectSystemCPS/ShadowDesigner/Logger.cs | 20 + .../ShadowDesigner/NewFormDesignerRedirect.cs | 176 +++ .../ShadowDesigner/RoslynToCodeDom.cs | 5 +- .../ShadowDesigner/ShadowDesignerBridge.cs | 728 ++++++++++++ .../ShadowDesigner/ShadowDesignerCleanup.cs | 389 ++++++ .../ShadowDesigner/SolutionWiring.cs | 10 +- .../XSharpShadowDesignerCommands.cs | 187 +++ .../XSharp.ProjectSystemCPS.imagemanifest | 19 + .../ProjectSystemCPS/XSharpCapabilities.cs | 41 + .../XSharpProjectSystemPackage.cs | 102 ++ src/VisualStudio/Support/XSharpShellLink.cs | 6 + 138 files changed, 10146 insertions(+), 3814 deletions(-) create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/ApplicationPropertyPage.XSharp.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/BuildPropertyPage.XSharp.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/DialectPage.XSharp.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/LanguagePage.XSharp.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.BrowseObject.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectItemsSchema.XSharp.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/ReferencesPage.XSharp.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.BrowseObject.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpCompilerCommandLineArgs.xaml create mode 100644 src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpProjectProperties.xaml delete mode 100644 src/VisualStudio/ProjectPackage/Commands/CommandBuild.cs delete mode 100644 src/VisualStudio/ProjectPackage/Commands/CommandPack.cs delete mode 100644 src/VisualStudio/ProjectPackage/Commands/CommandPublish.cs delete mode 100644 src/VisualStudio/ProjectPackage/Commands/PublishDialog.xaml delete mode 100644 src/VisualStudio/ProjectPackage/Commands/PublishDialog.xaml.cs delete mode 100644 src/VisualStudio/ProjectPackage/Commands/commandDebuggerFramework.cs delete mode 100644 src/VisualStudio/ProjectPackage/NodesSDK/SdkDependenciesContainer.cs delete mode 100644 src/VisualStudio/ProjectPackage/NodesSDK/SdkFolderNodes.cs delete mode 100644 src/VisualStudio/ProjectPackage/NodesSDK/SdkProjectNode.cs delete mode 100644 src/VisualStudio/ProjectPackage/NodesSDK/SdkReferenceNodes.cs delete mode 100644 src/VisualStudio/ProjectPackage/ShadowDesigner/ShadowDesignerBridge.cs delete mode 100644 src/VisualStudio/ProjectPackage/ShadowDesigner/ShadowDesignerCleanup.cs create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/CpsTestBed.sln create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/CpsTestBed.xsproj create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/Legacy/LegacyTestBed.xsproj create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/Legacy/Start.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/Program.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/SelectorTestBed.sln create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/StartExp.cmd create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Customer.Customer.xsdbs create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Customer.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Fieldspecs.FieldSpecs.xsfs create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Fieldspecs.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Help About.HELPABOUT.xsfrm create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Help About.HelpAbout.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Help About.POWXSHARPBMP.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Help About.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Properties/cavoded.tpl create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Properties/cavofed.tpl create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Properties/cavowed.inf create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Properties/cavowed.tpl create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Resources/HelpAbt.BMP create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Resources/XSharp.ICO create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Resources/cctl6.man create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.EmptySDIMenu.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.EmptySDIMenu.xsmnu create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.EmptySDIMenu_Accelerator.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.StandardSDIMenu.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.StandardSDIMenu.xsmnu create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.StandardSDIMenu_Accelerator.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.VS_VERSION_INFO.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/SDI Menus.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Standard SDI.IDI_STANDARDICON.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Standard SDI.Manifest.rc create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Standard SDI.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/Start.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/VO/VOTestBed.xsproj create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/WinForms/Form1.designer.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/WinForms/Form1.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/WinForms/Program.prg create mode 100644 src/VisualStudio/ProjectSystemCPS.TestBed/WinForms/WinFormsTestBed.xsproj create mode 100644 src/VisualStudio/ProjectSystemCPS/Evaluation/XSharpCpsGlobalPropertiesProvider.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/Imaging/XSharpImages.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/Imaging/XSharpProjectTreePropertiesProvider.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/Imaging/XSharpProjectTreePropertiesProviderSource.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/BuildErrorLoggerProvider.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/CommentTaskList.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/CommentTokens.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/IntellisenseErrorList.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/IntellisenseErrorStore.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/SourceFileWatcher.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/XSharpCommandLine.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/LanguageService/XSharpProjectAdapter.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/ProjectSystemCPS.csproj create mode 100644 src/VisualStudio/ProjectSystemCPS/Properties/AssemblyInfo.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/PropertyPages/KeyValuePairListEncoding.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/PropertyPages/XSharpDefineConstantsPropertiesProvider.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/PropertyPages/XSharpProjectDesignerPageProvider.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/README.md create mode 100644 src/VisualStudio/ProjectSystemCPS/Resources/XSharpDocument.png create mode 100644 src/VisualStudio/ProjectSystemCPS/Resources/XSharpProject.png create mode 100644 src/VisualStudio/ProjectSystemCPS/Selection/ProvideProjectSelectorAttribute.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/Selection/SdkProjectFile.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/Selection/XSharpMsBuildSupport.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/Selection/XSharpProjectSelector.cs rename src/VisualStudio/{ProjectPackage => ProjectSystemCPS}/ShadowDesigner/CompanionProjectWriter.cs (67%) rename src/VisualStudio/{ProjectPackage => ProjectSystemCPS}/ShadowDesigner/CompanionSaveWatcher.cs (93%) rename src/VisualStudio/{ProjectPackage => ProjectSystemCPS}/ShadowDesigner/DesignerChangesSync.cs (95%) rename src/VisualStudio/{ProjectPackage => ProjectSystemCPS}/ShadowDesigner/EventHandlerSync.cs (97%) create mode 100644 src/VisualStudio/ProjectSystemCPS/ShadowDesigner/Logger.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/ShadowDesigner/NewFormDesignerRedirect.cs rename src/VisualStudio/{ProjectPackage => ProjectSystemCPS}/ShadowDesigner/RoslynToCodeDom.cs (98%) create mode 100644 src/VisualStudio/ProjectSystemCPS/ShadowDesigner/ShadowDesignerBridge.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/ShadowDesigner/ShadowDesignerCleanup.cs rename src/VisualStudio/{ProjectPackage => ProjectSystemCPS}/ShadowDesigner/SolutionWiring.cs (96%) create mode 100644 src/VisualStudio/ProjectSystemCPS/ShadowDesigner/XSharpShadowDesignerCommands.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/XSharp.ProjectSystemCPS.imagemanifest create mode 100644 src/VisualStudio/ProjectSystemCPS/XSharpCapabilities.cs create mode 100644 src/VisualStudio/ProjectSystemCPS/XSharpProjectSystemPackage.cs diff --git a/src/Common/XSharpConstants.cs b/src/Common/XSharpConstants.cs index ed63d95e2d..8bf74ec7e7 100644 --- a/src/Common/XSharpConstants.cs +++ b/src/Common/XSharpConstants.cs @@ -22,6 +22,7 @@ internal static class XSharpConstants internal const string EditorFactoryGuidString = "B4829761-2BFA-44B7-8F8F-D2625EBCF218"; internal const string guidCpsProjectTypeString = "AB494DCE-A11B-4583-851E-D4A86775B3F0"; internal const string guidProjectSelectorString = "DF89AA3B-6AE6-4971-8F78-1A03B346A7D5"; + internal const string guidXSharpCpsProjectPkgString = "BAE3ADAE-83B3-44CC-BA79-A18F03F0D121"; internal static readonly Guid guidXSharpProjectFactory = new Guid(guidXSharpProjectFactoryString); internal static readonly Guid guidVOMenuEditorFactory = new Guid(guidXSharpVOMenuEditor); internal static readonly Guid guidVODbServerEditorFactory = new Guid(guidXSharpVODbServerEditor); diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ApplicationPropertyPage.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ApplicationPropertyPage.XSharp.xaml new file mode 100644 index 0000000000..76d871fe51 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ApplicationPropertyPage.XSharp.xaml @@ -0,0 +1,143 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + (has-evaluated-value "Application" "ResourceSpecificationKind" "IconAndManifest") + + + + + + + + + + + + + + + + (and + (has-evaluated-value "Application" "ApplicationManifestKind" "CustomManifest") + (has-evaluated-value "Application" "ResourceSpecificationKind" "IconAndManifest")) + + + + + + + + + + + + + + + + + (has-evaluated-value "Application" "ResourceSpecificationKind" "ResourceFile") + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/BuildPropertyPage.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/BuildPropertyPage.XSharp.xaml new file mode 100644 index 0000000000..5c9f479083 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/BuildPropertyPage.XSharp.xaml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + (has-evaluated-value "Build" "WarningLevelOverridden" false) + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/DialectPage.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/DialectPage.XSharp.xaml new file mode 100644 index 0000000000..648e6635a8 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/DialectPage.XSharp.xaml @@ -0,0 +1,152 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + + (has-evaluated-value "Language" "Dialect" "XPP") + + + + + + + + + (has-evaluated-value "Language" "Dialect" "FoxPro") + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (has-evaluated-value "Language" "Dialect" "FoxPro") + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/LanguagePage.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/LanguagePage.XSharp.xaml new file mode 100644 index 0000000000..22ee8e4d55 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/LanguagePage.XSharp.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (not (has-evaluated-value "Language" "Dialect" "Core")) + + + + + + + + (has-evaluated-value "Language" "MemVar" true) + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.BrowseObject.xaml new file mode 100644 index 0000000000..bcba14d58e --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.BrowseObject.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.xaml new file mode 100644 index 0000000000..5e28db5c84 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/NativeResource.xaml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectItemsSchema.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectItemsSchema.XSharp.xaml new file mode 100644 index 0000000000..b02cde9ef4 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ProjectItemsSchema.XSharp.xaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ReferencesPage.XSharp.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ReferencesPage.XSharp.xaml new file mode 100644 index 0000000000..4001371c2b --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/ReferencesPage.XSharp.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + true + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.BrowseObject.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.BrowseObject.xaml new file mode 100644 index 0000000000..19446f9949 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.BrowseObject.xaml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.xaml new file mode 100644 index 0000000000..9add003e83 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/VOBinary.xaml @@ -0,0 +1,107 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpCompilerCommandLineArgs.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpCompilerCommandLineArgs.xaml new file mode 100644 index 0000000000..da8ca1a8fd --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpCompilerCommandLineArgs.xaml @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpProjectProperties.xaml b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpProjectProperties.xaml new file mode 100644 index 0000000000..c598ad3125 --- /dev/null +++ b/src/Compiler/src/Compiler/XSharpBuildTask/Rules/XSharpProjectProperties.xaml @@ -0,0 +1,19 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Build.csproj b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Build.csproj index 4f7230f281..204f4fa28b 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Build.csproj +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.Build.csproj @@ -73,6 +73,42 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CrossTargeting.targets b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CrossTargeting.targets index 067451c607..28d70de313 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CrossTargeting.targets +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CrossTargeting.targets @@ -14,6 +14,13 @@ Copyright (C) XSharp BV. All rights reserved. + + $(MSBuildThisFileDirectory)XSharp.DesignTime.targets + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CurrentVersion.targets b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CurrentVersion.targets index 40a8b1d186..dcbbdf573e 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CurrentVersion.targets +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.CurrentVersion.targets @@ -374,6 +374,13 @@ Copyright (c) XSharp B.V. All Rights Reserved + + $(MSBuildThisFileDirectory)XSharp.DesignTime.targets + + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.DesignTime.targets b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.DesignTime.targets index 2ed7abc2f1..f7e9e38cd3 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.DesignTime.targets +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.DesignTime.targets @@ -6,14 +6,18 @@ WARNING: DO NOT MODIFY this file unless you are knowledgeable about MSBuild and created a backup copy. Incorrect changes to this file will make it impossible to load or build your projects from the command-line or the IDE. - This file contains Visual Studio and designer-related properties and items for X# projects. - It is based on Microsoft.CSharp.DesignTime.targets - It gets install inside the \MSBuild\Microsoft\VisualStudio\Managed folder. - This folder is also known as "ManagedXamlResourcesDirectory" - We inherit the property pages from Microsoft.Managed.DesignTime.targets and extend some of them - with X# specific properties. Our pages are called .XSharp.Xaml. - The order attribute in the xaml files determines the order in which pages are shown in the UI. + This file contains Visual Studio and designer-related properties and items for X# projects + that are loaded by the CPS based X# project system (XSharp.ProjectSystemCPS). + It is based on Microsoft.CSharp.DesignTime.targets. + It is imported by XSharp.CurrentVersion.targets and XSharp.CrossTargeting.targets, but only when + the property XSharpCpsProjectSystem is 'true'. The CPS project type sets that property as a global + property, so projects loaded by the MPFproj project system and command line builds are not affected. + + It imports Microsoft.Managed.DesignTime.targets from the Visual Studio installation + (\MSBuild\Microsoft\VisualStudio\Managed). That file declares the managed capabilities + (.NET, DependenciesTree, PackageReferences, ...) and the property page rules of the managed project system. + X# specific rules live in the Rules subfolder of this folder. Copyright (c) XSharp B.V. All Rights Reserved @@ -24,30 +28,74 @@ inspired by Microsoft.CSharp.DesignTime.targets - ProjectDebugger - $(MSBuildThisFileDirectory)\Microsoft + $(MSBuildExtensionsPath)\Microsoft\VisualStudio\Managed\Microsoft.Managed.DesignTime.targets + $(MSBuildThisFileDirectory)Rules\ - - + Properties false X# - {694DD9B6-B865-4C5B-AD85-86356E9C88DC} + + {E9B6EE0F-9BFA-4CFF-A60B-51A08BBC5050} XSharp - {FAE04EC0-301F-11d3-BF4B-00C04F79EFBC} - {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} - {FAE04EC1-301F-11d3-BF4B-00C04F79EFBC} + + {AA6C8D78-22FF-423A-9C7C-5F2393824E04} + {AA6C8D78-22FF-423A-9C7C-5F2393824E04} + {AA6C8D78-22FF-423A-9C7C-5F2393824E04} Private Camel Declarations - - false + + <_GlobalPropertiesToRemoveFromProjectReferences>$(_GlobalPropertiesToRemoveFromProjectReferences);XSharpCpsProjectSystem + + + + + Project + + + + File + + + BrowseObject + + + + ProjectSubscriptionService + + + + + diff --git a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.SDK.Props b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.SDK.Props index de18bdbd9b..ccca2ea88b 100644 --- a/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.SDK.Props +++ b/src/Compiler/src/Compiler/XSharpBuildTask/XSharp.SDK.Props @@ -23,6 +23,10 @@ Copyright (C) XSharp BV. All rights reserved. is imported after this file) and is listed so the value is picked up should that order ever change. The output directories are added explicitly for the same reason - they are only appended to DefaultItemExcludes later, which is too late for the globs below. --> + + $(DefaultItemExcludes);**/*.ShadowDesigner/** $(DefaultItemExcludes);$(DefaultExcludesInProjectFolder) $(XSharpDefaultItemExcludes);$(BaseOutputPath)/** $(XSharpDefaultItemExcludes);$(BaseIntermediateOutputPath)/** diff --git a/src/Master.slnx b/src/Master.slnx index bc59130651..a29ffe6d10 100644 --- a/src/Master.slnx +++ b/src/Master.slnx @@ -289,6 +289,7 @@ + diff --git a/src/VSIntegration2022.sln b/src/VSIntegration2022.sln index bc753ca6fb..b80997753a 100644 --- a/src/VSIntegration2022.sln +++ b/src/VSIntegration2022.sln @@ -51,6 +51,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeDomProvider", "VisualSt EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Support2022", "VisualStudio\Support\Support2022.csproj", "{FB387BE5-A620-46EA-A7A6-1CCB9177F7C1}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectSystemCPS", "VisualStudio\ProjectSystemCPS\ProjectSystemCPS.csproj", "{99708D46-58A9-46B6-B77F-003ADAF15FF6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -217,6 +219,18 @@ Global {FB387BE5-A620-46EA-A7A6-1CCB9177F7C1}.Release|arm64.Build.0 = Release|Any CPU {FB387BE5-A620-46EA-A7A6-1CCB9177F7C1}.Release|x86.ActiveCfg = Release|Any CPU {FB387BE5-A620-46EA-A7A6-1CCB9177F7C1}.Release|x86.Build.0 = Release|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Debug|arm64.ActiveCfg = Debug|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Debug|arm64.Build.0 = Debug|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Debug|x86.ActiveCfg = Debug|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Debug|x86.Build.0 = Debug|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Release|Any CPU.Build.0 = Release|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Release|arm64.ActiveCfg = Release|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Release|arm64.Build.0 = Release|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Release|x86.ActiveCfg = Release|Any CPU + {99708D46-58A9-46B6-B77F-003ADAF15FF6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -234,6 +248,7 @@ Global {960714E8-FF93-4A42-B9BA-610B0F2014DB} = {0D3C69B5-D236-42B3-B70D-2C9ABC9D434C} {7B7D9574-66A7-4719-AA48-C2386D7BF153} = {9F285506-97D3-486E-B59E-7C30C56B95AE} {FB387BE5-A620-46EA-A7A6-1CCB9177F7C1} = {0D3C69B5-D236-42B3-B70D-2C9ABC9D434C} + {99708D46-58A9-46B6-B77F-003ADAF15FF6} = {0D3C69B5-D236-42B3-B70D-2C9ABC9D434C} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6F61AAF2-9C04-4D27-887F-8A475F079D9C} diff --git a/src/VisualStudio/CodeDomProvider/XSharpCodeGenerator.cs b/src/VisualStudio/CodeDomProvider/XSharpCodeGenerator.cs index 0cac38dc6a..508b460ec4 100644 --- a/src/VisualStudio/CodeDomProvider/XSharpCodeGenerator.cs +++ b/src/VisualStudio/CodeDomProvider/XSharpCodeGenerator.cs @@ -809,7 +809,8 @@ protected override void GenerateFieldReferenceExpression(CodeFieldReferenceExpre { this.GenerateExpression(e.TargetObject); // If we have a Type, we must use a dot as a selector - if (e.TargetObject.GetType() == typeof(CodeTypeReferenceExpression)) + // (also for XCodeTypeReferenceExpression, which the parser creates, like in GeneratePropertyReferenceExpression) + if (e.TargetObject is CodeTypeReferenceExpression) { base.Output.Write(this.staticSelector); } diff --git a/src/VisualStudio/ProjectBase/FileNode.cs b/src/VisualStudio/ProjectBase/FileNode.cs index 5665d3234b..b9108165e0 100644 --- a/src/VisualStudio/ProjectBase/FileNode.cs +++ b/src/VisualStudio/ProjectBase/FileNode.cs @@ -1244,30 +1244,15 @@ protected virtual bool RenameDocument(string oldName, string newName, out Hierar bool bDependantItem = !string.IsNullOrEmpty(dependentOf); childAdded.ItemNode.RemoveFromProjectFile(); - if (this.ProjectMgr.IsSdkProject) - { - // For SDK Projects we retrieve the new element from the - // build project since the item was added to the project file and MSBuild will have created a new item for it. - this.ProjectMgr.BuildProject.ReevaluateIfNecessary(); - var items = this.ProjectMgr.BuildProject.Items.ToArray(); - foreach (var item in items.Where(i => i.EvaluatedInclude == newInclude && i.ItemType == this.ItemNode.ItemName)) - { - childAdded.ItemNode = new ProjectElement(ProjectMgr, item,false); - break; - } - } - else + // Assign the existing MSBuild item to the new child node and update its path. + childAdded.ItemNode = this.ItemNode; + childAdded.ItemNode.RefreshProperties(); + if (!childAdded.IsImported) { - // Assign the existing MSBuild item to the new child node and update its path. - childAdded.ItemNode = this.ItemNode; - childAdded.ItemNode.RefreshProperties(); - if (!childAdded.IsImported) - { - childAdded.ItemNode.Item.ItemType = this.ItemNode.ItemName; - childAdded.ItemNode.Item.Xml.Include = newInclude; - if (bDependantItem) - childAdded.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, dependentOf); - } + childAdded.ItemNode.Item.ItemType = this.ItemNode.ItemName; + childAdded.ItemNode.Item.Xml.Include = newInclude; + if (bDependantItem) + childAdded.ItemNode.SetMetadata(ProjectFileConstants.DependentUpon, dependentOf); } childAdded.ItemNode.RefreshProperties(); diff --git a/src/VisualStudio/ProjectBase/ProjectElement.cs b/src/VisualStudio/ProjectBase/ProjectElement.cs index 00e3a2b7a8..7f8cc23618 100644 --- a/src/VisualStudio/ProjectBase/ProjectElement.cs +++ b/src/VisualStudio/ProjectBase/ProjectElement.cs @@ -355,19 +355,15 @@ public void RefreshProperties() if(this.IsVirtual) return; - bool isSdk = !string.IsNullOrEmpty(itemProject?.BuildProject?.Xml?.Sdk); - if (!isSdk) + // prevent duplicate items. + itemProject.BuildProject.ReevaluateIfNecessary(); + IEnumerable items = itemProject.BuildProject.GetItems(this.item.ItemType); + foreach (ProjectItem projectItem in items) { - // prevent duplicate items. - itemProject.BuildProject.ReevaluateIfNecessary(); - IEnumerable items = itemProject.BuildProject.GetItems(this.item.ItemType); - foreach (ProjectItem projectItem in items) + if (string.Equals(projectItem?.UnevaluatedInclude, item.UnevaluatedInclude, StringComparison.OrdinalIgnoreCase)) { - if (string.Equals(projectItem?.UnevaluatedInclude, item.UnevaluatedInclude, StringComparison.OrdinalIgnoreCase)) - { - this.item = projectItem; - return; - } + this.item = projectItem; + return; } } } diff --git a/src/VisualStudio/ProjectBase/ProjectFactory.cs b/src/VisualStudio/ProjectBase/ProjectFactory.cs index d9cd9be9b9..91a716128a 100644 --- a/src/VisualStudio/ProjectBase/ProjectFactory.cs +++ b/src/VisualStudio/ProjectBase/ProjectFactory.cs @@ -107,7 +107,6 @@ protected ProjectFactory(Microsoft.VisualStudio.Shell.Package package) #region abstract methods protected abstract ProjectNode CreateProject(); - protected abstract ProjectNode CreateSdkProject(); #endregion #region overriden methods @@ -169,16 +168,9 @@ protected override object PreCreateForOuter(IntPtr outerProjectIUnknown) // Please be very carefull what is initialized here on the ProjectNode. Normally this should only instantiate and return a project node. // The reason why one should very carefully add state to the project node here is that at this point the aggregation has not yet been created and anything that would cause a CCW for the project to be created would cause the aggregation to fail // Our reasoning is that there is no other place where state on the project node can be set that is known by the Factory and has to execute before the Load method. - bool IsSdkProject = !String.IsNullOrEmpty(this.buildProject.Xml.Sdk); - ProjectNode node; - if (IsSdkProject) - { - node = this.CreateSdkProject(); - } - else - { - node = this.CreateProject(); - } + // SDK-style projects are rejected before this point (XSharpProjectFactory.CreateProject): they are + // loaded by the CPS project system. + ProjectNode node = this.CreateProject(); Utilities.CheckNotNull(node, "The project failed to be created"); node.BuildEngine = this.buildEngine; node.BuildProject = this.buildProject; diff --git a/src/VisualStudio/ProjectBase/ProjectNode.cs b/src/VisualStudio/ProjectBase/ProjectNode.cs index 94eb049870..d0f3381747 100644 --- a/src/VisualStudio/ProjectBase/ProjectNode.cs +++ b/src/VisualStudio/ProjectBase/ProjectNode.cs @@ -1001,8 +1001,6 @@ public IServiceProvider Site } } - public virtual bool IsSdkProject => false; - /// /// Gets an ImageHandler for the project node. /// @@ -7466,15 +7464,6 @@ private string GetComponentPickerDirectories() public int UpdateTargetFramework(IVsHierarchy pHier, string currentTargetFramework, string newTargetFramework) { ThreadHelper.ThrowIfNotOnUIThread(); - ThreadHelper.ThrowIfNotOnUIThread(); - if (this.IsSdkProject) - { - // Let the .NET SDK infer TargetFrameworkIdentifier/Version/Profile and the - // TargetPlatform* properties from the full moniker. Setting them here would - // suppress that inference and drop the platform suffix (e.g. net8.0-windows7.0). - SetProjectProperty("TargetFramework", newTargetFramework); - return VSConstants.S_OK; - } FrameworkName moniker = new FrameworkName(newTargetFramework); SetProjectProperty(ProjectFileConstants.TargetFrameworkIdentifier, moniker.Identifier); SetProjectProperty(ProjectFileConstants.TargetFrameworkVersion, "v" + moniker.Version); diff --git a/src/VisualStudio/ProjectBase/ProjectReferenceNode.cs b/src/VisualStudio/ProjectBase/ProjectReferenceNode.cs index 20c60bea25..d01e914576 100644 --- a/src/VisualStudio/ProjectBase/ProjectReferenceNode.cs +++ b/src/VisualStudio/ProjectBase/ProjectReferenceNode.cs @@ -420,7 +420,7 @@ public ProjectReferenceNode(ProjectNode root, ProjectElement element) ThreadHelper.ThrowIfNotOnUIThread(); this.ReferencedProjectName = this.ItemNode.GetMetadata(ProjectFileConstants.Name); - if (guidString == String.Empty && ! root.IsSdkProject) + if (guidString == String.Empty) { guidString = Guid.NewGuid().ToString("B"); } @@ -429,10 +429,7 @@ public ProjectReferenceNode(ProjectNode root, ProjectElement element) ReferencedProjectName = Path.GetFileNameWithoutExtension(referencedProjectRelativePath); } - // An SDK style project file does not store the guid of the referenced project, so we may - // not have one here, for example when the referenced project has not been loaded yet. - // Do not throw in that case: the node must appear in the hierarchy anyway. The guid is - // filled in later, see XSharpProjectNode.FixReferences() and UpdateReferencedProjectGuid(). + // Do not throw for an invalid guid: the node must appear in the hierarchy anyway. if (!Guid.TryParse(guidString, out var guid)) { guid = Guid.Empty; diff --git a/src/VisualStudio/ProjectPackage/CodeDomProvider/VSXsharpCodeDomProvider.cs b/src/VisualStudio/ProjectPackage/CodeDomProvider/VSXsharpCodeDomProvider.cs index 00f32658f4..c5c80746fb 100644 --- a/src/VisualStudio/ProjectPackage/CodeDomProvider/VSXsharpCodeDomProvider.cs +++ b/src/VisualStudio/ProjectPackage/CodeDomProvider/VSXsharpCodeDomProvider.cs @@ -14,6 +14,7 @@ using Microsoft; using Microsoft.VisualStudio.Project; using XSharp.Settings; +using XSharpModel; namespace XSharp.Project { @@ -30,6 +31,8 @@ public XDocDataTextReader(DocData docData, CodeTypeDeclaration classname) :base( public class VSXSharpCodeDomProvider : XSharp.CodeDom.XSharpCodeDomProvider { private XSharpFileNode _fileNode; + // Full path of the file when there is no MPFproj file node (see the second constructor) + private string _filePath; // The parameterless constructor is called by the WPF designer ? @@ -40,22 +43,34 @@ public VSXSharpCodeDomProvider(XSharpFileNode fileNode) _projectNode = projectNode.ProjectModel; } + /// + /// For a file of a project without MPFproj file nodes (an X# project loaded by the CPS project system): + /// the code model project of the file and its full path. + /// + public VSXSharpCodeDomProvider(XProject project, string filePath) + { + _projectNode = project; + _filePath = filePath; + } + #region helper functions private bool IsFormSubType { - get { return _fileNode.HasDesigner; } + get { return _fileNode != null && _fileNode.HasDesigner; } } private string GetFilePath() { + if (_fileNode == null) + return _filePath; return Path.Combine(Path.GetDirectoryName(_fileNode.GetMkDocument()), _fileNode.FileName); } private string GetDesignerFilePath() { - return Path.Combine(Path.GetDirectoryName(_fileNode.GetMkDocument()), - Path.GetFileNameWithoutExtension(_fileNode.FileName) + + return Path.Combine(Path.GetDirectoryName(GetFilePath()), + Path.GetFileNameWithoutExtension(GetFilePath()) + ".Designer.prg"); } @@ -139,17 +154,23 @@ private void SaveSource(string filename, string source, Encoding encoding, bool { source = XSettings.SynchronizeKeywordCase(source, filename); - XSharpFileNode node = _fileNode.FindChild(filename) as XSharpFileNode; + // assign the source to the open buffer when possible + string url = null; + if (_fileNode != null) + { + XSharpFileNode node = _fileNode.FindChild(filename) as XSharpFileNode; + url = node?.Url; + } + else + { + url = filename; + } bool done = false; - if (node != null) + if (url != null && XDocuments.IsOpen(url)) { - // assign the source to the open buffer when possible - if (XDocuments.IsOpen(node.Url)) + if (XDocuments.SetText(url, source)) { - if (XDocuments.SetText(node.Url, source)) - { - done = true; - } + done = true; } } if (!done && SaveToDisk) diff --git a/src/VisualStudio/ProjectPackage/CodeDomProvider/XSharpCodeDomHelper.cs b/src/VisualStudio/ProjectPackage/CodeDomProvider/XSharpCodeDomHelper.cs index f82a805830..7de4d49e4b 100644 --- a/src/VisualStudio/ProjectPackage/CodeDomProvider/XSharpCodeDomHelper.cs +++ b/src/VisualStudio/ProjectPackage/CodeDomProvider/XSharpCodeDomHelper.cs @@ -10,7 +10,14 @@ namespace XSharp.CodeDom { + // Also compiled into XSharp.ProjectSystemCPS (shadow WinForms designer), as an internal copy. It does not + // live in XSharp.CodeDomProvider because the X# installation puts that assembly in the GAC: a newer + // VSIX would then run against the older installed version. +#if XSHARP_PROJECTSYSTEMCPS + internal class XSharpCodeDomHelper +#else public class XSharpCodeDomHelper +#endif { /// /// Merge both CodeCompileUnit. The main type (class) will come from formCompileUnit diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandAddDesignerFile.cs b/src/VisualStudio/ProjectPackage/Commands/CommandAddDesignerFile.cs index 5cead49a07..44d96095d0 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandAddDesignerFile.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandAddDesignerFile.cs @@ -31,9 +31,14 @@ private async Task CheckAvailabilityAsync() bool visible = false; foreach (var item in items) { - if (item is PhysicalFile file) + if (item is PhysicalFile file && IsXSharpSourceFile(file)) { var subtype = await file.GetAttributeAsync(ProjectFileConstants.SubType); + if (string.IsNullOrEmpty(subtype) && !await Commands.ProjectIsMpfProjectAsync()) + { + // SDK-style projects (CPS) rarely have a SubType + subtype = InferSubType(file.FullPath); + } if (subtype == ProjectFileAttributeValue.Form || subtype == ProjectFileAttributeValue.UserControl) { visible = true; @@ -46,6 +51,12 @@ private async Task CheckAvailabilityAsync() currentFile = null; } } + if (visible && File.Exists(XSharpCodeDomHelper.BuildDesignerFileName(file.FullPath))) + { + // a designer file that is not nested below the form + visible = false; + currentFile = null; + } } } } @@ -57,36 +68,103 @@ private async Task CheckAvailabilityAsync() } } + private static bool IsXSharpSourceFile(PhysicalFile file) + { + return string.Equals(Path.GetExtension(file.FullPath), ".prg", StringComparison.OrdinalIgnoreCase) && + !file.FullPath.EndsWith(".designer.prg", StringComparison.OrdinalIgnoreCase) && + file.ContainingProject.IsXSharp(); + } + + /// + /// Form or UserControl when the first class of the file inherits from one of them, directly or through + /// its base classes. The same rule as XSharpFileNode.DetermineSubType, from the code model. + /// + private static string InferSubType(string path) + { + var xFile = XSolution.FindFile(path); + if (xFile?.Project == null) + return null; + var first = XDatabase.GetTypesInFile(xFile).FirstOrDefault(c => c.TypeName != XLiterals.GlobalName); + if (first == null) + return null; + var usings = xFile.Usings.Concat(xFile.StaticUsings).ToList(); + var baseType = first.BaseTypeName; + // a limit against cycles in broken code + for (int i = 0; i < 20 && !string.IsNullOrEmpty(baseType); i++) + { + var subType = XSharpFileNode.TypeNameToSubtype(baseType); + if (!string.IsNullOrEmpty(subType)) + return subType; + baseType = xFile.Project.FindType(baseType, usings)?.BaseTypeName; + } + return null; + } + protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) + { + try + { + await AddDesignerFileAsync(); + } + catch (Exception ex) + { + // The command framework would only write it to the activity log + XSettings.Exception(ex); + await VS.MessageBox.ShowErrorAsync(CommandTitle, ex.Message); + } + finally + { + await VS.StatusBar.ShowMessageAsync(""); + } + } + + private const string CommandTitle = "Add .designer file"; + + private async Task AddDesignerFileAsync() { if (currentFile != null) { var newfile = System.IO.Path.ChangeExtension(currentFile.FullPath, ".designer.prg"); - await VS.StatusBar.ShowMessageAsync("Creating designer file:" + newfile); - System.IO.File.WriteAllText(newfile, ""); var project = currentFile.ContainingProject; - XSharpProjectNode projectNode = null; - if (project != null) + var xproject = project != null ? XSolution.FindProjectByFileName(project.FullPath) : null; + if (xproject != null) { - var xproject = XSolution.FindProjectByFileName(project.FullPath); - if (xproject != null) + XSettings.Information($"Reading file data for {currentFile.FullPath} from database"); + VSXSharpCodeDomProvider provider; + if (xproject.ProjectNode is XSharpProjectNode projectNode && + projectNode.FindChild(currentFile.FullPath) is XSharpFileNode fileNode) { - xproject.ProjectNode.AddFileNode(newfile); - projectNode = (XSharpProjectNode)xproject.ProjectNode; + provider = new VSXSharpCodeDomProvider(fileNode); + } + else + { + provider = new VSXSharpCodeDomProvider(xproject, currentFile.FullPath); } - - XSettings.Information($"Reading file data for {currentFile.FullPath} from database"); - XSharpFileNode fileNode; - fileNode = (XSharpFileNode) projectNode.FindChild(currentFile.FullPath); - var provider = new VSXSharpCodeDomProvider(fileNode); provider.FileName = currentFile.FullPath; var source = File.ReadAllText(currentFile.FullPath); var reader = new StringReader(source); var ccuForm = provider.Parse(reader) as XCodeCompileUnit; + // The parser recognizes InitializeComponent (returning System.Void) and the types in it only with + // the references of the project. Right after the solution was opened they may not be loaded yet; + // then the generated code would be wrong (':' instead of '.' for static members). + var formClass = ccuForm == null ? null : XSharpCodeDomHelper.FindDesignerClass(ccuForm) as XCodeTypeDeclaration; + if (formClass == null) + { + await VS.MessageBox.ShowErrorAsync(CommandTitle, + $"Could not find the form class with its InitializeComponent method in {Path.GetFileName(currentFile.FullPath)}.\n\n" + + "When the solution was just opened, try again after the project has finished loading."); + return; + } ccuForm.Source = source; ccuForm.FileName = currentFile.FullPath; ccuForm.MustWrite = true; - var formClass = (XCodeTypeDeclaration) XSharpCodeDomHelper.FindDesignerClass(ccuForm); + + await VS.StatusBar.ShowMessageAsync("Creating designer file:" + newfile); + System.IO.File.WriteAllText(newfile, ""); + // MPFproj adds the designer file below the form. The CPS project system does nothing here: the + // SDK globs include the new file, and XSharp.SDK.Props makes it depend on the form. + xproject.ProjectNode.AddFileNode(newfile); + var designerClass = new XCodeTypeDeclaration(formClass.Name); var ccuDesigner = new XCodeCompileUnit(); ccuDesigner.FileName = newfile; @@ -146,10 +224,11 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) var writer = new StringWriter(); var options = new CodeGeneratorOptions(); provider.GenerateCodeFromCompileUnit(mergedccu, writer, options); - var newSource = writer.ToString().ToLower(); - if (newSource.Contains("#endregion") && !newSource.Contains("#region")) + var newSource = writer.ToString(); + // only the check is case insensitive: the form file is written as generated + var lowerSource = newSource.ToLower(); + if (lowerSource.Contains("#endregion") && !lowerSource.Contains("#region")) { - newSource = writer.ToString(); var lines = Regex.Split(newSource, "\r\n|\r|\n"); var sb = new StringBuilder(); foreach (var line in lines) @@ -161,9 +240,6 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) } File.WriteAllText(currentFile.FullPath, newSource); } - - - await VS.StatusBar.ShowMessageAsync(""); } } } diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandBuild.cs b/src/VisualStudio/ProjectPackage/Commands/CommandBuild.cs deleted file mode 100644 index ebc78b3064..0000000000 --- a/src/VisualStudio/ProjectPackage/Commands/CommandBuild.cs +++ /dev/null @@ -1,227 +0,0 @@ -using Community.VisualStudio.Toolkit; - -using Microsoft.VisualStudio; -using OLE=Microsoft.VisualStudio.OLE.Interop; -using Microsoft.VisualStudio.Shell; - -using System; -using System.Diagnostics; -using System.IO; -using System.Threading.Tasks; -using System.Reflection.Metadata.Ecma335; - -namespace XSharp.Project -{ - internal abstract class CommandBuild : BaseCommand where T : class, new() - { - protected abstract string CommandName { get; } - protected abstract string CommandDescription { get; } - protected CommandProgression DoCmd() - { - bool ourProject = false; - ThreadHelper.JoinableTaskFactory.Run(async () => - { - ourProject = await Commands.ProjectIsXSharpProjectAsync(); - if (ourProject) - await DoCmdAsync(); - - - }); - if (ourProject) - return CommandProgression.Stop; - return CommandProgression.Continue; - } - - - protected override async Task InitializeCompletedAsync() - { - await base.InitializeCompletedAsync(); - var cmd = await VS.Commands.FindCommandAsync(CommandName); - if (cmd != null) - { - await VS.Commands.InterceptAsync(CommandName, () => DoCmd()); - } - } - protected string projectPath; - protected async Task VerifySdkProjectAsync() - { - await VS.Commands.ExecuteAsync(KnownCommands.File_SaveAll); - var project = await VS.Solutions.GetActiveProjectAsync(); - if (project == null) - { - await VS.MessageBox.ShowErrorAsync(CommandDescription, "No active project selected."); - return false; - } - projectPath = project.FullPath; - var ourProject = await Commands.ProjectIsXSharpProjectAsync(); - if (!ourProject) - { - return false; - } - var prj = XSharpProjectNode.FindProject(projectPath); - if (prj == null || !prj.IsSdkProject) - { - await VS.MessageBox.ShowErrorAsync(CommandDescription, $"The {CommandDescription} command is only available for SDK-style projects."); - return false; - } - return true; - } - - protected async Task CreateProcessAsync(string arguments, string output) - { - var psi = new ProcessStartInfo - { - FileName = "dotnet", - Arguments = arguments, - WorkingDirectory = Path.GetDirectoryName(projectPath), - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - var process = new Process { StartInfo = psi }; - process.OutputDataReceived += Process_OutputDataReceived; - process.ErrorDataReceived += Process_ErrorDataReceived; ; - - await EnsureOutputPaneAsync(); - await outputPane.ActivateAsync(); - await outputPane.WriteLineAsync(output); - await outputPane.WriteLineAsync($"Command: dotnet {arguments}"); - await outputPane.WriteLineAsync(""); - process.Start(); - process.BeginOutputReadLine(); - process.BeginErrorReadLine(); - - await Task.Run(() => process.WaitForExit()); - - if (process.ExitCode == 0) - { - await outputPane.WriteLineAsync(""); - var msg = CommandDescription + " succeeded."; - await outputPane.WriteLineAsync(msg); - await VS.StatusBar.ShowMessageAsync(msg); - } - else - { - await outputPane.WriteLineAsync(""); - await outputPane.WriteLineAsync($"{CommandDescription} failed with exit code {process.ExitCode}."); - await VS.StatusBar.ShowMessageAsync(CommandDescription+" failed."); - await VS.MessageBox.ShowErrorAsync(CommandDescription, CommandDescription + " failed. See Output window for details."); - } - - return process.ExitCode; - } - - private void Process_ErrorDataReceived(object sender, DataReceivedEventArgs ea) - { - ThreadHelper.JoinableTaskFactory.Run(async () => - { - if (!string.IsNullOrEmpty(ea.Data)) - { - await outputPane.WriteLineAsync($"ERROR: {ea.Data}"); - } - }); - } - - private void Process_OutputDataReceived(object sender, DataReceivedEventArgs ea) - { - ThreadHelper.JoinableTaskFactory.Run(async () => - { - try - { - if (!string.IsNullOrEmpty(ea.Data)) - { - await outputPane.WriteLineAsync(ea.Data); - } - } - catch { } - }); - - } - - protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) - { - await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - await DoCmdAsync(); - } - protected abstract Task DoCmdAsync(); - protected static OutputWindowPane outputPane = null; - protected async Task EnsureOutputPaneAsync() - { - - if (outputPane == null) - { - var guid = VSConstants.GUID_BuildOutputWindowPane; - outputPane = await VS.Windows.GetOutputWindowPaneAsync(guid); - } - } - protected override void BeforeQueryStatus(EventArgs e) - { - base.BeforeQueryStatus(e); - ThreadHelper.JoinableTaskFactory.Run(CheckAvailabilityAsync); - } - protected async Task CheckAvailabilityAsync() - { - Command.Visible = await Commands.ProjectIsXSharpProjectAsync(); - if (Command.Visible) - { - var project = await VS.Solutions.GetActiveProjectAsync(); - if (project == null) - { - Command.Visible = false; - Command.Enabled = false; - return; - } - var path = project.FullPath; - var prj = XSharpProjectNode.FindProject(path); - // Only show for SDK-style projects as they support dotnet pack/publish - Command.Visible = prj != null && prj.IsSdkProject; - Command.Enabled = Command.Visible; - } - } - - - } - class BuildCommandFilter : OLE.IOleCommandTarget - { - static readonly Guid PackGuid = new Guid("{568ABDF7-D522-474D-9EED-34B5E5095BA5}"); - - public int QueryStatus(ref Guid pguidCmdGroup, uint cCmds, - OLE.OLECMD[] prgCmds, IntPtr pCmdText) - { - bool isXSharp = false; - ThreadHelper.JoinableTaskFactory.Run(async delegate - { - - isXSharp = await Commands.ProjectIsXSharpProjectAsync(); - }); - if (!isXSharp) - { - return VSConstants.S_OK; - } - var mustCheck = false; - var cmd = prgCmds[0].cmdID; - if (pguidCmdGroup == CommandPack.CommandGroup && cmd == CommandPack.CommandID) - mustCheck = true; - else if (pguidCmdGroup == CommandPublish.CommandGroup && cmd == CommandPublish.CommandID) - mustCheck = true; - if (mustCheck) - { - bool show = false; - ThreadHelper.JoinableTaskFactory.Run(async delegate - { - show = await Commands.ProjectIsXSharpSdkProjectAsync(); - }); - prgCmds[0].cmdf = show - ? (uint)(OLE.OLECMDF.OLECMDF_SUPPORTED | OLE.OLECMDF.OLECMDF_ENABLED) - : (uint)(OLE.OLECMDF.OLECMDF_SUPPORTED | OLE.OLECMDF.OLECMDF_INVISIBLE); - return VSConstants.S_OK; - } - return (int) OLE.Constants.OLECMDERR_E_NOTSUPPORTED; - } - - public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, - IntPtr pvaIn, IntPtr pvaOut) - => (int)OLE.Constants.OLECMDERR_E_NOTSUPPORTED; - } -} diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandConvertXsRuntime.cs b/src/VisualStudio/ProjectPackage/Commands/CommandConvertXsRuntime.cs index 40a15bb796..0ab1c4dbca 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandConvertXsRuntime.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandConvertXsRuntime.cs @@ -24,7 +24,7 @@ private async Task CheckAvailabilityAsync() var project = await VS.Solutions.GetActiveProjectAsync(); var path = project.FullPath; var prj = XSharpProjectNode.FindProject(path); - Command.Visible = prj != null && !prj.IsSdkProject; + Command.Visible = prj != null; } } diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandEditProjectFile.cs b/src/VisualStudio/ProjectPackage/Commands/CommandEditProjectFile.cs index 7611ad3f8e..51c9273b52 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandEditProjectFile.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandEditProjectFile.cs @@ -36,7 +36,8 @@ protected override void BeforeQueryStatus(EventArgs e) } private async Task CheckAvailabilityAsync() { - Command.Visible = await Commands.ProjectIsXSharpProjectAsync(); + // CPS projects have their own "Edit Project File" command (capability OpenProjectFile) + Command.Visible = await Commands.ProjectIsMpfProjectAsync(); } protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { @@ -54,9 +55,6 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) var projectNode = XSharpProjectNode.FindProject(project.FullPath); if (projectNode != null && projectNode.QueryEditProjectFile(true)) { -#if DEV17 - projectNode.ClearSdkProjectReferences(); -#endif projectNode.SetProjectFileDirty(false); Directory.CreateDirectory(tempProjectDir); var prjFile = project.FullPath; diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandGenerateWinForm.cs b/src/VisualStudio/ProjectPackage/Commands/CommandGenerateWinForm.cs index 57169be525..54c876907c 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandGenerateWinForm.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandGenerateWinForm.cs @@ -86,16 +86,19 @@ protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) } var newdesignerform = Path.ChangeExtension(newform, ".designer.prg"); var x = await project.AddExistingFilesAsync(new[] { newform, newdesignerform }); - var prjNode = (XSharpProjectNode) xproject.ProjectNode; - var file = prjNode.FindChild(newform); - if (file is XSharpFileNode fileNode && fileNode.IsLink) + // MPFproj only: remove the Link metadata. CPS projects are not an XSharpProjectNode. + if (xproject.ProjectNode is XSharpProjectNode prjNode) { - file.ItemNode.SetMetadata("Link", null); - } - file = prjNode.FindChild(newdesignerform); - if (file is XSharpFileNode designerfileNode && designerfileNode.IsLink) - { - file.ItemNode.SetMetadata("Link", null); + var file = prjNode.FindChild(newform); + if (file is XSharpFileNode fileNode && fileNode.IsLink) + { + file.ItemNode.SetMetadata("Link", null); + } + file = prjNode.FindChild(newdesignerform); + if (file is XSharpFileNode designerfileNode && designerfileNode.IsLink) + { + file.ItemNode.SetMetadata("Link", null); + } } diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandPack.cs b/src/VisualStudio/ProjectPackage/Commands/CommandPack.cs deleted file mode 100644 index 5b918ffbb3..0000000000 --- a/src/VisualStudio/ProjectPackage/Commands/CommandPack.cs +++ /dev/null @@ -1,71 +0,0 @@ -using Community.VisualStudio.Toolkit; - -using System; -using System.IO; - -using Task = System.Threading.Tasks.Task; - -namespace XSharp.Project -{ - [Command(PackageIds.idPackProject)] - internal sealed class CommandPack : CommandBuild - { - protected override string CommandName => "Build.PackSelection"; - protected override string CommandDescription => "Pack"; - public static readonly Guid CommandGroup = new Guid("{568ABDF7-D522-474D-9EED-34B5E5095BA5}"); - public const int CommandID = 8193; - - protected override async Task DoCmdAsync() - { - if (!await VerifySdkProjectAsync()) - { - return; - } - // Show confirmation dialog - var result = await VS.MessageBox.ShowAsync( - "Create NuGet Package", - "This will create a NuGet package from the project using 'dotnet pack'.\n\n" + - "The package will be created in the project's bin folder.\n\n" + - "Continue?", - Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_QUERY, - Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_OKCANCEL); - - if (result == Microsoft.VisualStudio.VSConstants.MessageBoxResult.IDOK) - { - await PackProjectAsync(projectPath); - } - } - - private async Task PackProjectAsync(string projectPath) - { - try - { - await VS.StatusBar.ShowMessageAsync("Creating NuGet package..."); - - // Build dotnet pack command - var arguments = $"pack \"{projectPath}\" -c Release"; - - var result = await CreateProcessAsync(arguments, - $"Creating NuGet package for: {Path.GetFileName(projectPath)}"); - - if (result == 0) - { - string packagePath = null; - var message = "NuGet package created successfully."; - if (!string.IsNullOrEmpty(packagePath)) - { - message += $"\n\nPackage location:\n{packagePath}"; - } - await VS.MessageBox.ShowAsync(CommandDescription, - message, - Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_INFO, - Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_OK); - } - } - catch (Exception ex) - { - await VS.MessageBox.ShowErrorAsync(CommandDescription+" Error", $"Failed to create NuGet package:\n{ex.Message}"); - } - } - } -} diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandPublish.cs b/src/VisualStudio/ProjectPackage/Commands/CommandPublish.cs deleted file mode 100644 index e1bbb1a89b..0000000000 --- a/src/VisualStudio/ProjectPackage/Commands/CommandPublish.cs +++ /dev/null @@ -1,244 +0,0 @@ -using Community.VisualStudio.Toolkit; - -using Microsoft.VisualStudio; -using Microsoft.VisualStudio.Project; - -using Newtonsoft.Json; - -using System; -using System.ComponentModel; -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; - -using Task = System.Threading.Tasks.Task; - -namespace XSharp.Project -{ - - - - [Command(PackageIds.idPublishProject)] - internal sealed class CommandPublish : CommandBuild - { - protected override string CommandName => "Build.PublishSelection"; - protected override string CommandDescription => "Publish"; - - public const int CommandID = (int)2005; // ECMD_PUBLISHSELECTION - public static readonly Guid CommandGroup = VsMenus.guidStandardCommandSet2K; - - protected override async Task DoCmdAsync() - { - if (!await VerifySdkProjectAsync()) - { - return; - } - - // Show publish dialog to get options - var dialog = new PublishDialog(projectPath); - var result = dialog.ShowDialog(); - - if (result == true) - { - await PublishProjectAsync(projectPath, dialog.PublishOptions); - } - } - - private async Task PublishProjectAsync(string projectPath, PublishOptions options) - { - try - { - await VS.StatusBar.ShowMessageAsync("Publishing project..."); - - var arguments = BuildPublishArguments(projectPath, options); - options.Save(); - var result = await CreateProcessAsync(arguments, - $"Publishing project: {Path.GetFileName(projectPath)}"); - - if (result == 0) - { - await VS.MessageBox.ShowAsync(CommandDescription, - $"{CommandDescription} published successfully to:\n{options.OutputPath}", - Microsoft.VisualStudio.Shell.Interop.OLEMSGICON.OLEMSGICON_INFO, - Microsoft.VisualStudio.Shell.Interop.OLEMSGBUTTON.OLEMSGBUTTON_OK); - } - } - catch (Exception ex) - { - await VS.MessageBox.ShowErrorAsync(CommandDescription+" Error", $"Failed to publish project:\n{ex.Message}"); - } - } - - private string BuildPublishArguments(string projectPath, PublishOptions options) - { - var args = $"publish \"{projectPath}\""; - - if (!string.IsNullOrEmpty(options.Configuration)) - { - args += $" -c {options.Configuration}"; - } - - if (!string.IsNullOrEmpty(options.TargetFramework)) - { - args += $" -f {options.TargetFramework}"; - } - - if (!string.IsNullOrEmpty(options.Runtime)) - { - args += $" -r {options.Runtime}"; - } - - if (!string.IsNullOrEmpty(options.OutputPath)) - { - args += $" -o \"{options.OutputPath}\""; - } - - if (options.SelfContained.HasValue) - { - args += options.SelfContained.Value ? " --self-contained" : " --no-self-contained"; - } - - if (options.SingleFile) - { - args += " -p:PublishSingleFile=true"; - } - - if (options.ReadyToRun) - { - args += " -p:PublishReadyToRun=true"; - } - - if (options.Trimmed) - { - args += " -p:PublishTrimmed=true"; - } - - return args; - } - } - - public class PublishOptions : INotifyPropertyChanged - { - private string _projectDir; - private string _projectName; - private string _jsonFile; - private string _configuration = "Release"; - private string _targetFramework; - private string _runtime; - private string _outputPath; - private bool? _selfContained; - private bool _singleFile; - private bool _readyToRun; - private bool _trimmed; - - public event PropertyChangedEventHandler PropertyChanged; - - public PublishOptions() - { - - } - public PublishOptions(string projectPath) - { - // Set default output path based on project location - _projectDir = Path.GetDirectoryName(projectPath); - _projectName = Path.GetFileNameWithoutExtension(projectPath); - OutputPath = Path.Combine(_projectDir, "bin", "publish", _projectName); - _jsonFile = Path.Combine(_projectDir, $"{_projectName}.publishsettings.json"); - var project = XSharpProjectNode.FindProject( projectPath ) as XSharpSdkProjectNode; - if (project != null) - { - TargetFramework = project.TargetFrameworks.FirstOrDefault(); - Runtime = "win-x86"; // Default runtime, could be improved to detect from project - } - } - - public string Configuration - { - get => _configuration; - set => SetProperty(ref _configuration, value); - } - - public string TargetFramework - { - get => _targetFramework; - set => SetProperty(ref _targetFramework, value); - } - - public string Runtime - { - get => _runtime; - set => SetProperty(ref _runtime, value); - } - - public string OutputPath - { - get => _outputPath; - set => SetProperty(ref _outputPath, value); - } - - public bool? SelfContained - { - get => _selfContained; - set => SetProperty(ref _selfContained, value); - } - - public bool SingleFile - { - get => _singleFile; - set => SetProperty(ref _singleFile, value); - } - - public bool ReadyToRun - { - get => _readyToRun; - set => SetProperty(ref _readyToRun, value); - } - - public bool Trimmed - { - get => _trimmed; - set => SetProperty(ref _trimmed, value); - } - - protected void OnPropertyChanged([CallerMemberName] string propertyName = null) - { - PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); - } - - protected bool SetProperty(ref T field, T value, [CallerMemberName] string propertyName = null) - { - if (Equals(field, value)) return false; - field = value; - OnPropertyChanged(propertyName); - return true; - } - - public void Save() - { - var str = JsonConvert.SerializeObject(this, Formatting.Indented); - System.IO.File.WriteAllText(_jsonFile, str); - - - } - public void Restore() - { - if (System.IO.File.Exists(_jsonFile)) - { - var str = System.IO.File.ReadAllText(_jsonFile); - var options = JsonConvert.DeserializeObject(str); - if (options != null) - { - Configuration = options.Configuration; - TargetFramework = options.TargetFramework; - Runtime = options.Runtime; - OutputPath = options.OutputPath; - SelfContained = options.SelfContained; - SingleFile = options.SingleFile; - ReadyToRun = options.ReadyToRun; - Trimmed = options.Trimmed; - } - } - - } - } -} diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs b/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs index e03c6133ba..959579cdd7 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandSyncDesignerChanges.cs @@ -11,7 +11,7 @@ using System.Linq; using System.Threading.Tasks; -using XSharp.Project.ShadowDesigner; +using XSharp.ProjectSystem.ShadowDesigner; using XSharpModel; namespace XSharp.Project @@ -26,12 +26,14 @@ namespace XSharp.Project [Command(PackageIds.idSyncDesignerChanges)] internal sealed class CommandSyncDesignerChanges : BaseCommand { - private XSharpFileNode _currentFile; + private string _currentPath; + private XProject _currentProject; protected override void BeforeQueryStatus(EventArgs e) { base.BeforeQueryStatus(e); - _currentFile = null; + _currentPath = null; + _currentProject = null; ThreadHelper.JoinableTaskFactory.Run(CheckAvailabilityAsync); } @@ -43,14 +45,13 @@ private async Task CheckAvailabilityAsync() { if (item is PhysicalFile file) { - var project = await VS.Solutions.GetActiveProjectAsync(); - var xproject = project != null ? XSolution.FindProject(project.FullPath, "") : null; - if (xproject?.ProjectNode is XSharpProjectNode prjNode && - prjNode.FindChild(file.FullPath) is XSharpFileNode fileNode && - fileNode.HasDesigner && - prjNode is XSharpSdkProjectNode) + // SDK-style projects, loaded by the CPS project system + var xproject = XSolution.FindFile(file.FullPath)?.Project; + bool sdkProject = ShadowDesignerBridge.IsCpsProject(xproject); + if (sdkProject && ShadowDesignerBridge.HasDesignerFile(file.FullPath)) { - _currentFile = fileNode; + _currentPath = file.FullPath; + _currentProject = xproject; visible = true; } } @@ -62,11 +63,11 @@ private async Task CheckAvailabilityAsync() protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - if (_currentFile == null) return; + if (_currentPath == null) return; await VS.Commands.ExecuteAsync(KnownCommands.File_SaveAll); - if (!ShadowDesignerBridge.TryResolveCompanionPaths(_currentFile, out var location, out string error)) + if (!ShadowDesignerBridge.TryResolveCompanionPaths(_currentPath, _currentProject, out var location, out string error)) { await VS.MessageBox.ShowErrorAsync("X# WinForms Designer", error); return; diff --git a/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs b/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs index da28fd8c2d..9cf9fe1d3e 100644 --- a/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs +++ b/src/VisualStudio/ProjectPackage/Commands/CommandSyncEventHandlers.cs @@ -10,7 +10,7 @@ using System; using System.Threading.Tasks; -using XSharp.Project.ShadowDesigner; +using XSharp.ProjectSystem.ShadowDesigner; using XSharpModel; namespace XSharp.Project @@ -25,12 +25,14 @@ namespace XSharp.Project [Command(PackageIds.idSyncEventHandlers)] internal sealed class CommandSyncEventHandlers : BaseCommand { - private XSharpFileNode _currentFile; + private string _currentPath; + private XProject _currentProject; protected override void BeforeQueryStatus(EventArgs e) { base.BeforeQueryStatus(e); - _currentFile = null; + _currentPath = null; + _currentProject = null; ThreadHelper.JoinableTaskFactory.Run(CheckAvailabilityAsync); } @@ -42,14 +44,13 @@ private async Task CheckAvailabilityAsync() { if (item is PhysicalFile file) { - var project = await VS.Solutions.GetActiveProjectAsync(); - var xproject = project != null ? XSolution.FindProject(project.FullPath, "") : null; - if (xproject?.ProjectNode is XSharpProjectNode prjNode && - prjNode.FindChild(file.FullPath) is XSharpFileNode fileNode && - fileNode.HasDesigner && - prjNode is XSharpSdkProjectNode) + // SDK-style projects, loaded by the CPS project system + var xproject = XSolution.FindFile(file.FullPath)?.Project; + bool sdkProject = ShadowDesignerBridge.IsCpsProject(xproject); + if (sdkProject && ShadowDesignerBridge.HasDesignerFile(file.FullPath)) { - _currentFile = fileNode; + _currentPath = file.FullPath; + _currentProject = xproject; visible = true; } } @@ -61,13 +62,13 @@ private async Task CheckAvailabilityAsync() protected override async Task ExecuteAsync(OleMenuCmdEventArgs e) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); - if (_currentFile == null) return; + if (_currentPath == null) return; // The Designer-added stub/wiring can sit unsaved in an open document buffer -- // both sync steps read the companion files from disk, not the live buffer. await VS.Commands.ExecuteAsync(KnownCommands.File_SaveAll); - if (!ShadowDesignerBridge.TryResolveCompanionPaths(_currentFile, out var location, out string error)) + if (!ShadowDesignerBridge.TryResolveCompanionPaths(_currentPath, _currentProject, out var location, out string error)) { await VS.MessageBox.ShowErrorAsync("X# WinForms Designer", error); return; diff --git a/src/VisualStudio/ProjectPackage/Commands/PublishDialog.xaml b/src/VisualStudio/ProjectPackage/Commands/PublishDialog.xaml deleted file mode 100644 index 5f995c110c..0000000000 --- a/src/VisualStudio/ProjectPackage/Commands/PublishDialog.xaml +++ /dev/null @@ -1,100 +0,0 @@ - - - - - - - - - - - - - - - - - - - - -