Replies: 4 comments 35 replies
-
That error is from the API compat tooling and it's highlighting that you've added a method to the implementation assembly but not to the reference assembly. You'd need to also add the signature to the System.Runtime.cs file at https://github.com/dotnet/runtime/blob/main/src/libraries/System.Runtime/ref/System.Runtime.cs.
When you build, e.g.
and that will include a .NET host named |
Beta Was this translation helpful? Give feedback.
-
Does anyone have any suggestions? I could change the String class source code and build its entire project successfully. The problem is this:
I used CMD and Visual Studio Test Explorer as well. I should mention that I am trying to do research and the process depends on this phase, so any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone, Thanks, @stephentoub, finally I resolved the problems. If you want to add functionalities to String class you have to follow up these instructions: 1- Add your code to System.Private.CoreLib Solution. It contains a project (System.Private.CoreLib.Shared) and you can find string class source code there. 2- Do not forget that add the signature of your added method to System.Runtime solution. It also contains System.Runtime.cs under the ref folder. 3- Remember that it is not possible to add properties to String class. 4- If you want to rebuild the core libraries use this command :
and if you want to rebuild Runtime as well you have to run this command
5- To test your new functionalities just add your test methods to one of the libraries' test projects. 6- If you want to add a field to the String class one of the options is using a static ConditionalWeakTable. Dear @stephentoub, I have a question, when I access a string, where is the "get" method that is called? For example:
In the second line, we access the str. I cannot find the getter method in the String class. I want to change the string value before returning it. |
Beta Was this translation helpful? Give feedback.
-
Can we add constructors to the String class? I tried to do it and I think it is not possible. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
For a specific project, I have to change the String class and test the new functionalities that I want to add to it. I found the System.Private.CoreLib solution and all functionalities related to the String class are there. I changed the class in that project and when I want to build the runtime again, this error occurs:
So the questions are:
1- How can I build the runtime again?
2- How can I use the new DLL in a simple console application? Because when we create a console application a reference to CoreLib is already added to it.
I also checked this answer #12045 (comment) , but the instruction did not work for me and I think something is wrong.
Thank you
Beta Was this translation helpful? Give feedback.
All reactions