Stack trace complaining about old non-existent codes - stack-trace

I have changed a piece of code completely from scratch re-using the same class. Changes were making a free-entry date field to a date entry, only with a calendar picker. It works on all systems, except one where it throws a stack trace complaining there are no getter methods for startDate in the class which was changed. It has been verified that all changes were merged and exist even on the system in which it doesn't work on. What could be the problem? What should I look into? I am completely lost on this one and any help is appreciated.

Sounds like you may have got the new version of the class itself on the system, but not replaced the code that was using that class. Look at the caller in the stack trace, and check what version that is.

Related

Visual Studio 2019 continues to look for the previous DbContext even after replacing it with a new one

Disclaimer: I am posting a self-answer to this. Even though it's something that's rather unusual to do, hopefully someone will benefit from reading this.
I recently replaced my original Entity Framework Core DbContext with a new one because I renamed the database (among other things). Let's call the original one OriginalDbContext and NewDbContext for convenience.
The table structure itself remained unchanged.
Naturally, I had to replace all instances of OriginalDbContext with NewDbContext. I was expecting that, once I did that, it would simply compile (since I didn't make any database changes other than replace OriginalDbContext with NewDbContext). However, even after I did that, I got numerous error messages stating to the effect that OldDbContext did not have a definition for my table clases.
I searched all files in my solution for any reference to OriginalDbContext and found none. I even deleted OriginalDbContext.cs entirely (including in version control).
Why would it continue to "look for" OriginalDbContext even though I verified that it was removed from all of my .cs files?
I finally did a "Find All" on the entire directory. It turns out that the only place that referred to OriginalDbContext was one of my publish profiles (which did not appear when I searched only in the solution). I deleted the profile and was able to compile again.
I guess the broader lesson here is that there could be references to your DbContext class that do not appear in your code base and may not even show up if you do a "Find All" on the entire solution.
Worse yet, when I double-clicked the original error messages, it made it appear like the errors were coming from my code base.

Mysterious compile error with groovy eclipse plugin

So, I am developing with eclipse 4.2 and groovy 2.3 / jdk 1.6.0_35.
I just worked on one of my classes when suddenly eclipse showed me a dozen compile errors in different classes out of nowhere. It says e.g. it can't find a class in an import statement, although the class is there. Running the code works fine even though the errors are shown. If I add a comment to one of the classes and save it, some errors go away but may come back as soon as I change another (totally different) class.
It also shows me some errors like these:
error description:
As you see, the error is totally unrelated (Optional is totally independent of any other class, also of course independend of the mentioned classes in the error message). If I add a comment somewhere and save Optional, the error goes away but comes back as soon as I save any other class.
I cleaned the project, deleted the bin-directory and restarted eclipse/computer but it didnt' help. Does anyone already experienced this behaviour? How to fix it?
I got similar problem and error was in file above one with compilation error. So try to comment file before and check if this solve problem.

Track code changes to specific functions

Not sure how to even search for this topic so I'm just going to ask. I have a couple places in my code where changes to one function have to be also made to a similar function. Basically the operations in the functions are very similar but the data being worked on is different.
I don't like it but for now that's how it is. My question is anyone knows of a way or a tool that will notify me if a certain function has changed. If I get the notification I know to confirm the changes were made to other function.
Please don't tell me to change my code. I know this isn't ideal and thought has been put into alternatives, but nothing elegant has popped up.
Thanks,
Gunner
Here is an idea I have. Maybe it will set the train of thought...
I can add a special comment in my code for a block that I want to be tracked. The comment will have opening and closing syntax:
my_code.php...
//track-start-1234
[CODE]
//track-end-1234
//track-start-5678
[CODE]
//track-end-5678
I will then have a script that I tell to check a list of files, my_code.php, for now. It will look for the special comment syntax. "1234" will represent a file that holds the last modified code for that function, so 1234.php. If the contents between the comments do not match the code stored in the file then an alert is fired. Also I might add a relationship to the other code so the alert says something like
Code 1234 has changed. Please make sure code 5678 has been updated as well.
I think I can add this script to GIT somehow so it either is part of the core git commands like "push" or maybe just another command I have to run as part of our deployment process. A second option might be adding it to phpstorm's code inspector or something like that.
When the code has been modified and everything is good I will just manually copy the new code into the comparison file. There will not be a ton of updates so this will not be too tedious.
For now this is probably the route I'll go, but any critiques or suggestions are definately welcome.

Adding code to class files just before building - Objective C

I am looking to develop a framework, for which I dont want get into details.
Suppose if I am having 100+ classes with 1000+ methods in my iPhone application.
In this scenario I want to add NSLog in each method(at start or end or both) of each class.
Manually adding NSLog is possible but is there any better solution?
Like building application in such a way that I can add this Log without me having to do manual work.
Thanks and Regards,
Denis,
Your answer was most useful throughout many forums.
Thanks a lot.
The reason I'm looking for something like this is, we have many client projects and many time it happens that we get some crashing or other issues while QA and UAT. ~80% of them are not reproducible or require some particular scenario. We were using .crash and dsym to track such issues. But it is not that useful in such scenario.
What I'm looking for is providing add hoc build which will log the steps which user has followed so that it will make easy to reproduce such issues.
Currently I am using precompiled headers and first method you have mentioned (searching for the first opening brace then replace it with macro).
I will look into DTrace and objc_msgSend as you mentioned. I will google out these meanwhile if you have any preferred tutorials it will be great.
Thanks and Regards,
:D
So you want to add a trace facility to your code?
Apple doesn't provide anything like this. You'll have to add your trace facility yourself. If your source code style is consistent, this might be relatively easy to do automatically, something like searching for the first opening brace following a line starting with a minus (or plus) sign...
Alternatively, you might want to use the public Objective-C runtime functions to enumerate all classes and all their methods, then method-swizzle each of them with another one that NSLog before jumping to the original.
Alternatively, you can take the open source implementation of objc_msgSend and insert a call to NSLog at the beginning. Note that obj_msgSend tail calls into the method, so that will prevent you from adding a call upon return. Be prepared to humongous output of course. You might want to condition your call to NSLog to the value of the selector parameter to objc_msgSend (such as a common prefix).
Finally, the best way to trace is probably to attach a DTrace probe to the entry to objc_msgSend. For the same tail-call reason mentioned above, you won't be able to attach a DTrace probe to its return though.
But the better question is why do you want to do that.

EXC_BAD_ACCESS thrown if files are edited, must be committed before running

I get EXC_BAD_ACCESS from starting my program, sometimes if I edit the files. It never used to do this until recently when I removed a PNG/PLIST file from the resource folder (by deleting it). But I did replace it with the same name.
After that whenever I changed my code I get the EXC_BAD_ACCESS thrown as soon as it gets to the point where it loads those files. (App Delegate out of scope).
However after committing the files via local source control I'm able to run it again without getting the EXC_BAD_ACCESS. As soon as I edit something else and not commit it, it throws it to me again. I think I mucked up my source control/versioning by deleting that resource file.
Got any ideas?
Solved the problem. I was going to post the code but it'll be hard to decipher since it spans a few classes.
I used Zombie to help me locate the culprit and turns out I was over-releasing one of my dictionary objects. It had nothing to do with those resources (which cleaning fixed), I must've added an extra release while editing the code (prior to cleaning).
A clean build fixed the problem where if I added (even just a comment) to one of my classes it would break the build unless I commit the changes. Thanks Deepak, hopefully this will help someone else out there :).
P.S. sorry for the slow update, I've been quite busy.