csharpier icon indicating copy to clipboard operation
csharpier copied to clipboard

VS2022 for mac Extension

Open belav opened this issue 3 years ago • 2 comments

Extensions for regular VS2022 are built on the .net framework, so I assume that they are not compatible with VS2022 for Mac.

Assuming there is demand it would be nice to have one built for VS2022 for Mac. It can probably be based on the existing VS2022 extension. I don't have a Mac to do the work however.

belav avatar Apr 28 '22 22:04 belav

Just commenting to express my interest. I've been looking for an extension to use CSharpier on Mac.

I could perhaps look into trying to port it, but I've never gone about making extensions for Visual Studio before, so I wouldn't know where to start.

That having been said... I mostly use VSCode for Mac, and the rest of my team uses Windows, so it actually isn't that high of a priority for me.

MichaelCharles avatar Oct 11 '22 01:10 MichaelCharles

I've made an AppleScript to save with csharpier. It works but you might have to save twice for it to apply. You have to make a workflow and map it to the save cmd. It is better than nothing but a proper extension would be nice.

It is made for VS Preview and some path might not work for you. You can follow this explanation for Xcode that use the same technique : https://luisramos.dev/xcode-format-and-save

on run {input, parameters}
	tell application "System Events"
		tell process "Visual Studio (Preview)"
			set frontmost to true
			set solution to value of attribute "AXDocument" of front window
			set solution to ((characters 8 thru -1 of solution) as string)
			set reversesolution to reverse of solution's items as text
			set solution to text 1 thru -(offset of "/" in reversesolution) of solution
			set filepath to name of front window
			set filepath to text ((offset of " – " in filepath) + 3) thru -1 of filepath
			set filepath to text 1 thru ((offset of " – " in filepath) - 1) of filepath
			set filepath to text 1 thru ((offset of "*" in filepath) - 1) of filepath
			set cmd to "/bin/zsh -c 'source ~/.zshrc && /usr/local/share/dotnet/dotnet csharpier \"" & solution & filepath & "\"'"
			set reversefilepath to reverse of filepath's items as text
			set filename to text (-(offset of "/" in reversefilepath) + 1) thru -1 of filepath			
			try
				click menu item ("Save " & filename) of menu "File" of menu bar 1
				delay 1
			on error errorMessage number errorNumber
		    	log ("errorMessage: " & errorMessage & ", errorNumber: " & errorNumber)
			end try
			do shell script cmd
		end tell
	end tell
	return input
end run

cl3m avatar Oct 26 '22 22:10 cl3m