How does C # generate annotated dll and reference
This article mainly explains "how to generate annotated dll and quote C #". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to generate annotated dll and quote it.
one。 Write a .cs file
Note: if comments are to be available in compiling dll, comments in the code should be commented with "/", otherwise comments will not work after compilation.
Comments are generated in the XML file.
ComputeDemo.cs:
Using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks Namespace MetaDataTest1 {/ Class name: ComputeDemo / public class ComputeDemo {/ add / public int Add (int a, int b) {return a + b } / / subtract public int Sub (int a, int b) {return a-b;} / / multiply public int Multi (int a, int b) {return a * b } / Division public double Div (int a, int b) {return a / b;}}
Program.cs:
Using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading.Tasks; namespace MetaDataTest1 {class Program {static void Main (string [] args) {var obj = new ComputeDemo (); int addResult = obj.Add (1,2); Console.WriteLine (addResult); Console.ReadKey ();} 2. Generate XML file comments
On the class library project, right-click Properties-generate-output, check the XML document file, select the document name and the path to the output of the DLL file. As shown below:
three。 Open MSBuild Command Prompt for VS2015 to generate dll file
Enter the command as follows:
Csc / t:library / out:D:\ DllPath\ MetaDataTest1.dll D:\ ComputeDemo.cs
Where: / out:D:\ DllPath\ MetaDataTest1.dll is the DLL path and DLL file of the generated output
D:\ ComputeDemo.cs is the .cs file path location
Then the MetaDataTest1.dll file is generated successfully (the .dll file name should be the same as the .xml file)
four。 Using another project to reference the .dll file, right-click References- Add References- Browers to add a reference. Check to see if the comment exists, as shown in the following figure:
View DLL related information, as shown in the following image:
five。 Run successfully:
At this point, I believe you have a deeper understanding of "how to generate annotated dll and quote from C #". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!