I was searching the web for compile method declaration and didn't find any,
I didn't find it on the web either in the squeak application browser,
Can anyone explain how does it work? what does it take? For now, I know that it takes a string but I don't know how the string supposed to be, and what it supposed to be built from (what should it include inside it)
Any explanations?
Related
I'm trying to port my console app over to a Blazor app. Everything worked fine inside the console type project, but it's not inside the Blazor project so I'm trying to troubleshoot. The app calls some things from a separate "class library" type project within the same solution.
The troubleshooting process itself is having issues of its own though. After a little bit of confusion I realized that the breakpoints set inside the referenced class library type project's code are not being hit.
Checking to console, I see it gives the error:
L: Unable to insert breakpoint at FtxApi.FtxWebSocketApi/<Test>d__5:MoveNext ():15
Is there anything I need to do (project settings or something) for the debugger to hit these? Or is it not supported at the moment?
Right now I'm just using a lot of Console.Writeline sort of as a workaround/replacement. And I noticed that the Console.Writelines inside the referenced class library type project are being called.. but only up to a certain method call that comes from a third party package. Execution seems to return from that point (nothing is called after it). Not sure what's going wrong there - more troubleshooting is needed, which brings us back to the breakpoints not firing (ideally I'd be able to make use of them).
I understand Blazor is new (and I'm an absolute beginner at using it), so not everything needs or is going to be perfect. I'm asking about the breakpoints kind of out of curiosity (I'd like to get them working but no big deal otherwise).
What I'd really like some insight into is: What might be going on with the code seemingly stopping execution / returning at that one particular method call? The method I'm calling is WebSocket.Open(), from the package WebSocket4Net. As mentioned above, I've tested this before (in a Console app) and it worked fine, so I'm guessing it's somehow related to Blazor which I'm unfamiliar with. I'm unsure how to get any more info to help debug this problem. Any help appreciated.
Edit:
I managed to find a solution to my problem without the use of debugging tools like breakpoints and such (I just used Console.Writeline a lot). I guess Blazor does not support some websocket implementations or something, because I found this error: System.PlatformNotSupportedException: Operation is not supported on this platform. blazor.webassembly.js:1 at System.Net.Sockets.Socket coming from websocket.Open(). I managed to get it working by implementing System.Net.Websockets instead, similar to this. Though my troubleshooting is over (for now), I'm still wondering if it's somehow possible to use breakpoints inside other referenced projects.
There are 2 solutions:
Solution 1: Right-click at Solution, choose Properties, choose Common Properties, Choose Multiple startup project, choose Action Start for Foo.Client, Foo.Server, Foo.Shared . Something like this
See https://blog.magnetismsolutions.com/blog/paulnieuwelaar/2015/04/07/debug-multiple-projects-at-the-same-time-in-visual-studio
Solution 2: Compile SharedProject, attacht PDB for debugging.
https://learn.microsoft.com/en-us/visualstudio/debugger/how-to-debug-an-executable-not-part-of-a-visual-studio-solution?view=vs-2019
There are similar or same questions all over the internet, but the answers don't work for me. We develop multiplatform product, which is compiled both under Delphi's compiler and under FPC.
First, I used:
Uses:
System.Character;
and
Character.TCharacter.IsLetterOrDigit(..)
, but it couldn't be compiled under FPC, so according to some other source, I used:
Uses:
Character;
and
TCharacter.IsLetterOrDigit(..)
instead, but still can't be compiled under FPC.
Can someone find a way that the code will work on both Delphi compiler and FPC? I don't have FPC set up to work with my project, so I can't figure out on my own, how to fix the code to work in FPC (I can test it only in complicated way via build server) and can't find a way, how to do it.
I also wanted to write it using regex, but colleagues say, that it would be too complicated for them.
Both Delphi and FPC include a class named TCharacter which exposes a method named IsLetterOrDigit. In other words, the premise of your question is wrong. It is perfectly reasonable to use TCharacter.IsLetterOrDigit.
Documentation links:
Delphi: http://docwiki.embarcadero.com/Libraries/en/System.Character.TCharacter
FPC: https://www.freepascal.org/docs-html/3.0.0/rtl/character/tcharacter.html
It's entirely possible that you are using an out of date version of FPC, which would explain why your code fails. Although that is guesswork since you did not include any details of the error message.
I'm currently having some trouble with a VB6 application that needs to encode some text using the same encoding method available at .NET framework 4.5.
I've searched through the internet and found some functions that tries to do the encoding based in UTF-8, but it still doesn't match the 4.5 output.
Then I looked for a way to import the 4.5 framework DLL within the VB6 project. This is what I accomplished so far:
Private Declare Function dotNetUrlEncode Lib "System.Web.dll" Alias "UrlEncode" (str As String) As String
The problem is that the method "UrlEncode" it's inside the namespace "HttpUtility", "System.Web.HttpUtility.UrlEncode" and using the code above I cant access the method. I've tried changing it to look like the code below, but the problem persists, I cant reach the method UrlEncode:
Private Declare Function dotNetUrlEncode Lib "System.Web.dll" Alias "HttpUtility.UrlEncode" (str As String) As String
Private Declare Function dotNetUrlEncode Lib "System.Web.HttpUtility.dll" Alias "UrlEncode" (str As String) As String
Is there a way to reach the method UrlEncode inside "System.Web.dll"? Where am I going wrong?
Thanks for the help!
Best regards.
This will not work. The .NET DLLs contained managed code, which requires the .NET runtime. Your VB6 app can't call that code. Its process does not have the .NET runtime loaded.
You can only import functions from native DLLs this way. That's why it works for system DLLs included with the operating system.
The best solution would really be to consult the documentation and determine precisely how the UrlEncode function works. The internals of the implementation will not be documented, of course, but that doesn't matter. All you're interested in is the specification. Follow that same specification when implementing your own function if you cannot find a system function that has equivalent behavior.
If you absolutely needed to call .NET functions from a VB 6 application, it can be done. You will need to create a .NET wrapper that calls the framework-provided function and exposes in a COM-compatible manner using the ComVisibleAttribute. More information here, here, and here.
I have a DLL used in a compliance scenario (the details of which are irrelevant). The important point is that the main executeable must display the DLL version number. My solution was that the DLL has a function to return it's own version - ie obtain it from the its own version resource and return it as a string.
My reviewer says that the main program should work out the DLL version number. He even gave me some code to get the DLL module handle and extract the version using that.
My question is, which is a better design and why? My feeling is that, using OO principles, I should ask the DLL for its version number. Doing it the other way means that the main program needs to know how the version information is stored and is hence more tightly coupled to the implementation.
Note that I know exactly how to extract the version information from a DLL. My question is about the best place for the code that does this.
Can you clarify the environment that you're working in? For now, since you've already mentioned getting the module handle, I'll assume you're using C++ and calling one of a handful of Win32 functions (GetModuleHandle, LoadLibrary etc).
First of all, I'd be careful about applying OO principles in too wide a context. The object oriented paradigm helps you structure your software in a more maintainable and understandable way, the problem you're describing sounds like it maybe stretches outside of the boundaries of your application. If you want to get information about a separate resource, such as a DLL, you should consider using a standard approach to achieving this to ensure that your code is decoupled from the items that it needs to inspect.
If you introduce a function into the DLL to return the version number to your main application, you have created a tight coupling between your main application and any DLL that needs to supply it's version information (by essentially defining a bespoke API or interface for this).
You should consider using standard, platform-wide functionality to retrieve the information instead This will allow your application to version any DLL for which it can obtain a handle.
Assuming you have an HMODULE for the dll (and you're using C++), call the following functions to get the version...
GetModuleFileNameEx (to get the full path and filename of the DLL if you don't already know this)
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683198(v=vs.85).aspx
using this filename, call
GetFileVersionInfoSize (look these up on MSDN)
This will tell you some crucial information about the file's version metadata (how much info, if any the file has). Assuming this function succeeds, call
GetFileVersionInfo
This will load all the file info metadata into a buffer, then call
VerQueryValue
Supply '\' as the lpSubBlock parameter to get the standard file info metadata (including the version number)
The above functions will allow you to write code to get the version number of any module that your code can get a handle to.
Of course, if you're using C# the solution is much simpler. Hope this helps...
I'm using Eclipse and Java, but the answer doesn't need to be specific to those. I'm sure platform specific answers will get plenty of upvotes if they're far quicker than non-platform specific ones.
Right now I'm using
grep "classname" find . -regex .*\.java > uses_classname.txt
to find code that might be affected by a change to the class. If there are only a few lines returned by this, I can look at it manually as it is. Otherwise, I can grep again to find the specific methods I'm modifying. Is there a better way to do this?
[Just being a bit of a librarian here:]
Finding references to a Java method/class:
How can I find all the methods that call a given method in Java?
How can I find references of a class in Eclipse?
References to Java annotations:
How to Check References of Annotated Methods
Finding references to 'derived' methods in Eclipse:
Eclipse Specific: Is it possible to find references of use of derived methods in a class?
How to do it with VIM:
Is it possible to find usage of java classes or methods in VIM?
And with Emacs:
How can I find the references of a class, method, variable in Emacs with Etags?
Finding (the number of) references to a method in C#:
How do you programmatically identify the number of references to a method with C#
Nice to read: how to find methods that are not used in C#/.NET:
Find unused code
Is there a tool for finding unreferenced functions (dead, obsolete code) in a C# app?
On refactoring of PHP code:
Tools for PHP code refactoring
Finding references in Smalltalk:
Find references to string/symbol/method
Finding references in (Apple) Xcode seems to be a popular question:
Find method references in Xcode
Xcode: view references for a variable?
Finding all references of a variable or a method in Xcode4
A good solution is to use JUnit and practice test-driven development. After refactoring, re-running your test cases will tell you whether any existing functionality has been damaged. Moreover, since you are actually testing the code rather than grep'ing over method names, you can get full backtrace, making debugging much easier. A good introduction to JUnit can be found here.