Code Monkey home page Code Monkey logo

docsbyreflection's Introduction

Senior .NET Developer | Web API | Framework | Azure | Unity 3D.

With over 23 years of professional programming experience, I am a senior .NET developer working for the last 19 years with .NET and C#.

I write about C#, Unity 3D, game development and web development, and more at https://diegogiacomelli.com.br.
I am Currently interested in anything I can code with C# and mostly working on web projects during the day and game development projects with Unity 3D at night.


Ask me about ๐Ÿค”

NO MORE ROOM IN HELL, Puzzimals, GeneticSharp, Ships N 'Battles, Curseings or any of my more than 100 projects directly on my Discord server or Twitter.


How to reach me ๐Ÿ”Ž

Blog, Twitter, Reddit, YouTube, and Discord.

docsbyreflection's People

Contributors

darkthread avatar giacomelli avatar josephadams-izenda avatar nsainaney avatar onionhammer avatar ppioli-cl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

docsbyreflection's Issues

Fails when executable is located on a UNC share

To test: create a compiled command-line tool that uses DocsByReflection about itself.

You can even hit it using administrative shares: \\localhost\C$\git\MySolution\MyApp\bin\debug\MyApp.exe.

Error  --->  DocsByReflection.DocsByReflectionException: Could not ascertain assembly filename from assembly code base 'file://storage/ict/Solutions/Systems/DocGen/Temp/1.12.7725.25130/DocGenDebug/DocGen.exe'

Method that returns a collection of an inner class is ignored

I found an edge case that it's not handled.

class outerclass
{
void SomeFunction(innerclass[] input)
{}

class innerclass
{}
}

In this case SomeFunction is ignored and the library cannot find the documentation for the element.

I added support for this case, it's really simple. In DocsTypeService add

        else if (type.IsNested)
        {
            return String.Format(CultureInfo.InvariantCulture, "{0}{1}.{2}{3}", typeNamespace, type.DeclaringType.Name, type.Name, isOut ? "@" : "").Replace("&", "");
        }
        else if (type.GetElementType() != null && type.GetElementType().IsNested)
        { // this is new
            return String.Format(CultureInfo.InvariantCulture, "{0}{1}.{2}{3}", typeNamespace, type.GetElementType().DeclaringType.Name, type.Name, isOut ? "@" : "").Replace("&", "");
        }
        else
        {
            return String.Format(CultureInfo.InvariantCulture, "{0}{1}{2}", typeNamespace, type.Name, isOut ? "@" : "").Replace("&", "");
        }

Are the maintainer interested in adding this case?
Anyway, hope this modification helps someone.

Fails to look up documentation for methods with out or ref parameters.

When trying to look up documentation for a method that has out or ref parameters DocsService.GetXmlFromMember fails. I originally tried using the code here http://jimblackler.net/blog/?p=49 and ran into this issue. I then tried using this nuget package which also has the same issue. I reverted back to the code on jim blacklers blog and changed a small piece of code in DocsByReflection.XMLFromMember(MethodInfo methodInfo)

Where the following line was

parametersString += parameterInfo.ParameterType.FullName;

I changed it too

if (parameterInfo.ParameterType.IsByRef)
{
    parametersString += parameterInfo.ParameterType.FullName.Replace('&', '@');
}
else
{
    parametersString += parameterInfo.ParameterType.FullName;
}

I have not identified where the appropriate fix would be in this projects code base. The problem was that the types name for ref and out parameters contains a trailing &, but the XML documentation contains a @ instead.

Unable to serialize 'ObjectContent`1'

Between version 1.0.12.14 -> 1.0.12.20 there is a regression causing the following error:

{
    "Message": "An error has occurred.",
    "ExceptionMessage": "The 'ObjectContent`1' type failed to serialize the response body for content type 'application/json; charset=utf-8'.",
    "ExceptionType": "System.InvalidOperationException",
    "StackTrace": null,
    "InnerException": {
        "Message": "An error has occurred.",
        "ExceptionMessage": "Unable to cast object of type 'System.Reflection.MdFieldInfo' to type 'System.Reflection.PropertyInfo'.",
        "ExceptionType": "System.InvalidCastException",
        "StackTrace": "   at DocsByReflection.DocsService.GetXmlFromMember(MemberInfo member, Boolean throwError)\r\n   at WebApiProxy.Server.MetadataProvider.GetDescription(MemberInfo member)\r\n   at WebApiProxy.Server.MetadataProvider.<AddModelDefinition>b__8_1(FieldInfo constant)\r\n   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n   at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__19.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Net.Http.HttpContent.<CopyToAsyncCore>d__44.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__22.MoveNext()"
    }
}

Formatted stack trace:

at DocsByReflection.DocsService.GetXmlFromMember(MemberInfo member, Boolean throwError)\r\n
   at WebApiProxy.Server.MetadataProvider.GetDescription(MemberInfo member)\r\n
   at WebApiProxy.Server.MetadataProvider.<AddModelDefinition>b__8_1(FieldInfo constant)\r\n
   at System.Linq.Enumerable.WhereSelectListIterator`2.MoveNext()\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeList(JsonWriter writer, IEnumerable values, JsonArrayContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeValue(JsonWriter writer, Object value, JsonContract valueContract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerProperty)\r\n
   at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n
   at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n
   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n
   at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n
   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, HttpContent content)\r\n
   at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
   at System.Web.Http.Tracing.ITraceWriterExtensions.<TraceBeginEndAsyncCore>d__19.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
   at System.Net.Http.HttpContent.<CopyToAsyncCore>d__44.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n
   at System.Web.Http.WebHost.HttpControllerHandler.<WriteBufferedResponseContentAsync>d__22.MoveNext()

Exception getting documentation when exist comment in xml file

Hello,

When in xml file exist a comment an InvalidCastException is thrown: "Unable to cast object of type 'System.Xml.XmlComment' to type 'System.Xml.XmlElement'."

You can se this exception by example using Microsoft.Data.Service.xml in


        This interface declares the methods required to support getting values
        from projected results for $select queries
        </summary>


    </member>

I found the exception is thrown in the public static method GetXmlFromName in DocsTypeService.cs. In the foreach loop over the xmlDocument["doc"]["members"].

Regards,

Josรฉ Luis

Check the availability of documentation

I want to get documentation for all properties that have it. Method DocsService.GetXmlFromMember for properety without documentation throw exception. How I can check availability of documentation for property without exception catching?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.