How to breaking lambda into multiple lines for debugging - vb.net

I am trying to debug something but this one statement got so much in it so it is very hard to debug it. It has multiple functions and a lambda in it and it won't step into TraceRoute method for me to debug. I am thinking of breaking it into a few lines of codes in order for me to step into the method. What would be correct way to do this!
WService(Of ICService).Use(Sub(svc) traceMessage = svc.TraceRoute(), False)

If you're having trouble with it, make it a subroutine/function until you know it's working correctly.

Related

Roslyn context.SemanticModel.GetDeclaredSymbol() returning NULL from InvocationExpression

Trying to develop an VS extension to help with migration from vb6 to Vb.net using Roslyn.
Unfortunately I am not having much luck with detecting the "DoEvents" expression in my source as I get NULL from my GetDeclaredSymbol during the detection.
My bad coding is......
Register the action:
context.RegisterSyntaxNodeAction(AddressOf ExpressionStatementDec, SyntaxKind.InvocationExpression)
Try and detect the "DoEvents" expression:
Private Sub ExpressionStatementDec(context As SyntaxNodeAnalysisContext)
Dim GotYou = context.SemanticModel.GetDeclaredSymbol(context.Node)
Dim WhatExpression = context.Node.ToFullString.ToString
' Find DoEvents.
If RemoveWhitespace(WhatExpression) = "DoEvents" Then
Dim diag = Diagnostic.Create(Rule, GotYou.Locations(0), GotYou.Name)
context.ReportDiagnostic(diag)
End If
End Sub
I have tried loads of options for trying to get the right type of object for "GotYou" but no luck so far.
Any pointers appreciated :)
Edit Additional info:
I have tried GetSymbolInfo but when I am detecting "DoEvents" in the context.Node.ToFullString.ToString I am still not getting anything in the context.SemanticModel.GetSymbolInfo(context.Node) as below.
Thanks,
Richard
If you want to look at what a invocation is referencing, call GetSymbolInfo not GetDeclaredSymbol.
Don’t have Visual Studio handy in order to get the code, but...
I believe what you want is something like:
Dim WhatExpression = TryCast(CType(context.Node, InvocationExpressionSyntax).Expression, IdentifierNameSyntax)?.Identifier.Text
This isn’t all of it, you could be dealing with a memberaccessexpression, in which case it’s probably not what you are looking for. The options would be a bit easier to handle with pattern matching in C#, but that’s the general idea. You don’t need the semantic tree at this point, because you first want to verify that you are dealing with the right text. Once you’ve got that, you can see where it comes from and whether it is something you need to deal with. Getting the semantic model is expensive, no reason to do so when (outside of your unit test) it is rarely going to be needed.

Matlab mex-function mexPrintf does not print immediately

This question hass been asked several times, but no solution does work for me. I want to use printf (or mexPrintf / ssPrintf) in an Matlab-mex file (called in a simulink s-function). The problem here is, that the output is only display after the function is finished, and I never get an instant message, while the function is running. I am using R2016b. I tried several things, like for example:
#define printf(...) { mexPrintf(__VA_ARGS__); mexEvalString("drawnow;"); mexEvalString("pause(0.01);"); }
I also tried the following solutions, but neither works:
how can I make a mex function printf while it's running?
https://de.mathworks.com/matlabcentral/answers/255615-why-are-mex-file-output-messages-using-mexprintf-mexevalstring-drawnow-not-printed-immediatel
Is there a way to get this working, or is this simply not possible in this release? Thanks.

The specified RegistryOptions value is invalid

What im trying to do is write a key to the registry but im stepping from one problem to another, first permissions problem, now this..
This is the line of code.
If PNGchk.Checked = True Then
My.Computer.Registry.Users.CreateSubKey(UserSID & "\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\UserChoice", True, Security.AccessControl.RegistryRights.FullControl).SetValue("Progid", "SIV.png", Microsoft.Win32.RegistryValueKind.String)
End If
You must have Option Strict Off for that code to even compile, so you might want to fix that to start with. Option Strict On would have flagged issues with that code right away. You should read the documentation or at least pay attention to Intellisense for that method because your second and third arguments make no sense. No overload that I can see has a Boolean parameter and if you want to use a RegistryRights value you do so within a RegistrySecurity object as far as I can see.
RegistryKeyPermissionCheck.ReadWriteSubTree worked for me.
Using clsid64 = view64.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.png\UserChoice", RegistryKeyPermissionCheck.ReadWriteSubTree)
clsid64.SetValue("StubPath", "SIV.png")
clsid64.Close()
End Using

How am I supposed to test if an assembly procedure works?

I'm starting to learn assembly.
Let's say I write a procedure to find to minium value in an array of integers.
PUBLIC _findmin
.MODEL SMALL
.CODE
_findmin PROC
// code here...
_findmin ENDP
END
How can I test if it does actually work?
How can I execute this code?
There are several ways of confirming your code is working. One is to go through a debugger. If you are testing against multiple resulty, you can also write a simple wrapper and loop with various input parameters, comparing the output to the expected result. I did this when I wrote a kind of pattern matching algorithm, because it's hard to keep track of all possible patterns and making sure they still work after a change.
There are also testframworks for more complex code.

obfuscated way to get "0" in a tcl function, cross platform?

I haven't used tcl before and just need to do one trick, I can do it trivially in something like bash but I need it to work cross-platform (e.g. tcl in cygwin on windows).
Can someone suggest a short (5-10) obfuscated function that just returns 0 after taking two string args? It just can't do something like run shell commands that won't work under Mac/Cygwin.
fwiw, why do this: buying some time in writing a test- the thing generating one of the files is broken but I can't change it, making a hack in the TCL test script until I make extensive changes to use a different 'test core' that isn't broken. For now just declare the first file as 'good' if it exists.
I don't understand the requirement for obfuscation, but the simplest way to create a command that takes two arguments and returns 0 is this:
proc theCommandName {firstArgument secondArgument} {
return 0
}
There are all sorts of ways of making things obscure (e.g., a regular expression that doesn't actually match anything, a complicated expression) but as I said before, I don't understand the requirement in that area; I always try to make my code be the simplest thing that could possibly work…