Merge pull request #57 from jellyfin/fixup

This commit is contained in:
Cody Robibero 2022-02-04 14:31:41 -07:00 committed by GitHub
commit 0c0a27abdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 528 additions and 462 deletions

View File

@ -13,7 +13,7 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
end_of_line = lf
max_line_length = 9999
max_line_length = off
# YAML indentation
[*.{yml,yaml}]

View File

@ -1,21 +1,22 @@
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Querying;
using System.Collections.Generic;
using System.Linq;
using MediaBrowser.Controller.Library;
#nullable disable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Jellyfin.Plugin.Reports.Api.Common;
using Jellyfin.Plugin.Reports.Api.Data;
using Jellyfin.Plugin.Reports.Api.Model;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Querying;
namespace Jellyfin.Plugin.Reports.Api.Activities
{
/// <summary> A report activities builder. </summary>
/// <seealso cref="T:MediaBrowser.Api.Reports.ReportBuilderBase"/>
/// <seealso cref="ReportBuilderBase"/>
public class ReportActivitiesBuilder : ReportBuilderBase
{
#region [Constructors]
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportActivitiesBuilder class. </summary>
/// <param name="libraryManager"> Manager for library. </param>
@ -26,16 +27,8 @@ namespace Jellyfin.Plugin.Reports.Api.Activities
_userManager = userManager;
}
#endregion
#region [Private Fields]
private readonly IUserManager _userManager; ///< Manager for user
#endregion
#region [Public Methods]
/// <summary> Gets a result. </summary>
/// <param name="queryResult"> The query result. </param>
/// <param name="request"> The request. </param>
@ -58,7 +51,7 @@ namespace Jellyfin.Plugin.Reports.Api.Activities
var rowsGroup = rows.SelectMany(x => x.Columns[i].Name.Split(';'), (x, g) => new { Group = g.Trim(), Rows = x })
.GroupBy(x => x.Group)
.OrderBy(x => x.Key)
.Select(x => new ReportGroup { Name = x.Key, Rows = x.Select(r => r.Rows).ToList() });
.Select(x => new ReportGroup(x.Key, x.Select(r => r.Rows).ToList()));
result.Groups = rowsGroup.ToList();
result.IsGrouped = true;
@ -72,38 +65,30 @@ namespace Jellyfin.Plugin.Reports.Api.Activities
return result;
}
#endregion
#region [Protected Internal Methods]
/// <summary> Gets the headers. </summary>
/// <typeparam name="H"> Type of the header. </typeparam>
/// <typeparam name="T"> Type of the header. </typeparam>
/// <param name="request"> The request. </param>
/// <returns> The headers. </returns>
/// <seealso cref="M:MediaBrowser.Api.Reports.ReportBuilderBase.GetHeaders{H}(H)"/>
protected internal override List<ReportHeader> GetHeaders<H>(H request)
/// <seealso cref="ReportBuilderBase.GetHeaders"/>
protected internal override List<ReportHeader> GetHeaders<T>(T request)
{
return this.GetHeaders<ActivityLogEntry>(request, () => this.GetDefaultHeaderMetadata(), (hm) => this.GetOption(hm));
}
#endregion
#region [Private Methods]
/// <summary> Gets default header metadata. </summary>
/// <returns> The default header metadata. </returns>
private List<HeaderMetadata> GetDefaultHeaderMetadata()
{
return new List<HeaderMetadata>
{
{
HeaderMetadata.UserPrimaryImage,
HeaderMetadata.Date,
HeaderMetadata.User,
HeaderMetadata.Type,
HeaderMetadata.Severity,
HeaderMetadata.Name,
HeaderMetadata.Name,
HeaderMetadata.ShortOverview,
HeaderMetadata.Overview,
HeaderMetadata.Overview,
//HeaderMetadata.UserId
//HeaderMetadata.Item,
};
@ -249,13 +234,10 @@ namespace Jellyfin.Plugin.Reports.Api.Activities
{
ReportRow rRow = new ReportRow
{
Id = item.Id.ToString(),
Id = item.Id.ToString(CultureInfo.InvariantCulture),
UserId = item.UserId
};
return rRow;
}
#endregion
}
}

View File

@ -1,7 +1,7 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum HeaderActivitiesMetadata
{
{
None,
Name,
Overview,
@ -12,5 +12,5 @@ namespace Jellyfin.Plugin.Reports.Api.Common
Severity,
Item,
User
}
}
}

View File

@ -1,53 +1,53 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum HeaderMetadata
{
None,
Path,
Name,
PremiereDate,
DateAdded,
ReleaseDate,
Runtime,
PlayCount,
Season,
SeasonNumber,
Series,
Network,
Year,
ParentalRating,
CommunityRating,
Trailers,
Specials,
AlbumArtist,
Album,
Disc,
Track,
Audio,
EmbeddedImage,
Video,
Resolution,
Subtitles,
Genres,
Countries,
{
None,
Path,
Name,
PremiereDate,
DateAdded,
ReleaseDate,
Runtime,
PlayCount,
Season,
SeasonNumber,
Series,
Network,
Year,
ParentalRating,
CommunityRating,
Trailers,
Specials,
AlbumArtist,
Album,
Disc,
Track,
Audio,
EmbeddedImage,
Video,
Resolution,
Subtitles,
Genres,
Countries,
Status,
Tracks,
EpisodeSeries,
EpisodeSeason,
Tracks,
EpisodeSeries,
EpisodeSeason,
EpisodeNumber,
AudioAlbumArtist,
MusicArtist,
AudioAlbum,
MusicArtist,
AudioAlbum,
Locked,
ImagePrimary,
ImageBackdrop,
ImageLogo,
Actor,
Actor,
Studios,
Composer,
Director,
GuestStar,
Producer,
Composer,
Director,
GuestStar,
Producer,
Writer,
Artist,
Years,
@ -64,5 +64,5 @@ namespace Jellyfin.Plugin.Reports.Api.Common
Item,
User,
UserId
}
}
}

View File

@ -1,22 +1,25 @@
using MediaBrowser.Controller.Entities;
#nullable disable
using System;
using System.Collections.Generic;
using System.Linq;
using System.Globalization;
using Jellyfin.Plugin.Reports.Api.Data;
using Jellyfin.Plugin.Reports.Api.Model;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Channels;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using Jellyfin.Plugin.Reports.Api.Data;
using Jellyfin.Plugin.Reports.Api.Model;
namespace Jellyfin.Plugin.Reports.Api.Common
{
/// <summary> A report builder base. </summary>
public abstract class ReportBuilderBase
{
#region [Constructors]
/// <summary> Manager for library. </summary>
private readonly ILibraryManager _libraryManager;
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportBuilderBase class. </summary>
@ -26,28 +29,13 @@ namespace Jellyfin.Plugin.Reports.Api.Common
_libraryManager = libraryManager;
}
#endregion
#region [Protected Fields]
/// <summary> Manager for library. </summary>
protected readonly ILibraryManager _libraryManager; ///< Manager for library
protected Func<bool, string> GetBoolString = s => s == true ? "x" : ""; ///< .
#endregion
#region [Protected Internal Methods]
protected Func<bool, string> GetBoolString => s => s == true ? "x" : string.Empty;
/// <summary> Gets the headers. </summary>
/// <typeparam name="H"> Type of the header. </typeparam>
/// <typeparam name="T"> Type of the header. </typeparam>
/// <param name="request"> The request. </param>
/// <returns> The headers. </returns>
protected internal abstract List<ReportHeader> GetHeaders<H>(H request) where H : IReportsHeader;
#endregion
#region [Protected Methods]
protected internal abstract List<ReportHeader> GetHeaders<T>(T request) where T : IReportsHeader;
/// <summary> Gets active headers. </summary>
/// <typeparam name="T"> Generic type parameter. </typeparam>
@ -70,11 +58,14 @@ namespace Jellyfin.Plugin.Reports.Api.Common
protected string GetAudioStream(BaseItem item)
{
var stream = GetStream(item, MediaStreamType.Audio);
if (stream != null)
return stream.Codec.ToUpper() == "DCA" ? stream.Profile : stream.Codec.
ToUpper();
if (stream == null)
{
return string.Empty;
}
return string.Empty;
return string.Equals(stream.Codec, "DCA", StringComparison.OrdinalIgnoreCase)
? stream.Profile
: stream.Codec.ToUpperInvariant();
}
/// <summary> Gets an episode. </summary>
@ -106,8 +97,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
{
if (string.IsNullOrEmpty(name))
return string.Empty;
return string.Format("{0:N}",
GetGenre(name).Id);
return GetGenre(name).Id.ToString("N", CultureInfo.InvariantCulture);
}
/// <summary> Gets the headers. </summary>
@ -155,7 +145,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
return "Episode";
}
string headerName = "";
string headerName = string.Empty;
if (internalHeader != HeaderMetadata.None)
{
string localHeader = internalHeader.ToString();
@ -169,24 +159,23 @@ namespace Jellyfin.Plugin.Reports.Api.Common
/// <returns> The media source information. </returns>
protected MediaSourceInfo GetMediaSourceInfo(BaseItem item)
{
var mediaSource = item as IHasMediaSources;
if (mediaSource != null)
if (item is IHasMediaSources mediaSource)
return mediaSource.GetMediaSources(false).FirstOrDefault(n => n.Type == MediaSourceType.Default);
return null;
}
/// <summary> Gets an object. </summary>
/// <typeparam name="T"> Generic type parameter. </typeparam>
/// <typeparam name="R"> Type of the r. </typeparam>
/// <typeparam name="TItem"> Generic type parameter. </typeparam>
/// <typeparam name="TReturn"> Type of the r. </typeparam>
/// <param name="item"> The item. </param>
/// <param name="function"> The function. </param>
/// <param name="defaultValue"> The default value. </param>
/// <returns> The object. </returns>
protected R GetObject<T, R>(BaseItem item, Func<T, R> function, R defaultValue = default(R)) where T : class
protected TReturn GetObject<TItem, TReturn>(BaseItem item, Func<TItem, TReturn> function, TReturn defaultValue = default)
where TItem : class
{
var value = item as T;
if (value != null && function != null)
if (item is TItem value && function != null)
return function(value);
else
return defaultValue;
@ -209,8 +198,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
{
if (string.IsNullOrEmpty(name))
return string.Empty;
return string.Format("{0:N}",
GetPerson(name).Id);
return GetPerson(name).Id.ToString("N", CultureInfo.InvariantCulture);
}
/// <summary> Gets report options. </summary>
@ -239,7 +227,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
if (this.DisplayTypeVisible(header.DisplayType, displayType))
{
if (!headersMetadataFiltered.Contains(header.FieldName) && displayType != ReportDisplayType.Export)
{
header.DisplayType = ReportDisplayType.None;
@ -317,8 +305,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
{
if (string.IsNullOrEmpty(name))
return string.Empty;
return string.Format("{0:N}",
GetStudio(name).Id);
return GetStudio(name).Id.ToString("N", CultureInfo.InvariantCulture);
}
/// <summary> Gets video resolution. </summary>
@ -329,7 +316,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
var stream = GetStream(item,
MediaStreamType.Video);
if (stream != null && stream.Width != null)
return string.Format("{0} * {1}",
return string.Format(CultureInfo.InvariantCulture, "{0} * {1}",
stream.Width,
stream.Height != null ? stream.Height.ToString() : "-");
@ -343,7 +330,7 @@ namespace Jellyfin.Plugin.Reports.Api.Common
{
var stream = GetStream(item, MediaStreamType.Video);
if (stream != null)
return stream.Codec.ToUpper();
return stream.Codec.ToUpperInvariant();
return string.Empty;
}
@ -360,8 +347,5 @@ namespace Jellyfin.Plugin.Reports.Api.Common
bool rval = headerDisplayType == displayType || headerDisplayType == ReportDisplayType.ScreenExport && (displayType == ReportDisplayType.Screen || displayType == ReportDisplayType.Export);
return rval;
}
#endregion
}
}

View File

@ -2,9 +2,9 @@ namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum ReportDisplayType
{
None,
Screen,
Export,
ScreenExport
}
None,
Screen,
Export,
ScreenExport
}
}

View File

@ -1,8 +1,8 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum ReportExportType
{
CSV,
Excel
}
{
CSV,
Excel
}
}

View File

@ -1,15 +1,15 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum ReportFieldType
{
String,
Boolean,
Date,
Time,
DateTime,
Int,
Image,
Object,
{
String,
Boolean,
Date,
Time,
DateTime,
Int,
Image,
Object,
Minutes
}
}
}

View File

@ -1,8 +1,8 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum ReportHeaderIdType
{
Row,
Item
}
{
Row,
Item
}
}

View File

@ -1,6 +1,6 @@
using MediaBrowser.Controller.Entities;
using System;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
namespace Jellyfin.Plugin.Reports.Api.Common
@ -8,56 +8,48 @@ namespace Jellyfin.Plugin.Reports.Api.Common
/// <summary> A report helper. </summary>
public class ReportHelper
{
#region [Public Methods]
/// <summary> Convert field to string. </summary>
/// <typeparam name="T"> Generic type parameter. </typeparam>
/// <param name="value"> The value. </param>
/// <param name="fieldType"> Type of the field. </param>
/// <returns> The field converted to string. </returns>
public static string ConvertToString<T>(T value, ReportFieldType fieldType)
public static string? ConvertToString<T>(T value, ReportFieldType fieldType)
{
if (value == null)
return "";
switch (fieldType)
{
case ReportFieldType.String:
return value.ToString();
case ReportFieldType.Boolean:
return value.ToString();
case ReportFieldType.Date:
return string.Format("{0:d}", value);
case ReportFieldType.Time:
return string.Format("{0:t}", value);
case ReportFieldType.DateTime:
return string.Format("{0:g}", value);
case ReportFieldType.Minutes:
return string.Format("{0}mn", value);
case ReportFieldType.Int:
return string.Format("", value);
default:
if (value is Guid)
return string.Format("{0:N}", value);
return value.ToString();
return string.Empty;
}
return fieldType switch
{
ReportFieldType.Boolean | ReportFieldType.Int | ReportFieldType.String => value.ToString(),
ReportFieldType.Date => string.Format(CultureInfo.InvariantCulture, "{0:d}", value),
ReportFieldType.Time => string.Format(CultureInfo.InvariantCulture, "{0:t}", value),
ReportFieldType.DateTime => string.Format(CultureInfo.InvariantCulture, "{0:g}", value),
ReportFieldType.Minutes => string.Format(CultureInfo.InvariantCulture, "{0}mn", value),
_ when value is Guid guid => guid.ToString("N", CultureInfo.InvariantCulture),
_ => value.ToString()
};
}
/// <summary> Gets filtered report header metadata. </summary>
/// <param name="reportColumns"> The report columns. </param>
/// <param name="defaultReturnValue"> The default return value. </param>
/// <returns> The filtered report header metadata. </returns>
public static List<HeaderMetadata> GetFilteredReportHeaderMetadata(string reportColumns, Func<List<HeaderMetadata>> defaultReturnValue = null)
public static List<HeaderMetadata> GetFilteredReportHeaderMetadata(string reportColumns, Func<List<HeaderMetadata>>? defaultReturnValue = null)
{
if (!string.IsNullOrEmpty(reportColumns))
{
var s = reportColumns.Split('|').Select(x => ReportHelper.GetHeaderMetadataType(x)).Where(x => x != HeaderMetadata.None);
return s.ToList();
}
else
if (defaultReturnValue != null)
return defaultReturnValue();
else
return new List<HeaderMetadata>();
if (defaultReturnValue == null)
{
return new List<HeaderMetadata>();
}
return defaultReturnValue();
}
/// <summary> Gets header metadata type. </summary>
@ -131,8 +123,5 @@ namespace Jellyfin.Plugin.Reports.Api.Common
{
return phrase;
}
#endregion
}
}

View File

@ -1,20 +1,20 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum ReportIncludeItemTypes
{
MusicArtist,
MusicAlbum,
Book,
BoxSet,
Episode,
Video,
Movie,
MusicVideo,
Trailer,
Season,
Series,
Audio,
BaseItem,
Artist
}
{
MusicArtist,
MusicAlbum,
Book,
BoxSet,
Episode,
Video,
Movie,
MusicVideo,
Trailer,
Season,
Series,
Audio,
BaseItem,
Artist
}
}

View File

@ -1,9 +1,8 @@
namespace Jellyfin.Plugin.Reports.Api.Common
{
public enum ReportViewType
{
{
ReportData,
ReportActivities
}
}
}

View File

@ -1,22 +1,21 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
#nullable disable
using System.Collections.Generic;
using System.Linq;
using Jellyfin.Plugin.Reports.Api.Common;
using Jellyfin.Plugin.Reports.Api.Model;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
namespace Jellyfin.Plugin.Reports.Api.Data
{
/// <summary> A report builder. </summary>
/// <seealso cref="T:MediaBrowser.Api.Reports.ReportBuilderBase"/>
/// <seealso cref="ReportBuilderBase"/>
public class ReportBuilder : ReportBuilderBase
{
#region [Constructors]
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportBuilder class. </summary>
/// <param name="libraryManager"> Manager for library. </param>
@ -25,10 +24,6 @@ namespace Jellyfin.Plugin.Reports.Api.Data
{
}
#endregion
#region [Public Methods]
/// <summary> Gets report result. </summary>
/// <param name="items"> The items. </param>
/// <param name="request"> The request. </param>
@ -53,7 +48,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
var rowsGroup = rows.SelectMany(x => x.Columns[i].Name.Split(';'), (x, g) => new { Group = g.Trim(), Rows = x })
.GroupBy(x => x.Group)
.OrderBy(x => x.Key)
.Select(x => new ReportGroup { Name = x.Key, Rows = x.Select(r => r.Rows).ToList() });
.Select(x => new ReportGroup(x.Key, x.Select(r => r.Rows).ToList()));
result.Groups = rowsGroup.ToList();
result.IsGrouped = true;
@ -67,25 +62,17 @@ namespace Jellyfin.Plugin.Reports.Api.Data
return result;
}
#endregion
#region [Protected Internal Methods]
/// <summary> Gets the headers. </summary>
/// <typeparam name="H"> Type of the header. </typeparam>
/// <typeparam name="T"> Type of the header. </typeparam>
/// <param name="request"> The request. </param>
/// <returns> The headers. </returns>
/// <seealso cref="M:MediaBrowser.Api.Reports.ReportBuilderBase.GetHeaders{H}(H)"/>
protected internal override List<ReportHeader> GetHeaders<H>(H request)
/// <seealso cref="ReportBuilderBase.GetHeaders"/>
protected internal override List<ReportHeader> GetHeaders<T>(T request)
{
ReportIncludeItemTypes reportRowType = ReportHelper.GetRowType(request.IncludeItemTypes);
return this.GetHeaders<BaseItem>(request, () => this.GetDefaultHeaderMetadata(reportRowType), (hm) => this.GetOption(hm));
}
#endregion
#region [Private Methods]
/// <summary> Gets default report header metadata. </summary>
/// <param name="reportIncludeItemTypes"> Type of the report row. </param>
/// <returns> The default report header metadata. </returns>
@ -358,7 +345,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
option.Header.CanGroup = false;
option.Header.DisplayType = ReportDisplayType.Export;
break;
case HeaderMetadata.Path:
option.Column = (i, r) => i.Path;
option.Header.SortField = "Path,SortName";
@ -513,7 +500,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
break;
case HeaderMetadata.Tracks:
option.Column = (i, r) => this.GetObject<MusicAlbum, List<Audio>>(i, (x) => x.Tracks.ToList(), new List<Audio>()).Count();
option.Column = (i, r) => this.GetObject<MusicAlbum, List<Audio>>(i, (x) => x.Tracks.ToList(), new List<Audio>()).Count;
break;
case HeaderMetadata.Audio:
@ -582,23 +569,18 @@ namespace Jellyfin.Plugin.Reports.Api.Data
/// <returns> The row. </returns>
private ReportRow GetRow(BaseItem item)
{
var video = item as Video;
ReportRow rRow = new ReportRow
return new ReportRow
{
Id = item.Id.ToString("N"),
HasLockData = item.IsLocked,
HasLocalTrailer = item.GetExtras(new[] { ExtraType.Trailer }).Any(),
HasImageTagsPrimary = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Primary) > 0,
HasImageTagsBackdrop = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Backdrop) > 0,
HasImageTagsLogo = item.ImageInfos != null && item.ImageInfos.Count(n => n.Type == ImageType.Logo) > 0,
HasImageTagsPrimary = item.ImageInfos != null && item.ImageInfos.Any(n => n.Type == ImageType.Primary),
HasImageTagsBackdrop = item.ImageInfos != null && item.ImageInfos.Any(n => n.Type == ImageType.Backdrop),
HasImageTagsLogo = item.ImageInfos != null && item.ImageInfos.Any(n => n.Type == ImageType.Logo),
HasSpecials = item.GetExtras(BaseItem.DisplayExtraTypes).Any(),
HasSubtitles = video != null ? video.HasSubtitles : false,
HasSubtitles = item is Video video && video.HasSubtitles,
RowType = ReportHelper.GetRowType(item.GetClientTypeName())
};
return rRow;
}
#endregion
}
}

View File

@ -1,4 +1,7 @@
using System.Linq;
#nullable disable
using System.Globalization;
using System.Linq;
using System.Text;
using Jellyfin.Plugin.Reports.Api.Model;
@ -14,20 +17,20 @@ namespace Jellyfin.Plugin.Reports.Api.Data
{
StringBuilder returnValue = new StringBuilder();
returnValue.AppendLine(string.Join(";", reportResult.Headers.Select(s => s.Name.Replace(',', ' ')).ToArray()));
returnValue.AppendLine(string.Join(';', reportResult.Headers.Select(s => s.Name.Replace(',', ' '))));
if (reportResult.IsGrouped)
foreach (ReportGroup group in reportResult.Groups)
{
foreach (ReportRow row in reportResult.Rows)
{
returnValue.AppendLine(string.Join(";", row.Columns.Select(s => s.Name.Replace(',', ' ')).ToArray()));
returnValue.AppendLine(string.Join(';', row.Columns.Select(s => s.Name.Replace(',', ' '))));
}
}
else
foreach (ReportRow row in reportResult.Rows)
{
returnValue.AppendLine(string.Join(";", row.Columns.Select(s => s.Name.Replace(',', ' ')).ToArray()));
returnValue.AppendLine(string.Join(';', row.Columns.Select(s => s.Name.Replace(',', ' '))));
}
return returnValue.ToString();
@ -168,7 +171,7 @@ namespace Jellyfin.Plugin.Reports.Api.Data
StringBuilder returnValue = new StringBuilder();
returnValue.AppendLine("<table class='gridtable'>");
returnValue.AppendLine("<tr>");
returnValue.AppendLine(string.Join("", reportResult.Headers.Select(s => string.Format("<th>{0}</th>", s.Name)).ToArray()));
returnValue.AppendLine(string.Join(string.Empty, reportResult.Headers.Select(s => string.Format(CultureInfo.InvariantCulture, "<th>{0}</th>", s.Name))));
returnValue.AppendLine("</tr>");
if (reportResult.IsGrouped)
foreach (ReportGroup group in reportResult.Groups)
@ -202,9 +205,8 @@ namespace Jellyfin.Plugin.Reports.Api.Data
ReportRow row)
{
returnValue.AppendLine("<tr>");
returnValue.AppendLine(string.Join("", row.Columns.Select(s => string.Format("<td>{0}</td>", s.Name)).ToArray()));
returnValue.AppendLine(string.Join(string.Empty, row.Columns.Select(s => string.Format(CultureInfo.InvariantCulture, "<td>{0}</td>", s.Name))));
returnValue.AppendLine("</tr>");
}
}
}

View File

@ -1,49 +1,51 @@
using System;
#nullable disable
using System;
using Jellyfin.Plugin.Reports.Api.Model;
namespace Jellyfin.Plugin.Reports.Api.Data
{
/// <summary> A report options. </summary>
public class ReportOptions<I>
{
/// <summary> Initializes a new instance of the ReportOptions class. </summary>
public ReportOptions()
{
}
public class ReportOptions<T>
{
/// <summary> Initializes a new instance of the ReportOptions class. </summary>
public ReportOptions()
{
}
/// <summary> Initializes a new instance of the ReportOptions class. </summary>
/// <param name="header"> . </param>
/// <param name="row"> . </param>
public ReportOptions(ReportHeader header, Func<I, ReportRow, object> column)
{
Header = header;
Column = column;
}
/// <summary> Initializes a new instance of the ReportOptions class. </summary>
/// <param name="header"> . </param>
/// <param name="row"> . </param>
public ReportOptions(ReportHeader header, Func<T, ReportRow, object> column)
{
Header = header;
Column = column;
}
/// <summary>
/// Initializes a new instance of the ReportOptions class.
/// </summary>
/// <param name="header"></param>
/// <param name="column"></param>
/// <param name="itemID"></param>
public ReportOptions(ReportHeader header, Func<I, ReportRow, object> column, Func<I, object> itemID)
{
Header = header;
Column = column;
ItemID = itemID;
}
/// <summary>
/// Initializes a new instance of the ReportOptions class.
/// </summary>
/// <param name="header"></param>
/// <param name="column"></param>
/// <param name="itemID"></param>
public ReportOptions(ReportHeader header, Func<T, ReportRow, object> column, Func<T, object> itemID)
{
Header = header;
Column = column;
ItemID = itemID;
}
/// <summary> Gets or sets the header. </summary>
/// <value> The header. </value>
public ReportHeader Header { get; set; }
/// <summary> Gets or sets the header. </summary>
/// <value> The header. </value>
public ReportHeader Header { get; set; }
/// <summary> Gets or sets the column. </summary>
/// <value> The column. </value>
public Func<I, ReportRow, object> Column { get; set; }
/// <summary> Gets or sets the column. </summary>
/// <value> The column. </value>
public Func<T, ReportRow, object> Column { get; set; }
/// <summary> Gets or sets the identifier of the item. </summary>
/// <value> The identifier of the item. </value>
public Func<I, object> ItemID { get; set; }
}
/// <summary> Gets or sets the identifier of the item. </summary>
/// <value> The identifier of the item. </value>
public Func<T, object> ItemID { get; set; }
}
}

View File

@ -5,36 +5,27 @@ namespace Jellyfin.Plugin.Reports.Api.Model
/// <summary> A report group. </summary>
public class ReportGroup
{
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportGroup class. </summary>
public ReportGroup()
{
Rows = new List<ReportRow>();
}
{
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportGroup class. </summary>
/// <param name="rows"> The rows. </param>
public ReportGroup(string name, List<ReportRow> rows)
{
Name = name;
Rows = rows;
}
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportGroup class. </summary>
/// <param name="rows"> The rows. </param>
public ReportGroup(List<ReportRow> rows)
{
Rows = rows;
}
/// <summary>Gets the name.</summary>
/// <value>The name.</value>
public string Name { get; }
/// <summary> Gets or sets the name. </summary>
/// <value> The name. </value>
public string Name { get; set; }
/// <summary>Gets the rows.</summary>
/// <value>The rows.</value>
public List<ReportRow> Rows { get; }
/// <summary> Gets or sets the rows. </summary>
/// <value> The rows. </value>
public List<ReportRow> Rows { get; set; }
/// <summary> Returns a string that represents the current object. </summary>
/// <returns> A string that represents the current object. </returns>
/// <seealso cref="M:System.Object.ToString()"/>
public override string ToString()
{
return Name;
}
}
/// <summary> Returns a string that represents the current object. </summary>
/// <returns> A string that represents the current object. </returns>
/// <seealso cref="Object.ToString()"/>
public override string ToString() => Name;
}
}

View File

@ -1,47 +1,49 @@
using Jellyfin.Plugin.Reports.Api.Common;
#nullable disable
using Jellyfin.Plugin.Reports.Api.Common;
namespace Jellyfin.Plugin.Reports.Api.Model
{
/// <summary> A report header. </summary>
public class ReportHeader
{
/// <summary> Initializes a new instance of the ReportHeader class. </summary>
public ReportHeader()
{
ItemViewType = ItemViewType.None;
Visible = true;
CanGroup = true;
{
/// <summary> Initializes a new instance of the ReportHeader class. </summary>
public ReportHeader()
{
ItemViewType = ItemViewType.None;
Visible = true;
CanGroup = true;
ShowHeaderLabel = true;
DisplayType = ReportDisplayType.ScreenExport;
}
}
/// <summary> Gets or sets the type of the header field. </summary>
/// <value> The type of the header field. </value>
public ReportFieldType HeaderFieldType { get; set; }
/// <summary> Gets or sets the type of the header field. </summary>
/// <value> The type of the header field. </value>
public ReportFieldType HeaderFieldType { get; set; }
/// <summary> Gets or sets the name of the header. </summary>
/// <value> The name of the header. </value>
public string Name { get; set; }
/// <summary> Gets or sets the name of the header. </summary>
/// <value> The name of the header. </value>
public string Name { get; set; }
/// <summary> Gets or sets the name of the field. </summary>
/// <value> The name of the field. </value>
public HeaderMetadata FieldName { get; set; }
/// <summary> Gets or sets the name of the field. </summary>
/// <value> The name of the field. </value>
public HeaderMetadata FieldName { get; set; }
/// <summary> Gets or sets the sort field. </summary>
/// <value> The sort field. </value>
public string SortField { get; set; }
/// <summary> Gets or sets the sort field. </summary>
/// <value> The sort field. </value>
public string SortField { get; set; }
/// <summary> Gets or sets the type. </summary>
/// <value> The type. </value>
public string Type { get; set; }
/// <summary> Gets or sets the type. </summary>
/// <value> The type. </value>
public string Type { get; set; }
/// <summary> Gets or sets the type of the item view. </summary>
/// <value> The type of the item view. </value>
public ItemViewType ItemViewType { get; set; }
/// <summary> Gets or sets the type of the item view. </summary>
/// <value> The type of the item view. </value>
public ItemViewType ItemViewType { get; set; }
/// <summary> Gets or sets a value indicating whether this object is visible. </summary>
/// <value> true if visible, false if not. </value>
public bool Visible { get; set; }
/// <summary> Gets or sets a value indicating whether this object is visible. </summary>
/// <value> true if visible, false if not. </value>
public bool Visible { get; set; }
/// <summary> Gets or sets the type of the display. </summary>
/// <value> The type of the display. </value>
@ -51,9 +53,9 @@ namespace Jellyfin.Plugin.Reports.Api.Model
/// <value> true if show header label, false if not. </value>
public bool ShowHeaderLabel { get; set; }
/// <summary> Gets or sets a value indicating whether we can group. </summary>
/// <value> true if we can group, false if not. </value>
public bool CanGroup { get; set; }
/// <summary> Gets or sets a value indicating whether we can group. </summary>
/// <value> true if we can group, false if not. </value>
public bool CanGroup { get; set; }
}
}
}

View File

@ -1,28 +1,30 @@
namespace Jellyfin.Plugin.Reports.Api.Model
#nullable disable
namespace Jellyfin.Plugin.Reports.Api.Model
{
/// <summary> A report item. </summary>
public class ReportItem
{
/// <summary> Gets or sets the identifier. </summary>
/// <value> The identifier. </value>
public string Id { get; set; }
{
/// <summary> Gets or sets the identifier. </summary>
/// <value> The identifier. </value>
public string Id { get; set; }
/// <summary> Gets or sets the name. </summary>
/// <value> The name. </value>
public string Name { get; set; }
/// <summary> Gets or sets the name. </summary>
/// <value> The name. </value>
public string Name { get; set; }
public string Image { get; set; }
public string Image { get; set; }
/// <summary> Gets or sets the custom tag. </summary>
/// <value> The custom tag. </value>
public string CustomTag { get; set; }
/// <summary> Gets or sets the custom tag. </summary>
/// <value> The custom tag. </value>
public string CustomTag { get; set; }
/// <summary> Returns a string that represents the current object. </summary>
/// <returns> A string that represents the current object. </returns>
/// <seealso cref="M:System.Object.ToString()"/>
public override string ToString()
{
return Name;
}
}
/// <summary> Returns a string that represents the current object. </summary>
/// <returns> A string that represents the current object. </returns>
/// <seealso cref="Object.ToString()"/>
public override string ToString()
{
return Name;
}
}
}

View File

@ -1,53 +1,55 @@
using System.Collections.Generic;
#nullable disable
using System.Collections.Generic;
namespace Jellyfin.Plugin.Reports.Api.Model
{
/// <summary> Encapsulates the result of a report. </summary>
public class ReportResult
{
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportResult class. </summary>
public ReportResult()
{
Rows = new List<ReportRow>();
Headers = new List<ReportHeader>();
Groups = new List<ReportGroup>();
TotalRecordCount = 0;
IsGrouped = false;
}
{
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportResult class. </summary>
public ReportResult()
{
Rows = new List<ReportRow>();
Headers = new List<ReportHeader>();
Groups = new List<ReportGroup>();
TotalRecordCount = 0;
IsGrouped = false;
}
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportResult class. </summary>
/// <param name="headers"> The headers. </param>
/// <param name="rows"> The rows. </param>
public ReportResult(List<ReportHeader> headers, List<ReportRow> rows)
{
Rows = rows;
Headers = headers;
TotalRecordCount = 0;
}
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportResult class. </summary>
/// <param name="headers"> The headers. </param>
/// <param name="rows"> The rows. </param>
public ReportResult(List<ReportHeader> headers, List<ReportRow> rows)
{
Rows = rows;
Headers = headers;
TotalRecordCount = 0;
}
/// <summary> Gets or sets the rows. </summary>
/// <value> The rows. </value>
public List<ReportRow> Rows { get; set; }
/// <summary> Gets or sets the rows. </summary>
/// <value> The rows. </value>
public List<ReportRow> Rows { get; set; }
/// <summary> Gets or sets the headers. </summary>
/// <value> The headers. </value>
public List<ReportHeader> Headers { get; set; }
/// <summary> Gets or sets the headers. </summary>
/// <value> The headers. </value>
public List<ReportHeader> Headers { get; set; }
/// <summary> Gets or sets the groups. </summary>
/// <value> The groups. </value>
public List<ReportGroup> Groups { get; set; }
/// <summary> Gets or sets the groups. </summary>
/// <value> The groups. </value>
public List<ReportGroup> Groups { get; set; }
/// <summary> Gets or sets the number of total records. </summary>
/// <value> The total number of record count. </value>
public int TotalRecordCount { get; set; }
/// <summary> Gets or sets the number of total records. </summary>
/// <value> The total number of record count. </value>
public int TotalRecordCount { get; set; }
/// <summary> Gets or sets the is grouped. </summary>
/// <value> The is grouped. </value>
public bool IsGrouped { get; set; }
/// <summary> Gets or sets the is grouped. </summary>
/// <value> The is grouped. </value>
public bool IsGrouped { get; set; }
}
}
}

View File

@ -1,4 +1,6 @@
using System.Collections.Generic;
#nullable disable
using System.Collections.Generic;
using System;
using Jellyfin.Plugin.Reports.Api.Common;

View File

@ -1,4 +1,6 @@
using System;
#nullable disable
using System;
using System.ComponentModel;
using System.Linq;
using Jellyfin.Data.Enums;
@ -479,7 +481,7 @@ namespace Jellyfin.Plugin.Reports.Api
if (string.IsNullOrEmpty(val))
{
return new VideoType[] { };
return Array.Empty<VideoType>();
}
return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (VideoType)Enum.Parse(typeof(VideoType), v, true)).ToArray();
@ -495,7 +497,7 @@ namespace Jellyfin.Plugin.Reports.Api
if (string.IsNullOrEmpty(val))
{
return new ItemFilter[] { };
return Array.Empty<ItemFilter>();
}
return val.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).Select(v => (ItemFilter)Enum.Parse(typeof(ItemFilter), v, true)).ToArray();
@ -511,7 +513,7 @@ namespace Jellyfin.Plugin.Reports.Api
if (string.IsNullOrEmpty(val))
{
return new ImageType[] { };
return Array.Empty<ImageType>();
}
return val.Split(',').Select(v => (ImageType)Enum.Parse(typeof(ImageType), v, true)).ToArray();
@ -526,13 +528,13 @@ namespace Jellyfin.Plugin.Reports.Api
return GetOrderBy(SortBy, SortOrder);
}
public static ValueTuple<string, SortOrder>[] GetOrderBy(string sortBy, string requestedSortOrder)
public static (string, SortOrder)[] GetOrderBy(string sortBy, string requestedSortOrder)
{
var val = sortBy;
if (string.IsNullOrEmpty(val))
{
return new ValueTuple<string, SortOrder>[] { };
return Array.Empty<(string, SortOrder)>();
}
var vals = val.Split(',');
@ -543,7 +545,7 @@ namespace Jellyfin.Plugin.Reports.Api
var sortOrders = requestedSortOrder.Split(',');
var result = new ValueTuple<string, SortOrder>[vals.Length];
var result = new (string, SortOrder)[vals.Length];
for (var i = 0; i < vals.Length; i++)
{
@ -552,7 +554,7 @@ namespace Jellyfin.Plugin.Reports.Api
var sortOrderValue = sortOrders.Length > sortOrderIndex ? sortOrders[sortOrderIndex] : null;
var sortOrder = string.Equals(sortOrderValue, "Descending", StringComparison.OrdinalIgnoreCase) ? Jellyfin.Data.Enums.SortOrder.Descending : Jellyfin.Data.Enums.SortOrder.Ascending;
result[i] = new ValueTuple<string, SortOrder>(vals[i], sortOrder);
result[i] = (vals[i], sortOrder);
}
return result;
@ -626,10 +628,9 @@ namespace Jellyfin.Plugin.Reports.Api
}
}
public class GetItemReport : BaseReportRequest
{
}
public class GetItemReport : BaseReportRequest
{
}
public class GetReportHeaders : IReportsHeader
{

View File

@ -1,6 +1,4 @@
#nullable enable
using System.Net.Mime;
using System.Net.Mime;
using System.Threading.Tasks;
using Jellyfin.Plugin.Reports.Api.Common;
using Jellyfin.Plugin.Reports.Api.Model;

View File

@ -1,29 +1,29 @@
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Querying;
#nullable disable
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System;
using System.Threading.Tasks;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Library;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.Querying;
using Jellyfin.Data.Queries;
using Jellyfin.Plugin.Reports.Api.Activities;
using Jellyfin.Plugin.Reports.Api.Common;
using Jellyfin.Plugin.Reports.Api.Data;
using Jellyfin.Plugin.Reports.Api.Model;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Activity;
using MediaBrowser.Model.Globalization;
using User = Jellyfin.Data.Entities.User;
namespace Jellyfin.Plugin.Reports.Api
{
/// <summary> The reports service. </summary>
/// <seealso cref="T:MediaBrowser.Api.BaseApiService"/>
/// <seealso cref="BaseApiService"/>
public class ReportsService
{
#region [Constructors]
/// <summary>
/// Initializes a new instance of the MediaBrowser.Api.Reports.ReportsService class. </summary>
/// <param name="userManager"> Manager for user. </param>
@ -38,24 +38,15 @@ namespace Jellyfin.Plugin.Reports.Api
_activityManager = activityManager;
}
#endregion
#region [Private Fields]
private readonly IActivityManager _activityManager; ///< Manager for activity
private readonly IActivityManager _activityManager;
/// <summary> Manager for library. </summary>
private readonly ILibraryManager _libraryManager; ///< Manager for library
/// <summary> The localization. </summary>
private readonly ILibraryManager _libraryManager;
private readonly ILocalizationManager _localization; ///< The localization
private readonly ILocalizationManager _localization;
/// <summary> Manager for user. </summary>
private readonly IUserManager _userManager; ///< Manager for user
#endregion
#region [Public Methods]
private readonly IUserManager _userManager;
/// <summary> Gets the given request. </summary>
/// <param name="request"> The request. </param>
@ -92,7 +83,6 @@ namespace Jellyfin.Plugin.Reports.Api
}
return result;
}
/// <summary> Gets the given request. </summary>
@ -135,7 +125,7 @@ namespace Jellyfin.Plugin.Reports.Api
}
var filename = "ReportExport." + fileExtension;
headers["Content-Disposition"] = string.Format("attachment; filename=\"{0}\"", filename);
headers["Content-Disposition"] = string.Format(CultureInfo.InvariantCulture, "attachment; filename=\"{0}\"", filename);
headers["Content-Encoding"] = "UTF-8";
var user = !string.IsNullOrWhiteSpace(request.UserId) ? _userManager.GetUserById(new Guid(request.UserId)) : null;
@ -168,8 +158,6 @@ namespace Jellyfin.Plugin.Reports.Api
return (returnResult, contentType, headers);
}
#endregion
private InternalItemsQuery GetItemsQuery(BaseReportRequest request, User user)
{
var query = new InternalItemsQuery(user)
@ -396,8 +384,6 @@ namespace Jellyfin.Plugin.Reports.Api
};
}
#region [Private Methods]
/// <summary> Gets report activities. </summary>
/// <param name="request"> The request. </param>
/// <returns> The report activities. </returns>
@ -428,8 +414,5 @@ namespace Jellyfin.Plugin.Reports.Api
return reportResult;
}
#endregion
}
}

View File

@ -5,6 +5,13 @@
<AssemblyVersion>12.0.0.0</AssemblyVersion>
<FileVersion>12.0.0.0</FileVersion>
<RootNamespace>Jellyfin.Plugin.Reports</RootNamespace>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<CodeAnalysisRuleSet>../jellyfin.ruleset</CodeAnalysisRuleSet>
<Nullable>enable</Nullable>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<AnalysisMode>Recommended</AnalysisMode>
</PropertyGroup>
<ItemGroup>

View File

@ -17,17 +17,11 @@ namespace Jellyfin.Plugin.Reports
public override string Name => "Reports";
public override string Description
=> "Generate Reports";
public override string Description => "Generate Reports";
public PluginConfiguration PluginConfiguration => Configuration;
private Guid _id = new Guid("d4312cd9-5c90-4f38-82e8-51da566790e8");
public override Guid Id
{
get { return _id; }
}
public override Guid Id { get; } = new Guid("d4312cd9-5c90-4f38-82e8-51da566790e8");
public IEnumerable<PluginPageInfo> GetPages()
{

144
jellyfin.ruleset Normal file
View File

@ -0,0 +1,144 @@
<?xml version="1.0" encoding="utf-8"?>
<RuleSet Name="Rules for Jellyfin.Server" Description="Code analysis rules for Jellyfin.Server.csproj" ToolsVersion="14.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<!-- error on SA1000: The keyword 'new' should be followed by a space -->
<Rule Id="SA1000" Action="Error" />
<!-- error on SA1001: Commas should not be preceded by whitespace -->
<Rule Id="SA1001" Action="Error" />
<!-- error on SA1117: The parameters should all be placed on the same line or each parameter should be placed on its own line -->
<Rule Id="SA1117" Action="Error" />
<!-- error on SA1142: Refer to tuple fields by name -->
<Rule Id="SA1142" Action="Error" />
<!-- error on SA1210: Using directives should be ordered alphabetically by the namespaces -->
<Rule Id="SA1210" Action="Error" />
<!-- error on SA1316: Tuple element names should use correct casing -->
<Rule Id="SA1316" Action="Error" />
<!-- error on SA1414: Tuple types in signatures should have element names -->
<Rule Id="SA1414" Action="Error" />
<!-- error on SA1518: File is required to end with a single newline character -->
<Rule Id="SA1518" Action="Error" />
<!-- error on SA1629: Documentation text should end with a period -->
<Rule Id="SA1629" Action="Error" />
<!-- disable warning SA1009: Closing parenthesis should be followed by a space. -->
<Rule Id="SA1009" Action="None" />
<!-- disable warning SA1011: Closing square bracket should be followed by a space. -->
<Rule Id="SA1011" Action="None" />
<!-- disable warning SA1101: Prefix local calls with 'this.' -->
<Rule Id="SA1101" Action="None" />
<!-- disable warning SA1108: Block statements should not contain embedded comments -->
<Rule Id="SA1108" Action="None" />
<!-- disable warning SA1118: Parameter must not span multiple lines. -->
<Rule Id="SA1118" Action="None" />
<!-- disable warning SA1128:: Put constructor initializers on their own line -->
<Rule Id="SA1128" Action="None" />
<!-- disable warning SA1130: Use lambda syntax -->
<Rule Id="SA1130" Action="None" />
<!-- disable warning SA1200: 'using' directive must appear within a namespace declaration -->
<Rule Id="SA1200" Action="None" />
<!-- disable warning SA1202: 'public' members must come before 'private' members -->
<Rule Id="SA1202" Action="None" />
<!-- disable warning SA1204: Static members must appear before non-static members -->
<Rule Id="SA1204" Action="None" />
<!-- disable warning SA1309: Fields must not begin with an underscore -->
<Rule Id="SA1309" Action="None" />
<!-- disable warning SA1413: Use trailing comma in multi-line initializers -->
<Rule Id="SA1413" Action="None" />
<!-- disable warning SA1512: Single-line comments must not be followed by blank line -->
<Rule Id="SA1512" Action="None" />
<!-- disable warning SA1515: Single-line comment should be preceded by blank line -->
<Rule Id="SA1515" Action="None" />
<!-- disable warning SA1600: Elements should be documented -->
<Rule Id="SA1600" Action="None" />
<!-- disable warning SA1602: Enumeration items should be documented -->
<Rule Id="SA1602" Action="None" />
<!-- disable warning SA1633: The file header is missing or not located at the top of the file -->
<Rule Id="SA1633" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.NetAnalyzers" RuleNamespace="Microsoft.Design">
<!-- error on CA1063: Implement IDisposable correctly -->
<Rule Id="CA1063" Action="Error" />
<!-- error on CA1305: Specify IFormatProvider -->
<Rule Id="CA1305" Action="Error" />
<!-- error on CA1307: Specify StringComparison for clarity -->
<Rule Id="CA1307" Action="Error" />
<!-- error on CA1309: Use ordinal StringComparison -->
<Rule Id="CA1309" Action="Error" />
<!-- error on CA1725: Parameter names should match base declaration -->
<Rule Id="CA1725" Action="Error" />
<!-- error on CA1725: Call async methods when in an async method -->
<Rule Id="CA1727" Action="Error" />
<!-- error on CA1813: Avoid unsealed attributes -->
<Rule Id="CA1813" Action="Error" />
<!-- error on CA1843: Do not use 'WaitAll' with a single task -->
<Rule Id="CA1843" Action="Error" />
<!-- error on CA1845: Use span-based 'string.Concat' -->
<Rule Id="CA1845" Action="Error" />
<!-- error on CA1849: Call async methods when in an async method -->
<Rule Id="CA1849" Action="Error" />
<!-- error on CA2016: Forward the CancellationToken parameter to methods that take one
or pass in 'CancellationToken.None' explicitly to indicate intentionally not propagating the token -->
<Rule Id="CA2016" Action="Error" />
<!-- error on CA2254: Template should be a static expression -->
<Rule Id="CA2254" Action="Error" />
<!-- disable warning CA1014: Mark assemblies with CLSCompliantAttribute -->
<Rule Id="CA1014" Action="Info" />
<!-- disable warning CA1024: Use properties where appropriate -->
<Rule Id="CA1024" Action="Info" />
<!-- disable warning CA1031: Do not catch general exception types -->
<Rule Id="CA1031" Action="Info" />
<!-- disable warning CA1032: Implement standard exception constructors -->
<Rule Id="CA1032" Action="Info" />
<!-- disable warning CA1040: Avoid empty interfaces -->
<Rule Id="CA1040" Action="Info" />
<!-- disable warning CA1062: Validate arguments of public methods -->
<Rule Id="CA1062" Action="Info" />
<!-- TODO: enable when false positives are fixed -->
<!-- disable warning CA1508: Avoid dead conditional code -->
<Rule Id="CA1508" Action="Info" />
<!-- disable warning CA1716: Identifiers should not match keywords -->
<Rule Id="CA1716" Action="Info" />
<!-- disable warning CA1720: Identifiers should not contain type names -->
<Rule Id="CA1720" Action="Info" />
<!-- disable warning CA1724: Type names should not match namespaces -->
<Rule Id="CA1724" Action="Info" />
<!-- disable warning CA1805: Do not initialize unnecessarily -->
<Rule Id="CA1805" Action="Info" />
<!-- disable warning CA1812: internal class that is apparently never instantiated.
If so, remove the code from the assembly.
If this class is intended to contain only static members, make it static -->
<Rule Id="CA1812" Action="Info" />
<!-- disable warning CA1822: Member does not access instance data and can be marked as static -->
<Rule Id="CA1822" Action="Info" />
<!-- disable warning CA2000: Dispose objects before losing scope -->
<Rule Id="CA2000" Action="Info" />
<!-- disable warning CA2253: Named placeholders should not be numeric values -->
<Rule Id="CA2253" Action="Info" />
<!-- disable warning CA5394: Do not use insecure randomness -->
<Rule Id="CA5394" Action="Info" />
<!-- disable warning CA1054: Change the type of parameter url from string to System.Uri -->
<Rule Id="CA1054" Action="None" />
<!-- disable warning CA1055: URI return values should not be strings -->
<Rule Id="CA1055" Action="None" />
<!-- disable warning CA1056: URI properties should not be strings -->
<Rule Id="CA1056" Action="None" />
<!-- disable warning CA1303: Do not pass literals as localized parameters -->
<Rule Id="CA1303" Action="None" />
<!-- disable warning CA1308: Normalize strings to uppercase -->
<Rule Id="CA1308" Action="None" />
<!-- disable warning CA1848: Use the LoggerMessage delegates -->
<Rule Id="CA1848" Action="None" />
<!-- disable warning CA2101: Specify marshaling for P/Invoke string arguments -->
<Rule Id="CA2101" Action="None" />
<!-- disable warning CA2234: Pass System.Uri objects instead of strings -->
<Rule Id="CA2234" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.CodeAnalysis.BannedApiAnalyzers" RuleNamespace="Microsoft.Design">
<!-- error on RS0030: Do not used banned APIs -->
<Rule Id="RS0030" Action="Error" />
</Rules>
</RuleSet>