The place for the VB community to join our collective voice! See https://github.com/CommunityVB/Main for more info.
to answer your question about VB, I'm working on trying to make things more async, and to work on perf not causing blocking issues in it in the typing experience -- @CyrusNajmabadi
Can you take a moment to update about the work you were referring to when you posted this a while back?
?
for printing, even if it possible. In C#, we use cw+tab shortcut for Console.writeline snippent, which doesn't exist in VB, and there is an issue about that dotnet/roslyn#37049
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<CodeSnippet Format="1.0.0">
<Header>
<Title>Console.WriteLine</Title>
<Author>M. Hmdy Ghanem</Author>
<Shortcut>cw</Shortcut>
</Header>
<Snippet>
<Code Language="VB">
<![CDATA[Console.WriteLine($msg$)]]>
</Code>
<Declarations>
<Object>
<ID>msg</ID>
<Type>System.String</Type>
<ToolTip>The message you want to write.</ToolTip>
<Default>"Hello"</Default>
</Object>
</Declarations>
</Snippet>
</CodeSnippet>
</CodeSnippets>
Console.WriteLine("Hello")
?
as a shortcut for the snippet, but didn't work as it is used to show the snippet context menu. It would be nice ;)
cwl
.
@CyrusNajmabadi
Does the visual basic specification and compiler, assert atomicity within "multi-part" block structures.
For example the ElseIf
in an If Then ... End If
block.
We have the following code (as is).
' statements 0
If someCondition = True Then
' statements 1
ElseIf someCondition = False Then
' statements 2
Else
' statements 3
End If
' statements 4
is transformed into
' statements 0
If someCondition = True Then
' statements 1
Else
' *** What prevents evaluate of someCondition being different from prior evaluation.
If someCondition = False Then
' statements 2
Else
' statements 3
End If
End If
' statements 4
Is someCondition
asserted to be atomic ( non-changing ) between each usage?
As from my knowledge the lowered form does not seem to have that "ambient property", or does the transformation production obtain that "ambient property" from the transformation of an ElseIf
statement.
If it doesn't would a copy of the value of "someConditon" into "tmp" prior to the If Block, and rename the usage of "someCondition" with on this block to "tmp". Gain that guarentee.
I think this is something to do with Side-Effects and/or Contract propagation.
Otherwise, if the variable you are testing is not a local variable but instead a property of a class... the class could literally return a different result each and every check.
Alternatively (I believe) this could be resolve by using Select Case
.
If it doesn't would a copy of the value of "someConditon" into "tmp" prior to the If Block, and rename the usage of "someCondition" with on this block to "tmp". Gain that guarentee.
This would only be true if the developer honored this restriction.
is predominantly is lowered to an
If ... Then` structure, so same suitable effect exists. In a "pure" single threaded non-eventing/interuptting evaluation it trivial and can be ignored. In a non-linear evaluation environment it does, so assisting the programmer to have awareness, or code-fix.
If
checking is completely within the context of the If
statements. So multi-threaded code shouldn't be an issue (in this example - which I feel is more common). In the event the value does change, there is a high possibility this was what the developer desired/intended. Now if we talk about properties... the value of the property is controlled by the object and one would have to wonder under what conditions that this would be an issue. In some circumstances, the value changing between the If
statements may actually be desired. There are also two very different Select Case
models (lowering)... as you said there is one that is basically a bunch of individual If
statements while the (ultimately) desired lowering would be the "jump list". To my knowledge, the "jump list" version would evaluate the value once and is significantly faster than and something I tend to try to setup for under normal conditions. If the desire is to make the variable unchanging, there are (of course) mechanisms in place to assist with that as well. But I don't think there is a "blanket" mechanism or even warning that would cover all the scenarios and my gut is telling me this would create more confusion than it would potentially address any sort of pitfall. In other words, I can't imagine how one would look at the code a know whether or not this might be a potential issue across all the possible scenarios that could exist. I could, of course, be missing something... so there is always that. ;-)
and is a code fix possible?
Of course it would be better if intellisense take snippets shortcuts into account.
A nice surprise: @sharwell pointed out that there is an option to trun on this feature!
https://github.com/dotnet/roslyn/issues/37049#issuecomment-998997945
something
, otherthing
) are to be treated as having a single immutable value (or the "value" will not be altered.). Is there enough evidence to support or proof that statement, from the specification.