< p > #pragma warning disable 1591
如果你需要恢复它,使用:
#pragma warning restore 1591 < / p >
这里有一个例子:
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using RealEstate.Entity.Models.Base;
namespace RealEstate.Models.Base
{
public class CityVM
{
#pragma warning disable 1591
[Required]
public string Id { get; set; }
[Required]
public string Name { get; set; }
public List<LanguageBasedName> LanguageBasedNames { get; set; }
[Required]
public string CountryId { get; set; }
#pragma warning restore 1591
/// <summary>
/// Some countries do not have neither a State, nor a Province
/// </summary>
public string StateOrProvinceId { get; set; }
}
}
public EventLogger()
{
LogFile = string.Format("{0}{1}", LogFilePath, FileName);
}
显示警告
缺少公开可见类型或成员'.EventLogger()'
. XML注释
我为成员添加了评论,警告消失了。
///<Summary>
/// To write a log <Anycomment as per your code>
///</Summary>
public EventLogger()
{
LogFile = string.Format("{0}{1}", LogFilePath, FileName);
}
/// <summary>
/// Creates a Service
/// </summary>
/// <param name="service">The Service Definition</param> (**note no cancellation token param**)
/// <returns>A newly created item</returns>
/// <response code="201">Returns the newly created service</response>
/// <response code="400">If there are validation errors with the submitted json body</response>
/// <response code="409">Conflict. The service already exists</response>
/// <response code="500">Because life is never perfect</response>
[ProducesResponseType(typeof(Service), 201)]
[ProducesResponseType(400)]
[ProducesResponseType(409)]
[ProducesResponseType(500)]
[HttpPost]
public async Task<ActionResult> ServiceCreate([FromBody] ServicePostRequest service,
#pragma warning disable 1573
CancellationToken cancellationToken = default) //**note: no warning**
#pragma warning restore 1573
{