integrated-application-development / delphilint

Delphi IDE package providing on-the-fly code analysis and linting, powered by SonarDelphi
GNU Lesser General Public License v3.0
79 stars 9 forks source link

TEdgeBrowser.UserDataFolder is not converting %LOCALAPPDATA% in Delphi 11.0 #34

Closed M0nsieurT closed 3 months ago

M0nsieurT commented 3 months ago

Prerequisites

Delphi IDE version

Delphi 11.0 Version 28.0.42600.6491 (Professional)

DelphiLint version

1.0.2

SonarDelphi version

1.4.0

SonarQube version

9.9

Issue description

Hi, First thanks for your work ! I bought a Professional licence in 2021 and I did not renew my subscruption, so unfortunately I am locked with Delphi 11.0.

I was able to install DelphiLint but I got the issue below every time I tried to open DelphiLint analyse form : DelphiLint Delphi 11 0

So I had to add the line before RuleBrowser.CreateWebView into TLintToolFrame.Create to make it work : RuleBrowser.UserDataFolder := IncludeTrailingPathDelimiter(TPath.GetHomePath()) + 'bds.exe.WebView2';

I know TPath.GetHomePath is not refering to %LOCALAPPDATA% but to %APPDATA%, but this change worked for me.

Maybe you can add a conditional for versions 11.0 and 11.1 to setup the path.

Steps to reproduce

Open Analyze File form in Delphi 11.0

Minimal Delphi code exhibiting the issue

No response

fourls commented 3 months ago

Hi @M0nsieurT, thanks for raising this issue! I'm glad that you were able to get DelphiLint working, and I hope you're finding it useful.

I'm not sure why this error would be happening. Could you confirm that LOCALAPPDATA is present and correct in the Delphi IDE settings (Tools > Options > IDE > Environment Variables > System Variables)?

I know TPath.GetHomePath is not refering to %LOCALAPPDATA% but to %APPDATA%, but this change worked for me.

Maybe you can add a conditional for versions 11.0 and 11.1 to setup the path.

If the default behaviour can be problematic, I'm happy to add code to set the UserDataFolder on all versions. Since we own %APPDATA%\DelphiLint, a user data folder like %APPDATA%\DelphiLint\bds.exe.WebView2 could be appropriate - could you confirm whether using this line works for you?

RuleBrowser.UserDataFolder := '%APPDATA%\DelphiLint\bds.exe.WebView2';
M0nsieurT commented 3 months ago

I'm not sure why this error would be happening. Could you confirm that LOCALAPPDATA is present and correct in the Delphi IDE settings (Tools > Options > IDE > Environment Variables > System Variables)?

image

If the default behaviour can be problematic, I'm happy to add code to set the UserDataFolder on all versions. Since we own %APPDATA%\DelphiLint, a user data folder like %APPDATA%\DelphiLint\bds.exe.WebView2 could be appropriate - could you confirm whether using this line works for you?

%APPDATA% did not work, it seems this value does not handle environment variables in previous versions, but it worked using the one below (I slighty changed it to make it more readable)

RuleBrowser.UserDataFolder := TPath.Combine(TPath.GetHomePath, 'DelphiLint\bds.exe.WebView2');

And below is the %APPDATA%\DelphiLint folder's content :

image

fourls commented 3 months ago

Thanks for investigating - as you say, seems like 11.0 doesn't handle environment variables here.

Glad to hear that this solution works, I'll get this into master soon.