Can I instrumenting Microsoft Pex? - pex

Can I instrument Microsoft Pex ? Like pass the a method code to it (in a string variable) and get the PUT in return ? or a set of path conditions ?

Related

vb.net my.settings.* storage location

I am new in vb.net, and someone used 'My.Settings.*' on a vb.net program
I inherited.
I would like to know where the data are stored when using My.Settings in vb.net
If I have a member variable called IpAddress for example, can I have an other class using its own member variable called IpAddress without being confusing for the program ?
What if an other program is runing using a variable called IpAddress, can those be mixed up ?
My.Setting are stored in user/AppData/Local
You can have variables with same name in different scopes. Even though they appear to have the same name to you, they do not to the code.

TFS 2015 Build Variable Expansion

We have a VNext build definition, on the Variables tab we have added a few custom variables. In one of the variable values we refer to another variable, i.e.
FileDescription = $(Build.DefinitionName)
However it appears that when we reference it in a PowerShell script the FILEDESCRIPTION environment variable exists but the value is not expanded(it contains "$(Build.DefinitionName)" ) and is treated as a string literal.
The documentation appears to suggest that we should be able to refer to it and it will be subsituted at run-time -
https://msdn.microsoft.com/en-us/library/vs/alm/build/scripts/variables
Is there a way to get TFS to automatically expand the variable at runtime?
In vNext build, it seems not expanded the variable everywhere.
For example, in MSBuild-Arguments, /p:OUTPUT="$(FileDescription)" is expanded to /p:OUTPUT="(the name of build definition)" , but in powershell it will only prints "$(Build.DefinitionName)" directly.
Try to use below Workaround: Try to use the corresponding generated environment variables (for example $env:Build.DefinitionName).
$FileDescription = $env:Build.DefinitionName
Note: If you need to change the path, you have to change the PS script instead of a build variable.

Confusion about the Argument< T > and Variable< T > in .NET 4.0 Workflow Foundation

I am using Windows Workflow Foundation in .NET 4.0. Below is some syntax/semantic confusion I have.
I have 2 equivalent way to declare an Assign activity to assign a value to a workflow variable (varIsFreeShipping).
(1) Using XAML in the designer.
(2) Using code.
But in approach 2, the it seems I am creating a new OutArgument< Boolean > and assign value to it, not to the original Variable< Boolean> varIsFreeShipping. And OutArgument and Variable are totally different types.
So how could the value assigned to this new Argument finally reach the original Variable?
This pattern seems common in WF 4.0. Could anybody shed some light on this?
Thanks!
As a matter of fact, the second (2) method can be written just as:
Then = new Assign<bool>
{
To = varIsFreeShipping,
Value = true
}
This all works because OutArgument<T> can be initialized through a Variable<T> using an implicit operator.
In your first (1) assign, using the editor, that's what's happening behind the scene; the variable is being implicitly converted from Variable to OutArgument.
WF4 uses alot of implicit operators mainly on Activity<T> from/to Variable<T>, OutArgument<T> from/to Variable<T>, etc. If you look at it, they all represent a piece of data (already evaluated or not), that is located somewhere. It's exactly the same as in C#, for example:
public int SomeMethod(int a)
{
var b = a;
return a;
}
You can assign an argument to a variable, but you can also return that same variable as an out argument. That's what you're doing with that Assign<T> activity (using the variable varIsFreeShipping as the activity's out argument).
This answers your question?

VB.NET logical expression evaluator

I need to test a logical expression held in a string to see if it evaluate to TRUE or FALSE.(the strig is built dynamically)
For example the resulting string may contain "'dog'<'cat' OR (1>4 AND 4<6)". There are no variables in the string, it will logically evaluate. It will only contain simple operators = > < >< >= <= and AND , OR and Open and Close Brackets, string constants and numbers. (converted to correct syntax && || etc.)
I currently acheive this by creating a jscipt function and compiling it into a .dll. I then reference the .dll in my VB.NET project.
class ExpressionEvaluator
{
function Evaluate(Expression : String)
{
return eval(Expression);
}
}
Is there a simpler method using built in .NET functions or Lamdba expressions.
I tried the demo out for this project and you might like it over you current method of evaluating. Note, it doesn't use lamdba expressions or any build it .NET methods.
http://web1.codeproject.com/KB/vb/expression_evaluator.aspx?msg=1151870
try out: http://www.codeproject.com/KB/cs/ExpressionEval.aspx
More guidance :http://www.thefreakparade.com/2008/07/evaluating-expressions-at-runtime-in-net-c/
Good one: http://flee.codeplex.com/
Boolean Example which you are looking for : http://flee.codeplex.com/wikipage?title=BooleanExpression&referringTitle=Examples (ignore the variable adding part as you are not looking for variable)

How do you read a registry value using a custom msbuild task?

I'm creating an MSBuild task that will read the registry for a specific registry key. If I write the same line of code (see below) in a console application, it returns the expected result, but when it is within the MSBuild task, it returns nothing.
Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing)
I would expect the above code to return Nothing if the key/value pair doesn't exist, and return the value if it does exist. I am getting Nothing when the MSBuild task gets executed. Is there some attribute that I need to apply to the Execute function of the MSBuild task to tell it that it needs to read the registry?
EDIT:
Here is what is being executed from the MSBuild task:
Return Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing)
I beleive this to be caused by the Registry Redirector on my Vista x64 machine running MSBuild in 32bit. Is there any way that you can tell the custom MSBuild task (written in VB .Net) to look in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\ then only if nothing exists there then look in HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\?
Thank you,
Scott Blue
You can read the registry directly from MSBuild, without a custom task, like this:
$(registry:Hive\MyKey\MySubKey#Value)
E.g.,
$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\)
You said that you're looking to do this from a custom task, so this may not apply, but I'm posting it in case it helps.
Our msbuild script runs from an x86 Visual Studio Command Prompt. It does not read the 64 bit registry when using this syntax. It there a different syntax which would allow the x86 to read the 64 bit registry?
How about using VB's If() ternary function?
Function GetSqlPathFromReg() As Object
Return If(Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing), _
Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\MSSQLServer\Setup\", "SQLPath", Nothing))
End Function
Assuming you have an Output() property:
Private _sqlPath As String
<Output()> _
Public ReadOnly Property SqlPath() As String
Get
Return _sqlPath
End Get
End Property
Then all you have to do is calling it from the Execute() method:
_sqlPath = GetSqlPathFromReg().ToString()