FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

A new hosting model which is easier for Editor Services and other script analyzer hosting by JamesWTruher · Pull Request #1361 · PowerShell/PSScriptAnalyzer · GitHub

A new hosting model which is easier for Editor Services and other script analyzer hosting - #1361

Closed
James Truher (JamesWTruher) wants to merge 62 commits into
PowerShell:masterfrom
JamesWTruher:hosting
Closed

A new hosting model which is easier for Editor Services and other script analyzer hosting#1361
James Truher (JamesWTruher) wants to merge 62 commits into
PowerShell:masterfrom
JamesWTruher:hosting

Conversation

Copy link
Copy Markdown
Contributor

PR Summary

This implements a new approach for hosting script analyzer for C# developers. It does not require the developer to manage the powershell engine or runspaces, and handles that internally. It does not need the developer to call the analyzer via pipeline.invoke. It provides a number of APIs which will make it easier for EditorServices to use ScriptAnalyzer.

PR Checklist

Had to make the initialization of the analyzer optional as it was clobbering the settings that had been created in the formatter
Hosting seems to work, starting to work on nuget packaging
Had to make the initialization of the analyzer optional as it was clobbering the settings that had been created in the formatter
Hosting seems to work, starting to work on nuget packaging
There really isn't a good way to do this as the underlying apis aren't really thread safe, but we can do _something_ to the hosted analyzer
If someone is using both the hosted analyzer and the module there may be some unexpected behaviors but doing something is probably better than doing nothing.
Disposing the helper seems to cause downstream problems.
Add async calls to the analyzer
Add a simple tostring method to the HostedAnalyzer
This will check to be sure that we can actually using the nupgk in a project
update the version to 1.18.4
Comment thread Reference/global.json
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "2.2.402"

Christoph Bergmeister (bergmeister) Jan 16, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

.net core 2.2 has reached EOL in December already and PSSA has already moved on to 3.1.101 in the root directory. I think we can simply remove the file

Christoph Bergmeister (bergmeister) changed the title WIP: A new hosting model which is easier for Editor Services and other script analyzer hosting A new hosting model which is easier for Editor Services and other script analyzer hosting Jan 16, 2020
Comment thread Engine/Formatter.cs
Helper.Instance = new Helper(runspace.SessionStateProxy.InvokeCommand, writer);
Helper.Instance.Initialize();

var ruleOrder = new string[]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

note sure if .net optimises that anyway but we could use a constant for this

Comment thread Engine/Formatter.cs

Range updatedRange;
bool fixesWereApplied;
text = ScriptAnalyzer.Instance.Fix(text, range, out updatedRange, out fixesWereApplied);

Christoph Bergmeister (bergmeister) Jan 16, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

the above bool fixesWereApplied line can be inlined just by using out bool fixesWereApplied here. Same for the Range parameter

Comment thread Engine/HostedAnalyzer.cs
/// PSUseConsistentWhitespace
/// PSUseConsistentIndentation
/// PSAlignAssignmentStatement
/// PSUseCorrectCasing

Christoph Bergmeister (bergmeister) Jan 16, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

the exact list of those rules could change, I'd take them out of the comment therefore. Same for other comments

Comment thread Engine/HostedAnalyzer.cs
/// <summary>
/// The encapsulated results of the analyzer
/// </summary>
public class AnalyzerResult

Christoph Bergmeister (bergmeister) Jan 16, 2020
edited
Loading

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

please move each class/enum into its own file if it is public

Comment thread Engine/Settings.cs
public IEnumerable<string> ExcludeRules => excludeRules;
public IEnumerable<string> Severities => severities;
public IEnumerable<string> CustomRulePath => customRulePath;
public List<string> IncludeRules => includeRules;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I don't think this change is needed?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

A lot of code and quite complex but if it makes it better on the PSES side of things or performance wise, then go for it. Most comments are minor but would be nice to be be addressed.

Comment thread Engine/Settings.cs
{
// the rule does not exist, that's a problem, first create it and then add the key/value pair
Dictionary<string, object> settingDictionary;
if ( ! RuleArguments.TryGetValue(rule, out settingDictionary))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

variable declaration can be inlined: out Dictionary<string, object> settingDictionary, also in a few lines below

<owners>Microsoft,PowerShellTeam</owners>
<projectUrl>https://github.com/PowerShell/PSScriptAnalyzer</projectUrl>
<iconUrl>https://raw.githubusercontent.com/powershell/psscriptanalyzer/master/logo.png</iconUrl>
<licenseUrl>https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt</licenseUrl>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
<licenseUrl>https://github.com/PowerShell/PowerShell/blob/master/LICENSE.txt</licenseUrl>
<licenseUrl>https://github.com/PowerShell/PSScriptAnalyzer/blob/master/LICENSE</licenseUrl>

Copy link
Copy Markdown
Collaborator

Close and re-open to re-trigger CI

Copy link
Copy Markdown
Contributor Author

I'm going to close this as it's not needed at the moment.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL