question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Conditional Compilation in XML Comments

See original GitHub issue

Please support conditional compilation within XML documentation comments. This has been a source of pain since portable libraries came on the scene a while ago. Often linked code files are used to share source between different target platforms of the same API; however, as a result often times the documentation comments must change conditionally as well. As of now, there’s no good way around this limitation - you have to duplicate the entire XML comments conditionally, rather than just each section or line.

For example, I’d like to do this:

  /// <summary>
  /// Summary for Foo.
  /// </summary>
  /// <remarks>
  /// <para>Foo is great.</para>
#if !PORTABLE_403
  /// <para>Foo works well with <see cref="INotifyCollectionChanged"/>.<para>
#endif
  /// <para>Did I mention Foo is great?</para>
  /// </remarks>
  public void Foo() { ... }

INotifyCollectionChanged is not defined in .NET 4.0.3, so when targeting .NET 4.0.3 with a portable library the paragraph referencing it must be elided from the documentation.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:3
  • Comments:24 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
sharwellcommented, Aug 2, 2017

@gafter Do you still have the automated tool for moving these over? Depending on the role/scope I play in moving some of the documentation comment requests forward, I could certainly see this as one of the relevant ones.

🔗 This was already moved to dotnet/csharplang#295.

1reaction
NickCravercommented, May 23, 2016

So, we have a use for this in Dapper as well, same situation since some members we <see cref /> aren’t in .NET Core. For example:

        /// <summary>
        /// Execute parameterized SQL and return an <see cref="IDataReader"/>
        /// </summary>
        /// <returns>An <see cref="IDataReader"/> that can be used to iterate over the results of the SQL query.</returns>
        /// <remarks>
        /// This is typically used when the results of a query are not processed by Dapper, for example, used to fill a <see cref="DataTable"/>
#if !COREFX
        /// or <see cref="DataSet"/>.
#endif
        /// </remarks>
        /// <example>
        /// <code>
        /// <![CDATA[
        /// DataTable table = new DataTable("MyTable");
        /// using (var reader = ExecuteReader(cnn, sql, param))
        /// {
        ///     table.Load(reader);
        /// }
        /// ]]>
        /// </code>
        /// </example>
        public static IDataReader ExecuteReader(

…which of course won’t compile. Can we get some love here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to use conditional compilation symbols in xml
As the XML files are not compiled, there is no such thing like Conditional Compilation. So I identify the fact that you have...
Read more >
Using conditional compilation inside an app's XML file
Hello guys,. Do you know how to use the value of conditional compilation variable inside the app's XML file?
Read more >
How XSL and XML Help in Java's Conditional Compilation
Conditional compilation is a rather extensive concept. In the context of this article, with the meaning “conditional compilation,” we will have ...
Read more >
conditional compilation by xml and VS or application ...
I weave an aspect into an generic external library to disable logging. So far it is working perfect by a xml configuration and...
Read more >
Insert XML documentation comments - Visual Studio
The Insert Comment command that automatically inserts XML documentation comments is available in C# and Visual Basic. However, you can manually ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found