This is more of a design issue with Visual Studio [>=2010].
Example: When you implement IDisposed in a VB environment, in the body of Public Sub Dispose there are numerous comments and a branch about how to do it. Also the field disposed is automaticaly inserted to the Class.
Now when I design an Interface or abstract Class, is there a way to define some kind of 'template' for each abstract procedure/property body, containing comments or even branches/loops?
Edit:
Now i realize that the C# environment has a different approach to these templates/snippets, but i'd like to make them available for developers in both environments.
These code snippets should be inserted preferebly when using Implement Interface or Implement abstract Class or when TABing after selecting an overridable procedure.
Edit2:
Ok, the Snipped Editor did indeed provide a reasonable solution.
Essentially i have to update my custom snippets for each target instance of VS at the path
C:\%ProgramFiles%\Microsoft Visual Studio %VSVER%\%ENV%\Snippets\%LANG%\...
I hoped there was a way to provide VS with the snippets via the referenced Assembly/Resource only.*
Related
I don't have Resharper installed.. I want to see all subclasses inherited from IActionResult and there is no things like show derived classes in object browser and class view.
I try to install a extension TypeHierarchyViewer(https://marketplace.visualstudio.com/items?itemName=munyabe.TypeHierarchyViewer) but it is not working (even using the example List, just remains blank) .
So what should I do?
I use this function frequently developing java application using eclipse..It seems there is no out-of-box tool in VS2017 or I just missed some things??
(Go To Implementation says the symbol has no implementations)
(Same in class view)
I have searched many "solutions"(like Visual Studio: How do I show all classes inherited from a base class?) but not work or need other tools(or just see the doc?).
I want to see if there anyway to do it just using VS.
Before I thought VS was a very good IDE but I can't image it lacks so much basic functions...(so there is Resharper...)
And I find there is derived types but in Solution explorer:
But you can't input the class you want And if I input IActionResult in search box it will not find it(not in the my source and I don't implement it).
After trying..I find VS support it in solution explorer...
But it's hard to use...
I need to find some classes or interface in my source code related to the class or interface I want and use derived type and implements to find the it..
It looks like:
(I find a class and navigate to object, it lists all classes .Then I find ActionResult and choose implements find IActionResult, finally I can see all derived classes above... ...)
emmmmm
it seems there is no direct way using VS(although I can get all sub classes using solution explorer but it's too verbose...) to get the result I want.
Finally I choose to use dotpeek(I don't want to buy resharper because I just study ASP.net core not for work)
I open C:\Program Files\dotnet\sdk\NuGetFallbackFolder in dotpeek where the dependencies located.
Then using Hierarchies get the result.
feel a little disappointed about VS. Not so strong before I heared.
Thx for help. :)
Updated
I'm somewhat new to Visual Studio and C#. I've come across a number of S.O posts where the answer refers to deriving (through inheritance) from a Microsoft base class and extending it. I've been meaning to figure out how to add custom properties to a base WinForms control and manage it in Visual Studio.
I stumbled across a Microsoft procedure for doing so. After seeing the response to summarizing this procedure, I'm changing the question and deleting the summary (my original answer)
Comments by Ron Beyer on the Microsoft procedure follow.
Bottom line, just build the derived class from scratch. The result will be the same
I really recommend against using a new "User Control" object and then changing the base class in the code-behind. This breaks the designer (you have to hand-edit the AutoScale property) and really there is no reason for the designer. Just start a new class file and derive the appropriate control, no need to do all the steps above. RonBeyer
#RonBeyer: For example, if I create a new class file (instead of a new project), how would I reuse the custom control in another project? If I don't use the procedure, how and where do I implement the Dispose method currently provided by the Designer.cs file? Do I need to re-implement the guts of the InitializeComponent method provided by the Designer.cs file, or will the InitializeComponent method in my standalone project take care of it? Is it really just as simple as creating a new class file? NovaSysEng
Yes, it is that simple. You don't need the Dispose method, the base class has it, unless you are using additional unmanaged resources, then you implement it normally (and call base.Dispose). You don't need the IntializeComponent call at all, you can add your own initialization code to the constructor if needed. Literally public class MyButton : Button { } is a perfectly valid derived control. RonBeyer
I am writing a basic code generation tool. It's pretty bare-bones and I am only doing it as a learning exercise and for messing around for fun, not for serious use. It prompts you for a Class name and lets you add fields, specifying the name, type, whether it is a Primary Key, Foreign Key, nullable, a Collection type such as an array or Generic List, etc. It creates a DTO class with Properties and if you check that it is a database table class, it also creates a DataAccess class (only things fully fleshed out with actual functional code that interacts with DB are GetByID, Insert, Update, Delete and an optional GetAll), a Business Logic Layer class with only pass through methods that call DataAccess class by default, a XAML and corresponding .cs class for both a details screen as well as a search screen with two-way model binding for all the field controls on the details screen. It also creates the text for the Stored Procedures for all of the methods in the DataAccess class.
Is there a way for me to make the functionality I've described a plug-in for my copy of Visual Studio so I could use it on any of my projects I choose as I develop them from inside VS and have the generated classes automatically added to the solution? I only want to use it for playing around, so I won't be too disappointed if this isn't possible. Can this be done in Visual Studio by an average programmer? I know I can finish my project in terms of code-generation functionality, except I'm more asking if it can be added to VS as a plug-in and what type of skills I would need to acquire to get it accomplished. In particular, is it even possible for it to use the generated SP text to create actual SPs in the database from within a Visual Studio project?
Yes, this would be possible, look at the visual studio SDK: https://learn.microsoft.com/en-us/visualstudio/extensibility/visual-studio-sdk
However it would not be at all trivial.
I need to develop a web service, I received the WSDL (with HORRIBLE unintuitive field names), so I decided to import it as a Service Reference in Visual Studio 2015 to get the classes and the methods to call.
This is the WSDL (I'm sorry I'll need to use pastebin for the characters limit in the body of a question):
http://pastebin.com/B4pFH3jY
The generated code can be found here:
http://pastebin.com/Y9ehXQxy
When I try to build I get several errors:
public partial class Z_CA_WS_ARS_AFC_GET_SCH_CC has the same name of an interface, so I get error.
Lot of items argue about not having as parameter the interface (as it is considered the partial class)
I tried to rename the partial class, but I don't know in the remaining code where I should change and call the class or the interface. The names, as I previously said, don't really help.
When I import in Visual Studio I use the following (default) advanced settings, maybe it helps.
Is there any way to import the WSDL with no issues without asking for a new version (it seems correct to me)?
I even tried to use svcutil with no luck, maybe I used the wrong version.
Thanks for help.
So lately I have been building a DLL in C# for my Access 2013 Frontend application that handles mail through SMTP and does some validation since Access Mailing library's did not fulfill my requirements.
This all worked great but it also got me wondering, and I cant really find an answer to it on the forum hence my question, is it possible that instead of creating my own mailing methods and classes to just create one COM visible class and make it inherit from, in my example, the Mailing class (SMTPClient for example) so that in Access I can call the properties/methods from the inherited .NET class?
I actually don't think it is possible because then there would be likely more info on the subject but on the other hand, Access 2013 had a lot of improvements and one of them being importing DLL's right?
I not sure really why not? The only issue is when you create your class (com) object, is the required code stubs placed into the class as public members so Access can see them?
The only real caution here is if you not building a custom interface in your class (I usually don’t), then any property exposed as a non-compatible VBA variable type will render the whole COM object as invalid. (so make those routines (and variables) as private).
So as a general rule, any method/property of your class that is exposed to Access will have to be a public property – this suggests and implies that you can inherit the original object properties into your custom class – but you still need public code stubs to expose those methods/properties.
I don’t use c#, but in vb.net, when you inherit, then all of the code stubs are auto-generated for you – so if c# is the same, then I don’t see why this approach will not work for you.