Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Mohammad Hamdy Ghanem
@VBAndCs
Think of the checksum as a bonus. I need to run the whole generator and make sure it doesn't throw. The test can end here, but I added a checksum to make sure that the output file is ok. There are other tests focusing on the important parts of the generated code (the property definition, the constructor, and the With method). It is a good idea to ignore white-spaces in comparison, but this will need time and will give me nothing write now. May be I can do it in new tests to come. Thanks.
CyrusNajmabadi
@CyrusNajmabadi
up to you :)
Paul M Cohen
@paul1956
@VBAndCs I never depend on line ending, I use several functions that deal with the various line ending in a language/encoding independent way. Look here https://github.com/paul1956/CSharpToVB/blob/master/CodeConverter/Utilities/UnicodeNewline.vb
Mohammad Hamdy Ghanem
@VBAndCs
Nice, but I am not parsing here. I am just normalizing. I can include white spaces in normalization like this:
Public Function Normalize(str As String) As String
    Dim sb As New StringBuilder(str)

    ' Normalize tab and line terminator
    sb.Replace(vbTab, " ")
    sb.Replace(vbCr, vbLf)

    ' Remove duplicate spaces
    DeleteDuplicates(" ", sb)

    ' Trim each line
    sb.Replace(vbLf & " ", vbLf)
    sb.Replace(" " & vbLf, vbLf)

    ' Remove duplicate lines
    DeleteDuplicates(vbLf, sb)

    ' Trim the string
    If sb(0) = " " OrElse sb(0) = vbLf Then sb.Remove(0, 1)
    Dim en = sb.Length - 1
    If sb(en) = " " OrElse sb(en) = vbLf Then sb.Remove(en, 1)

    Return sb.ToString()
End Function
Sub DeleteDuplicates(str As String, fromStr As StringBuilder)
    Dim L As Integer
    Dim dupStr = str & str
    Do
        L = fromStr.Length
        fromStr.Replace(dupStr, str)
        If L = fromStr.Length Then Return
    Loop
End Sub
Mohammad Hamdy Ghanem
@VBAndCs
Is vb pretty listing available to us via Roslyn API? I want to apply it on the generated code
Paul M Cohen
@paul1956
Yes. There is NormalizeWhiteSpace and AsyncFormatAsync to start depending on what you are looking for.
Eugene
@JohnyL
@steveharter As for your answer. Yes, I have mentioned using JsonSerializeralready in my dotnet/runtime#54158. But what is CreateFromObject you have mentioned? Is it about to appear in API?
Paul M Cohen
@paul1956
Will the SourceGenerator for JSON be available for VB as well?
masonwheeler
@masonwheeler
Isn't VB.NET basically "in maintenance mode" now?
Paul M Cohen
@paul1956
@masonwheeler No, in fact is just got Source Generators and support for System.JSON.
CyrusNajmabadi
@CyrusNajmabadi
Yeah. Vb is not in maintenance mode.
It's currently in active development.
masonwheeler
@masonwheeler
OK, maybe not. Don't remember where, but I definitely heard someone say that a few months ago. I guess they were wrong.
Paul M Cohen
@paul1956
None of that answered the original question about VB source generator for JSON.
akima15
@akima15

We have detected that your app is incompatible with Windows 10 S. Please update your app to support Windows 10 S if possible. Otherwise include a prominent statement anywhere in the Metadata that the app does not support Windows 10 S. This issue may affect merchandisability.

This seems to be the reason after enabling "SiPolicy_Audit.p7b":

Code integrity determined that a process x attempted to load
dotnet\shared\Microsoft.NETCore.App\5.0.9\System.IO.FileSystem.dll
dotnet\shared\Microsoft.NETCore.App\5.0.9\System.Diagnostics.FileVersionInfo.dll
dotnet\shared\Microsoft.NETCore.App\5.0.9\System.Text.RegularExpressions.dll
dotnet\shared\Microsoft.NETCore.App\5.0.9\System.Text.Json.dll
that did meet the Custom 1 signing level requirements or violated code integrity policy (Policy ID:{A244370E-44C9-4C06-B551-F6016E563076}). However, due to code integrity auditing policy, the image was allowed to load.

So this means every app made with NET5 can't run in Windows 10 S Mode? Is this normal? o.o

Michael W Powell
@mwpowellhtx
Q: does anyone have any ideas what the migration path for netstandard target assemblies is in light of the coming .NET 6? I've asked in a couple of forums and gotten ambiguous responses leading me to believe that, "there is no migration path", but what does this mean in light of 6? what is the proposed solution to that issue? thanks...
Joe4evr
@Joe4evr
@mwpowellhtx the migration path is simply having your libraries target .NET 5/6 (where possible)
Michael W Powell
@mwpowellhtx
@Joe4evr thanks, after drudging up a couple of odd blogs about it, figured that might be the case. what I am more miffed at is the politicking dance. if this is known, then that is a fairly direct answer I think. i.e. multitarget your assemblies, possibly, i.e. netstandard2.x and /or net5.0 and/or net6.0, along these lines. Not counting target choices, which API surface areas are appropriate, etc.
CyrusNajmabadi
@CyrusNajmabadi
@mwpowellhtx this is what i mentioned to you when you asked :)
Ciaran ODonnell
@ciaranodonnell
Is this the right room for a Gitter noob to ask questions about source generators? And why my generator that generates a property ends up with an entry in the Error Window saying "The type 'TestEntity' already contains a definition for 'TestProperty'" but I can't access the generated property in code.
Michael W Powell
@mwpowellhtx
@CyrusNajmabadi sorry, must've gotten swamped amid other unrelated bits. never saw it, but I appreciate the response.
CyrusNajmabadi
@CyrusNajmabadi
no worries
Michael W Powell
@mwpowellhtx
I have been unable to download VS 2019 16.11.4build version 16.11.31727.386. The page 'loads' but nothing happens after that. I try click here to retry and nothing happens. Based on a gitter response, tried Firefox, also Chrome, same result. Anyone else experiencing the same? Is there a workaround? Thank you...
Mohammad Hamdy Ghanem
@VBAndCs
In StringBuilder methods Like Append, passing strings by value seems unnecessary overhead as it involves copying the string (it will not always a string literal). In fact all string params sent to SB methods should be byRef. This will not break VB code but will brake C# code, which lead us to a question: Why must C# compiler be such a stupid to require the ref keyword? why can't it be optional and the compilers add it when necessary, esp that we can't send a ref to a value param, and can't send a value to a ref param?
Why must we use a less optimum methods just because C# compiler has no brain?
Stephen A. Imhoff
@Clockwork-Muse

passing strings by value seems unnecessary overhead as it involves copying the string (it will not always a string literal)

Strings (and everything else descended from object) are reference types. When you pass one of them, you're passing a pointer in memory to the data of the object, not the data itself; you're already passing a reference.

You maybe save the cost of copying the value of the reference (I don't know how compilers actually handle this).
Stephen A. Imhoff
@Clockwork-Muse

Why must C# compiler be such a stupid to require the ref keyword?

It's a deliberate choice that most languages with similar features have also made. It's a form of explicitness about possible behavior.

Mohammad Hamdy Ghanem
@VBAndCs
What I know is that string is copied by value. It is an object but has some special rules to make using it easier.
Stephen A. Imhoff
@Clockwork-Muse
Why do you think it's copied by value?
(Note that even if the string object itself was copied by value, that doesn't mean that its contents were, since it uses an array/pointer-to to store the actual data, which means there's at least one other reference involved anyways)
Stephen A. Imhoff
@Clockwork-Muse
If by "copied by value", you mean "the contents of the string are copied into the string builder" - it has to: the string builder can remove characters from the middle of its buffer, which you couldn't do if you only maintained a reference to a string.
Michał Zegan
@webczat
@Clockwork-Muse actually string is really special I think. it does not reference an array of chars but somehow seems to embed the contents inside of it. but the rest of it is correct from what I can tell
masonwheeler
@masonwheeler
The string object reference is copied by value. Strings passed to methods do not have their contents copied. The contents of the string are copied when you insert a string into a StringBuilder because that's inherent to the nature of StringBuilder functionality, but this is not how string passing works in the general case.
CyrusNajmabadi
@CyrusNajmabadi
In StringBuilder methods Like Append, passing strings by value seems unnecessary overhead as it involves copying the string (it will not always a string literal)
this is not true.
What I know is that string is copied by value. It is an object but has some special rules to make using it easier.
there is no copying going on here.
when you pass a string around, you are effectively passing a pointer around to the single place in memory where the data is stored.
why can't it be optional and the compilers add it when necessary
because it's very valuable (in our opinion) that people be able to know when variables are passed by ref or not.
It's extremely different to me if i call:
DoFrob(myStr) vs DoFrob(ref myStr)
with teh latter i will assume that DoFrob will actually change my variable. Where with the former i know it cannot.
This will not break VB code
This would break existing VB programs as well. The ABI would change, which would render all existing programs out there non-functional. It would require recompiles of all programs to deal with this.
Stephen A. Imhoff
@Clockwork-Muse
That's beside any silent breaks due to somebody recompiling with unchanged source, but it turns out the reassign the parameter inside the method and now weird things happen. Good luck tracking down errors from that...
Joe4evr
@Joe4evr

You maybe save the cost of copying the value of the reference (I don't know how compilers actually handle this).

of note, this may even cause more overhead in certain scenarios, altho most-if-not-all of those are when it involves pointer-sized structs

John Moreno
@jrmoreno1
“In StringBuilder methods Like Append, passing strings by value seems unnecessary “ String is a class and as with all classes, passing “by value” passes a reference/pointer. For classes there is effectively no performance difference between by ref and by value, all that changes is what the pointer points to.