Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Dec 03 20:55
    BrennanConroy review_requested #43124
  • Dec 03 20:55
    BrennanConroy review_requested #43124
  • Dec 03 20:30
    BrennanConroy synchronize #43124
  • Dec 03 20:12
    BrennanConroy synchronize #43124
  • Dec 03 19:57
    BrennanConroy synchronize #43124
  • Dec 03 19:40
    BrennanConroy milestoned #43124
  • Dec 03 19:40
    BrennanConroy labeled #43124
  • Dec 03 19:40
    Dotnet-GitSync-Bot labeled #43124
  • Dec 03 19:39
    BrennanConroy opened #43124
  • Dec 03 09:39
  • Dec 03 09:39
    RanhaoKang starred dotnet/corefx
  • Dec 01 23:05
    lin-bin-as-developer starred dotnet/corefx
  • Dec 01 16:06
    OsamaAlBannaST starred dotnet/corefx
  • Dec 01 09:56
    isakkasi starred dotnet/corefx
  • Nov 27 01:39
    danmoseley closed #42874
  • Nov 27 01:39
    danmoseley commented #42874
  • Nov 26 05:46
    ShadowReaperSCPF starred dotnet/corefx
  • Nov 25 11:14
    edsdck starred dotnet/corefx
  • Nov 25 07:21
    lghwlgjy starred dotnet/corefx
  • Nov 24 15:48
    MiglenaPencheva starred dotnet/corefx
Mohammad Hamdy Ghanem
@VBAndCs
@paul1956 Scientific Basic has advanced graphical capabilities as I see on the samples of the remade file. You may use whatever lib they are using for that:
https://github.com/xieguigang/sciBASIC
Paul M Cohen
@paul1956
@VBAndCs very nice but I hope to start with something simpler.
Urban
@Jinjinov
Hi! Does anyone know when .NET 6 Preview 4 comes out?
Igor Velikorossov
@RussKie
IIUIC it should release with the #Build
Valentyn Bondarenko
@bond-id
Hello. What would your recommend me to learn first -- WinForms or WPF? I just start off with C# and .NET. WinForms is much easier, but WPF is more flexible and yet much more complex. At this point, I tend to believe, WinForms would teach me faster this basic understanding of what a C# framework looks like, and how it can be used.
Igor Velikorossov
@RussKie
This question is very similar to the question "tabs vs spaces" ;)
Both frameworks have their pros and cons. They are both supported, maintained and innovated.
Like you said - Winfows Forms had is easier to start with, but may not very be suitable for graphics heavy or themed apps. WPF has a significantly steeper learning curve, but provides vector graphics support, theming, better databinding. And XAML for better or worse.
So pick your poison ;)
Igor Velikorossov
@RussKie
If you're starting - you can start with Windows Forms, play with it, then move on to WPF, and play with it too :)
Igor Velikorossov
@RussKie
If you have issues with zeinfoes
If you have issues with Windows Forms raise those in github.com/dotnet/winforms
Paul M Cohen
@paul1956
@RussKie I just realized its not a bug but a bug that was fixed between Framework and Core and I actually love the new behavior now that I understand it.
Eugene
@JohnyL

hey, guys! can't figure it out how to create and obtain the value of object property in new writable JSON:

Person person = new() { Age = 22, Name = "Linda" };
JsonObject json = new()
{
  ["person"] = JsonValue.Create(person)
};
WriteLine((int)json["person"]["Age"]);

however, I get the error:

Unhandled exception. System.InvalidOperationException: The node must be of type 'JsonObject'.
at System.Text.Json.Node.JsonNode.AsObject() in System.Text.Json.dll:token 0x60005bb+0x20
at System.Text.Json.Node.JsonNode.get_Item(String propertyName) in System.Text.Json.dll:token 0x60005c5+0x0
at ConsoleApp.Program.TestJsonNodes() in E:\Projects\ConsoleApp\Program.cs:line 121
at ConsoleApp.Program.Main(String[] args) in E:\Projects\ConsoleApp\Program.cs:line 81

Mohammad Hamdy Ghanem
@VBAndCs
I am using this function to get hash code to use in a test method. It is supposed to give the same hash for the same source string every time. That is true as long as I run on my win 7 32 bit machine, but when I ran the test on a win 7 64 bit machine it failed because the Hash function returned another hash for the same source string!
Why? Does the DM5 depend on the machine, the OS or the 32/64 bit architecture? Ir this is related to the ASCII encoding or ToString("X2")?
    Function GetHash(sourceStr As String) As String
        Dim b = ASCIIEncoding.ASCII.GetBytes(sourceStr)
        Dim hash = New MD5CryptoServiceProvider().ComputeHash(b)
        Dim sb As New StringBuilder(hash.Length)
        For i = 0 To hash.Length - 1
            sb.Append(hash(i).ToString("X2"))
        Next
        Return sb.ToString()
    End Function
Steve Harter
@steveharter

@Eugene was your intent to use an already-instantiated POCO?

If not, create the JsonObject directly

JsonObject jObject = new()
{
    ["person"] = new JsonObject()
    {
        ["Age"] = 22,
        ["Name"] = "Linda"
    }
};

If the intent was to use the POCO instance and not modify it as a JsonObject you can treat the POCO as a JsonValue:

Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
    ["person"] = JsonValue.Create(person)
};

If the intent was to use the POCO instance + treat it as a modifiable JsonObject, you'll need to serialize+deserialize:

Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
    ["person"] = JsonNode.Parse(JsonSerializer.Serialize(person)).AsObject()
};

Note that a new "CreateFromObject" helper could be added to JsonObject to make this easier for the latter sample:

Person person = new() { Age = 22, Name = "Linda" };
JsonObject jObject = new()
{
    ["person"] = JsonObject.CreateFromObject(person)
};
Mohammad Hamdy Ghanem
@VBAndCs
I am using this function to get hash code to use in a test method. It is supposed to give the same hash for the same source string every time. That is true as long as I run on my win 7 32 bit machine, but when I ran the test on a win 7 64 bit machine it failed because the Hash function returned another hash for the same source string!
Why? Does the DM5 depend on the machine, the OS or the 32/64 bit architecture? Ir this is related to the ASCII encoding or ToString("X2")?
There is nothing wring in the Hash function :)
The issue is caused by github :)
I downloaded the source on win 7 x64 bit, and its tests failed, because github normalized the line terminatorof a multiline string to vblf while the test expected vbcrlf.
Mohammad Hamdy Ghanem
@VBAndCs
I don't know if this happens with files uploaded to github, or because I modified the file manually by pasting code in the github online editor.
I was cautious to normalize strings coming CDATA sections in my code, but now I have to normalize all strings to avoid this github issue :)
The fix is just callingSourceStr.Recplace(vbCrLf, vbLf)
Stephen A. Imhoff
@Clockwork-Muse
@VBAndCs - That depends - if you're only doing that for your test file, that's the wrong fix (you should ensure that the file has the proper line endings when uploaded by git). If it's in the normal hashing method, that's something you have to be upfront about to your callers, because otherwise your MD5 isn't going to be the same as stuff they might get elsewhere.
Also, why MD5? It's been deprecated for everything but certain legacy applications.
Stephen A. Imhoff
@Clockwork-Muse
And see this answer for some other options for converting to the byte string.
Mohammad Hamdy Ghanem
@VBAndCs
As I read, MD5 is still valid as a checksum, bit not secure for passwords. I just use it for testing.
Mohammad Hamdy Ghanem
@VBAndCs
The issue is that string literal uses vbCrLf, but CDATA and github use vbLf. I jst ensue to normalize the output string b4 hashing, and seems to work fine. SyntaxTree seems not complaining about vbCrLf ot vbLf, so, the functionality isn't affected.
Stephen A. Imhoff
@Clockwork-Muse
Checksum? Only from non-malicious (ie, accidental, bit rot) modification. Otherwise you need something else. If, for example, this is getting posted for download verification from mirrors, MD5 is not sufficient (you need SHA2 or better, currently).
The implication is that you're hashing one of your code files. Why?
CyrusNajmabadi
@CyrusNajmabadi
GitHub didn't care. This relates to your git client settings.
Do this @VBAndCs
git config --global core.autocrlf false
Now your git client won't change line endings
Mohammad Hamdy Ghanem
@VBAndCs

Now your git client won't change line endings

Nice. Thanks.

The implication is that you're hashing one of your code files. Why?

I decided to use hashing in test methods that test the generated code. Input line terminator doesn't matter, but the output must have the same hash that the one I am comparing to.

I am using a vb-like code to generate a record class. I am using Roslyn to parse my syntax. So, the input is code, and the output is also code.
Mohammad Hamdy Ghanem
@VBAndCs
I felt tired of pasting the whole long class in each test method, so, tried the hashing.
Assert.AreEqual(GetHash(result.Output), "BC7C020F61E28086AD90B7E27DA8B21E") seems nice :)
Stephen A. Imhoff
@Clockwork-Muse
... as opposed to comparing file contents, or a syntax tree diff? Which could even be used to tell you where the difference in the file is. If the hash is different now you have a mystery.
Also, updating the hash becomes a self-fulfilling prophecy for these tests: "I changed the generation, so the hash changes, and the test outputs the new hash..."

GitHub didn't care. This relates to your git client settings.

For this sort of situation I wish you could explicitly set certain files to be a specific file ending. Especially since I think GitHub may have mucked with them on top of things, too.

CyrusNajmabadi
@CyrusNajmabadi
I decided to use hashing in test methods that test the generated code.
I guess the question is: why?
Why not actually just validate the contents?
Assert.AreEqual(GetHash(result.Output), "BC7C020F61E28086AD90B7E27DA8B21E")
This seems completely not understandable. I have no way to know what the actual expected outcome is. So if somethign breaks all i get is a message saying "XYZ" != "ABC". that doesn't tell me why things are broken or what i would need to do to get a correct hash again.
Mohammad Hamdy Ghanem
@VBAndCs
Think of this as an Integral Test, where I check that the whole generator is working without exception, and the the output has the expected fingerprint.
<TestMethod>
    Public Sub NameValue()
        Dim TestRecord = <![CDATA[Public Record NameValue(Name ="", Value = 0.0)]]>.Value
        Dim result = GetGeneratedOutput(TestSourceCode, TestRecord)
        For Each diag In result.Diagnostics
            Assert.AreNotEqual(diag.Id, "BC42502", diag.ToString())
        Next
        Assert.AreEqual(GetHash(result.Output), "BC7C020F61E28086AD90B7E27DA8B21E")
    End Sub

    <TestMethod>