✅ Crazy C# Beahviour
This is a very basic problem that it's getting me mad. Since it doesn't work in this case but on an online c# compiler is works more than fine.
So I have this string that I want to split to retrive different datas and this is what I get.
Here's the string and the snippet.
Error That I get:
System.IndexOutOfRangeException: 'Index was outside the bounds of the array.'
Any kind of help would be more than apriciated
84 Replies
Are you absolutely 100% certain that you don't do other stuff in between? Doing what you have posted should work. It does for me tho
I know, you want a sceen? Since this is exactly what I'm doing
the problem is that in the watcher the _raw string is singed as the 1689514251* part and the other is just gone
sure, post the code here
Jimmacle
REPL Result: Success
Console Output
Compile: 642.028ms | Execution: 77.481ms | React with ❌ to remove this embed.
¯\_(ツ)_/¯
Jimmacle
REPL Result: Success
Console Output
Compile: 555.737ms | Execution: 89.269ms | React with ❌ to remove this embed.
more readable imo
same reaction honestly
I am 100% sure of the reutrn var of the Method Called (RawLeaderboardBody)
I've been debugging it for a lot and I've come to the conlusion that the problem is loacated at the 2nd line inside the try statement
the only possibility there is that
RawLeaderboardBody(_AID)
isn't returning what you think it isbut it is, I am 100% sure
I removed all the logs but the value is correct
if you set a breakpoint on the second line of your try block, what does it tell you the value of
_raw
is?
or just print it to the console or somethingi send you a screen
the crazy thing is that on console has a value in the editor tracer it has anotherone
no my bad if I add a breakpoin the values are the same
for the sake of experiement, what if you try the version i showed?
Parameter lenght cannot be lower than 0
basically he's telling us that there is no ] char
so
end
is -1 in the debugger?end is not -1 it's 348
then it is in the string
yeah
but then he goes crazy
"goes crazy" isn't a helpful issue description 😛
what's the value of
start
?yeah sorry man, I realized I'm not beein that helpful
and can you give me the entire exception when it fails?
and _raw's value it's still the same
yeah
because everything is pointing to nothing being wrong with this part of your code
ok ok little update, removing the breakpoint gives us new values
yeah i just saw your issue looking at the code again
you're splitting on
,
on the next line
where is a ,
anywhere in your string?jesus
no wait there is
it looks like it uses
;
as a separator, not ,
no after the 3 in the first row
ah yeah i see
or better second
well, i'm guessing the actual issue is somewhere else in your parsing code either way
that makes 0 sense given the debugger values you told me
click "show call stack"
nah the debugger was stuck before the error
okay, that solves it
your string doesn't contain a
[
or a ]
exactly
so
RawLeaderboardBody
isn't returning what you think it isyeah by getting a closer look it has a value then it has another one without any change in the code
i mean, that doesn't happen
I know
values don't randomly change in code, something is happening that changes it or it was never right to begin with 😛
I have just to look on it
nah the return is correct, it just truncates while passing from the function a to the function b at the '*'
the funny thing it's that in the debugger is wrong in the console is right
again, values don't randomly change
they do when you ingenuly set them to be an edited version of themself
updates tomorrow, I spent to much time on this today
that's... not random
this is leading me crazy
seems pretty obvious to me
the API you're hitting doesn't return the same result every time
which is the first thing i said
Jimmacle
the only possibility there is that
RawLeaderboardBody(_AID)
isn't returning what you think it isQuoted by
<@901546879530172498> from #Crazy C# Beahviour (click here)
React with ❌ to remove this embed.
this is why it's important to debug using a minimal reproduction of the issue, you have things in your code that none of us can even test
it's not magically changing, you're calling the whole method multiple times and the API is returning something different for different calls of your method
if this is for the it.bidoo.com auctioning website then I don't think they offer an API (from what I can tell) and the issue probably lies in your parser
so this is potentially sketchy scraping to begin with?
possibly
the website is in another language so I am not entirely sure
considering the whole site is gated with a captcha i'm gonna go with yes
@impingu_ unless you have permission to scrape this site we can't help you any further
and again, next time don't lead us on a wild goose chase with misleading repro cases
it does, + it's completly ok to scrape that API, it just retriving public infos
also just a little precisation, as you can see from the video it’s a c# related problem in a very specific situation with has nothing to do with the apis
The video just shows that you got a different value returned the two times you called the API
I didn't call the api 2 times
In your video it starts at line Line 58, goes to Line 63, then back to Line 58, then to Line 63, so it would have made a call to the API both times it hit Line 58?
yeah but have a look at the watcher, the _raw string gets the right value
also I just looped this function always the right return
It shows it has the right value the first time, it doesn't show it has the right value the second time
right value
still right
now wrong
so right the first time you call it, wrong the second time you call it...
i.e. seems like a different value coming from your API call
Where do I call it the second time?
well two of those screens have a breakpoint at line 64 but with different watched values so I assume you must have, hard to tell exactly when you're cropping the screens
why are you insisting that C# is magically changing your string and not even considering the very likely possibility that the API is returning different results?
this is easy to test, call the API in something like postman multiple times and see what happens
rule #1 of debugging is isolate the problem
Code runs from top to bottom. You're showing us that it has the correct value on Line 64 but then later has the incorrect value on Line 61.
The only way to get back up to Line 61 is to come from the top of your Update method, which includes Line 58. You're getting a new
_raw
string from RawLeaderboardBody
, it's not changing your old one.
That's why people have been telling you that your API doesn't return the same result every timeJust checked and the API does always return the same value, checked in axios for node, in another c# project and trought fiddler
show code for RawLeaderboardBody method
! Natan
Quoted by
<@186327148519227394> from #Crazy C# Beahviour (click here)
React with ❌ to remove this embed.
check the status code of your http get response, it is possible you are being rate limited or something else so your result will end up being null if so
Can you show us where you're calling
Update
and how/if _AID
is being changed?Just to let you know the issue has been fixed
I just changed the Call for Update from the constructor, below the assignation of _AID, to the static void main of the program class
🤯
I am amazed that is even ran without async await
No need to await it, since it wouldn't bring me any benefit in general inside my project, I need everything to run sincronously
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.