Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code Formatting of Repo - Add Preprocessing to Compilation Process - Introduction of Dev/Build Tools to WinUtil (Although very simple at the moment) #2383

Conversation

og-mrk
Copy link
Contributor

@og-mrk og-mrk commented Jul 16, 2024

Type of Change

  • New feature
  • Refactoring

Description

Makes sure all files don't have any trailing whitespace.
And by putting in inside a function (the Do-PreProcessing function) it'll be possible in the future to do other things, like replacing Tabs with 4 spaces (the convention that's used the most.. other than Invoke-WPFMicrowin.ps1).

Testing

I ran the script and not only does it compile WinUtil, but also makes sure every file follows specific coding conventions (like having no trailing whitespace)

Additional Information

Not only does it do this preprocessing on other files in the repo.. it also does it on the Compile.ps1 file itself, indicating that PowerShell interpreter makes a Copy of the running script in memory, before actually running said script.. which's somewhat a new discovery (at least for me).

Checklist

  • My code adheres to the coding and style guidelines of the project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no errors/warnings/merge conflicts.

@og-mrk og-mrk requested a review from ChrisTitusTech as a code owner July 16, 2024 20:00
@ruxunderscore
Copy link
Contributor

Nice!

@og-mrk og-mrk requested a review from MyDrift-user July 17, 2024 10:00
Copy link
Contributor

@MyDrift-user MyDrift-user left a comment

Choose a reason for hiding this comment

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

good commits @og-mrk!

@og-mrk
Copy link
Contributor Author

og-mrk commented Jul 25, 2024

@ChrisTitusTech Fixed.

Just discarded every change on my branch (HEAD) for every merge conflicts, and for updates.md file, I just added it with git add docs/updates.md to confirm its deletion.

@og-mrk og-mrk closed this Jul 25, 2024
@og-mrk og-mrk force-pushed the compiler-improvement/remove-trailing-whitespace branch from e514b95 to 8ae328c Compare July 25, 2024 21:21
@og-mrk og-mrk reopened this Jul 25, 2024
@og-mrk og-mrk marked this pull request as draft July 25, 2024 21:38
@og-mrk og-mrk marked this pull request as ready for review July 26, 2024 03:51
@og-mrk
Copy link
Contributor Author

og-mrk commented Jul 26, 2024

Now a few things happened:

  1. Even after using git for a while.. I got a bit cocky & did something, which I personally thought was quite impossible to do.. which's losing your changes with git 😆, I'll never do a Force Push to any branch without double/triple checking my previous commands, LOL
  2. The deletion of my code (yes, it was gone locally & on remote) was at first.. a bit annoying, had to re-write it from memory (no snippets, screenshots, or anything).. but thankfully, this happened to a somewhat simple PR, so it was trivial to re-program it again. It was a nice memory test as well 👍
  3. .. Somehow by starting over, I got a chance to re-think & improve upon my work, and thankfully I'm a bit more knowledgeable about RegEx (used it in Workflow Update PRs), so I used its power to make any Code Formatting choice, which I personally see it as the most fitting, or the "common convention" used in the source code.
  4. Also, my bad for the review comments above.. I didn't mean to delete my own PR 😢 (It was an accident), so it's now referencing to code that doesn't exist anymore (gone forever.. I think).

With that being said, I made the PR read to review. If you've anything you don't like or want to improve upon, @ChrisTitusTech you can do so.
image

@og-mrk og-mrk changed the title Add Preprocessing in Compiler Code Formatting of Repo - Add Preprocessing to Compilation Process - Introduction of Dev/Build Tools to WinUtil (Although very simple at the moment) Jul 26, 2024
@Marterich
Copy link
Contributor

Marterich commented Jul 26, 2024

Could you rename the function and the file Do-preprossing to something following the function naming convention from Microsoft like Start-Preprocessing or Invoke-Preprocessing
https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/09-functions?view=powershell-7.4

Seeing as there are not really any code conventions for winutil in place, and it's quite the wild west, I think it's probably smart to try to adhere to the one from Microsoft at least

@og-mrk
Copy link
Contributor Author

og-mrk commented Jul 26, 2024

Could you rename the function and the file Do-preprossing to something following the function naming convention from Microsoft like Start-Preprocessing or Invoke-Preprocessing https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/09-functions?view=powershell-7.4

Yahh I do agree on this weird naming convention I've used 😅, also didn't check the Official Microsoft PowerShell Standards, I'll be sure to refer to it when adding Formatting Rules, thanks @Marterich

@ChrisTitusTech
Copy link
Owner

This is one big PR @og-mrk still reviewing it. Looks awesome from a cleanup and standardizing some of the files.

@og-mrk
Copy link
Contributor Author

og-mrk commented Jul 31, 2024

Thanks @ChrisTitusTech for taking your time to review this.

And although I'm happy with the result of this tiny script I've made (it's quite simple if you checked Invoke-Preprocessing code, just some find & replace code).. there's still room for improvement, and because it's a script that can modify almost every file in the repo.. I'll need to test it more, and see what other formatting rules to add/implement.

Therefore, I'll convert this PR to draft until I see/think it's ready (both "feature" and stability wise).

I know the core concept & idea is finished (tested it with every change along the way).. but when you've RegEx which's untested to every possible case, and said RegEx can modify your entire code base.. yahh, I think I'll do some Unit Testing for this script. And the Tests themselves shouldn't change over time.. as long as the code itself (formatting rule) doesn't change, because the input (possible cases) for each Rule is many, but limited, and expected output is always one (the desired formatted code).

@og-mrk og-mrk marked this pull request as draft July 31, 2024 03:23
@og-mrk
Copy link
Contributor Author

og-mrk commented Aug 6, 2024

Even though there's more Formatting rules I'd like to add.. the current (and somewhat simple) RegEx formatting is ok.. more complex formatting would require parsing PowerShell and figuring out the AST (Abstract Syntax Tree), which in the long run.. would make it a script that can be used in any project, and would work just as intended (formatting PowerShell code bases).

@ChrisTitusTech Tested this script, and it works as intended. Will make PR ready for review...

@og-mrk og-mrk marked this pull request as ready for review August 6, 2024 18:28
@ChrisTitusTech ChrisTitusTech merged commit 3903eaa into ChrisTitusTech:main Aug 6, 2024
@og-mrk og-mrk deleted the compiler-improvement/remove-trailing-whitespace branch August 20, 2024 13:44
@ChrisTitusTech ChrisTitusTech added the skip-changelog Skip Change Logs label Sep 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-changelog Skip Change Logs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants