Is it possible to configure TypeLite to replicate documentation from the source to the target class, so that tooltip docs are available in Visual Studio?
Here's a basic example (configured as described in TypeLite quickstart):
public class Poco
{
/// <summary>
/// Documentation.
/// </summary>
/// <remarks>
/// Remarks.
/// </remarks>
public string Name { get; set; }
}
Which generates the following:
interface Poco {
Name: string;
}
But I want:
interface Poco {
/**
* Documentation.
*
* Remarks.
*/
Name: string;
}
TypeLite supports generation of JDoc comments from Xml comments in C# classes. You need to call the WithJSDoc() fluent configuration method.
<#
var ts = TypeScript.Definitions()
.WithReference("Enums.ts")
.WithJSDoc();
#>
It requires XML files with documentation to be generated alongside your binaries.
This feature isn't supported in .NET portable projects.
Related
I am implementing a system based on SignalR that will be pushing client events, for message serialization I would want to use MessagePack. When trying to implement the messaging I have run into a problem where SignalR fails to deserialize the messages on the client.
The messages are polymorphic and described with Union attributes, the standard MessagePack Serializer have no problem serializing and deserializing the messages BUT in case of Signal R it fails with error.
The error reported is System.InvalidOperationException: Invalid Union data was detected.
On the client serialization only works when using the actual class, if I try to use the interface or base class then the error appears.
Classes
[DataContract()]
[MessagePackObject()]
[Union(0,typeof(EntityChangeEventMessage))]
public abstract class EntityEventMessage : IEntityEventMessage
{
}
[DataContract()]
[MessagePackObject()]
public class EntityChangeEventMessage : EntityEventMessage
{
#region PROPERTIES
/// <summary>
/// Gets entity id.
/// </summary>
[DataMember(Order = 1)]
[Key(1)]
public int EntityId
{
get; set;
}
/// <summary>
/// Gets event type.
/// </summary>
/// <remarks>
/// This value identifies database operation such as create,delete,update etc.
/// </remarks>
[DataMember(Order = 2)]
[Key(2)]
public int EventType
{
get; set;
}
/// <summary>
/// Gets entity type name.
/// </summary>
[DataMember(Order = 3)]
[Key(3)]
public string EntityType
{
get; set;
}
#endregion
}
[Union(0,typeof(EntityChangeEventMessage))]
public interface IEntityEventMessage
{
}
So this works
connection.On("EntityEvent", (EntityChangeEventMessage d)
This dont work
connection.On("EntityEvent", (IEntityEventMessaged)
So in general it looks like the problem should be in the Microsoft.AspNetCore.SignalR.Protocols.MessagePack library ?
Anyone have implemented such functionality with success ?
Currently SignalR does not support polymorphism with MessagePack, more info here.
We have several environments that had their own run settings when we used MSTest. Since Microsoft is abandoning MSTest we are switching to xUnit. Whether it's through a runsettings or a command line property, I need a way to specify TestRunParameters in my xUnit test. Does xUnit have a native way to do that like MSTest or do I need to come up with my own solution?
While you can still use RunSettings to control some aspects of vstest.console while using xUnit the current version does not have a native way to pass in parameters. I believe v3 is going to have some kind of parameter passing.
For now you could use environment variables but if you are running multiple tests sets in parallel on the same system you would have conflicts.
I use a base class which reads in a TestSettings.json file with the settings for that test set. Using the following code I am able to pass in new types and have them read in by the base class json reader.
/// <inheritdoc />
/// <summary>
/// Common TestBase which uses CommonSettingsModel. Use TestBase<T> to override with custom settings Type.
/// </summary>
public abstract class TestBase : TestBase<CommonSettingsModel>
{
}
/// <inheritdoc />
/// <summary>
/// Common TestBase for loading settings.
/// </summary>
/// <typeparam name="T">Type to read TestSettings.json file</typeparam>
public abstract class TestBase<T> where T : ICommonSettings, new()
{
/// <inheritdoc />
/// <summary>
/// Constructor loads Settings T
/// </summary>
protected TestBase()
{
Settings = SettingsUtil.GetSettings<T>();
}
/// <summary>
/// Settings T loaded from TestSettings.json
/// </summary>
protected T Settings { get; }
}
You could also do the same type of thing with a Class or AssemblyFixture for the tests.
public class DatabaseFixture : IDisposable
{
public DatabaseFixture()
{
Db = new SqlConnection("MyConnectionString");
// ... initialize data in the test database ...
}
public void Dispose()
{
// ... clean up test data from the database ...
}
public SqlConnection Db { get; private set; }
}
public class MyDatabaseTests : IClassFixture<DatabaseFixture>
{
DatabaseFixture fixture;
public MyDatabaseTests(DatabaseFixture fixture)
{
this.fixture = fixture;
}
// ... write tests, using fixture.Db to get access to the SQL Server ...
}
https://xunit.net/docs/shared-context
Introduction
I've followed this tutorial to setup my ASP.NET Web API Help Pages.
Using <package id="Microsoft.AspNet.WebApi.HelpPage" version="5.2.3" targetFramework="net452" />
The documentation seems to be fine, but I'm getting empty model property descriptions.
They are empty in both controller method/endpoint and model details doc.
Controller method example
/// <summary>
/// POST: api/remitent
/// </summary>
/// <param name="remitent"></param>
public void Post([FromBody]Remitent remitent)
{
}
Model property example
/// <summary>
/// First name property summary
/// </summary>
[Required]
[MaxLength(49)]
public string FirstName { get; set; }
Results
I would expect the FirstName property summary to fill the model property description on docs. Instead the description column is empty:
Does anyone know how to solve that?
Did you uncomment this line of code in Areas/HelpPage/App_Start/HelpPageConfig.cs:
config.SetDocumentationProvider(new XmlDocumentationProvider(
HttpContext.Current.Server.MapPath("~/App_Data/XmlDocument.xml")));
Can you use Swashbuckle instead of Microsoft.AspNet.WebApi.HelpPage. I find Swashbuckle provides better documentation and friendly UI to explore your API. You can also use it to test your API.
Ok so let's say I have the following class in C#:
class Foo
{
public void Bar() { Console.WriteLine("FooBar"); }
}
In Visual Studio, whenever I instantiate my class and implement my method intellisense looks like this:
All this is showing is the name, return type and input parameters of my method. When viewing any method inside any of the .Net base classes using intellisense, a description is provided.
How do I add a description for my own methods to intellisense, so anybody who uses a *.dll I have written in the future can understand what my methods do without having to refer to external documentation?
Thanks
Add xml documentation :
/// <summary>
/// Foos something
/// </summary>
public void Foo()
{
}
Where can I find a Visual Studio plug-in that automatically generates documentation header for methods and properties?
Example the comment to a property could look like this:
/// <summary>
/// Gets or sets the value of message
/// </summary>
public static string Message
{
get
{
return message;
}
set
{
message = value;
}
}
Ghostdoc from http://www.roland-weigelt.de/ghostdoc/
GhostDoc is the usual suspect.
As another poster mentioned, Visual Studio also does this to an extent by entering 3 '///' (forward slashes) on the line preceding a property/method/class definition.
Visual Studio does this automatically. Just position the cursor directly above the method and enter three '/'s
for example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace MvcWidgets.Models
{
/// <summary>
/// This is a summary comment
/// </summary>
public class Comment
{
/// <summary>
///
/// </summary>
/// <param name="name"></param>
/// <param name="birthdate"></param>
/// <param name="website"></param>
/// <returns></returns>
public int SomeMethod(string name, DateTime birthdate, Uri website)
{
return 0;
}
}
}
You can then generate an XML comment file and then generate a Help file using SandCastle.
You may have to enable this feature in the Text Editor/C#/Advanced options dialog.