Strongly typed parameter crashes Primalscript

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST LICENSE NUMBERS, ACTIVATION KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Strongly typed parameter crashes Primalscript

Post by clum09 »

Product, version and build: 7.4.117
32 or 64 bit version of product: 64 bit
Operating system: Windows 10
32 or 64 bit OS: 64 bit

PrimalScript keeps crashing when I add or edit a strongly typed parameter within a function of a very large script. Consider the function below whose parameters I am editing.

Code: Select all

function Validate-Data {
	[CmdletBinding()]
	param ([Parameter(Mandatory=$true,
		ValueFromPipeline=$true,
		ValueFromPipelineByPropertyName=$true)]
		[string]
		$Parameter1,
		[string]
		$Parameter2,
		[string]
		$object
	)
	# Some code to do something below.
}
When I attempt to add another parameter or edit one of the strongly typed parameters to become another data type within the function above, PrimalScript starts to crash in a random manner, and I had no choice but to close PrimalScript which will result in losing all the changes I made to the script if I have not saved the script. This behavior is very annoying.

Please investigate this problem and correct it.

Thank you.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Strongly typed parameter crashes Primalscript

Post by Alexander Riedel »

With the code block provided above all seems to work just fine. I have added about 17 new parameters and changed all types twice and it operates without any crashes or hiccup.
I can only guess that there is something above that function that creates that condition. If you get a crash, you generally get exception information in the system log. Please provide that information.
Additionally, it you can, please provide the entire script for evaluation.
You can upload it here: https://www.sapien.com/support/upload
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Re: Strongly typed parameter crashes Primalscript

Post by clum09 »

This behavior of crashing has been happening for the last several service builds, and it has never been corrected.

With a simple function as I posted may not cause PrimalScript to crash. The crash seems to happen randomly and mostly on large scripts with 10 thousand plus lines with multiple functions. It looks like PrimalScript is attempting to monitor and parsing the case of the code as I type and wants to correct the casing while the program just crashes. I will get the system event log and upload it when this happens again.
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Strongly typed parameter crashes Primalscript

Post by Alexander Riedel »

If this has happened "for several builds", why did you not let us know?

Once again, most likely it is some construct in your script causing this, so it would really help to have the script that can actually produce that problem, rather than a snippet that works fine.
Without it, it is quite unlikely to isolate the actual problem in any reasonable amount of time.
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
clum09
Posts: 150
Last visit: Sun Jan 21, 2024 5:07 pm

Re: Strongly typed parameter crashes Primalscript

Post by clum09 »

What you are saying is the crash was caused by the way how code is instructed within scripts which is not correct.

The scripts does not crash when I edit them using PowerShell ISE and they runs just fine during test when I run them in the PowerShell console.

Or are you saying there are only certain PowerShell codes that the PrimalScript editor can work on?
User avatar
Alexander Riedel
Posts: 8479
Last visit: Thu Mar 28, 2024 9:29 am
Answers: 19
Been upvoted: 37 times

Re: Strongly typed parameter crashes Primalscript

Post by Alexander Riedel »

I am not saying any of these. I think if you re-read what I posted you would understand.
The code snippet you posted is about a dozen lines and does not make the crash you indicate happen. So it is not the stretch of code that causes the problem. You have not posted any information from your system log either which *might* help in locating the cause or location of the problem.
Ultimately, as you say your script is 10'000 plus lines, the problem is somewhere in there and it makes PrimalScript's parser blow up.
I am not saying and never indicated that your code is wrong, I was asking if you could provide all your code as to helping to locate the problem.
We have analyzed your code snippet and inserted it into our own 10'000 lines plus script but to no avail.

So the question to you is, can you help out here or not and provide the script in question?
Alexander Riedel
SAPIEN Technologies, Inc.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.