content stringlengths 5 1.04M | avg_line_length float64 1.75 12.9k | max_line_length int64 2 244k | alphanum_fraction float64 0 0.98 | licenses list | repository_name stringlengths 7 92 | path stringlengths 3 249 | size int64 5 1.04M | lang stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|
using System;
namespace RandomchaosMGShaderPlayground
{
public static class Program
{
[STAThread]
static void Main()
{
using (var game = new Game1())
game.Run();
}
}
}
| 16.133333 | 42 | 0.508264 | [
"MIT"
] | Lajbert/Randomchaos-MonoGame-Samples | Sandboxs/RandomchaosMGShaderPlaygroundCore/Program.cs | 244 | C# |
using System.Collections.Generic;
namespace PersonalPortfolio.Shared.Storage
{
public class Currency: Entity
{
public string Code { get; set; }
public string Description { get; set; }
public ICollection<CurrencyRate> Rates { get; set; }
}
}
| 24.166667 | 61 | 0.634483 | [
"MIT"
] | DarthKurt/PersonalPortfolio | PersonalPortfolio.Shared.Storage/Currency.cs | 292 | C# |
namespace Luminous.Code.VisualStudio.Commands
{
public enum CommandStatuses
{
Unknown,
Success,
Problem,
Cancelled,
Information
}
} | 16.727273 | 46 | 0.581522 | [
"MIT"
] | luminous-software/luminous-code | src/vs/Commands/CommandStatuses.cs | 186 | C# |
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Xml;
using AniDBAPI;
using NLog;
using Shoko.Models.Azure;
using Shoko.Models.Enums;
using Shoko.Models.Metro;
using Shoko.Models.PlexAndKodi;
using Shoko.Models.Server;
using Shoko.Models.TvDB;
using Shoko.Server.AniDB_API.Raws;
using Shoko.Server.LZ4;
using Shoko.Server.Models;
using Shoko.Server.Providers.MovieDB;
using Shoko.Server.Providers.TraktTV.Contracts;
using Shoko.Server.Repositories;
using TvDbSharper.Dto;
namespace Shoko.Server.Extensions
{
public static class ModelProviders
{
private static Logger logger = LogManager.GetCurrentClassLogger();
public static Azure_CrossRef_AniDB_Other_Request ToRequest(this CrossRef_AniDB_Other c)
{
return new Azure_CrossRef_AniDB_Other_Request
{
CrossRef_AniDB_OtherID = c.CrossRef_AniDB_OtherID,
AnimeID = c.AnimeID,
CrossRefID = c.CrossRefID,
CrossRefSource = c.CrossRefSource,
CrossRefType = c.CrossRefType,
};
}
public static Azure_FileHash_Request ToHashRequest(this AniDB_File anifile)
{
Azure_FileHash_Request r = new Azure_FileHash_Request
{
ED2K = anifile.Hash,
CRC32 = anifile.CRC,
MD5 = anifile.MD5,
SHA1 = anifile.SHA1,
FileSize = anifile.FileSize,
Username = Constants.AnonWebCacheUsername,
AuthGUID = string.Empty
};
return r;
}
public static Azure_FileHash_Request ToHashRequest(this SVR_VideoLocal vl)
{
Azure_FileHash_Request r = new Azure_FileHash_Request
{
ED2K = vl.Hash,
CRC32 = vl.CRC32,
MD5 = vl.MD5,
SHA1 = vl.SHA1,
FileSize = vl.FileSize,
Username = Constants.AnonWebCacheUsername,
AuthGUID = string.Empty
};
return r;
}
public static Media ToMedia(this Azure_Media m)
{
int size = (m.MediaInfo[0] << 24) | (m.MediaInfo[1] << 16) | (m.MediaInfo[2] << 8) | m.MediaInfo[3];
byte[] data = new byte[m.MediaInfo.Length - 4];
Array.Copy(m.MediaInfo, 4, data, 0, data.Length);
return CompressionHelper.DeserializeObject<Media>(data, size);
}
public static Azure_Media_Request ToMediaRequest(this SVR_VideoLocal v)
{
//Cleanup any File subtitles from media information.
Media m = new Media(v.VideoLocalID, v.Media);
if (m.Parts != null && m.Parts.Count > 0)
{
foreach (Part p in m.Parts)
{
if (p.Streams != null)
{
List<Stream> streams = p.Streams
.Where(a => a.StreamType == 3 && !string.IsNullOrEmpty(a.File))
.ToList();
if (streams.Count > 0)
streams.ForEach(a => p.Streams.Remove(a));
}
}
}
//Cleanup the VideoLocal id
byte[] data = CompressionHelper.SerializeObject(m, out int outsize);
m.Id = 0;
Azure_Media_Request r = new Azure_Media_Request
{
ED2K = v.ED2KHash,
Version = SVR_VideoLocal.MEDIA_VERSION,
Username = Constants.AnonWebCacheUsername,
AuthGUID = string.Empty,
MediaInfo = new byte[data.Length + 4]
};
r.MediaInfo[0] = (byte)(outsize >> 24);
r.MediaInfo[1] = (byte)((outsize >> 16) & 0xFF);
r.MediaInfo[2] = (byte)((outsize >> 8) & 0xFF);
r.MediaInfo[3] = (byte)(outsize & 0xFF);
Array.Copy(data, 0, r.MediaInfo, 4, data.Length);
return r;
}
public static Azure_Media_Request ToMediaRequest(this Media m, string ed2k)
{
byte[] data = CompressionHelper.SerializeObject(m, out int outsize);
Azure_Media_Request r = new Azure_Media_Request
{
ED2K = ed2k,
MediaInfo = new byte[data.Length + 4],
Version = SVR_VideoLocal.MEDIA_VERSION,
Username = Constants.AnonWebCacheUsername,
AuthGUID = string.Empty
};
r.MediaInfo[0] = (byte)(outsize >> 24);
r.MediaInfo[1] = (byte)((outsize >> 16) & 0xFF);
r.MediaInfo[2] = (byte)((outsize >> 8) & 0xFF);
r.MediaInfo[3] = (byte)(outsize & 0xFF);
Array.Copy(data, 0, r.MediaInfo, 4, data.Length);
return r;
}
public static Azure_CrossRef_AniDB_Trakt_Request ToRequest(this CrossRef_AniDB_TraktV2 xref, string animeName)
{
Azure_CrossRef_AniDB_Trakt_Request r = new Azure_CrossRef_AniDB_Trakt_Request
{
AnimeID = xref.AnimeID,
AnimeName = animeName,
AniDBStartEpisodeType = xref.AniDBStartEpisodeType,
AniDBStartEpisodeNumber = xref.AniDBStartEpisodeNumber,
TraktID = xref.TraktID,
TraktSeasonNumber = xref.TraktSeasonNumber,
TraktStartEpisodeNumber = xref.TraktStartEpisodeNumber,
TraktTitle = xref.TraktTitle,
CrossRefSource = xref.CrossRefSource,
Username = Constants.AnonWebCacheUsername,
AuthGUID = string.Empty
};
return r;
}
public static Azure_CrossRef_AniDB_TvDB_Request ToRequest(this CrossRef_AniDB_TvDBV2 xref, string animeName)
{
Azure_CrossRef_AniDB_TvDB_Request r = new Azure_CrossRef_AniDB_TvDB_Request
{
AnimeID = xref.AnimeID,
AnimeName = animeName,
AniDBStartEpisodeType = xref.AniDBStartEpisodeType,
AniDBStartEpisodeNumber = xref.AniDBStartEpisodeNumber,
TvDBID = xref.TvDBID,
TvDBSeasonNumber = xref.TvDBSeasonNumber,
TvDBStartEpisodeNumber = xref.TvDBStartEpisodeNumber,
TvDBTitle = xref.TvDBTitle,
CrossRefSource = xref.CrossRefSource,
Username = Constants.AnonWebCacheUsername,
AuthGUID = string.Empty
};
return r;
}
public static Azure_CrossRef_File_Episode_Request ToRequest(this CrossRef_File_Episode xref)
{
Azure_CrossRef_File_Episode_Request r = new Azure_CrossRef_File_Episode_Request
{
Hash = xref.Hash,
AnimeID = xref.AnimeID,
EpisodeID = xref.EpisodeID,
Percentage = xref.Percentage,
EpisodeOrder = xref.EpisodeOrder,
Username = Constants.AnonWebCacheUsername,
};
return r;
}
public static FileNameHash ToFileNameHash(this CrossRef_File_Episode cfe)
{
return new FileNameHash
{
FileName = cfe.FileName,
FileSize = cfe.FileSize,
Hash = cfe.Hash,
DateTimeUpdated = DateTime.Now,
};
}
public static void Populate(this MovieDB_Fanart m, MovieDB_Image_Result result, int movieID)
{
m.MovieId = movieID;
m.ImageID = result.ImageID;
m.ImageType = result.ImageType;
m.ImageSize = result.ImageSize;
m.ImageWidth = result.ImageWidth;
m.ImageHeight = result.ImageHeight;
m.Enabled = 1;
}
public static void Populate(this MovieDB_Movie m, MovieDB_Movie_Result result)
{
m.MovieId = result.MovieID;
m.MovieName = result.MovieName;
m.OriginalName = result.OriginalName;
m.Overview = result.Overview;
m.Rating = (int) Math.Round(result.Rating * 10D);
}
public static void Populate(this MovieDB_Poster m, MovieDB_Image_Result result, int movieID)
{
m.MovieId = movieID;
m.ImageID = result.ImageID;
m.ImageType = result.ImageType;
m.ImageSize = result.ImageSize;
m.URL = result.URL;
m.ImageWidth = result.ImageWidth;
m.ImageHeight = result.ImageHeight;
m.Enabled = 1;
}
public static void Populate(this Trakt_Friend friend, TraktV2User user)
{
friend.Username = user.username;
friend.FullName = user.name;
friend.LastAvatarUpdate = DateTime.Now;
}
public static void Populate(this Trakt_Show show, TraktV2ShowExtended tvshow)
{
show.Overview = tvshow.overview;
show.Title = tvshow.title;
show.TraktID = tvshow.ids.slug;
show.TvDB_ID = tvshow.ids.tvdb;
show.URL = tvshow.ShowURL;
show.Year = tvshow.year.ToString();
}
public static void Populate(this Trakt_Show show, TraktV2Show tvshow)
{
show.Overview = tvshow.Overview;
show.Title = tvshow.Title;
show.TraktID = tvshow.ids.slug;
show.TvDB_ID = tvshow.ids.tvdb;
show.URL = tvshow.ShowURL;
show.Year = tvshow.Year.ToString();
}
public static void Populate(this TvDB_Episode episode, EpisodeRecord apiEpisode)
{
episode.Id = apiEpisode.Id;
episode.SeriesID =apiEpisode.SeriesId;
episode.SeasonID = 0;
episode.SeasonNumber = apiEpisode.AiredSeason ?? 0;
episode.EpisodeNumber = apiEpisode.AiredEpisodeNumber ?? 0;
int flag = 0;
if (apiEpisode.Filename != string.Empty)
flag = 1;
episode.EpImgFlag = flag;
episode.AbsoluteNumber = apiEpisode.AbsoluteNumber ?? 0;
episode.EpisodeName = apiEpisode.EpisodeName ?? string.Empty;
episode.Overview = apiEpisode.Overview;
episode.Filename = apiEpisode.Filename ?? string.Empty;
episode.AirsAfterSeason = apiEpisode.AirsAfterSeason;
episode.AirsBeforeEpisode = apiEpisode.AirsBeforeEpisode;
episode.AirsBeforeSeason = apiEpisode.AirsBeforeSeason;
if (apiEpisode.SiteRating != null) episode.Rating = (int) Math.Round(apiEpisode.SiteRating.Value);
if (!string.IsNullOrEmpty(apiEpisode.FirstAired))
{
episode.AirDate = DateTime.ParseExact(apiEpisode.FirstAired, "yyyy-MM-dd", DateTimeFormatInfo.InvariantInfo);
}
}
private static string TryGetProperty(XmlNode node, string propertyName)
{
try
{
string prop = node[propertyName].InnerText.Trim();
return prop;
}
catch
{
//logger.Error( ex,"Error in TvDB_Episode.TryGetProperty: " + ex.ToString());
}
return string.Empty;
}
private static string TryGetEpisodeProperty(XmlDocument doc, string propertyName)
{
try
{
string prop = doc["Data"]["Episode"][propertyName].InnerText.Trim();
return prop;
}
catch (Exception ex)
{
logger.Error(ex, "Error in TvDB_Episode.TryGetProperty: " + ex);
}
return string.Empty;
}
private static string TryGetSeriesProperty(XmlDocument doc, string propertyName)
{
try
{
string prop = doc["Data"]["Series"][propertyName].InnerText.Trim();
return prop;
}
catch (Exception ex)
{
logger.Error(ex, "Error in TvDB_Series.TryGetProperty: " + ex);
}
return string.Empty;
}
[Obsolete("Populate XmlNode is deprecated, please use Populate TvDbSharper.Series.Image instead.")]
public static bool Populate(this TvDB_ImageFanart fanart, int seriesID, XmlNode node)
{
try
{
fanart.SeriesID = seriesID;
fanart.Id = int.Parse(node["id"].InnerText);
fanart.BannerPath = node["BannerPath"].InnerText;
fanart.BannerType = node["BannerType"].InnerText;
fanart.BannerType2 = node["BannerType2"].InnerText;
fanart.Colors = node["Colors"].InnerText;
fanart.Language = node["Language"].InnerText;
fanart.VignettePath = node["VignettePath"].InnerText;
return true;
}
catch (Exception ex)
{
logger.Error(ex, "Error in TvDB_ImageFanart.Init: " + ex);
return false;
}
}
public static bool Populate(this TvDB_ImageFanart fanart, int seriesID, Image image)
{
try
{
fanart.SeriesID = seriesID;
fanart.Id = image.Id;
fanart.BannerPath = image.FileName;
fanart.BannerType2 = image.Resolution;
fanart.Colors = string.Empty;
fanart.VignettePath = string.Empty;
return true;
}
catch (Exception ex)
{
logger.Error(ex, "Error in TvDB_ImageFanart.Init: " + ex);
return false;
}
}
public static bool Populate(this TvDB_ImagePoster poster, int seriesID, Image image)
{
try
{
poster.SeriesID = seriesID;
poster.SeasonNumber = null;
poster.Id = image.Id;
poster.BannerPath = image.FileName;
poster.BannerType = image.KeyType;
poster.BannerType2 = image.Resolution;
return true;
}
catch (Exception ex)
{
logger.Error(ex, "Error in TvDB_ImagePoster.Populate: " + ex);
return false;
}
}
public static bool Populate(this TvDB_ImageWideBanner poster, int seriesID, Image image)
{
try
{
poster.SeriesID = seriesID;
try
{
poster.SeasonNumber = int.Parse(image.SubKey);
}
catch (FormatException)
{
poster.SeasonNumber = null;
}
poster.Id = image.Id;
poster.BannerPath = image.FileName;
poster.BannerType = image.KeyType;
poster.BannerType2 = image.Resolution;
return true;
}
catch (Exception ex)
{
logger.Error(ex, "Error in TvDB_ImageWideBanner.Populate: " + ex);
return false;
}
}
public static void PopulateFromSearch(this TvDB_Series series, XmlDocument doc)
{
series.SeriesID = 0;
series.Overview = string.Empty;
series.SeriesName = string.Empty;
series.Status = string.Empty;
series.Banner = string.Empty;
series.Fanart = string.Empty;
series.Lastupdated = string.Empty;
series.Poster = string.Empty;
series.SeriesID = int.Parse(TryGetSeriesProperty(doc, "seriesid"));
series.SeriesName = TryGetSeriesProperty(doc, "SeriesName");
series.Overview = TryGetSeriesProperty(doc, "Overview");
series.Banner = TryGetSeriesProperty(doc, "banner");
}
[Obsolete("PopulateFromSeriesInfo XmlDocument is deprecated, please use PopulateFromSeriesInfo TvDbSharper.Series instead.")]
public static void PopulateFromSeriesInfo(this TvDB_Series series, XmlDocument doc)
{
series.SeriesID = 0;
series.Overview = string.Empty;
series.SeriesName = string.Empty;
series.Status = string.Empty;
series.Banner = string.Empty;
series.Fanart = string.Empty;
series.Lastupdated = string.Empty;
series.Poster = string.Empty;
series.SeriesID = int.Parse(TryGetSeriesProperty(doc, "id"));
series.SeriesName = TryGetSeriesProperty(doc, "SeriesName");
series.Overview = TryGetSeriesProperty(doc, "Overview");
series.Banner = TryGetSeriesProperty(doc, "banner");
series.Status = TryGetSeriesProperty(doc, "Status");
series.Fanart = TryGetSeriesProperty(doc, "fanart");
series.Lastupdated = TryGetSeriesProperty(doc, "lastupdated");
series.Poster = TryGetSeriesProperty(doc, "poster");
}
public static void PopulateFromSeriesInfo(this TvDB_Series series, Series apiSeries)
{
series.SeriesID = 0;
series.Overview = string.Empty;
series.SeriesName = string.Empty;
series.Status = string.Empty;
series.Banner = string.Empty;
series.Fanart = string.Empty;
series.Lastupdated = string.Empty;
series.Poster = string.Empty;
series.SeriesID = apiSeries.Id;
series.SeriesName = apiSeries.SeriesName;
series.Overview = apiSeries.Overview;
series.Banner = apiSeries.Banner;
series.Status = apiSeries.Status;
series.Lastupdated = apiSeries.LastUpdated.ToString();
if (apiSeries.SiteRating != null) series.Rating = (int) Math.Round(apiSeries.SiteRating.Value * 10);
}
[Obsolete("Populate XmlNode is deprecated, please use Populate TvDbSharper.SeriesSearchResult instead.")]
public static void Populate(this TVDB_Series_Search_Response response, XmlNode series)
{
response.Id = string.Empty;
response.SeriesID = 0;
response.Overview = string.Empty;
response.SeriesName = string.Empty;
response.Banner = string.Empty;
if (series["seriesid"] != null) response.SeriesID = int.Parse(series["seriesid"].InnerText);
if (series["SeriesName"] != null) response.SeriesName = series["SeriesName"].InnerText;
if (series["id"] != null) response.Id = series["id"].InnerText;
if (series["Overview"] != null) response.Overview = series["Overview"].InnerText;
if (series["banner"] != null) response.Banner = series["banner"].InnerText;
if (series["language"] != null) response.Language = series["language"].InnerText;
}
public static void Populate(this TVDB_Series_Search_Response response, SeriesSearchResult series)
{
response.Id = string.Empty;
response.SeriesID = series.Id;
response.SeriesName = series.SeriesName;
response.Overview = series.Overview;
response.Banner = series.Banner;
response.Language = string.Intern("en");
}
public static bool Populate(this AniDB_Anime_Character character, Raw_AniDB_Character rawChar)
{
if (rawChar == null) return false;
if (rawChar.AnimeID <= 0 || rawChar.CharID <= 0 || string.IsNullOrEmpty(rawChar.CharType)) return false;
character.CharID = rawChar.CharID;
character.AnimeID = rawChar.AnimeID;
character.CharType = rawChar.CharType;
character.EpisodeListRaw = rawChar.EpisodeListRaw;
return true;
}
public static bool Populate(this AniDB_Anime_Relation rel, Raw_AniDB_RelatedAnime rawRel)
{
if (rawRel == null) return false;
if (rawRel.AnimeID <= 0 || rawRel.RelatedAnimeID <= 0 || string.IsNullOrEmpty(rawRel.RelationType))
return false;
rel.AnimeID = rawRel.AnimeID;
rel.RelatedAnimeID = rawRel.RelatedAnimeID;
rel.RelationType = rawRel.RelationType;
return true;
}
public static bool Populate(this AniDB_Anime_Similar similar, Raw_AniDB_SimilarAnime rawSim)
{
if (rawSim == null) return false;
if (rawSim.AnimeID <= 0 || rawSim.Approval < 0 || rawSim.SimilarAnimeID <= 0 || rawSim.Total < 0)
return false;
similar.AnimeID = rawSim.AnimeID;
similar.Approval = rawSim.Approval;
similar.Total = rawSim.Total;
similar.SimilarAnimeID = rawSim.SimilarAnimeID;
return true;
}
public static bool Populate(this AniDB_Anime_Tag tag, Raw_AniDB_Tag rawTag)
{
if (rawTag == null) return false;
if (rawTag.AnimeID <= 0 || rawTag.TagID <= 0) return false;
tag.AnimeID = rawTag.AnimeID;
tag.TagID = rawTag.TagID;
tag.Approval = 100;
tag.Weight = rawTag.Weight;
return true;
}
public static bool Populate(this AniDB_Anime_Title title, Raw_AniDB_Anime_Title rawTitle)
{
if (rawTitle == null) return false;
if (rawTitle.AnimeID <= 0 || string.IsNullOrEmpty(rawTitle.Title) ||
string.IsNullOrEmpty(rawTitle.Language) || string.IsNullOrEmpty(rawTitle.TitleType)) return false;
title.AnimeID = rawTitle.AnimeID;
title.Language = rawTitle.Language;
title.Title = rawTitle.Title;
title.TitleType = rawTitle.TitleType;
return true;
}
private static bool Populate(this AniDB_Character character, Raw_AniDB_Character rawChar)
{
if (rawChar == null) return false;
if (rawChar.CharID <= 0 || string.IsNullOrEmpty(rawChar.CharName)) return false;
character.CharID = rawChar.CharID;
character.CharDescription = rawChar.CharDescription ?? string.Empty;
character.CharKanjiName = rawChar.CharKanjiName ?? string.Empty;
character.CharName = rawChar.CharName;
character.PicName = rawChar.PicName ?? string.Empty;
character.CreatorListRaw = rawChar.CreatorListRaw ?? string.Empty;
return true;
}
public static bool PopulateFromHTTP(this AniDB_Character character, Raw_AniDB_Character rawChar)
{
if (character.CharID != 0)
{
// only update the fields that come from HTTP API
if (string.IsNullOrEmpty(rawChar?.CharName)) return false;
character.CharDescription = rawChar.CharDescription ?? string.Empty;
character.CharName = rawChar.CharName;
character.CreatorListRaw = rawChar.CreatorListRaw ?? string.Empty;
character.PicName = rawChar.PicName ?? string.Empty;
return true;
}
//a new object
return character.Populate(rawChar);
}
public static bool PopulateFromUDP(this AniDB_Character character, Raw_AniDB_Character rawChar)
{
if (character.CharID != 0)
{
if (string.IsNullOrEmpty(rawChar?.CharKanjiName) || string.IsNullOrEmpty(rawChar.CharName))
return false;
// only update the fields that com from UDP API
character.CharKanjiName = rawChar.CharKanjiName;
character.CharName = rawChar.CharName;
//this.CreatorListRaw = rawChar.CreatorListRaw;
return true;
}
//a new object
return character.Populate(rawChar);
}
public static Metro_AniDB_Character ToContractMetro(this AniDB_Character character,
AniDB_Anime_Character charRel)
{
Metro_AniDB_Character contract = new Metro_AniDB_Character
{
AniDB_CharacterID = character.AniDB_CharacterID,
CharID = character.CharID,
CharName = character.CharName,
CharKanjiName = character.CharKanjiName,
CharDescription = character.CharDescription,
CharType = charRel.CharType,
ImageType = (int)ImageEntityType.AniDB_Character,
ImageID = character.AniDB_CharacterID
};
AniDB_Seiyuu seiyuu = character.GetSeiyuu();
if (seiyuu != null)
{
contract.SeiyuuID = seiyuu.AniDB_SeiyuuID;
contract.SeiyuuName = seiyuu.SeiyuuName;
contract.SeiyuuImageType = (int) ImageEntityType.AniDB_Creator;
contract.SeiyuuImageID = seiyuu.AniDB_SeiyuuID;
}
return contract;
}
public static Azure_AnimeCharacter ToContractAzure(this AniDB_Character character,
AniDB_Anime_Character charRel)
{
Azure_AnimeCharacter contract = new Azure_AnimeCharacter
{
CharID = character.CharID,
CharName = character.CharName,
CharKanjiName = character.CharKanjiName,
CharDescription = character.CharDescription,
CharType = charRel.CharType,
CharImageURL = string.Format(ShokoService.AnidbProcessor.ImageServerUrl, character.PicName)
};
AniDB_Seiyuu seiyuu = character.GetSeiyuu();
if (seiyuu != null)
{
contract.SeiyuuID = seiyuu.AniDB_SeiyuuID;
contract.SeiyuuName = seiyuu.SeiyuuName;
contract.SeiyuuImageURL = string.Format(ShokoService.AnidbProcessor.ImageServerUrl, seiyuu.PicName);
}
return contract;
}
public static void Populate(this AniDB_Episode episode, Raw_AniDB_Episode epInfo)
{
episode.AirDate = epInfo.AirDate;
episode.AnimeID = epInfo.AnimeID;
episode.DateTimeUpdated = DateTime.Now;
episode.EpisodeID = epInfo.EpisodeID;
episode.EpisodeNumber = epInfo.EpisodeNumber;
episode.EpisodeType = epInfo.EpisodeType;
episode.LengthSeconds = epInfo.LengthSeconds;
episode.Rating = epInfo.Rating.ToString(CultureInfo.InvariantCulture);
episode.Votes = epInfo.Votes.ToString(CultureInfo.InvariantCulture);
episode.Description = epInfo.Description ?? string.Empty;
}
public static void Populate(this AniDB_GroupStatus grpstatus, Raw_AniDB_GroupStatus raw)
{
grpstatus.AnimeID = raw.AnimeID;
grpstatus.GroupID = raw.GroupID;
grpstatus.GroupName = raw.GroupName;
grpstatus.CompletionState = raw.CompletionState;
grpstatus.LastEpisodeNumber = raw.LastEpisodeNumber;
grpstatus.Rating = raw.Rating;
grpstatus.Votes = raw.Votes;
grpstatus.EpisodeRange = raw.EpisodeRange;
}
public static void Populate(this AniDB_MylistStats stats, Raw_AniDB_MyListStats raw)
{
stats.Animes = raw.Animes;
stats.Episodes = raw.Episodes;
stats.Files = raw.Files;
stats.SizeOfFiles = raw.SizeOfFiles;
stats.AddedAnimes = raw.AddedAnimes;
stats.AddedEpisodes = raw.AddedEpisodes;
stats.AddedFiles = raw.AddedFiles;
stats.AddedGroups = raw.AddedGroups;
stats.LeechPct = raw.LeechPct;
stats.GloryPct = raw.GloryPct;
stats.ViewedPct = raw.ViewedPct;
stats.MylistPct = raw.MylistPct;
stats.ViewedMylistPct = raw.ViewedMylistPct;
stats.EpisodesViewed = raw.EpisodesViewed;
stats.Votes = raw.Votes;
stats.Reviews = raw.Reviews;
stats.ViewiedLength = raw.ViewiedLength;
}
public static void Populate(this AniDB_Recommendation recommendation, Raw_AniDB_Recommendation rawRec)
{
recommendation.AnimeID = rawRec.AnimeID;
recommendation.UserID = rawRec.UserID;
recommendation.RecommendationText = rawRec.RecommendationText;
recommendation.RecommendationType = (int) AniDBRecommendationType.Recommended;
if (rawRec.RecommendationTypeText.Equals("recommended", StringComparison.InvariantCultureIgnoreCase))
recommendation.RecommendationType = (int) AniDBRecommendationType.Recommended;
if (rawRec.RecommendationTypeText.Equals("for fans", StringComparison.InvariantCultureIgnoreCase))
recommendation.RecommendationType = (int) AniDBRecommendationType.ForFans;
if (rawRec.RecommendationTypeText.Equals("must see", StringComparison.InvariantCultureIgnoreCase))
recommendation.RecommendationType = (int) AniDBRecommendationType.MustSee;
}
public static void Populate(this AniDB_ReleaseGroup releasegroup, Raw_AniDB_Group raw)
{
releasegroup.GroupID = raw.GroupID;
releasegroup.Rating = raw.Rating;
releasegroup.Votes = raw.Votes;
releasegroup.AnimeCount = raw.AnimeCount;
releasegroup.FileCount = raw.FileCount;
releasegroup.GroupName = raw.GroupName;
releasegroup.GroupNameShort = raw.GroupNameShort;
releasegroup.IRCChannel = raw.IRCChannel;
releasegroup.IRCServer = raw.IRCServer;
releasegroup.URL = raw.URL;
releasegroup.Picname = raw.Picname;
}
public static void Populate(this AniDB_Review review, Raw_AniDB_Review rawReview)
{
review.ReviewID = rawReview.ReviewID;
review.AuthorID = rawReview.AuthorID;
review.RatingAnimation = rawReview.RatingAnimation;
review.RatingSound = rawReview.RatingSound;
review.RatingStory = rawReview.RatingStory;
review.RatingCharacter = rawReview.RatingCharacter;
review.RatingValue = rawReview.RatingValue;
review.RatingEnjoyment = rawReview.RatingEnjoyment;
review.ReviewText = rawReview.ReviewText;
}
public static bool Populate(this AniDB_Tag tag, Raw_AniDB_Tag rawTag)
{
if (rawTag == null) return false;
if (rawTag.TagID <= 0 || string.IsNullOrEmpty(rawTag.TagName)) return false;
tag.TagID = rawTag.TagID;
tag.GlobalSpoiler = rawTag.GlobalSpoiler;
tag.LocalSpoiler = rawTag.LocalSpoiler;
tag.Spoiler = 0;
tag.TagCount = 0;
tag.TagDescription = rawTag.TagDescription ?? string.Empty;
tag.TagName = rawTag.TagName;
return true;
}
public static void PopulateManually(this CrossRef_File_Episode cross, SVR_VideoLocal vid, SVR_AnimeEpisode ep)
{
cross.Hash = vid.ED2KHash;
cross.FileName = vid.FileName;
cross.FileSize = vid.FileSize;
cross.CrossRefSource = (int) CrossRefSource.User;
cross.AnimeID = ep.GetAnimeSeries().AniDB_ID;
cross.EpisodeID = ep.AniDB_EpisodeID;
cross.Percentage = 100;
cross.EpisodeOrder = 1;
}
public static void Populate(this SVR_AnimeGroup agroup, SVR_AnimeSeries series)
{
agroup.Populate(series, DateTime.Now);
}
public static void Populate(this SVR_AnimeGroup agroup, SVR_AnimeSeries series, DateTime now)
{
SVR_AniDB_Anime anime = series.GetAnime();
agroup.Description = anime.Description;
string name = series.GetSeriesName();
agroup.GroupName = name;
agroup.SortName = name;
agroup.DateTimeUpdated = now;
agroup.DateTimeCreated = now;
}
public static void Populate(this SVR_AnimeGroup agroup, SVR_AniDB_Anime anime, DateTime now)
{
agroup.Description = anime.Description;
string name = anime.GetFormattedTitle();
agroup.GroupName = name;
agroup.SortName = name;
agroup.DateTimeUpdated = now;
agroup.DateTimeCreated = now;
}
public static void Populate(this SVR_AnimeEpisode animeep, AniDB_Episode anidbEp)
{
animeep.AniDB_EpisodeID = anidbEp.EpisodeID;
animeep.DateTimeUpdated = DateTime.Now;
animeep.DateTimeCreated = DateTime.Now;
}
public static CrossRef_AniDB_TvDBV2 ToV2Model(this CrossRef_AniDB_TvDB xref)
{
return new CrossRef_AniDB_TvDBV2
{
AnimeID = xref.AniDBID,
CrossRefSource = (int) xref.CrossRefSource,
TvDBID = xref.TvDBID
};
}
public static (int season, int episodeNumber) GetNextEpisode(this TvDB_Episode ep)
{
if (ep == null) return (0, 0);
int epsInSeason = RepoFactory.TvDB_Episode.GetNumberOfEpisodesForSeason(ep.SeriesID, ep.SeasonNumber);
if (ep.EpisodeNumber == epsInSeason)
{
int numberOfSeasons = RepoFactory.TvDB_Episode.getLastSeasonForSeries(ep.SeriesID);
if (ep.SeasonNumber == numberOfSeasons) return (0, 0);
return (ep.SeasonNumber + 1, 1);
}
return (ep.SeasonNumber, ep.EpisodeNumber + 1);
}
public static (int season, int episodeNumber) GetPreviousEpisode(this TvDB_Episode ep)
{
// check bounds and exit
if (ep.SeasonNumber == 1 && ep.EpisodeNumber == 1) return (0, 0);
// self explanatory
if (ep.EpisodeNumber > 1) return (ep.SeasonNumber, ep.EpisodeNumber - 1);
// episode number is 1
// get the last episode of last season
int epsInSeason = RepoFactory.TvDB_Episode.GetNumberOfEpisodesForSeason(ep.SeriesID, ep.SeasonNumber - 1);
return (ep.SeasonNumber - 1, epsInSeason);
}
public static int GetAbsoluteEpisodeNumber(this TvDB_Episode ep)
{
if (ep.SeasonNumber == 1 || ep.SeasonNumber == 0) return ep.EpisodeNumber;
int number = ep.EpisodeNumber;
for (int season = 1; season < RepoFactory.TvDB_Episode.getLastSeasonForSeries(ep.SeriesID); season++)
number += RepoFactory.TvDB_Episode.GetNumberOfEpisodesForSeason(ep.SeriesID, ep.SeasonNumber);
return number;
}
}
}
| 40.40046 | 133 | 0.58209 | [
"MIT"
] | EraYaN/ShokoServer | Shoko.Server/Extensions/ModelProviders.cs | 35,110 | C# |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DtoGenerator.Logic.UI
{
public abstract class ViewModelBase : INotifyPropertyChanged
{
protected void InvokePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
| 25.904762 | 89 | 0.720588 | [
"MIT"
] | Aytekin/dto-generator | src/DtoGenerator/DtoGenerator.Logic/UI/ViewModelBase.cs | 546 | C# |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.EntityFrameworkCore.TestModels.InheritanceRelationshipsModel
{
public class NonEntityBase
{
public int Id { get; set; }
public string Name { get; set; }
public ReferencedEntity Reference { get; set; }
}
}
| 33.076923 | 111 | 0.706977 | [
"Apache-2.0"
] | belav/efcore | test/EFCore.Specification.Tests/TestModels/InheritanceRelationshipsModel/NonEntityBase.cs | 432 | C# |
using System;
using System.Windows.Forms;
namespace MessageSerializerClassFileCreator
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FormMain());
}
}
}
| 22.6 | 65 | 0.59292 | [
"MIT"
] | jacknino/MessageSerializer | MessageSerializerClassFileCreator/Program.cs | 454 | C# |
using System;
using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Graphics;
using Android.OS;
using Android.Support.V7.App;
using Android.Views;
using Android.Widget;
using DeepSound.Helpers.Utils;
using DeepSoundClient.Classes.Global;
using DeepSoundClient.Requests;
using Toolbar = Android.Support.V7.Widget.Toolbar;
namespace DeepSound.Activities.Default
{
[Activity(Icon = "@mipmap/icon", Theme = "@style/MyTheme", ConfigurationChanges = ConfigChanges.Locale | ConfigChanges.UiMode | ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class ForgotPasswordActivity : AppCompatActivity
{
#region Variables Basic
private Toolbar Toolbar;
private EditText EmailEditText;
private Button BtnSend;
private ProgressBar ProgressBar;
#endregion
#region General
protected override void OnCreate(Bundle savedInstanceState)
{
try
{
base.OnCreate(savedInstanceState);
// Create your application here
SetContentView(Resource.Layout.ForgotPasswordLayout);
//Get Value And Set Toolbar
InitComponent();
InitToolbar();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
protected override void OnResume()
{
try
{
base.OnResume();
AddOrRemoveEvent(true);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
protected override void OnPause()
{
try
{
base.OnPause();
AddOrRemoveEvent(false);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public override void OnTrimMemory(TrimMemory level)
{
try
{
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced);
base.OnTrimMemory(level);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
public override void OnLowMemory()
{
try
{
GC.Collect(GC.MaxGeneration);
base.OnLowMemory();
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
#endregion
#region Menu
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Android.Resource.Id.Home:
Finish();
return true;
}
return base.OnOptionsItemSelected(item);
}
#endregion
#region Functions
private void InitComponent()
{
try
{
EmailEditText = FindViewById<EditText>(Resource.Id.edt_email);
BtnSend = FindViewById<Button>(Resource.Id.SignInButton);
ProgressBar = FindViewById<ProgressBar>(Resource.Id.progressBar);
ProgressBar.Visibility = ViewStates.Gone;
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private void InitToolbar()
{
try
{
Toolbar = FindViewById<Toolbar>(Resource.Id.toolbar);
if (Toolbar != null)
{
Toolbar.Title = " ";
Toolbar.SetTitleTextColor(AppSettings.SetTabDarkTheme ? Color.White : Color.Black);
SetSupportActionBar(Toolbar);
SupportActionBar.SetDisplayShowCustomEnabled(true);
SupportActionBar.SetDisplayHomeAsUpEnabled(true);
SupportActionBar.SetHomeButtonEnabled(true);
SupportActionBar.SetDisplayShowHomeEnabled(true);
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
private void AddOrRemoveEvent(bool addEvent)
{
try
{
// true += // false -=
if (addEvent)
{
BtnSend.Click += BtnSendOnClick;
}
else
{
BtnSend.Click -= BtnSendOnClick;
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
#endregion
#region Events
//Send email
private async void BtnSendOnClick(object sender, EventArgs e)
{
try
{
if (!string.IsNullOrEmpty(EmailEditText.Text))
{
if (Methods.CheckConnectivity())
{
var check = Methods.FunString.IsEmailValid(EmailEditText.Text);
if (!check)
{
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_VerificationFailed), GetText(Resource.String.Lbl_IsEmailValid), GetText(Resource.String.Lbl_Ok));
}
else
{
ProgressBar.Visibility = ViewStates.Visible;
BtnSend.Visibility = ViewStates.Gone;
var (apiStatus, respond) = await RequestsAsync.Auth.ForgotPasswordAsync(EmailEditText.Text);
if (apiStatus == 200)
{
if (respond is MessageObject result)
{
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_VerificationFailed), result.Message, GetText(Resource.String.Lbl_Ok));
}
}
else if (apiStatus == 400)
{
if (respond is ErrorObject error)
{
string errorText = error.Error;
switch (errorText)
{
case "Please check your details":
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security), GetText(Resource.String.Lbl_ErrorPleaseCheckYourDetails), GetText(Resource.String.Lbl_Ok));
break;
case "This e-mail is not found":
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security), GetText(Resource.String.Lbl_ErrorForgotPassword2), GetText(Resource.String.Lbl_Ok));
break;
case "Error found while sending the reset link, please try again later":
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security), GetText(Resource.String.Lbl_ErrorForgotPassword3), GetText(Resource.String.Lbl_Ok));
break;
default:
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security), errorText, GetText(Resource.String.Lbl_Ok));
break;
}
}
ProgressBar.Visibility = ViewStates.Gone;
BtnSend.Visibility = ViewStates.Visible;
}
else if (apiStatus == 404)
{
ProgressBar.Visibility = ViewStates.Gone;
BtnSend.Visibility = ViewStates.Visible;
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_Security), GetText(Resource.String.Lbl_something_went_wrong), GetText(Resource.String.Lbl_Ok));
}
}
}
else
{
ProgressBar.Visibility = ViewStates.Gone;
BtnSend.Visibility = ViewStates.Visible;
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_VerificationFailed), GetText(Resource.String.Lbl_something_went_wrong), GetText(Resource.String.Lbl_Ok));
}
}
}
catch (Exception exception)
{
Console.WriteLine(exception);
ProgressBar.Visibility = ViewStates.Gone;
BtnSend.Visibility = ViewStates.Visible;
Methods.DialogPopup.InvokeAndShowDialog(this, GetText(Resource.String.Lbl_VerificationFailed), exception.ToString(), GetText(Resource.String.Lbl_Ok));
}
}
#endregion
}
} | 36.741313 | 220 | 0.477932 | [
"Apache-2.0"
] | dengzhicheng092/DeepSound | DeepSound/Activities/Default/ForgotPasswordActivity.cs | 9,518 | C# |
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
namespace VkApi.Wrapper.Objects
{
public class FriendsRequests
{
///<summary>
/// ID of the user by whom friend has been suggested
///</summary>
[JsonProperty("from")]
public String From { get; set; }
[JsonProperty("mutual")]
public FriendsRequestsMutual Mutual { get; set; }
///<summary>
/// User ID
///</summary>
[JsonProperty("user_id")]
public int UserId { get; set; }
}
} | 24.217391 | 60 | 0.576302 | [
"MIT"
] | FrediKats/VkLibrary | VkApi.Wrapper/Objects/Friends/FriendsRequests.cs | 557 | C# |
namespace SendGrid.Tests
{
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using Xunit;
public class LicenseTests
{
[Fact]
public void ShouldHaveCurrentYearInLicense()
{
var directoryInfo = new DirectoryInfo(Directory.GetCurrentDirectory());
var line = File.ReadLines(Path.Combine(directoryInfo.Parent.Parent.Parent.Parent.Parent.FullName, "LICENSE.txt")).Skip(2).Take(1).First();
Assert.Contains(DateTime.Now.Year.ToString(), line);
}
}
} | 29.052632 | 150 | 0.664855 | [
"MIT"
] | DarkFox/sendgrid-csharp | tests/SendGrid.Tests/LicenseTests.cs | 552 | C# |
// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
// ------------------------------------------------------------
#pragma warning disable CA1051 // Do not declare visible instance fields
namespace Microsoft.Azure.Cosmos.Serialization.HybridRow.Json
{
public readonly struct RowReaderJsonSettings
{
/// <summary>If non-null then child objects are indented by one copy of this string per level.</summary>
public readonly string IndentChars;
/// <summary>The quote character to use.</summary>
/// <remarks>May be <see cref="lang:\""/> or <see cref="'" />.</remarks>
public readonly char QuoteChar;
public RowReaderJsonSettings(string indentChars = " ", char quoteChar = '"')
{
this.IndentChars = indentChars;
this.QuoteChar = quoteChar;
}
}
}
| 36.92 | 112 | 0.562297 | [
"MIT"
] | microsoft/HybridRow | src/Serialization/HybridRow.Json/RowReaderJsonSettings.cs | 925 | C# |
//------------------------------------------------------------
// Author: 烟雨迷离半世殇
// Mail: 1778139321@qq.com
// Data: 2020年1月12日 16:08:44
//------------------------------------------------------------
using System;
using System.Collections.Generic;
using Animancer;
using ETModel.NKGMOBA.Battle.Fsm;
using ETModel.NKGMOBA.Battle.State;
using UnityEngine;
namespace ETModel
{
[ObjectSystem]
public class AnimationComponentAwakeSystem: AwakeSystem<AnimationComponent>
{
public override void Awake(AnimationComponent self)
{
self.AnimancerComponent = self.Parent.GameObject.GetComponent<AnimancerComponent>();
self.StackFsmComponent = self.Entity.GetComponent<StackFsmComponent>();
//如果是以Anim开头的key值,说明是动画文件,需要添加引用
foreach (var VARIABLE in self.Parent.GameObject.GetComponent<ReferenceCollector>().data)
{
if (VARIABLE.key.StartsWith("Anim"))
{
self.AnimationClips.Add(VARIABLE.key, VARIABLE.gameObject as AnimationClip);
}
}
self.PlayAnimByStackFsmCurrent();
}
}
/// <summary>
/// 基于Animancer插件做的动画机系统。配合可视化编辑使用效果更佳
/// 暂时只提供基本的跑,默认外部接口,技能动画的播放应该交给可视化编辑器来做
/// </summary>
public class AnimationComponent: Component
{
/// <summary>
/// Animacner的组件
/// </summary>
public AnimancerComponent AnimancerComponent;
/// <summary>
/// 栈式状态机组件,用于辅助切换动画
/// </summary>
public StackFsmComponent StackFsmComponent;
/// <summary>
/// 管理所有的动画文件
/// </summary>
public Dictionary<string, AnimationClip> AnimationClips = new Dictionary<string, AnimationClip>();
/// <summary>
/// 运行时所播放的动画文件,会动态变化
/// 例如移动速度快到一定程度将会播放另一种跑路动画,这时候就需要动态替换RuntimeAnimationClips的Run所对应的VALUE
/// KEY:外部调用的名称
/// VALEU:对应AnimationClips中的KEY,可以取得相应的动画文件
/// </summary>
public Dictionary<StateTypes, string> RuntimeAnimationClips = new Dictionary<StateTypes, string>
{
{ StateTypes.Run, "Anim_Run1" }, { StateTypes.Idle, "Anim_Idle1" }, { StateTypes.CommonAttack, "Anim_Attack1" }
};
/// <summary>
/// 播放一个动画,默认过渡时间为0.3s,如果在此期间再次播放,则会继续播放
/// </summary>
/// <param name="stateTypes"></param>
/// <param name="fadeDuration">动画过渡时间</param>
/// <returns></returns>
public AnimancerState PlayAnim(StateTypes stateTypes, float fadeDuration = 0.3f, float speed = 1.0f)
{
AnimancerState animancerState = AnimancerComponent.CrossFade(this.AnimationClips[RuntimeAnimationClips[stateTypes]], fadeDuration);
animancerState.Speed = speed;
return animancerState;
}
/// <summary>
/// 播放一个动画,默认过渡时间为0.3s,如果在此期间再次播放,则会从头开始
/// </summary>
/// <param name="stateTypes"></param>
/// <param name="fadeDuration">动画过渡时间</param>
/// <returns></returns>
public AnimancerState PlayAnimFromStart(StateTypes stateTypes, float fadeDuration = 0.3f, float speed = 1.0f)
{
AnimancerState animancerState = AnimancerComponent.CrossFadeFromStart(this.AnimationClips[RuntimeAnimationClips[stateTypes]], fadeDuration);
animancerState.Speed = speed;
return animancerState;
}
/// <summary>
/// 播放一个动画(播放完成自动回到默认动画)
/// </summary>
/// <param name="stateTypes"></param>
/// <returns></returns>
public void PlayAnimAndReturnIdel(StateTypes stateTypes, float fadeDuration = 0.3f, float speed = 1.0f)
{
PlayAnim(stateTypes, fadeDuration, speed).OnEnd = PlayIdel;
}
/// <summary>
/// 播放一个动画(播放完成自动回到默认动画),如果在此期间再次播放,则会从头开始
/// </summary>
/// <param name="stateTypes"></param>
/// <returns></returns>
public void PlayAnimAndReturnIdelFromStart(StateTypes stateTypes, float fadeDuration = 0.3f, float speed = 1.0f)
{
PlayAnimFromStart(stateTypes, fadeDuration, speed).OnEnd = PlayIdelFromStart;
}
/// <summary>
/// 播放跑路动画(非正式版)
/// </summary>
public void PlayRun()
{
if (this.AnimancerComponent.IsPlayingClip(this.AnimationClips[RuntimeAnimationClips[StateTypes.Idle]]))
AnimancerComponent.CrossFade(this.AnimationClips[RuntimeAnimationClips[StateTypes.Run]]);
}
/// <summary>
/// 播放默认动画(非正式版)
/// </summary>
public void PlayIdel()
{
AnimancerComponent.CrossFade(this.AnimationClips[RuntimeAnimationClips[StateTypes.Idle]]);
}
/// <summary>
/// 播放默认动画(非正式版),如果在此期间再次播放,则会从头开始
/// </summary>
public void PlayIdelFromStart()
{
AnimancerComponent.CrossFadeFromStart(this.AnimationClips[RuntimeAnimationClips[StateTypes.Idle]]);
}
/// <summary>
/// 根据栈式状态机来自动播放动画
/// </summary>
public void PlayAnimByStackFsmCurrent()
{
//Log.Info($"动画组件收到通知,当前状态{this.StackFsmComponent.GetCurrentFsmState().StateTypes}");
PlayAnim(this.StackFsmComponent.GetCurrentFsmState().StateTypes);
}
public override void Dispose()
{
if (this.IsDisposed)
{
return;
}
base.Dispose();
this.AnimancerComponent = null;
this.AnimationClips.Clear();
this.AnimationClips = null;
RuntimeAnimationClips.Clear();
this.RuntimeAnimationClips = null;
this.StackFsmComponent = null;
}
}
} | 35.109091 | 152 | 0.588124 | [
"MIT"
] | mosheepdev/NKGMobaBasedOnET | Unity/Assets/Model/NKGMOBA/Battle/Component/AnimationComponent.cs | 6,609 | C# |
/*
* Copyright 2014, 2015 Dominick Baier, Brock Allen
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using IdentityModel;
using IdentityServer3.Core.Extensions;
using IdentityServer3.Core.Models;
using IdentityServer3.Core.Services;
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
namespace IdentityServer3.Core.Validation
{
/// <summary>
/// Validates a secret based on the thumbprint of an X509 Certificate
/// </summary>
public class X509CertificateThumbprintSecretValidator : ISecretValidator
{
/// <summary>
/// Validates a secret
/// </summary>
/// <param name="secrets">The stored secrets.</param>
/// <param name="parsedSecret">The received secret.</param>
/// <returns>
/// A validation result
/// </returns>
/// <exception cref="System.ArgumentException">ParsedSecret.Credential is not an X509 Certificate</exception>
public Task<SecretValidationResult> ValidateAsync(IEnumerable<Secret> secrets, ParsedSecret parsedSecret)
{
var fail = Task.FromResult(new SecretValidationResult { Success = false });
var success = Task.FromResult(new SecretValidationResult { Success = true });
if (parsedSecret.Type != Constants.ParsedSecretTypes.X509Certificate)
{
return fail;
}
var cert = parsedSecret.Credential as X509Certificate2;
if (cert == null)
{
throw new ArgumentException("ParsedSecret.Credential is not an X509 Certificate");
}
var thumbprint = cert.Thumbprint;
foreach (var secret in secrets)
{
// check if client secret is still valid
if (secret.Expiration.HasExpired()) continue;
if (secret.Type == Constants.SecretTypes.X509CertificateThumbprint)
{
if (TimeConstantComparer.IsEqual(thumbprint.ToLowerInvariant(), secret.Value.ToLowerInvariant()))
{
return success;
}
}
}
return fail;
}
}
} | 35.820513 | 117 | 0.634574 | [
"Apache-2.0"
] | DecimusN7/IdentityServer3 | source/Core/Validation/X509CertificateThumbprintSecretValidator.cs | 2,796 | C# |
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using NuGet.Packaging;
namespace NuGet.Commands.Rules
{
/// <summary>
/// Warn if the version is not parsable by older nuget clients.
/// </summary>
/// <remarks>This rule should be removed once more users move to SemVer 2.0.0 capable clients.</remarks>
internal class LegacyVersionRule : IPackageRule
{
// NuGet 2.12 regex for version parsing.
private const string LegacyRegex = @"^(?<Version>\d+(\s*\.\s*\d+){0,3})(?<Release>-[a-z][0-9a-z-]*)?$";
public IEnumerable<PackageIssue> Validate(PackageBuilder builder)
{
var regex = new Regex(LegacyRegex, RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture);
if (!regex.IsMatch(builder.Version.ToFullString()))
{
yield return new PackageIssue(
AnalysisResources.LegacyVersionTitle,
string.Format(CultureInfo.CurrentCulture, AnalysisResources.LegacyVersionDescription, builder.Version.ToFullString()),
AnalysisResources.LegacyVersionSolution);
}
}
}
} | 39.866667 | 138 | 0.649666 | [
"Apache-2.0"
] | OctopusDeploy/NuGet.Client | src/NuGet.Core/NuGet.Commands/Rules/LegacyVersionRule.cs | 1,198 | C# |
using System;
using System.Collections;
using System.Web.UI.WebControls;
namespace EADPPROJ
{
public partial class bookShop : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
var button = (LinkButton)sender;
ListViewItem item = (ListViewItem)button.NamingContainer;
Label id = (Label)item.FindControl("Id");
int Id = Convert.ToInt32(id.Text);
if (Session["cart"] == null)
{
Hashtable ht = new Hashtable();
ht.Add(Id, 1);
Session["cart"] = ht;
Session["successCart"] = true;
Response.Redirect("./bookShop.aspx");
}
else
{
Hashtable ht = (Hashtable)Session["cart"];
if (ht.Contains(Id))
{
int count = Convert.ToInt32(ht[Id].ToString());
ht[Id] = count + 1;
Session["successCart"] = true;
Response.Redirect("./bookShop.aspx");
}
else
{
ht.Add(Id, 1);
Session["successCart"] = true;
Response.Redirect("./bookShop.aspx");
}
}
}
}
} | 30.510638 | 69 | 0.458856 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | NorthstarWang/Education-System-NYP | EADPPROJ/Shop/bookShop.aspx.cs | 1,436 | C# |
using Ship;
using Upgrade;
using UnityEngine;
using ActionsList;
namespace UpgradesList.FirstEdition
{
public class IG88D : GenericUpgrade
{
public IG88D() : base()
{
UpgradeInfo = new UpgradeCardInfo(
"IG-88D",
UpgradeType.Crew,
cost: 1,
isLimited: true,
restriction: new FactionRestriction(Faction.Scum),
abilityType: typeof(Abilities.FirstEdition.Ig2000Ability)
);
}
}
} | 24.5 | 73 | 0.541744 | [
"MIT"
] | 97saundersj/FlyCasual | Assets/Scripts/Model/Content/FirstEdition/Upgrades/Crew/IG88D.cs | 541 | C# |
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Orleans;
using UnitTests.GrainInterfaces;
namespace UnitTests.Grains
{
public class CatalogTestGrain : Grain, ICatalogTestGrain
{
public override Task OnActivateAsync()
{
return Task.Delay(TimeSpan.FromMilliseconds(50));
}
public Task Initialize()
{
return Task.CompletedTask;
}
public Task BlastCallNewGrains(int nGrains, long startingKey, int nCallsToEach)
{
var promises = new List<Task>(nGrains * nCallsToEach);
for (int i = 0; i < nGrains; i++)
{
var grain = GrainFactory.GetGrain<ICatalogTestGrain>(startingKey + i);
for (int j = 0; j < nCallsToEach; j++)
promises.Add(grain.Initialize());
}
return Task.WhenAll(promises);
}
}
} | 26.25 | 87 | 0.584127 | [
"MIT"
] | DarkCow/orleans | test/TestGrains/CatalogTestGrain.cs | 947 | C# |
// Copyright (c) 2017 Jan Pluskal, Martin Kmet
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Netfox.SnooperRTP")]
[assembly: Guid("61029379-d416-4556-8ce7-361c06917e4e")] | 40.263158 | 74 | 0.764706 | [
"Apache-2.0"
] | mvondracek/NetfoxDetective | Framework/Snoopers/SnooperRTP/Properties/AssemblyInfo.cs | 767 | C# |
// Copyright 2007-2011 The Apache Software Foundation.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use
// this file except in compliance with the License. You may obtain a copy of the
// License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
namespace Topshelf
{
using HostConfigurators;
public static class DependencyExtensions
{
public static HostConfigurator AddDependency(this HostConfigurator configurator, string name)
{
var dependencyConfigurator = new DependencyHostConfigurator(name);
configurator.AddConfigurator(dependencyConfigurator);
return configurator;
}
public static HostConfigurator DependsOn(this HostConfigurator configurator, string name)
{
return AddDependency(configurator, name);
}
public static HostConfigurator DependsOnMsmq(this HostConfigurator configurator)
{
return AddDependency(configurator, KnownServiceNames.Msmq);
}
public static HostConfigurator DependsOnMsSql(this HostConfigurator configurator)
{
return AddDependency(configurator, KnownServiceNames.SqlServer);
}
public static HostConfigurator DependsOnEventLog(this HostConfigurator configurator)
{
return AddDependency(configurator, KnownServiceNames.EventLog);
}
public static HostConfigurator DependsOnIis(this HostConfigurator configurator)
{
return AddDependency(configurator, KnownServiceNames.IIS);
}
}
} | 33.481481 | 96 | 0.757743 | [
"Apache-2.0"
] | apobekiaris/Topshelf | src/Topshelf/Config/DependencyExtensions.cs | 1,810 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// <auto-generated/>
#nullable disable
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Core.Pipeline;
using Azure.ResourceManager.Core;
using Azure.ResourceManager.CosmosDB;
namespace Azure.ResourceManager.CosmosDB.Models
{
/// <summary> Create or update an Azure Cosmos DB Gremlin database. </summary>
public partial class GremlinResourceCreateUpdateGremlinDatabaseOperation : Operation<GremlinDatabase>, IOperationSource<GremlinDatabase>
{
private readonly OperationInternals<GremlinDatabase> _operation;
private readonly ArmResource _operationBase;
/// <summary> Initializes a new instance of GremlinResourceCreateUpdateGremlinDatabaseOperation for mocking. </summary>
protected GremlinResourceCreateUpdateGremlinDatabaseOperation()
{
}
internal GremlinResourceCreateUpdateGremlinDatabaseOperation(ArmResource operationsBase, ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Request request, Response response)
{
_operation = new OperationInternals<GremlinDatabase>(this, clientDiagnostics, pipeline, request, response, OperationFinalStateVia.Location, "GremlinResourceCreateUpdateGremlinDatabaseOperation");
_operationBase = operationsBase;
}
/// <inheritdoc />
public override string Id => _operation.Id;
/// <inheritdoc />
public override GremlinDatabase Value => _operation.Value;
/// <inheritdoc />
public override bool HasCompleted => _operation.HasCompleted;
/// <inheritdoc />
public override bool HasValue => _operation.HasValue;
/// <inheritdoc />
public override Response GetRawResponse() => _operation.GetRawResponse();
/// <inheritdoc />
public override Response UpdateStatus(CancellationToken cancellationToken = default) => _operation.UpdateStatus(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response> UpdateStatusAsync(CancellationToken cancellationToken = default) => _operation.UpdateStatusAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<GremlinDatabase>> WaitForCompletionAsync(CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(cancellationToken);
/// <inheritdoc />
public override ValueTask<Response<GremlinDatabase>> WaitForCompletionAsync(TimeSpan pollingInterval, CancellationToken cancellationToken = default) => _operation.WaitForCompletionAsync(pollingInterval, cancellationToken);
GremlinDatabase IOperationSource<GremlinDatabase>.CreateResult(Response response, CancellationToken cancellationToken)
{
using var document = JsonDocument.Parse(response.ContentStream);
return new GremlinDatabase(_operationBase, GremlinDatabaseData.DeserializeGremlinDatabaseData(document.RootElement));
}
async ValueTask<GremlinDatabase> IOperationSource<GremlinDatabase>.CreateResultAsync(Response response, CancellationToken cancellationToken)
{
using var document = await JsonDocument.ParseAsync(response.ContentStream, default, cancellationToken).ConfigureAwait(false);
return new GremlinDatabase(_operationBase, GremlinDatabaseData.DeserializeGremlinDatabaseData(document.RootElement));
}
}
}
| 45.666667 | 230 | 0.75014 | [
"MIT"
] | 93mishra/azure-sdk-for-net | sdk/cosmosdb/Azure.ResourceManager.CosmosDB/src/Generated/LongRunningOperation/GremlinResourceCreateUpdateGremlinDatabaseOperation.cs | 3,562 | C# |
/*
* Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the securityhub-2018-10-26.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
using System.Text;
using System.IO;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
namespace Amazon.SecurityHub.Model
{
/// <summary>
/// A finding's severity.
/// </summary>
public partial class Severity
{
private int? _normalized;
private double? _product;
/// <summary>
/// Gets and sets the property Normalized.
/// <para>
/// The normalized severity of a finding.
/// </para>
/// </summary>
public int Normalized
{
get { return this._normalized.GetValueOrDefault(); }
set { this._normalized = value; }
}
// Check to see if Normalized property is set
internal bool IsSetNormalized()
{
return this._normalized.HasValue;
}
/// <summary>
/// Gets and sets the property Product.
/// <para>
/// The native severity as defined by the security findings provider's solution that generated
/// the finding.
/// </para>
/// </summary>
public double Product
{
get { return this._product.GetValueOrDefault(); }
set { this._product = value; }
}
// Check to see if Product property is set
internal bool IsSetProduct()
{
return this._product.HasValue;
}
}
} | 28.644737 | 109 | 0.615526 | [
"Apache-2.0"
] | Bio2hazard/aws-sdk-net | sdk/src/Services/SecurityHub/Generated/Model/Severity.cs | 2,177 | C# |
using StrongSyntax.DbHelpers;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace StrongSyntax.QueryBuilders
{
class SelectBuilder : QueryBuilderBase, IDynamicQuery, ISelectClause, IFromClause, IWhereClause, IGroupByClause, IOrderByClause, IOffsetClause, IFetchClause
{
public SelectBuilder(Syntax syntax)
: base(syntax)
{
}
public ISelectClause Select(params string[] selector)
{
this._select = selector;
this._query.AppendLine("SELECT");
var sb = this.CreateList(_select, true);
this._query.AppendLine(sb.ToString());
return this;
}
public ISelectClause SubSelect(params string[] selector)
{
SubSelectBuilder subSelect = new SubSelectBuilder(this._syntax, this);
return subSelect.Select(selector);
}
public IFromClause From(string tableName)
{
this.CheckNullException(tableName, "tableName");
this._query.AppendFormat("FROM {0}", tableName)
.AppendLine();
return this;
}
private void ValidatSubselect(ICompleteQuery subSelect, string alias)
{
this.CheckNullException(subSelect, "subSelect");
this.CheckNullException(alias, "alias");
}
public IFromClause From(ICompleteQuery subSelect, string alias)
{
ValidatSubselect(subSelect, alias);
this._paramList.AddRange(subSelect.SqlParameters);
this._query.AppendLine("FROM")
.AppendLine("(")
.Append(subSelect.ToString())
.AppendFormat(") AS [{0}]", alias)
.AppendLine();
return this;
}
private IFromClause Join(string join, string tableName, string condition)
{
this.CheckNullException(tableName, "tableName");
this.CheckNullException(condition, "condition");
this._query.AppendFormat("{0} JOIN {1}", join, tableName)
.AppendLine()
.AppendFormat(" ON {0}", condition)
.AppendLine();
return this;
}
private IFromClause Join(string join, ICompleteQuery subSelect, string condition, string alias)
{
ValidatSubselect(subSelect, alias);
this.CheckNullException(condition, "condition");
this._paramList.AddRange(subSelect.SqlParameters);
this._query.AppendFormat("{0} JOIN", join)
.AppendLine()
.AppendLine("(")
.AppendFormat("\t{0}", subSelect.ToString())
.AppendFormat(") AS {0}", alias)
.AppendLine()
.AppendFormat("\tON {0}", condition)
.AppendLine();
return this;
}
public IFromClause LeftJoin(string tableName, string condition)
{
return Join("LEFT OUTER", tableName, condition);
}
public IFromClause LeftJoin(string tableName, string condition, params object[] values)
{
CreateFilterParams(condition, values);
return Join("LEFT OUTER", tableName, condition);
}
public IFromClause LeftJoin(ICompleteQuery subSelect, string condition, string alias)
{
return Join("LEFT OUTER", subSelect, condition, alias);
}
public IFromClause LeftJoin(ICompleteQuery subSelect, string condition, string alias, params object[] values)
{
CreateFilterParams(condition, values);
return Join("LEFT OUTER", subSelect, condition, alias);
}
public IFromClause RightJoin(string tableName, string condition)
{
return Join("RIGHT OUTER", tableName, condition);
}
public IFromClause RightJoin(string tableName, string condition, params object[] values)
{
CreateFilterParams(condition, values);
return Join("RIGHT OUTER", tableName, condition);
}
public IFromClause RightJoin(ICompleteQuery subSelect, string condition, string alias)
{
return Join("RIGHT OUTER", subSelect, condition, alias);
}
public IFromClause RightJoin(ICompleteQuery subSelect, string condition, string alias, params object[] values)
{
CreateFilterParams(condition, values);
return Join("RIGHT OUTER", subSelect, condition, alias);
}
public IFromClause InnerJoin(string tableName, string condition)
{
return Join("INNER", tableName, condition);
}
public IFromClause InnerJoin(string tableName, string condition, params object[] values)
{
CreateFilterParams(condition, values);
return Join("INNER", tableName, condition);
}
public IFromClause InnerJoin(ICompleteQuery subSelect, string condition, string alias)
{
return Join("INNER", subSelect, condition, alias);
}
public IFromClause InnerJoin(ICompleteQuery subSelect, string condition, string alias, params object[] values)
{
CreateFilterParams(condition, values);
return Join("INNER OUTER", subSelect, condition, alias);
}
private void ValidateWhereClause(string filter, int paramCount, object[] values)
{
this.CheckNullException(filter, "filter");
if (paramCount != values.Length)
{
throw new ArgumentException("Wrong number of parameters were passed to the query.");
}
}
private void CreateFilterParams(string filter, object[] values)
{
var paramCount = filter.Split(' ')
.Where(s => Regex.IsMatch(s, @"\@[0-9]+"))
.Select(s=> Regex.Match(s, @"\@[0-9]+").Value)
.Distinct()
.Count();
ValidateWhereClause(filter, paramCount, values);
foreach (var val in values)
{
this.AddParam(val);
}
}
public IWhereClause Where(string filter, params object[] values)
{
CreateFilterParams(filter, values);
this._query.AppendFormat("WHERE {0}", filter)
.AppendLine();
return this;
}
public IGroupByClause GroupBy(params string[] groupings)
{
this._query.AppendLine("GROUP BY");
var groupBy = this.CreateList(groupings);
this._query.AppendLine(groupBy.ToString());
return this;
}
private IOrderByClause OrderBy(string order, params string[] orderList)
{
this._query.AppendLine("ORDER BY");
var sb = this.CreateList(orderList);
this._query.Append(sb.ToString())
.Append(" ")
.AppendLine(order);
return this;
}
public IOrderByClause OrderBy(params string[] orderList)
{
return OrderBy("ASC", orderList);
}
public IOrderByClause OrderByDescending(params string[] orderList)
{
return OrderBy("DESC", orderList);
}
public IOffsetClause Offset(int rowsToSkip)
{
this._query.AppendFormat("OFFSET {0} ROWS", rowsToSkip)
.AppendLine();
return this;
}
public IFetchClause Fetch(int rowsToTake)
{
this._query.AppendFormat("FETCH NEXT {0} ROWS ONLY", rowsToTake)
.AppendLine();
return this;
}
public IQueryReader<TEntity> PrepareReader<TEntity>()
where TEntity : class, new()
{
return new DbQueryReader<TEntity>(this);
}
public IQueryReader<TEntity> PrepareReader<TEntity>(string entityName)
where TEntity : class, new()
{
return new DbQueryReader<TEntity>(this)
{
EntityName = entityName
};
}
public virtual string ToString(string alias)
{
this.CheckNullException(alias, "alias");
this._query.Insert(0, "(");
this._query.AppendFormat(") AS [{0}]", alias);
return this.ToString();
}
}
}
| 29.923077 | 160 | 0.571863 | [
"Apache-2.0"
] | HaykShirinyan/StrongSyntax | StrongSyntax/StrongSyntax/QueryBuilders/SelectBuilder.cs | 8,560 | C# |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Globalization;
using Microsoft.Build.Shared;
#nullable disable
namespace Microsoft.Build.Tasks
{
/// <summary>
/// Provides read-only cached instances of <see cref="CultureInfo"/>.
/// <remarks>
/// Original source:
/// https://raw.githubusercontent.com/aspnet/Localization/dev/src/Microsoft.Framework.Globalization.CultureInfoCache/CultureInfoCache.cs
/// </remarks>
/// </summary>
internal static class CultureInfoCache
{
private static readonly HashSet<string> ValidCultureNames;
static CultureInfoCache()
{
ValidCultureNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
#if !FEATURE_CULTUREINFO_GETCULTURES
if (!AssemblyUtilities.CultureInfoHasGetCultures())
{
ValidCultureNames = HardcodedCultureNames;
return;
}
#endif
foreach (CultureInfo cultureName in AssemblyUtilities.GetAllCultures())
{
ValidCultureNames.Add(cultureName.Name);
}
// https://docs.microsoft.com/en-gb/windows/desktop/Intl/using-pseudo-locales-for-localization-testing
// These pseudo-locales are available in versions of Windows from Vista and later.
// However, from Windows 10, version 1803, they are not returned when enumerating the
// installed cultures, even if the registry keys are set. Therefore, add them to the list manually.
var pseudoLocales = new[] { "qps-ploc", "qps-ploca", "qps-plocm", "qps-Latn-x-sh" };
foreach (string pseudoLocale in pseudoLocales)
{
ValidCultureNames.Add(pseudoLocale);
}
}
/// <summary>
/// Determine if a culture string represents a valid <see cref="CultureInfo"/> instance.
/// </summary>
/// <param name="name">The culture name.</param>
/// <returns>True if the culture is determined to be valid.</returns>
internal static bool IsValidCultureString(string name)
{
return ValidCultureNames.Contains(name);
}
#if !FEATURE_CULTUREINFO_GETCULTURES
// Copied from https://github.com/aspnet/Localization/blob/5e1fb16071affd15f15b9c732833f3ae2ac46e10/src/Microsoft.Framework.Globalization.CultureInfoCache/CultureInfoList.cs
// Regenerated using the tool (removed by https://github.com/aspnet/Localization/pull/130)
// * Removed the empty string from the list
// * Any cultures not present when regenerated were retained
// * Added the Windows pseudo-locales
private static readonly HashSet<string> HardcodedCultureNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
{
"aa",
"aa-DJ",
"aa-ER",
"aa-ET",
"af",
"af-NA",
"af-ZA",
"agq",
"agq-CM",
"ak",
"ak-GH",
"am",
"am-ET",
"ar",
"ar-001",
"ar-AE",
"ar-BH",
"ar-DJ",
"ar-DZ",
"ar-EG",
"ar-ER",
"ar-IL",
"ar-IQ",
"ar-JO",
"ar-KM",
"ar-KW",
"ar-LB",
"ar-LY",
"ar-MA",
"ar-MR",
"ar-OM",
"ar-PS",
"ar-QA",
"ar-SA",
"ar-SD",
"ar-SO",
"ar-SS",
"ar-SY",
"ar-TD",
"ar-TN",
"ar-YE",
"arn",
"arn-CL",
"as",
"as-IN",
"asa",
"asa-TZ",
"ast",
"ast-ES",
"az",
"az-Cyrl",
"az-Cyrl-AZ",
"az-Latn",
"az-Latn-AZ",
"ba",
"ba-RU",
"bas",
"bas-CM",
"be",
"be-BY",
"bem",
"bem-ZM",
"bez",
"bez-TZ",
"bg",
"bg-BG",
"bin",
"bin-NG",
"bm",
"bm-Latn",
"bm-Latn-ML",
"bn",
"bn-BD",
"bn-IN",
"bo",
"bo-CN",
"bo-IN",
"br",
"br-FR",
"brx",
"brx-IN",
"bs",
"bs-Cyrl",
"bs-Cyrl-BA",
"bs-Latn",
"bs-Latn-BA",
"byn",
"byn-ER",
"ca",
"ca-AD",
"ca-ES",
"ca-ES-valencia",
"ca-FR",
"ca-IT",
"ce",
"ce-RU",
"cgg",
"cgg-UG",
"chr",
"chr-Cher",
"chr-Cher-US",
"co",
"co-FR",
"cs",
"cs-CZ",
"cu",
"cu-RU",
"cy",
"cy-GB",
"da",
"da-DK",
"da-GL",
"dav",
"dav-KE",
"de",
"de-AT",
"de-BE",
"de-CH",
"de-DE",
"de-IT",
"de-LI",
"de-LU",
"dje",
"dje-NE",
"dsb",
"dsb-DE",
"dua",
"dua-CM",
"dv",
"dv-MV",
"dyo",
"dyo-SN",
"dz",
"dz-BT",
"ebu",
"ebu-KE",
"ee",
"ee-GH",
"ee-TG",
"el",
"el-CY",
"el-GR",
"en",
"en-001",
"en-029",
"en-150",
"en-AG",
"en-AI",
"en-AS",
"en-AT",
"en-AU",
"en-BB",
"en-BE",
"en-BI",
"en-BM",
"en-BS",
"en-BW",
"en-BZ",
"en-CA",
"en-CC",
"en-CH",
"en-CK",
"en-CM",
"en-CX",
"en-CY",
"en-DE",
"en-DK",
"en-DM",
"en-ER",
"en-FI",
"en-FJ",
"en-FK",
"en-FM",
"en-GB",
"en-GD",
"en-GG",
"en-GH",
"en-GI",
"en-GM",
"en-GU",
"en-GY",
"en-HK",
"en-ID",
"en-IE",
"en-IL",
"en-IM",
"en-IN",
"en-IO",
"en-JE",
"en-JM",
"en-KE",
"en-KI",
"en-KN",
"en-KY",
"en-LC",
"en-LR",
"en-LS",
"en-MG",
"en-MH",
"en-MO",
"en-MP",
"en-MS",
"en-MT",
"en-MU",
"en-MW",
"en-MY",
"en-NA",
"en-NF",
"en-NG",
"en-NL",
"en-NR",
"en-NU",
"en-NZ",
"en-PG",
"en-PH",
"en-PK",
"en-PN",
"en-PR",
"en-PW",
"en-RW",
"en-SB",
"en-SC",
"en-SD",
"en-SE",
"en-SG",
"en-SH",
"en-SI",
"en-SL",
"en-SS",
"en-SX",
"en-SZ",
"en-TC",
"en-TK",
"en-TO",
"en-TT",
"en-TV",
"en-TZ",
"en-UG",
"en-UM",
"en-US",
"en-VC",
"en-VG",
"en-VI",
"en-VU",
"en-WS",
"en-ZA",
"en-ZM",
"en-ZW",
"eo",
"eo-001",
"es",
"es-419",
"es-AR",
"es-BO",
"es-BR",
"es-BZ",
"es-CL",
"es-CO",
"es-CR",
"es-CU",
"es-DO",
"es-EC",
"es-ES",
"es-GQ",
"es-GT",
"es-HN",
"es-MX",
"es-NI",
"es-PA",
"es-PE",
"es-PH",
"es-PR",
"es-PY",
"es-SV",
"es-US",
"es-UY",
"es-VE",
"et",
"et-EE",
"eu",
"eu-ES",
"ewo",
"ewo-CM",
"fa",
"fa-IR",
"ff",
"ff-CM",
"ff-GN",
"ff-Latn",
"ff-Latn-SN",
"ff-MR",
"ff-NG",
"fi",
"fi-FI",
"fil",
"fil-PH",
"fo",
"fo-DK",
"fo-FO",
"fr",
"fr-029",
"fr-BE",
"fr-BF",
"fr-BI",
"fr-BJ",
"fr-BL",
"fr-CA",
"fr-CD",
"fr-CF",
"fr-CG",
"fr-CH",
"fr-CI",
"fr-CM",
"fr-DJ",
"fr-DZ",
"fr-FR",
"fr-GA",
"fr-GF",
"fr-GN",
"fr-GP",
"fr-GQ",
"fr-HT",
"fr-KM",
"fr-LU",
"fr-MA",
"fr-MC",
"fr-MF",
"fr-MG",
"fr-ML",
"fr-MQ",
"fr-MR",
"fr-MU",
"fr-NC",
"fr-NE",
"fr-PF",
"fr-PM",
"fr-RE",
"fr-RW",
"fr-SC",
"fr-SN",
"fr-SY",
"fr-TD",
"fr-TG",
"fr-TN",
"fr-VU",
"fr-WF",
"fr-YT",
"fur",
"fur-IT",
"fy",
"fy-NL",
"ga",
"ga-IE",
"gd",
"gd-GB",
"gl",
"gl-ES",
"gn",
"gn-PY",
"gsw",
"gsw-CH",
"gsw-FR",
"gsw-LI",
"gu",
"gu-IN",
"guz",
"guz-KE",
"gv",
"gv-IM",
"ha",
"ha-Latn",
"ha-Latn-GH",
"ha-Latn-NE",
"ha-Latn-NG",
"haw",
"haw-US",
"he",
"he-IL",
"hi",
"hi-IN",
"hr",
"hr-BA",
"hr-HR",
"hsb",
"hsb-DE",
"hu",
"hu-HU",
"hy",
"hy-AM",
"ia",
"ia-001",
"ia-FR",
"ibb",
"ibb-NG",
"id",
"id-ID",
"ig",
"ig-NG",
"ii",
"ii-CN",
"is",
"is-IS",
"it",
"it-CH",
"it-IT",
"it-SM",
"it-VA",
"iu",
"iu-Cans",
"iu-Cans-CA",
"iu-Latn",
"iu-Latn-CA",
"ja",
"ja-JP",
"jgo",
"jgo-CM",
"jmc",
"jmc-TZ",
"jv",
"jv-Java",
"jv-Java-ID",
"jv-Latn",
"jv-Latn-ID",
"ka",
"ka-GE",
"kab",
"kab-DZ",
"kam",
"kam-KE",
"kde",
"kde-TZ",
"kea",
"kea-CV",
"khq",
"khq-ML",
"ki",
"ki-KE",
"kk",
"kk-KZ",
"kkj",
"kkj-CM",
"kl",
"kl-GL",
"kln",
"kln-KE",
"km",
"km-KH",
"kn",
"kn-IN",
"ko",
"ko-KP",
"ko-KR",
"kok",
"kok-IN",
"kr",
"kr-NG",
"ks",
"ks-Arab",
"ks-Arab-IN",
"ks-Deva",
"ks-Deva-IN",
"ksb",
"ksb-TZ",
"ksf",
"ksf-CM",
"ksh",
"ksh-DE",
"ku",
"ku-Arab",
"ku-Arab-IQ",
"ku-Arab-IR",
"kw",
"kw-GB",
"ky",
"ky-KG",
"la",
"la-001",
"lag",
"lag-TZ",
"lb",
"lb-LU",
"lg",
"lg-UG",
"lkt",
"lkt-US",
"ln",
"ln-AO",
"ln-CD",
"ln-CF",
"ln-CG",
"lo",
"lo-LA",
"lrc",
"lrc-IQ",
"lrc-IR",
"lt",
"lt-LT",
"lu",
"lu-CD",
"luo",
"luo-KE",
"luy",
"luy-KE",
"lv",
"lv-LV",
"mas",
"mas-KE",
"mas-TZ",
"mer",
"mer-KE",
"mfe",
"mfe-MU",
"mg",
"mg-MG",
"mgh",
"mgh-MZ",
"mgo",
"mgo-CM",
"mi",
"mi-NZ",
"mk",
"mk-MK",
"ml",
"ml-IN",
"mn",
"mn-Cyrl",
"mn-MN",
"mn-Mong",
"mn-Mong-CN",
"mn-Mong-MN",
"mni",
"mni-IN",
"moh",
"moh-CA",
"mr",
"mr-IN",
"ms",
"ms-BN",
"ms-MY",
"ms-SG",
"mt",
"mt-MT",
"mua",
"mua-CM",
"my",
"my-MM",
"mzn",
"mzn-IR",
"naq",
"naq-NA",
"nb",
"nb-NO",
"nb-SJ",
"nd",
"nd-ZW",
"nds",
"nds-DE",
"nds-NL",
"ne",
"ne-IN",
"ne-NP",
"nl",
"nl-AW",
"nl-BE",
"nl-BQ",
"nl-CW",
"nl-NL",
"nl-SR",
"nl-SX",
"nmg",
"nmg-CM",
"nn",
"nn-NO",
"nnh",
"nnh-CM",
"no",
"nqo",
"nqo-GN",
"nr",
"nr-ZA",
"nso",
"nso-ZA",
"nus",
"nus-SS",
"nyn",
"nyn-UG",
"oc",
"oc-FR",
"om",
"om-ET",
"om-KE",
"or",
"or-IN",
"os",
"os-GE",
"os-RU",
"pa",
"pa-Arab",
"pa-Arab-PK",
"pa-Guru",
"pa-IN",
"pap",
"pap-029",
"pl",
"pl-PL",
"prg",
"prg-001",
"prs",
"prs-AF",
"ps",
"ps-AF",
"pt",
"pt-AO",
"pt-BR",
"pt-CH",
"pt-CV",
"pt-GQ",
"pt-GW",
"pt-LU",
"pt-MO",
"pt-MZ",
"pt-PT",
"pt-ST",
"pt-TL",
"qps-ploc",
"qps-ploca",
"qps-plocm",
"qps-Latn-x-sh",
"quc",
"quc-Latn",
"quc-Latn-GT",
"qut",
"qut-GT",
"quz",
"quz-BO",
"quz-EC",
"quz-PE",
"rm",
"rm-CH",
"rn",
"rn-BI",
"ro",
"ro-MD",
"ro-RO",
"rof",
"rof-TZ",
"ru",
"ru-BY",
"ru-KG",
"ru-KZ",
"ru-MD",
"ru-RU",
"ru-UA",
"rw",
"rw-RW",
"rwk",
"rwk-TZ",
"sa",
"sa-IN",
"sah",
"sah-RU",
"saq",
"saq-KE",
"sbp",
"sbp-TZ",
"sd",
"sd-Arab",
"sd-Arab-PK",
"sd-Deva",
"sd-Deva-IN",
"se",
"se-FI",
"se-NO",
"se-SE",
"seh",
"seh-MZ",
"ses",
"ses-ML",
"sg",
"sg-CF",
"shi",
"shi-Latn",
"shi-Latn-MA",
"shi-Tfng",
"shi-Tfng-MA",
"si",
"si-LK",
"sk",
"sk-SK",
"sl",
"sl-SI",
"sma",
"sma-NO",
"sma-SE",
"smj",
"smj-NO",
"smj-SE",
"smn",
"smn-FI",
"sms",
"sms-FI",
"sn",
"sn-Latn",
"sn-Latn-ZW",
"so",
"so-DJ",
"so-ET",
"so-KE",
"so-SO",
"sq",
"sq-AL",
"sq-MK",
"sq-XK",
"sr",
"sr-Cyrl",
"sr-Cyrl-BA",
"sr-Cyrl-CS",
"sr-Cyrl-ME",
"sr-Cyrl-RS",
"sr-Cyrl-XK",
"sr-Latn",
"sr-Latn-BA",
"sr-Latn-CS",
"sr-Latn-ME",
"sr-Latn-RS",
"sr-Latn-XK",
"ss",
"ss-SZ",
"ss-ZA",
"ssy",
"ssy-ER",
"st",
"st-LS",
"st-ZA",
"sv",
"sv-AX",
"sv-FI",
"sv-SE",
"sw",
"sw-CD",
"sw-KE",
"sw-TZ",
"sw-UG",
"syr",
"syr-SY",
"ta",
"ta-IN",
"ta-LK",
"ta-MY",
"ta-SG",
"te",
"te-IN",
"teo",
"teo-KE",
"teo-UG",
"tg",
"tg-Cyrl",
"tg-Cyrl-TJ",
"th",
"th-TH",
"ti",
"ti-ER",
"ti-ET",
"tig",
"tig-ER",
"tk",
"tk-TM",
"tn",
"tn-BW",
"tn-ZA",
"to",
"to-TO",
"tr",
"tr-CY",
"tr-TR",
"ts",
"ts-ZA",
"tt",
"tt-RU",
"twq",
"twq-NE",
"tzm",
"tzm-Arab",
"tzm-Arab-MA",
"tzm-Latn",
"tzm-Latn-DZ",
"tzm-Latn-MA",
"tzm-Tfng",
"tzm-Tfng-MA",
"ug",
"ug-CN",
"uk",
"uk-UA",
"ur",
"ur-IN",
"ur-PK",
"uz",
"uz-Arab",
"uz-Arab-AF",
"uz-Cyrl",
"uz-Cyrl-UZ",
"uz-Latn",
"uz-Latn-UZ",
"vai",
"vai-Latn",
"vai-Latn-LR",
"vai-Vaii",
"vai-Vaii-LR",
"ve",
"ve-ZA",
"vi",
"vi-VN",
"vo",
"vo-001",
"vun",
"vun-TZ",
"wae",
"wae-CH",
"wal",
"wal-ET",
"wo",
"wo-SN",
"xh",
"xh-ZA",
"xog",
"xog-UG",
"yav",
"yav-CM",
"yi",
"yi-001",
"yo",
"yo-BJ",
"yo-NG",
"zgh",
"zgh-Tfng",
"zgh-Tfng-MA",
"zh",
"zh-CN",
"zh-Hans",
"zh-Hans-HK",
"zh-Hans-MO",
"zh-Hant",
"zh-HK",
"zh-MO",
"zh-SG",
"zh-TW",
"zu",
"zu-ZA",
"zh-CHS",
"zh-CHT"
};
#endif
}
}
| 22.387689 | 181 | 0.262891 | [
"MIT"
] | GaryPlattenburg/msbuild | src/Tasks/CultureInfoCache.cs | 20,733 | C# |
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
namespace Kentico.Kontent.Management.Models.Assets
{
/// <summary>
/// Represents an asset upsert model.
/// </summary>
public sealed class AssetUpsertModel
{
/// <summary>
/// Gets or sets file reference for the asset.
/// </summary>
[JsonProperty("file_reference", Required = Required.Always)]
public FileReference FileReference { get; set; }
/// <summary>
/// Gets or sets description for the asset.
/// </summary>
[JsonProperty("descriptions", Required = Required.Always)]
public IEnumerable<AssetDescription> Descriptions { get; set; } = Enumerable.Empty<AssetDescription>();
/// <summary>
/// Gets or sets title for the asset.
/// </summary>
[JsonProperty("title")]
public string Title { get; set; }
}
}
| 29.21875 | 111 | 0.610695 | [
"MIT"
] | matus666/kontent-management-sdk-net | Kentico.Kontent.Management/Models/Assets/AssetUpsertModel.cs | 937 | C# |
using NUnit.Framework;
using Scalar.FunctionalTests.FileSystemRunners;
using Scalar.FunctionalTests.Should;
using Scalar.FunctionalTests.Tools;
using Scalar.Tests.Should;
using System;
using System.Diagnostics;
using System.IO;
namespace Scalar.FunctionalTests.Tests.EnlistmentPerFixture
{
[TestFixture]
public class CloneTests : TestsWithEnlistmentPerFixture
{
private const int ScalarGenericError = 3;
[TestCase]
public void CloneInsideExistingEnlistment()
{
this.SubfolderCloneShouldFail();
}
[TestCase]
public void CloneWithLocalCachePathWithinSrc()
{
string newEnlistmentRoot = ScalarFunctionalTestEnlistment.GetUniqueEnlistmentRoot();
ProcessStartInfo processInfo = new ProcessStartInfo(ScalarTestConfig.PathToScalar);
processInfo.Arguments = $"clone {Properties.Settings.Default.RepoToClone} {newEnlistmentRoot} --local-cache-path {Path.Combine(newEnlistmentRoot, "src", ".scalarCache")}";
processInfo.WindowStyle = ProcessWindowStyle.Hidden;
processInfo.CreateNoWindow = true;
processInfo.WorkingDirectory = Path.GetDirectoryName(this.Enlistment.EnlistmentRoot);
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
ProcessResult result = ProcessHelper.Run(processInfo);
result.ExitCode.ShouldEqual(ScalarGenericError);
result.Output.ShouldContain("'--local-cache-path' cannot be inside the src folder");
}
[TestCase]
public void SparseCloneWithNoFetchOfCommitsAndTreesSucceeds()
{
ScalarFunctionalTestEnlistment enlistment = null;
try
{
enlistment = ScalarFunctionalTestEnlistment.CloneWithPerRepoCache(ScalarTestConfig.PathToScalar, skipFetchCommitsAndTrees: true);
ProcessResult result = GitProcess.InvokeProcess(enlistment.RepoRoot, "status");
result.ExitCode.ShouldEqual(0, result.Errors);
}
finally
{
enlistment?.DeleteAll();
}
}
[TestCase]
[Category(Categories.MacOnly)]
public void CloneWithDefaultLocalCacheLocation()
{
FileSystemRunner fileSystem = FileSystemRunner.DefaultRunner;
string homeDirectory = Environment.GetEnvironmentVariable("HOME");
homeDirectory.ShouldBeADirectory(fileSystem);
string newEnlistmentRoot = ScalarFunctionalTestEnlistment.GetUniqueEnlistmentRoot();
ProcessStartInfo processInfo = new ProcessStartInfo(ScalarTestConfig.PathToScalar);
processInfo.Arguments = $"clone {Properties.Settings.Default.RepoToClone} {newEnlistmentRoot} --no-fetch-commits-and-trees";
processInfo.WindowStyle = ProcessWindowStyle.Hidden;
processInfo.CreateNoWindow = true;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
processInfo.WorkingDirectory = Properties.Settings.Default.EnlistmentRoot;
ProcessResult result = ProcessHelper.Run(processInfo);
result.ExitCode.ShouldEqual(0, result.Errors);
string gitObjectsRoot = ScalarHelpers.GetObjectsRootFromGitConfig(Path.Combine(newEnlistmentRoot, "src"));
string defaultScalarCacheRoot = Path.Combine(homeDirectory, ".scalarCache");
gitObjectsRoot.StartsWith(defaultScalarCacheRoot, StringComparison.Ordinal).ShouldBeTrue($"Git objects root did not default to using {homeDirectory}");
RepositoryHelpers.DeleteTestDirectory(newEnlistmentRoot);
}
[TestCase]
public void CloneToPathWithSpaces()
{
ScalarFunctionalTestEnlistment enlistment = ScalarFunctionalTestEnlistment.CloneEnlistmentWithSpacesInPath(ScalarTestConfig.PathToScalar);
enlistment.DeleteAll();
}
[TestCase]
public void CloneCreatesCorrectFilesInRoot()
{
ScalarFunctionalTestEnlistment enlistment = ScalarFunctionalTestEnlistment.Clone(ScalarTestConfig.PathToScalar);
try
{
Directory.GetFiles(enlistment.EnlistmentRoot).ShouldBeEmpty("There should be no files in the enlistment root after cloning");
string[] directories = Directory.GetDirectories(enlistment.EnlistmentRoot);
directories.Length.ShouldEqual(1);
directories.ShouldContain(x => Path.GetFileName(x).Equals("src", StringComparison.Ordinal));
}
finally
{
enlistment.DeleteAll();
}
}
private void SubfolderCloneShouldFail()
{
ProcessStartInfo processInfo = new ProcessStartInfo(ScalarTestConfig.PathToScalar);
processInfo.Arguments = "clone " + ScalarTestConfig.RepoToClone + " src\\scalar\\test1";
processInfo.WindowStyle = ProcessWindowStyle.Hidden;
processInfo.CreateNoWindow = true;
processInfo.WorkingDirectory = this.Enlistment.EnlistmentRoot;
processInfo.UseShellExecute = false;
processInfo.RedirectStandardOutput = true;
ProcessResult result = ProcessHelper.Run(processInfo);
result.ExitCode.ShouldEqual(ScalarGenericError);
result.Output.ShouldContain("You can't clone inside an existing Scalar repo");
}
}
}
| 42.96124 | 183 | 0.677192 | [
"MIT"
] | Bhaskers-Blu-Org2/scalar | Scalar.FunctionalTests/Tests/EnlistmentPerFixture/CloneTests.cs | 5,542 | C# |
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
using System;
using Common;
using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Infra;
using Windows.UI.Xaml.Tests.MUXControls.InteractionTests.Common;
using System.Collections.Generic;
using Windows.Foundation.Metadata;
#if USING_TAEF
using WEX.TestExecution;
using WEX.TestExecution.Markup;
using WEX.Logging.Interop;
#else
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VisualStudio.TestTools.UnitTesting.Logging;
#endif
using Microsoft.Windows.Apps.Test.Automation;
using Microsoft.Windows.Apps.Test.Foundation;
using Microsoft.Windows.Apps.Test.Foundation.Controls;
using Microsoft.Windows.Apps.Test.Foundation.Patterns;
using Microsoft.Windows.Apps.Test.Foundation.Waiters;
namespace Windows.UI.Xaml.Tests.MUXControls.InteractionTests
{
public class Expander : UIObject, IExpandCollapse
{
public Expander(UIObject uiObject)
: base(uiObject)
{
this.Initialize();
}
private void Initialize()
{
_expandCollapsePattern = new ExpandCollapseImplementation(this);
}
public void ExpandAndWait()
{
using (var waiter = GetExpandedWaiter())
{
Expand();
waiter.Wait();
}
Wait.ForIdle();
}
public void CollapseAndWait()
{
using (var waiter = GetCollapsedWaiter())
{
Collapse();
waiter.Wait();
}
Wait.ForIdle();
}
public void Expand()
{
_expandCollapsePattern.Expand();
}
public void Collapse()
{
_expandCollapsePattern.Collapse();
}
public UIEventWaiter GetExpandedWaiter()
{
return _expandCollapsePattern.GetExpandedWaiter();
}
public UIEventWaiter GetCollapsedWaiter()
{
return _expandCollapsePattern.GetCollapsedWaiter();
}
public ExpandCollapseState ExpandCollapseState
{
get { return _expandCollapsePattern.ExpandCollapseState; }
}
new public static IFactory<Expander> Factory
{
get
{
if (null == Expander._factory)
{
Expander._factory = new ExpanderFactory();
}
return Expander._factory;
}
}
private IExpandCollapse _expandCollapsePattern;
private static IFactory<Expander> _factory = null;
private class ExpanderFactory : IFactory<Expander>
{
public Expander Create(UIObject element)
{
return new Expander(element);
}
}
}
[TestClass]
public class ExpanderTests
{
[ClassInitialize]
[TestProperty("RunAs", "User")]
[TestProperty("Classification", "Integration")]
[TestProperty("Platform", "Any")]
[TestProperty("MUXControlsTestSuite", "SuiteB")]
public static void ClassInitialize(TestContext testContext)
{
TestEnvironment.Initialize(testContext);
}
public void TestCleanup()
{
TestCleanupHelper.Cleanup();
}
[TestMethod]
public void ExpandCollapseAutomationTests()
{
using (var setup = new TestSetupHelper("Expander Tests"))
{
Expander expander = FindElement.ByName<Expander>("ExpandedExpander");
expander.SetFocus();
Wait.ForIdle();
Log.Comment("Collapse using keyboard space key.");
KeyboardHelper.PressKey(Key.Space);
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed);
Log.Comment("Expand using keyboard space key.");
KeyboardHelper.PressKey(Key.Space);
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Expanded);
Log.Comment("Collapse by clicking.");
expander.Click();
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed);
Log.Comment("Expand by clicking.");
expander.Click();
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Expanded);
Log.Comment("Collapse using UIA ExpandCollapse pattern");
expander.CollapseAndWait();
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed);
Log.Comment("Expand using UIA ExpandCollapse pattern");
expander.ExpandAndWait();
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Expanded);
}
}
[TestMethod]
public void AutomationPeerTest()
{
using (var setup = new TestSetupHelper("Expander Tests"))
{
Expander expander = FindElement.ByName<Expander>("ExpanderWithToggleSwitch");
expander.SetFocus();
Wait.ForIdle();
// Verify ExpandedExpander header content AutomationProperties.Name properties are set
VerifyElement.Found("This expander with ToggleSwitch is expanded by default.", FindBy.Name);
VerifyElement.Found("This is the second line of text.", FindBy.Name);
VerifyElement.Found("SettingsToggleSwitch", FindBy.Name);
// Verify ExpandedExpander content AutomationProperties.Name property is set
VerifyElement.Found("ExpanderWithToggleSwitch Content", FindBy.Name);
Log.Comment("Collapse using keyboard space key.");
KeyboardHelper.PressKey(Key.Space);
Verify.AreEqual(expander.ExpandCollapseState, ExpandCollapseState.Collapsed);
// Verify ExpandedExpander content AutomationProperties.Name property is not visible once collapsed
VerifyElement.NotFound("ExpanderWithToggleSwitch Content", FindBy.Name);
}
}
}
}
| 33.230366 | 115 | 0.606586 | [
"MIT"
] | SamChaps/microsoft-ui-xaml | dev/Expander/InteractionTests/ExpanderTests.cs | 6,349 | C# |
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Net.Http;
using System.Threading.Tasks;
using Windows.Storage;
using VDMP.App.Model;
using VDMP.DBmodel;
namespace VDMP.App.Scraper
{
/// <summary>User for building movie objects</summary>
/// <remarks>
/// Called upon either by Collection picker class, or when user wants
/// to update a movie
/// </remarks>
public class MediaBuilder
{
/// <summary>Adds a new video asynchronous.</summary>
/// <param name="file">A scanned file from disk.</param>
/// <returns>A movie object matching results found</returns>
public async Task<Movie> AddANewVideoAsync(StorageFile file)
{
var response = new Movie();
// See if there is a hit for the file:
var results = await SearchForMetaDataAsync(file).ConfigureAwait(false);
if (results != null)
{
if (results.Count > 1)
{
// Look up the first hit:
response = await LookUpKnownMediaIdAsync(results[0].id).ConfigureAwait(false);
}
}
return await MovieBuilder(response, file).ConfigureAwait(true);
}
/// <summary>
/// Searches for matching titles asynchronous.
/// Used when the user requests to update a movie
/// </summary>
/// <param name="titleToSearchFor">The title passed by the user.</param>
/// <returns>Returns a ObservableCollection with results</returns>
public async Task<ObservableCollection<Result>> SearchForMatchingTitleAsync(string titleToSearchFor)
{
var response = await Response(titleToSearchFor).ConfigureAwait(false);
if (response == null) return null;
var results = new ObservableCollection<Result>();
if (response.Count <= 1) return results;
foreach (var resp in response)
{
resp.Poster_path = "https://image.tmdb.org/t/p/w500" + resp.Poster_path;
results.Add(resp);
}
return results;
}
public async Task<Movie> UpdateSecondStage(Movie oldMovie, int idForNewMove)
{
// Look up selection from user
var response = await LookUpKnownMediaIdAsync(idForNewMove).ConfigureAwait(true);
return await MovieBuilderUpdater(response, oldMovie).ConfigureAwait(true);
}
/// <summary>Searches for meta data asynchronous.</summary>
/// <param name="file">The file.</param>
/// <returns></returns>
private async Task<List<Result>> SearchForMetaDataAsync(StorageFile file)
{
// Check if file is supported
if (file == null) return null;
var supportedMedia = new List<string> {".mov", ".mkv", ".avi", ".mpg"};
if (supportedMedia.Contains(file.FileType))
{
return await Response(new FileNameCleaner(file.Name).ReturnTidyFilename()).ConfigureAwait(false);
}
// Illegal media was inserted or connection was down
return null;
}
private async Task<List<Result>> Response(string titleToSearchFor)
{
try
{
var tmdbApi = new TMDBApi();
var response = await tmdbApi.SearchForMovieAsync(titleToSearchFor)
.ConfigureAwait(true);
//Search returned no matches
if (response != null)
return response;
}
catch (HttpRequestException)
{
// Connection was down?
//Console.WriteLine(e);
}
return null;
}
/// <summary>Looks up known media identifier asynchronous.</summary>
/// <param name="idForMedia">The identifier for media.</param>
/// <returns></returns>
protected virtual async Task<Movie> LookUpKnownMediaIdAsync(int idForMedia)
{
var tmdbApi = new TMDBApi();
if (idForMedia > -1)
{
var response = await tmdbApi.LookUpIdForMovieAsync(idForMedia).ConfigureAwait(false);
return response;
}
// Illegal media was inserted
return null;
}
/// <summary>Injects a poster image to the movie file.</summary>
/// <param name="response">The response containing the posters.</param>
/// <remarks>If the file can't be matched with any responses, default posters are set</remarks>
/// <returns>Gives back the updated response with set posters.</returns>
private async Task<Movie> PosterInserter(Movie response)
{
// If there are supplied values, assign posters:
if (response.PosterPath != null && response.BackdropPath != null)
{
var img = new ImageDownloader();
var img2 = new ImageDownloader();
try
{
var urlGrid = await img.ImageDownloaderTask($"https://image.tmdb.org/t/p/w500{response.PosterPath}",
response.PosterPath).ConfigureAwait(true);
await Task.Delay(100).ConfigureAwait(true);
var urlBack = await img2.ImageDownloaderTask(
$"https://image.tmdb.org/t/p/w780{response.BackdropPath}",
response.PosterPath).ConfigureAwait(true);
await Task.Delay(100).ConfigureAwait(true);
response.GridPosterImageSource = urlGrid;
response.BackdropImageSource = urlBack;
}
catch (HttpRequestException e)
{
// Loss of connection occured
Console.WriteLine(e);
throw;
}
}
else
{
// If no values were given, set default:
response.GridPosterImageSource =
"ms-appx:///Assets/splashsquare.png";
response.BackdropImageSource = "ms-appx:///Assets/splashsquare.png";
response.TitleOfMovie = response.FileName;
}
return response;
}
/// <summary>Builds a movie object by combining the file info and response info.</summary>
/// <param name="response">The response matching the file data.</param>
/// <param name="file">File scanned on disk.</param>
/// <returns>A movie object</returns>
private async Task<Movie> MovieBuilder(Movie response, StorageFile file)
{
// Assign file values to movie object
response.FileName = file.Name;
response.PathToVideo = file.Path;
response = await PosterInserter(response).ConfigureAwait(true);
if (response.TMDbId != 0)
{
response.genre = response.GenresMovie[0].IdGenre;
}
return response;
}
// When a movie is replaced
private async Task<Movie> MovieBuilderUpdater(Movie response, Movie oldMovie)
{
// Get unique properties
response.FileName = oldMovie.FileName;
response.PathToVideo = oldMovie.PathToVideo;
response.genre = response.GenresMovie[0].IdGenre;
response.Rating = oldMovie.Rating;
response.TMDbId = oldMovie.TMDbId;
response = await PosterInserter(response).ConfigureAwait(true);
response.LibraryId = oldMovie.LibraryId;
response.MovieId = oldMovie.MovieId;
return response;
}
}
} | 40.691919 | 121 | 0.551446 | [
"MIT"
] | Andreni/VDMP_public | VDMP.App/Scraper/MediaBuilder.cs | 8,059 | C# |
using System.Text;
using Xunit;
namespace Librame.Extensions.Core.Tests
{
using Serializers;
public class SerializableStringTests
{
[Fact]
public void AllTest()
{
var encoding = new SerializableString<Encoding>(Encoding.UTF8);
Assert.NotEmpty(encoding.Value);
var rawEncoding = encoding.Value;
encoding.ChangeSource(Encoding.ASCII);
Assert.NotEmpty(encoding.Value);
Assert.NotEqual(rawEncoding, encoding.Value);
}
}
}
| 22.625 | 75 | 0.616943 | [
"MIT"
] | gitter-badger/extensions-2 | tests/Librame.Extensions.Core.Abstractions.Tests/Serializers/SerializableStringTests.cs | 545 | C# |
// This file was generated by a tool; you should avoid making direct changes.
// Consider using 'partial classes' to extend these types
// Input: map_crosswalk.proto
#pragma warning disable 0612, 1591, 3021
namespace apollo.hdmap
{
[global::ProtoBuf.ProtoContract()]
public partial class Crosswalk : global::ProtoBuf.IExtensible
{
private global::ProtoBuf.IExtension __pbn__extensionData;
global::ProtoBuf.IExtension global::ProtoBuf.IExtensible.GetExtensionObject(bool createIfMissing)
{
return global::ProtoBuf.Extensible.GetExtensionObject(ref __pbn__extensionData, createIfMissing);
}
public Crosswalk()
{
overlap_id = new global::System.Collections.Generic.List<Id>();
OnConstructor();
}
partial void OnConstructor();
[global::ProtoBuf.ProtoMember(1)]
public Id id { get; set; }
[global::ProtoBuf.ProtoMember(2)]
public Polygon polygon { get; set; }
[global::ProtoBuf.ProtoMember(3)]
public global::System.Collections.Generic.List<Id> overlap_id { get; private set; }
}
}
#pragma warning restore 0612, 1591, 3021
| 30.538462 | 109 | 0.671704 | [
"Apache-2.0",
"BSD-3-Clause"
] | 0x8BADFOOD/simulator | Assets/Scripts/Bridge/Cyber/Protobuf/map/proto/map_crosswalk.cs | 1,191 | C# |
namespace CodeBase.Off.Website.Models {
using System.ComponentModel;
public sealed class AttributeGridModel {
[DisplayName(@"شناسه مالک")]
public object Owner { get; set; }
[DisplayName(@"کلید")]
public string Key { get; set; }
[DisplayName(@"مقدار")]
public object Value { get; set; }
}
} | 25.214286 | 44 | 0.597734 | [
"MIT"
] | m-sadegh-sh/CodeBase | src/Off/CodeBase.Off.Website/Models/AttributeGridModel.cs | 373 | C# |
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace MyChess.Interfaces
{
public class UserSettings
{
[JsonPropertyName("id")]
public string ID { get; set; } = string.Empty;
[JsonPropertyName("playAlwaysUp")]
public bool PlayAlwaysUp { get; set; }
[JsonPropertyName("notifications")]
public List<UserNotifications> Notifications { get; set; } = new List<UserNotifications>();
}
}
| 27.222222 | 100 | 0.640816 | [
"MIT"
] | JanneMattila/mychess | src/MyChess/Interfaces/UserSettings.cs | 492 | C# |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using Microsoft.AspNetCore.Razor.Language.Legacy;
namespace Microsoft.AspNetCore.Razor.Language.Syntax
{
internal static class SyntaxNodeExtensions
{
public static TNode WithAnnotations<TNode>(this TNode node, params SyntaxAnnotation[] annotations) where TNode : SyntaxNode
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
return (TNode)node.Green.SetAnnotations(annotations).CreateRed(node.Parent, node.Position);
}
public static object GetAnnotationValue<TNode>(this TNode node, string key) where TNode : SyntaxNode
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
var annotation = node.GetAnnotations().FirstOrDefault(n => n.Kind == key);
return annotation?.Data;
}
public static TNode WithDiagnostics<TNode>(this TNode node, params RazorDiagnostic[] diagnostics) where TNode : SyntaxNode
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
return (TNode)node.Green.SetDiagnostics(diagnostics).CreateRed(node.Parent, node.Position);
}
public static TNode AppendDiagnostic<TNode>(this TNode node, params RazorDiagnostic[] diagnostics) where TNode : SyntaxNode
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
var existingDiagnostics = node.GetDiagnostics();
var allDiagnostics = existingDiagnostics.Concat(diagnostics).ToArray();
return (TNode)node.WithDiagnostics(allDiagnostics);
}
public static SourceLocation GetSourceLocation(this SyntaxNode node, RazorSourceDocument source)
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
try
{
if (source.Length == 0)
{
// Just a marker symbol
return new SourceLocation(source.FilePath, 0, 0, 0);
}
if (node.Position == source.Length)
{
// E.g. Marker symbol at the end of the document
var lastPosition = source.Length - 1;
var endsWithLineBreak = ParserHelpers.IsNewLine(source[lastPosition]);
var lastLocation = source.Lines.GetLocation(lastPosition);
return new SourceLocation(
source.FilePath, // GetLocation prefers RelativePath but we want FilePath.
lastLocation.AbsoluteIndex + 1,
lastLocation.LineIndex + (endsWithLineBreak ? 1 : 0),
endsWithLineBreak ? 0 : lastLocation.CharacterIndex + 1);
}
var location = source.Lines.GetLocation(node.Position);
return new SourceLocation(
source.FilePath, // GetLocation prefers RelativePath but we want FilePath.
location.AbsoluteIndex,
location.LineIndex,
location.CharacterIndex);
}
catch (IndexOutOfRangeException)
{
Debug.Assert(false, "Node position should stay within document length.");
return new SourceLocation(source.FilePath, node.Position, 0, 0);
}
}
public static SourceSpan GetSourceSpan(this SyntaxNode node, RazorSourceDocument source)
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
var location = node.GetSourceLocation(source);
return new SourceSpan(location, node.FullWidth);
}
/// <summary>
/// Creates a new tree of nodes with the specified nodes, tokens and trivia replaced.
/// </summary>
/// <typeparam name="TRoot">The type of the root node.</typeparam>
/// <param name="root">The root node of the tree of nodes.</param>
/// <param name="nodes">The nodes to be replaced.</param>
/// <param name="computeReplacementNode">A function that computes a replacement node for the
/// argument nodes. The first argument is the original node. The second argument is the same
/// node potentially rewritten with replaced descendants.</param>
public static TRoot ReplaceSyntax<TRoot>(
this TRoot root,
IEnumerable<SyntaxNode> nodes,
Func<SyntaxNode, SyntaxNode, SyntaxNode> computeReplacementNode)
where TRoot : SyntaxNode
{
return (TRoot)root.ReplaceCore(
nodes: nodes, computeReplacementNode: computeReplacementNode);
}
/// <summary>
/// Creates a new tree of nodes with the specified old node replaced with a new node.
/// </summary>
/// <typeparam name="TRoot">The type of the root node.</typeparam>
/// <typeparam name="TNode">The type of the nodes being replaced.</typeparam>
/// <param name="root">The root node of the tree of nodes.</param>
/// <param name="nodes">The nodes to be replaced; descendants of the root node.</param>
/// <param name="computeReplacementNode">A function that computes a replacement node for the
/// argument nodes. The first argument is the original node. The second argument is the same
/// node potentially rewritten with replaced descendants.</param>
public static TRoot ReplaceNodes<TRoot, TNode>(this TRoot root, IEnumerable<TNode> nodes, Func<TNode, TNode, SyntaxNode> computeReplacementNode)
where TRoot : SyntaxNode
where TNode : SyntaxNode
{
return (TRoot)root.ReplaceCore(nodes: nodes, computeReplacementNode: computeReplacementNode);
}
/// <summary>
/// Creates a new tree of nodes with the specified old node replaced with a new node.
/// </summary>
/// <typeparam name="TRoot">The type of the root node.</typeparam>
/// <param name="root">The root node of the tree of nodes.</param>
/// <param name="oldNode">The node to be replaced; a descendant of the root node.</param>
/// <param name="newNode">The new node to use in the new tree in place of the old node.</param>
public static TRoot ReplaceNode<TRoot>(this TRoot root, SyntaxNode oldNode, SyntaxNode newNode)
where TRoot : SyntaxNode
{
if (oldNode == newNode)
{
return root;
}
return (TRoot)root.ReplaceCore(nodes: new[] { oldNode }, computeReplacementNode: (o, r) => newNode);
}
/// <summary>
/// Creates a new tree of nodes with specified old node replaced with a new nodes.
/// </summary>
/// <typeparam name="TRoot">The type of the root node.</typeparam>
/// <param name="root">The root of the tree of nodes.</param>
/// <param name="oldNode">The node to be replaced; a descendant of the root node and an element of a list member.</param>
/// <param name="newNodes">A sequence of nodes to use in the tree in place of the old node.</param>
public static TRoot ReplaceNode<TRoot>(this TRoot root, SyntaxNode oldNode, IEnumerable<SyntaxNode> newNodes)
where TRoot : SyntaxNode
{
return (TRoot)root.ReplaceNodeInListCore(oldNode, newNodes);
}
/// <summary>
/// Creates a new tree of nodes with new nodes inserted before the specified node.
/// </summary>
/// <typeparam name="TRoot">The type of the root node.</typeparam>
/// <param name="root">The root of the tree of nodes.</param>
/// <param name="nodeInList">The node to insert before; a descendant of the root node an element of a list member.</param>
/// <param name="newNodes">A sequence of nodes to insert into the tree immediately before the specified node.</param>
public static TRoot InsertNodesBefore<TRoot>(this TRoot root, SyntaxNode nodeInList, IEnumerable<SyntaxNode> newNodes)
where TRoot : SyntaxNode
{
return (TRoot)root.InsertNodesInListCore(nodeInList, newNodes, insertBefore: true);
}
/// <summary>
/// Creates a new tree of nodes with new nodes inserted after the specified node.
/// </summary>
/// <typeparam name="TRoot">The type of the root node.</typeparam>
/// <param name="root">The root of the tree of nodes.</param>
/// <param name="nodeInList">The node to insert after; a descendant of the root node an element of a list member.</param>
/// <param name="newNodes">A sequence of nodes to insert into the tree immediately after the specified node.</param>
public static TRoot InsertNodesAfter<TRoot>(this TRoot root, SyntaxNode nodeInList, IEnumerable<SyntaxNode> newNodes)
where TRoot : SyntaxNode
{
return (TRoot)root.InsertNodesInListCore(nodeInList, newNodes, insertBefore: false);
}
public static string GetContent<TNode>(this TNode node) where TNode : SyntaxNode
{
if (node == null)
{
throw new ArgumentNullException(nameof(node));
}
var tokens = node.DescendantNodes().Where(n => n.IsToken).Cast<SyntaxToken>();
var content = string.Concat(tokens.Select(t => t.Content));
return content;
}
public static string GetTagName(this MarkupTagBlockSyntax tagBlock)
{
if (tagBlock == null)
{
throw new ArgumentNullException(nameof(tagBlock));
}
var child = tagBlock.Children[0];
if (tagBlock.Children.Count == 0 || !(child is MarkupTextLiteralSyntax))
{
return null;
}
var childLiteral = (MarkupTextLiteralSyntax)child;
SyntaxToken textToken = null;
for (var i = 0; i < childLiteral.LiteralTokens.Count; i++)
{
var token = childLiteral.LiteralTokens[i];
if (token != null &&
(token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.Text))
{
textToken = token;
break;
}
}
if (textToken == null)
{
return null;
}
return textToken.Kind == SyntaxKind.Whitespace ? null : textToken.Content;
}
public static string GetTagName(this MarkupTagHelperStartTagSyntax tagBlock)
{
if (tagBlock == null)
{
throw new ArgumentNullException(nameof(tagBlock));
}
var child = tagBlock.Children[0];
if (tagBlock.Children.Count == 0 || !(child is MarkupTextLiteralSyntax))
{
return null;
}
var childLiteral = (MarkupTextLiteralSyntax)child;
SyntaxToken textToken = null;
for (var i = 0; i < childLiteral.LiteralTokens.Count; i++)
{
var token = childLiteral.LiteralTokens[i];
if (token != null &&
(token.Kind == SyntaxKind.Whitespace || token.Kind == SyntaxKind.Text))
{
textToken = token;
break;
}
}
if (textToken == null)
{
return null;
}
return textToken.Kind == SyntaxKind.Whitespace ? null : textToken.Content;
}
public static bool IsSelfClosing(this MarkupTagBlockSyntax tagBlock)
{
if (tagBlock == null)
{
throw new ArgumentNullException(nameof(tagBlock));
}
var lastChild = tagBlock.ChildNodes().LastOrDefault();
return lastChild?.GetContent().EndsWith("/>", StringComparison.Ordinal) ?? false;
}
public static bool IsVoidElement(this MarkupTagBlockSyntax tagBlock)
{
if (tagBlock == null)
{
throw new ArgumentNullException(nameof(tagBlock));
}
return ParserHelpers.VoidElements.Contains(tagBlock.GetTagName());
}
}
}
| 41.266458 | 152 | 0.578851 | [
"Apache-2.0"
] | hvanbakel/AspNetCore | src/Razor/src/Microsoft.AspNetCore.Razor.Language/Syntax/SyntaxNodeExtensions.cs | 13,166 | C# |
namespace ARMeilleure.CodeGen.Unwinding
{
struct UnwindInfo
{
public UnwindPushEntry[] PushEntries { get; }
public int PrologueSize { get; }
public int FixedAllocSize { get; }
public UnwindInfo(UnwindPushEntry[] pushEntries, int prologueSize, int fixedAllocSize)
{
PushEntries = pushEntries;
PrologueSize = prologueSize;
FixedAllocSize = fixedAllocSize;
}
}
} | 25.722222 | 94 | 0.615551 | [
"MIT"
] | AidanXu/Ryujinx | ARMeilleure/CodeGen/Unwinding/UnwindInfo.cs | 463 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.CodeFixes;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.UseConditionalExpression;
using Microsoft.CodeAnalysis.Diagnostics;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Diagnostics;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.UseConditionalExpression
{
public partial class UseConditionalExpressionForReturnTests : AbstractCSharpDiagnosticProviderBasedUserDiagnosticTest
{
public UseConditionalExpressionForReturnTests(ITestOutputHelper logger)
: base(logger)
{
}
internal override (DiagnosticAnalyzer, CodeFixProvider) CreateDiagnosticProviderAndFixer(Workspace workspace)
=> (new CSharpUseConditionalExpressionForReturnDiagnosticAnalyzer(),
new CSharpUseConditionalExpressionForReturnCodeFixProvider());
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnSimpleReturn()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
return 0;
}
else
{
return 1;
}
}
}",
@"
class C
{
int M()
{
return true ? 0 : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnSimpleReturn_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return 1;
}
}
}",
@"
class C
{
int M()
{
return true ? throw new System.Exception() : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnSimpleReturn_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
return 0;
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
int M()
{
return true ? 0 : throw new System.Exception();
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotWithTwoThrows()
{
await TestMissingAsync(
@"
class C
{
int M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
throw new System.Exception();
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotOnSimpleReturn_Throw1_CSharp6()
{
await TestMissingAsync(
@"
class C
{
int M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return 1;
}
}
}", parameters: new TestParameters(parseOptions: CSharpParseOptions.Default.WithLanguageVersion(LanguageVersion.CSharp6)));
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotWithSimpleThrow()
{
await TestMissingAsync(
@"
class C
{
int M()
{
[||]if (true)
{
throw;
}
else
{
return 1;
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnSimpleReturnNoBlocks()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
return 0;
else
return 1;
}
}",
@"
class C
{
int M()
{
return true ? 0 : 1;
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnSimpleReturnNoBlocks_NotInBlock()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
if (true)
[||]if (true)
return 0;
else
return 1;
}
}",
@"
class C
{
int M()
{
if (true)
return true ? 0 : 1;
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingReturnValue1()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
return 0;
}
else
{
return;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingReturnValue1_Throw()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return;
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingReturnValue2()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
return;
}
else
{
return 1;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingReturnValue2_Throw()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
return;
}
else
{
throw new System.Exception();
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingReturnValue3()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
return;
}
else
{
return;
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestWithNoElseBlockButFollowingReturn()
{
await TestInRegularAndScript1Async(
@"
class C
{
void M()
{
[||]if (true)
{
return 0;
}
return 1;
}
}",
@"
class C
{
void M()
{
return true ? 0 : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestWithNoElseBlockButFollowingReturn_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
void M()
{
[||]if (true)
{
throw new System.Exception();
}
return 1;
}
}",
@"
class C
{
void M()
{
return true ? throw new System.Exception() : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestWithNoElseBlockButFollowingReturn_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
void M()
{
[||]if (true)
{
return 0;
}
throw new System.Exception();
}
}",
@"
class C
{
void M()
{
return true ? 0 : throw new System.Exception();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingWithoutElse()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
return 0;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingWithoutElse_Throw()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
[||]if (true)
{
throw new System.Exception();
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestConversion1()
{
await TestInRegularAndScript1Async(
@"
class C
{
object M()
{
[||]if (true)
{
return ""a"";
}
else
{
return ""b"";
}
}
}",
@"
class C
{
object M()
{
return true ? ""a"" : ""b"";
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestConversion1_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
object M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return ""b"";
}
}
}",
@"
class C
{
object M()
{
return true ? throw new System.Exception() : ""b"";
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestConversion1_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
object M()
{
[||]if (true)
{
return ""a"";
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
object M()
{
return true ? ""a"" : throw new System.Exception();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestConversion2()
{
await TestInRegularAndScript1Async(
@"
class C
{
string M()
{
[||]if (true)
{
return ""a"";
}
else
{
return null;
}
}
}",
@"
class C
{
string M()
{
return true ? ""a"" : null;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
[InlineData(LanguageVersion.CSharp8, "(string)null")]
[InlineData(LanguageVersion.CSharp9, "null")]
public async Task TestConversion2_Throw1(LanguageVersion languageVersion, string expectedFalseExpression)
{
await TestInRegularAndScript1Async(
@"
class C
{
string M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return null;
}
}
}",
@"
class C
{
string M()
{
return true ? throw new System.Exception() : " + expectedFalseExpression + @";
}
}", parameters: new(parseOptions: CSharpParseOptions.Default.WithLanguageVersion(languageVersion)));
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestConversion2_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
string M()
{
[||]if (true)
{
return ""a"";
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
string M()
{
return true ? ""a"" : throw new System.Exception();
}
}");
}
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
[InlineData(LanguageVersion.CSharp8, "(string)null")]
[InlineData(LanguageVersion.CSharp9, "null")]
public async Task TestConversion3(LanguageVersion languageVersion, string expectedFalseExpression)
{
await TestInRegularAndScript1Async(
@"
class C
{
string M()
{
[||]if (true)
{
return null;
}
else
{
return null;
}
}
}",
@"
class C
{
string M()
{
return true ? null : " + expectedFalseExpression + @";
}
}", parameters: new(parseOptions: CSharpParseOptions.Default.WithLanguageVersion(languageVersion)));
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
[InlineData(LanguageVersion.CSharp8, "(string)null")]
[InlineData(LanguageVersion.CSharp9, "null")]
public async Task TestConversion3_Throw1(LanguageVersion languageVersion, string expectedFalseExpression)
{
await TestInRegularAndScript1Async(
@"
class C
{
string M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return null;
}
}
}",
@"
class C
{
string M()
{
return true ? throw new System.Exception() : " + expectedFalseExpression + @";
}
}", parameters: new(parseOptions: CSharpParseOptions.Default.WithLanguageVersion(languageVersion)));
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Theory, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
[InlineData(LanguageVersion.CSharp8, "(string)null")]
[InlineData(LanguageVersion.CSharp9, "null")]
public async Task TestConversion3_Throw2(LanguageVersion languageVersion, string expectedTrue)
{
await TestInRegularAndScript1Async(
@"
class C
{
string M()
{
[||]if (true)
{
return null;
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
string M()
{
return true ? " + expectedTrue + @" : throw new System.Exception();
}
}", parameters: new(parseOptions: CSharpParseOptions.Default.WithLanguageVersion(languageVersion)));
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestKeepTriviaAroundIf()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
// leading
[||]if (true)
{
return 0;
}
else
{
return 1;
} // trailing
}
}",
@"
class C
{
int M()
{
// leading
return true ? 0 : 1; // trailing
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestFixAll1()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
{|FixAllInDocument:if|} (true)
{
return 0;
}
else
{
return 1;
}
if (true)
{
return 2;
}
return 3;
}
}",
@"
class C
{
int M()
{
return true ? 0 : 1;
return true ? 2 : 3;
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMultiLine1()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
return Foo(
1, 2, 3);
}
else
{
return 1;
}
}
}",
@"
class C
{
int M()
{
return true
? Foo(
1, 2, 3)
: 1;
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMultiLine2()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
return 0;
}
else
{
return Foo(
1, 2, 3);
}
}
}",
@"
class C
{
int M()
{
return true
? 0
: Foo(
1, 2, 3);
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMultiLine3()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
return Foo(
1, 2, 3);
}
else
{
return Foo(
4, 5, 6);
}
}
}",
@"
class C
{
int M()
{
return true
? Foo(
1, 2, 3)
: Foo(
4, 5, 6);
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestElseIfWithBlock()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
if (true)
{
}
else [||]if (false)
{
return 1;
}
else
{
return 0;
}
}
}",
@"
class C
{
int M()
{
if (true)
{
}
else
{
return false ? 1 : 0;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestElseIfWithBlock_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
if (true)
{
}
else [||]if (false)
{
throw new System.Exception();
}
else
{
return 0;
}
}
}",
@"
class C
{
int M()
{
if (true)
{
}
else
{
return false ? throw new System.Exception() : 0;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestElseIfWithBlock_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
if (true)
{
}
else [||]if (false)
{
return 1;
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
int M()
{
if (true)
{
}
else
{
return false ? 1 : throw new System.Exception();
}
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestElseIfWithoutBlock()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
if (true) return 2;
else [||]if (false) return 1;
else return 0;
}
}",
@"
class C
{
int M()
{
if (true) return 2;
else return false ? 1 : 0;
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestRefReturns1()
{
await TestInRegularAndScript1Async(
@"
class C
{
ref int M(ref int i, ref int j)
{
[||]if (true)
{
return ref i;
}
else
{
return ref j;
}
}
}",
@"
class C
{
ref int M(ref int i, ref int j)
{
return ref true ? ref i : ref j;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestRefReturns1_Throw1()
{
await TestMissingAsync(
@"
class C
{
ref int M(ref int i, ref int j)
{
[||]if (true)
{
throw new System.Exception();
}
else
{
return ref j;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestRefReturns1_Throw2()
{
await TestMissingAsync(
@"
class C
{
ref int M(ref int i, ref int j)
{
[||]if (true)
{
return ref i;
}
else
{
throw new System.Exception();
}
}
}");
}
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnYieldReturn()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
yield return 0;
}
else
{
yield return 1;
}
}
}",
@"
class C
{
int M()
{
yield return true ? 0 : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnYieldReturn_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
throw new System.Exception();
}
else
{
yield return 1;
}
}
}",
@"
class C
{
int M()
{
yield return true ? throw new System.Exception() : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnYieldReturn_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
int M()
{
[||]if (true)
{
yield return 0;
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
int M()
{
yield return true ? 0 : throw new System.Exception();
}
}");
}
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestOnYieldReturn_IEnumerableReturnType()
{
await TestInRegularAndScript1Async(
@"
using System.Collections.Generic;
class C
{
IEnumerable<int> M()
{
[||]if (true)
{
yield return 0;
}
else
{
yield return 1;
}
}
}",
@"
using System.Collections.Generic;
class C
{
IEnumerable<int> M()
{
yield return true ? 0 : 1;
}
}");
}
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotOnMixedYields()
{
await TestMissingAsync(
@"
class C
{
int M()
{
[||]if (true)
{
yield break;
}
else
{
yield return 1;
}
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotOnMixedYields_Throw1()
{
await TestMissingAsync(
@"
class C
{
int M()
{
[||]if (true)
{
yield break;
}
else
{
throw new System.Exception();
}
}
}");
}
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotOnMixedYields_IEnumerableReturnType()
{
await TestMissingAsync(
@"
using System.Collections.Generic;
class C
{
IEnumerable<int> M()
{
[||]if (true)
{
yield break;
}
else
{
yield return 1;
}
}
}");
}
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotWithNoElseBlockButFollowingYieldReturn()
{
await TestMissingAsync(
@"
class C
{
void M()
{
[||]if (true)
{
yield return 0;
}
yield return 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestWithNoElseBlockButFollowingYieldReturn_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
void M()
{
[||]if (true)
{
throw new System.Exception();
}
yield return 1;
}
}",
@"
class C
{
void M()
{
yield return true ? throw new System.Exception() : 1;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotWithNoElseBlockButFollowingYieldReturn_Throw2()
{
await TestMissingAsync(
@"
class C
{
void M()
{
[||]if (true)
{
yield return 0;
}
throw new System.Exception();
}
}");
}
[WorkItem(27960, "https://github.com/dotnet/roslyn/issues/27960")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestNotWithNoElseBlockButFollowingYieldReturn_IEnumerableReturnType()
{
await TestMissingAsync(
@"
using System.Collections.Generic;
class C
{
IEnumerable<int> M()
{
[||]if (true)
{
yield return 0;
}
yield return 1;
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse1()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
return true;
}
else
{
return false;
}
}
}",
@"
class C
{
bool M(int a)
{
return a == 0;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse1_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
throw new System.Exception();
}
else
{
return false;
}
}
}",
@"
class C
{
bool M(int a)
{
return a == 0 ? throw new System.Exception() : false;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse1_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
return true;
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
bool M(int a)
{
return a == 0 ? true : throw new System.Exception();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse2()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
return false;
}
else
{
return true;
}
}
}",
@"
class C
{
bool M(int a)
{
return a != 0;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse2_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
throw new System.Exception();
}
else
{
return true;
}
}
}",
@"
class C
{
bool M(int a)
{
return a == 0 ? throw new System.Exception() : true;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse2_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
return false;
}
else
{
throw new System.Exception();
}
}
}",
@"
class C
{
bool M(int a)
{
return a == 0 ? false : throw new System.Exception();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse3()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
return false;
}
return true;
}
}",
@"
class C
{
bool M(int a)
{
return a != 0;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse3_Throw1()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
throw new System.Exception();
}
return true;
}
}",
@"
class C
{
bool M(int a)
{
return a == 0 ? throw new System.Exception() : true;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse3_Throw2()
{
await TestInRegularAndScript1Async(
@"
class C
{
bool M(int a)
{
[||]if (a == 0)
{
return false;
}
throw new System.Exception();
}
}",
@"
class C
{
bool M(int a)
{
return a == 0 ? false : throw new System.Exception();
}
}");
}
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse4()
{
await TestInRegularAndScript1Async(
@"
using System.Collections.Generic;
class C
{
IEnumerable<bool> M(int a)
{
[||]if (a == 0)
{
yield return false;
}
else
{
yield return true;
}
}
}",
@"
using System.Collections.Generic;
class C
{
IEnumerable<bool> M(int a)
{
yield return a != 0;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse4_Throw1()
{
await TestInRegularAndScript1Async(
@"
using System.Collections.Generic;
class C
{
IEnumerable<bool> M(int a)
{
[||]if (a == 0)
{
throw new System.Exception();
}
else
{
yield return true;
}
}
}",
@"
using System.Collections.Generic;
class C
{
IEnumerable<bool> M(int a)
{
yield return a == 0 ? throw new System.Exception() : true;
}
}");
}
[WorkItem(43291, "https://github.com/dotnet/roslyn/issues/43291")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestReturnTrueFalse4_Throw2()
{
await TestInRegularAndScript1Async(
@"
using System.Collections.Generic;
class C
{
IEnumerable<bool> M(int a)
{
[||]if (a == 0)
{
yield return false;
}
else
{
throw new System.Exception();
}
}
}",
@"
using System.Collections.Generic;
class C
{
IEnumerable<bool> M(int a)
{
yield return a == 0 ? false : throw new System.Exception();
}
}");
}
[WorkItem(36117, "https://github.com/dotnet/roslyn/issues/36117")]
[Fact, Trait(Traits.Feature, Traits.Features.CodeActionsUseConditionalExpression)]
public async Task TestMissingWhenCrossingPreprocessorDirective()
{
await TestMissingInRegularAndScriptAsync(
@"
class C
{
int M()
{
bool check = true;
#if true
[||]if (check)
return 3;
#endif
return 2;
}
}");
}
}
}
| 19.747909 | 123 | 0.524345 | [
"MIT"
] | 333fred/roslyn | src/Analyzers/CSharp/Tests/UseConditionalExpression/UseConditionalExpressionForReturnTests.cs | 35,410 | C# |
using System;
using System.Net.Http;
using System.Net.Http.Headers;
namespace GitHubCompanion.Services.Version4
{
/// <summary>
/// A base service class for all GitHub API v3 services.
/// </summary>
public abstract class GitHubServiceV4Base
{
protected const string API_ENDPOINT = "https://api.github.com/graphql";
protected HttpClient CreateHttpClient(string token = null)
{
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Add("User-Agent", "Git-Hub-Companion");
client.DefaultRequestHeaders.Add("Accept", "application/vnd.github.full+json");
if (!String.IsNullOrWhiteSpace(token)) client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", token);
return client;
}
}
} | 32.230769 | 143 | 0.671838 | [
"MIT"
] | RyanThiele/GitHub-Companion | GitHub Companion/GitHubCompanion.Services/Version4/_GitHubServiceV4Base.cs | 840 | C# |
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Manual changes to this file may cause unexpected behavior in your application.
// Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DatabaseConnector
{
using System;
using System.Collections.Generic;
public partial class productSimple
{
public int id { get; set; }
public string name { get; set; }
public string category_name { get; set; }
public Nullable<bool> sold { get; set; }
public Nullable<bool> stored { get; set; }
}
}
| 33.125 | 85 | 0.518239 | [
"MIT"
] | DrimTim32/db_gui | Main/DatabaseConnector/productSimple.cs | 795 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace UI.Models.DAL
{
public class ProductImagess : BaseModel
{
public string desc { get; set; }
public string image_url { get; set; }
}
}
| 19.285714 | 45 | 0.677778 | [
"MIT"
] | feritgezgil/ASP.NET-CORE-MVC-Ecommerce | UI/Models/DAL/ProductModels/ProductImagess.cs | 272 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using Cassette.Scripts;
using Cassette.Stylesheets;
using Cassette.Utilities;
#if NET35
using Iesi.Collections.Generic;
#endif
namespace Cassette
{
class ReferenceBuilder : IReferenceBuilder
{
public ReferenceBuilder(BundleCollection allBundles, IPlaceholderTracker placeholderTracker, IBundleFactoryProvider bundleFactoryProvider, CassetteSettings settings)
{
this.allBundles = allBundles;
this.placeholderTracker = placeholderTracker;
this.bundleFactoryProvider = bundleFactoryProvider;
this.settings = settings;
}
readonly BundleCollection allBundles;
readonly IPlaceholderTracker placeholderTracker;
readonly IBundleFactoryProvider bundleFactoryProvider;
readonly CassetteSettings settings;
readonly HashedSet<ReferencedBundle> referencedBundles = new HashedSet<ReferencedBundle>();
readonly HashedSet<string> renderedLocations = new HashedSet<string>();
public void Reference<T>(string path, string location = null)
where T : Bundle
{
using (allBundles.GetReadLock())
{
var factory = bundleFactoryProvider.GetBundleFactory<T>();
var bundles = GetBundles(path, () => factory.CreateExternalBundle(path)).OfType<T>();
#if NET35
Reference(bundles.Cast<Bundle>(), location);
#else
Reference(bundles, location);
#endif
}
}
public void Reference(string path, string location = null)
{
using (allBundles.GetReadLock())
{
var bundles = GetBundles(path, () => CreateExternalBundleByInferringTypeFromFileExtension(path));
Reference(bundles, location);
}
}
Bundle CreateExternalBundleByInferringTypeFromFileExtension(string path)
{
var pathToExamine = path.IsUrl() ? RemoveQuerystring(path) : path;
if (pathToExamine.EndsWith(".js", StringComparison.OrdinalIgnoreCase))
{
return CreateExternalScriptBundle(path);
}
else if (pathToExamine.EndsWith(".css", StringComparison.OrdinalIgnoreCase))
{
return CreateExternalStylesheetBundle(path);
}
else
{
throw new ArgumentException(
string.Format(
"Cannot determine the type of bundle for the URL \"{0}\". Specify the type using the generic type parameter.",
path
)
);
}
}
string RemoveQuerystring(string url)
{
var index = url.IndexOf('?');
if (index < 0) return url;
return url.Substring(0, index);
}
Bundle CreateExternalScriptBundle(string path)
{
var factory = bundleFactoryProvider.GetBundleFactory<ScriptBundle>();
return factory.CreateExternalBundle(path);
}
Bundle CreateExternalStylesheetBundle(string path)
{
var factory = bundleFactoryProvider.GetBundleFactory<StylesheetBundle>();
return factory.CreateExternalBundle(path);
}
IEnumerable<Bundle> GetBundles(string path, Func<Bundle> createExternalBundle)
{
path = PathUtilities.AppRelative(path);
var bundles = allBundles.FindBundlesContainingPath(path).ToArray();
if (bundles.Length == 0 && path.IsUrl())
{
var bundle = createExternalBundle();
bundle.Process(settings);
bundles = new[] { bundle };
}
if (bundles.Length == 0)
{
throw new ArgumentException("Cannot find an asset bundle containing the path \"" + path + "\".");
}
return bundles;
}
public void Reference(Bundle bundle, string location = null)
{
using (allBundles.GetReadLock())
{
Reference(new[] { bundle }, location);
}
}
void Reference(IEnumerable<Bundle> bundles, string location = null)
{
if (!settings.IsHtmlRewritingEnabled && HasRenderedLocation(location))
{
ThrowRewritingRequiredException(location);
}
foreach (var bundle in bundles)
{
referencedBundles.Add(new ReferencedBundle(bundle, location));
}
foreach (var bundle in bundles)
{
var references = allBundles.FindAllReferences(bundle);
foreach (var reference in references)
{
referencedBundles.Add(new ReferencedBundle(reference));
}
}
}
bool HasRenderedLocation(string location)
{
return renderedLocations.Contains(location ?? "");
}
void ThrowRewritingRequiredException(string location)
{
if (string.IsNullOrEmpty(location))
{
throw new InvalidOperationException(
"Cannot add a bundle reference. The bundles have already been rendered. Either move the reference before the render call, or set ICassetteApplication.IsHtmlRewritingEnabled to true in your Cassette configuration."
);
}
else
{
throw new InvalidOperationException(
string.Format(
"Cannot add a bundle reference, for location \"{0}\". This location has already been rendered. Either move the reference before the render call, or set ICassetteApplication.IsHtmlRewritingEnabled to true in your Cassette configuration.",
location
)
);
}
}
public IEnumerable<Bundle> GetBundles(string location)
{
var bundles = referencedBundles.Where(r => r.PageLocation == location).Select(r => r.Bundle).ToArray();
return allBundles.SortBundles(bundles);
}
public string Render<T>(string location = null)
where T : Bundle
{
renderedLocations.Add(location ?? "");
return placeholderTracker.InsertPlaceholder(
() => CreateHtml<T>(location)
);
}
string CreateHtml<T>(string location)
where T : Bundle
{
return string.Join(Environment.NewLine,
GetBundles(location).OfType<T>().Select(
bundle => bundle.Render()
).ToArray()
);
}
class ReferencedBundle
{
readonly Bundle bundle;
readonly string pageLocation;
public ReferencedBundle(Bundle bundle, string pageLocation)
{
this.bundle = bundle;
this.pageLocation = pageLocation;
}
public ReferencedBundle(Bundle bundle)
{
this.bundle = bundle;
}
public Bundle Bundle
{
get { return bundle; }
}
public string PageLocation
{
get { return pageLocation ?? bundle.PageLocation; }
}
public override bool Equals(object obj)
{
var other = obj as ReferencedBundle;
return other != null
&& bundle.Equals(other.bundle);
}
public override int GetHashCode()
{
return bundle.GetHashCode();
}
}
}
} | 34.722222 | 262 | 0.539815 | [
"MIT"
] | DanielWare/cassette | src/Cassette/ReferenceBuilder.cs | 8,125 | C# |
// *** WARNING: this file was generated by the Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.AzureNative.Network.V20201101.Outputs
{
[OutputType]
public sealed class HubRouteResponse
{
/// <summary>
/// The type of destinations (eg: CIDR, ResourceId, Service).
/// </summary>
public readonly string DestinationType;
/// <summary>
/// List of all destinations.
/// </summary>
public readonly ImmutableArray<string> Destinations;
/// <summary>
/// The name of the Route that is unique within a RouteTable. This name can be used to access this route.
/// </summary>
public readonly string Name;
/// <summary>
/// NextHop resource ID.
/// </summary>
public readonly string NextHop;
/// <summary>
/// The type of next hop (eg: ResourceId).
/// </summary>
public readonly string NextHopType;
[OutputConstructor]
private HubRouteResponse(
string destinationType,
ImmutableArray<string> destinations,
string name,
string nextHop,
string nextHopType)
{
DestinationType = destinationType;
Destinations = destinations;
Name = name;
NextHop = nextHop;
NextHopType = nextHopType;
}
}
}
| 28.596491 | 113 | 0.595706 | [
"Apache-2.0"
] | sebtelko/pulumi-azure-native | sdk/dotnet/Network/V20201101/Outputs/HubRouteResponse.cs | 1,630 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
public class LongestSubstringWithoutRepeatingCharacters : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
/**
自己的解法:
使用一个字典保存当前循环的字符的位置,如果已经存在,则更新位置,并且更新非重复字符串的起始点
*/
public int LengthOfLongestSubstring(string s) {
if(string.IsNullOrEmpty(s)) return 0;
int result = 1;
int start = 0;
Dictionary<char, int> dic = new Dictionary<char, int>();
for(int i = 0; i < s.Length; i++){
if(dic.ContainsKey(s[i])){
start = Math.Max(dic[s[i]] + 1, start);
dic[s[i]] = i;
}else{
dic.Add(s[i], i);
}
result = Math.Max(result, i - start + 1);
}
return result;
}
}
| 22.525 | 73 | 0.559378 | [
"MIT"
] | dftty/LeetCode | Assets/Second/LongestSubstringWithoutRepeatingCharacters.cs | 1,007 | C# |
using System;
using System.Runtime.InteropServices;
namespace uk.JohnCook.dotnet.NAudioWrapperLibrary.AudioDeviceCmdlets
{
[Guid("00000000-0000-0000-C000-000000000046"),
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
internal interface IPolicyConfig10
{
[PreserveSig]
int GetMixFormat(string pszDeviceName, IntPtr ppFormat);
[PreserveSig]
int GetDeviceFormat(string pszDeviceName, bool bDefault, IntPtr ppFormat);
[PreserveSig]
int ResetDeviceFormat(string pszDeviceName);
[PreserveSig]
int SetDeviceFormat(string pszDeviceName, IntPtr pEndpointFormat, IntPtr MixFormat);
[PreserveSig]
int GetProcessingPeriod(string pszDeviceName, bool bDefault, IntPtr pmftDefaultPeriod, IntPtr pmftMinimumPeriod);
[PreserveSig]
int SetProcessingPeriod(string pszDeviceName, IntPtr pmftPeriod);
[PreserveSig]
int GetShareMode(string pszDeviceName, IntPtr pMode);
[PreserveSig]
int SetShareMode(string pszDeviceName, IntPtr mode);
[PreserveSig]
int GetPropertyValue(string pszDeviceName, bool bFxStore, IntPtr key, IntPtr pv);
[PreserveSig]
int SetPropertyValue(string pszDeviceName, bool bFxStore, IntPtr key, IntPtr pv);
[PreserveSig]
int SetDefaultEndpoint(string pszDeviceName, NAudio.CoreAudioApi.Role role);
[PreserveSig]
int SetEndpointVisibility(string pszDeviceName, bool bVisible);
}
}
| 32.148936 | 121 | 0.713435 | [
"MIT"
] | watfordjc/csharp-stream-controller | NAudioWrapperLibrary/lib/AudioDeviceCmdlets/IPolicyConfig10.cs | 1,513 | C# |
namespace Discord.Json.Payloads
{
public class GatewayWebhookUpdate
{
public ulong guild_id;
public ulong channel_id;
}
}
| 16.777778 | 37 | 0.655629 | [
"MIT"
] | QuiCM/Discord-Core-Objects | Json/Payloads/GatewayWebhookUpdate.cs | 153 | C# |
////////////////////////////////////////////////////////////////////////////////
//NUnit tests for "EF Core Provider for LCPI OLE DB"
// IBProvider and Contributors. 02.05.2021.
using System;
using System.Data;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Microsoft.EntityFrameworkCore;
using NUnit.Framework;
using xdb=lcpi.data.oledb;
namespace EFCore_LcpiOleDb_Tests.General.Work.DBMS.Firebird.V03_0_0.D3.Query.Operators.SET_001.GreaterThan.Complete.SByte.Decimal{
////////////////////////////////////////////////////////////////////////////////
using T_DATA1 =System.SByte;
using T_DATA2 =System.Decimal;
////////////////////////////////////////////////////////////////////////////////
//class TestSet_504__param__01__VV
public static class TestSet_504__param__01__VV
{
private const string c_NameOf__TABLE ="DUAL";
private sealed class MyContext:TestBaseDbContext
{
[Table(c_NameOf__TABLE)]
public sealed class TEST_RECORD
{
[Key]
[Column("ID")]
public System.Int32? TEST_ID { get; set; }
};//class TEST_RECORD
//----------------------------------------------------------------------
public DbSet<TEST_RECORD> testTable { get; set; }
//----------------------------------------------------------------------
public MyContext(xdb.OleDbTransaction tr)
:base(tr)
{
}//MyContext
};//class MyContext
//-----------------------------------------------------------------------
[Test]
public static void Test_001__less()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
T_DATA1 vv1=3;
T_DATA2 vv2=4;
var recs=db.testTable.Where(r => vv1 /*OP{*/ > /*}OP*/ vv2);
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE ").P_BOOL("__Exec_V_V_0"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_001__less
//-----------------------------------------------------------------------
[Test]
public static void Test_002__equal()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
T_DATA1 vv1=4;
T_DATA2 vv2=4;
var recs=db.testTable.Where(r => vv1 /*OP{*/ > /*}OP*/ vv2);
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE ").P_BOOL("__Exec_V_V_0"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_002__equal
//-----------------------------------------------------------------------
[Test]
public static void Test_003__greater()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
T_DATA1 vv1=4;
T_DATA2 vv2=3;
var recs=db.testTable.Where(r => vv1 /*OP{*/ > /*}OP*/ vv2);
int nRecs=0;
foreach(var r in recs)
{
Assert.AreEqual
(0,
nRecs);
++nRecs;
Assert.IsTrue
(r.TEST_ID.HasValue);
Assert.AreEqual
(1,
r.TEST_ID.Value);
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE ").P_BOOL("__Exec_V_V_0"));
Assert.AreEqual
(1,
nRecs);
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_003__greater
//-----------------------------------------------------------------------
[Test]
public static void Test_ZA01NV()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
object vv1__null_obj=null;
T_DATA2 vv2=4;
var recs=db.testTable.Where(r => ((T_DATA1)vv1__null_obj) /*OP{*/ > /*}OP*/ vv2);
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE NULL"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_ZA01NV
//-----------------------------------------------------------------------
[Test]
public static void Test_ZA02VN()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
T_DATA1 vv1=3;
object vv2__null_obj=null;
var recs=db.testTable.Where(r => vv1 /*OP{*/ > /*}OP*/ ((T_DATA2)vv2__null_obj));
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE NULL"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_ZA02VN
//-----------------------------------------------------------------------
[Test]
public static void Test_ZA03NN()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
object vv1__null_obj=null;
object vv2__null_obj=null;
var recs=db.testTable.Where(r => ((T_DATA1)vv1__null_obj) /*OP{*/ > /*}OP*/ ((T_DATA2)vv2__null_obj));
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE NULL"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_ZA03NN
//-----------------------------------------------------------------------
[Test]
public static void Test_ZB01NV()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
object vv1__null_obj=null;
T_DATA2 vv2=4;
var recs=db.testTable.Where(r => !(((T_DATA1)vv1__null_obj) /*OP{*/ > /*}OP*/ vv2));
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE NULL"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_ZB01NV
//-----------------------------------------------------------------------
[Test]
public static void Test_ZB02VN()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
T_DATA1 vv1=3;
object vv2__null_obj=null;
var recs=db.testTable.Where(r => !(vv1 /*OP{*/ > /*}OP*/ ((T_DATA2)vv2__null_obj)));
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE NULL"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_ZB02VN
//-----------------------------------------------------------------------
[Test]
public static void Test_ZB03NN()
{
using(var cn=LocalCnHelper.CreateCn())
{
cn.Open();
using(var tr=cn.BeginTransaction())
{
//insert new record in external transaction
using(var db=new MyContext(tr))
{
object vv1__null_obj=null;
object vv2__null_obj=null;
var recs=db.testTable.Where(r => !(((T_DATA1)vv1__null_obj) /*OP{*/ > /*}OP*/ ((T_DATA2)vv2__null_obj)));
foreach(var r in recs)
{
TestServices.ThrowSelectedRow();
}//foreach r
db.CheckTextOfLastExecutedCommand
(new TestSqlTemplate()
.T("SELECT ").N("d","ID").EOL()
.T("FROM ").N(c_NameOf__TABLE).T(" AS ").N("d").EOL()
.T("WHERE NULL"));
}//using db
tr.Commit();
}//using tr
}//using cn
}//Test_ZB03NN
};//class TestSet_504__param__01__VV
////////////////////////////////////////////////////////////////////////////////
}//namespace EFCore_LcpiOleDb_Tests.General.Work.DBMS.Firebird.V03_0_0.D3.Query.Operators.SET_001.GreaterThan.Complete.SByte.Decimal
| 24.641361 | 132 | 0.530862 | [
"MIT"
] | ibprovider/Lcpi.EFCore.LcpiOleDb | Tests/General/Source/Work/DBMS/Firebird/V03_0_0/D3/Query/Operators/SET_001/GreaterThan/Complete/SByte/Decimal/TestSet_504__param__01__VV.cs | 9,415 | C# |
using System;
using System.Data;
using System.Threading;
namespace Dapper
{
public static partial class SqlMapper
{
private class CacheInfo
{
public DeserializerState Deserializer { get; set; }
public Func<IDataReader, object>[] OtherDeserializers { get; set; }
public Action<IDbCommand, object> ParamReader { get; set; }
private int hitCount;
public int GetHitCount() { return Interlocked.CompareExchange(ref hitCount, 0, 0); }
public void RecordHit() { Interlocked.Increment(ref hitCount); }
}
}
}
| 30.5 | 96 | 0.631148 | [
"MIT"
] | eznew-net/EZNEW.Develop | EZNEW/Dapper/SqlMapper.CacheInfo.cs | 612 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CiteProc.Compilation
{
internal class Property : Scope
{
private string _Signature;
public Property(Class parent, string signature)
: base(parent, null)
{
// init
this._Signature = signature;
// getter and setter
this.Getter = new Scope(this, null);
}
public Scope Getter
{
get;
private set;
}
public override void Render(CodeWriter writer)
{
// class
writer.AppendIndent();
writer.Append(this._Signature);
writer.Append(Environment.NewLine);
// {
writer.AppendIndent();
writer.Append("{");
writer.Append(Environment.NewLine);
writer.IncreaseIndent();
// getter
writer.AppendIndent();
writer.Append("get");
writer.Append(Environment.NewLine);
writer.AppendIndent();
writer.Append("{");
writer.Append(Environment.NewLine);
writer.IncreaseIndent();
this.Getter.Render(writer);
writer.DecreaseIndent();
writer.AppendIndent();
writer.Append("}");
writer.Append(Environment.NewLine);
// }
writer.DecreaseIndent();
writer.AppendIndent();
writer.Append("}");
writer.Append(Environment.NewLine);
}
}
}
| 25.453125 | 55 | 0.524248 | [
"Unlicense"
] | fouke-boss/citeproc-dotnet | Sources/CiteProc/Compilation/Property.cs | 1,631 | C# |
using Nethereum.JsonRpc.Client;
namespace Nethereum.Wallet.Services
{
public interface IWalletConfigurationService
{
string ClientUrl { get; set; }
IClient Client { get; set; }
bool IsConfigured();
string[] GetAccounts();
}
} | 18.2 | 48 | 0.637363 | [
"MIT"
] | cksuper0928/xamarin | Nethereum.UI/Nethereum.Wallet/Services/IWalletConfigurationService.cs | 273 | C# |
#nullable enable
using System;
using System.Threading.Tasks;
using Content.Server.Fluids.Components;
using Content.Server.Fluids.EntitySystems;
using Content.Shared.Chemistry.Components;
using Content.Shared.FixedPoint;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Timing;
namespace Content.IntegrationTests.Tests.Fluids;
[TestFixture]
[TestOf(typeof(FluidSpreaderSystem))]
public sealed class FluidSpill : ContentIntegrationTest
{
private static PuddleComponent? GetPuddle(IEntityManager entityManager, IMapGrid mapGrid, Vector2i pos)
{
foreach (var uid in mapGrid.GetAnchoredEntities(pos))
{
if (entityManager.TryGetComponent(uid, out PuddleComponent puddleComponent))
return puddleComponent;
}
return null;
}
private readonly Direction[] _dirs =
{
Direction.East,
Direction.SouthEast,
Direction.South,
Direction.SouthWest,
Direction.West,
Direction.NorthWest,
Direction.North,
Direction.NorthEast,
};
private readonly Vector2i _origin = new(1, 1);
[Test]
public async Task SpillEvenlyTest()
{
// --- Setup
var server = StartServer();
await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>();
var gameTiming = server.ResolveDependency<IGameTiming>();
MapId mapId;
GridId gridId = default;
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
var grid = mapManager.CreateGrid(mapId);
gridId = grid.Index;
for (var x = 0; x < 3; x++)
{
for (var y = 0; y < 3; y++)
{
grid.SetTile(new Vector2i(x, y), new Tile(1));
}
}
});
await server.WaitAssertion(() =>
{
var grid = mapManager.GetGrid(gridId);
var solution = new Solution("Water", FixedPoint2.New(100));
var tileRef = grid.GetTileRef(_origin);
var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear");
Assert.That(puddle, Is.Not.Null);
Assert.That(GetPuddle(entityManager, grid, _origin), Is.Not.Null);
});
var sTimeToWait = (int) Math.Ceiling(2f * gameTiming.TickRate);
await server.WaitRunTicks(sTimeToWait);
server.Assert(() =>
{
var grid = mapManager.GetGrid(gridId);
var puddle = GetPuddle(entityManager, grid, _origin);
Assert.That(puddle, Is.Not.Null);
Assert.That(puddle!.CurrentVolume, Is.EqualTo(FixedPoint2.New(20)));
foreach (var direction in _dirs)
{
var newPos = _origin.Offset(direction);
var sidePuddle = GetPuddle(entityManager, grid, newPos);
Assert.That(sidePuddle, Is.Not.Null);
Assert.That(sidePuddle!.CurrentVolume, Is.EqualTo(FixedPoint2.New(10)));
}
});
await server.WaitIdleAsync();
}
[Test]
public async Task SpillSmallOverflowTest()
{
// --- Setup
var server = StartServer();
await server.WaitIdleAsync();
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var spillSystem = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SpillableSystem>();
var gameTiming = server.ResolveDependency<IGameTiming>();
MapId mapId;
GridId gridId = default;
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
var grid = mapManager.CreateGrid(mapId);
for (var x = 0; x < 3; x++)
{
for (var y = 0; y < 3; y++)
{
grid.SetTile(new Vector2i(x, y), new Tile(1));
}
}
gridId = grid.Index;
});
await server.WaitAssertion(() =>
{
var solution = new Solution("Water", FixedPoint2.New(20.01));
var grid = mapManager.GetGrid(gridId);
var tileRef = grid.GetTileRef(_origin);
var puddle = spillSystem.SpillAt(tileRef, solution, "PuddleSmear");
Assert.That(puddle, Is.Not.Null);
});
var sTimeToWait = (int) Math.Ceiling(2f * gameTiming.TickRate);
await server.WaitRunTicks(sTimeToWait);
server.Assert(() =>
{
var grid = mapManager.GetGrid(gridId);
var puddle = GetPuddle(entityManager, grid, _origin);
Assert.That(puddle, Is.Not.Null);
Assert.That(puddle!.CurrentVolume, Is.EqualTo(FixedPoint2.New(20)));
// we don't know where a spill would happen
// but there should be only one
var emptyField = 0;
var fullField = 0;
foreach (var direction in _dirs)
{
var newPos = _origin.Offset(direction);
var sidePuddle = GetPuddle(entityManager, grid, newPos);
if (sidePuddle == null)
{
emptyField++;
}
else if (sidePuddle.CurrentVolume == FixedPoint2.Epsilon)
{
fullField++;
}
}
Assert.That(emptyField, Is.EqualTo(7));
Assert.That(fullField, Is.EqualTo(1));
});
await server.WaitIdleAsync();
}
}
| 31.869565 | 110 | 0.572817 | [
"MIT"
] | 14th-Batallion-Marine-Corps/14-Marine-Corps | Content.IntegrationTests/Tests/Fluids/FluidSpillTest.cs | 5,866 | C# |
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------
// **NOTE** This file was generated by a tool and any changes will be overwritten.
// <auto-generated/>
// Template Source: EntityWithReferenceRequest.cs.tt
namespace Microsoft.Graph
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Threading;
using System.Linq.Expressions;
/// <summary>
/// The type AndroidWorkProfileCertificateProfileBaseWithReferenceRequest.
/// </summary>
public partial class AndroidWorkProfileCertificateProfileBaseWithReferenceRequest : BaseRequest, IAndroidWorkProfileCertificateProfileBaseWithReferenceRequest
{
/// <summary>
/// Constructs a new AndroidWorkProfileCertificateProfileBaseWithReferenceRequest.
/// </summary>
/// <param name="requestUrl">The URL for the built request.</param>
/// <param name="client">The <see cref="IBaseClient"/> for handling requests.</param>
/// <param name="options">Query and header option name value pairs for the request.</param>
public AndroidWorkProfileCertificateProfileBaseWithReferenceRequest(
string requestUrl,
IBaseClient client,
IEnumerable<Option> options)
: base(requestUrl, client, options)
{
}
/// <summary>
/// Gets the specified AndroidWorkProfileCertificateProfileBase.
/// </summary>
/// <returns>The AndroidWorkProfileCertificateProfileBase.</returns>
public System.Threading.Tasks.Task<AndroidWorkProfileCertificateProfileBase> GetAsync()
{
return this.GetAsync(CancellationToken.None);
}
/// <summary>
/// Gets the specified AndroidWorkProfileCertificateProfileBase.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The AndroidWorkProfileCertificateProfileBase.</returns>
public async System.Threading.Tasks.Task<AndroidWorkProfileCertificateProfileBase> GetAsync(CancellationToken cancellationToken)
{
this.Method = "GET";
var retrievedEntity = await this.SendAsync<AndroidWorkProfileCertificateProfileBase>(null, cancellationToken).ConfigureAwait(false);
return retrievedEntity;
}
/// <summary>
/// Creates the specified AndroidWorkProfileCertificateProfileBase using POST.
/// </summary>
/// <param name="androidWorkProfileCertificateProfileBaseToCreate">The AndroidWorkProfileCertificateProfileBase to create.</param>
/// <returns>The created AndroidWorkProfileCertificateProfileBase.</returns>
public System.Threading.Tasks.Task<AndroidWorkProfileCertificateProfileBase> CreateAsync(AndroidWorkProfileCertificateProfileBase androidWorkProfileCertificateProfileBaseToCreate)
{
return this.CreateAsync(androidWorkProfileCertificateProfileBaseToCreate, CancellationToken.None);
}
/// <summary>
/// Creates the specified AndroidWorkProfileCertificateProfileBase using POST.
/// </summary>
/// <param name="androidWorkProfileCertificateProfileBaseToCreate">The AndroidWorkProfileCertificateProfileBase to create.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The created AndroidWorkProfileCertificateProfileBase.</returns>
public async System.Threading.Tasks.Task<AndroidWorkProfileCertificateProfileBase> CreateAsync(AndroidWorkProfileCertificateProfileBase androidWorkProfileCertificateProfileBaseToCreate, CancellationToken cancellationToken)
{
this.ContentType = "application/json";
this.Method = "POST";
var newEntity = await this.SendAsync<AndroidWorkProfileCertificateProfileBase>(androidWorkProfileCertificateProfileBaseToCreate, cancellationToken).ConfigureAwait(false);
return newEntity;
}
/// <summary>
/// Updates the specified AndroidWorkProfileCertificateProfileBase using PATCH.
/// </summary>
/// <param name="androidWorkProfileCertificateProfileBaseToUpdate">The AndroidWorkProfileCertificateProfileBase to update.</param>
/// <returns>The updated AndroidWorkProfileCertificateProfileBase.</returns>
public System.Threading.Tasks.Task<AndroidWorkProfileCertificateProfileBase> UpdateAsync(AndroidWorkProfileCertificateProfileBase androidWorkProfileCertificateProfileBaseToUpdate)
{
return this.UpdateAsync(androidWorkProfileCertificateProfileBaseToUpdate, CancellationToken.None);
}
/// <summary>
/// Updates the specified AndroidWorkProfileCertificateProfileBase using PATCH.
/// </summary>
/// <param name="androidWorkProfileCertificateProfileBaseToUpdate">The AndroidWorkProfileCertificateProfileBase to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidWorkProfileCertificateProfileBase.</returns>
public async System.Threading.Tasks.Task<AndroidWorkProfileCertificateProfileBase> UpdateAsync(AndroidWorkProfileCertificateProfileBase androidWorkProfileCertificateProfileBaseToUpdate, CancellationToken cancellationToken)
{
if (androidWorkProfileCertificateProfileBaseToUpdate.AdditionalData != null)
{
if (androidWorkProfileCertificateProfileBaseToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidWorkProfileCertificateProfileBaseToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidWorkProfileCertificateProfileBaseToUpdate.GetType().Name)
});
}
}
if (androidWorkProfileCertificateProfileBaseToUpdate.AdditionalData != null)
{
if (androidWorkProfileCertificateProfileBaseToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidWorkProfileCertificateProfileBaseToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidWorkProfileCertificateProfileBaseToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidWorkProfileCertificateProfileBase>(androidWorkProfileCertificateProfileBaseToUpdate, cancellationToken).ConfigureAwait(false);
return updatedEntity;
}
/// <summary>
/// Deletes the specified AndroidWorkProfileCertificateProfileBase.
/// </summary>
/// <returns>The task to await.</returns>
public System.Threading.Tasks.Task DeleteAsync()
{
return this.DeleteAsync(CancellationToken.None);
}
/// <summary>
/// Deletes the specified AndroidWorkProfileCertificateProfileBase.
/// </summary>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <returns>The task to await.</returns>
public async System.Threading.Tasks.Task DeleteAsync(CancellationToken cancellationToken)
{
this.Method = "DELETE";
await this.SendAsync<AndroidWorkProfileCertificateProfileBase>(null, cancellationToken).ConfigureAwait(false);
}
/// <summary>
/// Adds the specified expand value to the request.
/// </summary>
/// <param name="value">The expand value.</param>
/// <returns>The request object to send.</returns>
public IAndroidWorkProfileCertificateProfileBaseWithReferenceRequest Expand(string value)
{
this.QueryOptions.Add(new QueryOption("$expand", value));
return this;
}
/// <summary>
/// Adds the specified expand value to the request.
/// </summary>
/// <param name="expandExpression">The expression from which to calculate the expand value.</param>
/// <returns>The request object to send.</returns>
public IAndroidWorkProfileCertificateProfileBaseWithReferenceRequest Expand(Expression<Func<AndroidWorkProfileCertificateProfileBase, object>> expandExpression)
{
if (expandExpression == null)
{
throw new ArgumentNullException(nameof(expandExpression));
}
string error;
string value = ExpressionExtractHelper.ExtractMembers(expandExpression, out error);
if (value == null)
{
throw new ArgumentException(error, nameof(expandExpression));
}
else
{
this.QueryOptions.Add(new QueryOption("$expand", value));
}
return this;
}
/// <summary>
/// Adds the specified select value to the request.
/// </summary>
/// <param name="value">The select value.</param>
/// <returns>The request object to send.</returns>
public IAndroidWorkProfileCertificateProfileBaseWithReferenceRequest Select(string value)
{
this.QueryOptions.Add(new QueryOption("$select", value));
return this;
}
/// <summary>
/// Adds the specified select value to the request.
/// </summary>
/// <param name="selectExpression">The expression from which to calculate the select value.</param>
/// <returns>The request object to send.</returns>
public IAndroidWorkProfileCertificateProfileBaseWithReferenceRequest Select(Expression<Func<AndroidWorkProfileCertificateProfileBase, object>> selectExpression)
{
if (selectExpression == null)
{
throw new ArgumentNullException(nameof(selectExpression));
}
string error;
string value = ExpressionExtractHelper.ExtractMembers(selectExpression, out error);
if (value == null)
{
throw new ArgumentException(error, nameof(selectExpression));
}
else
{
this.QueryOptions.Add(new QueryOption("$select", value));
}
return this;
}
}
}
| 50.429204 | 230 | 0.67158 | [
"MIT"
] | GeertVL/msgraph-beta-sdk-dotnet | src/Microsoft.Graph/Generated/requests/AndroidWorkProfileCertificateProfileBaseWithReferenceRequest.cs | 11,397 | C# |
// ***************************************************************
// Copyright(c) Yeto
// FileName : AssetConfDownload.cs
// Creator :
// Date : 2015-6-26
// Comment : 状态机流程:
// 1,载入上一次没有处理完的临时配置文件, 放入到临时数据里面
// 2,载入包体里的配置文件,载入缓存中的配置文件,对比这两个配置文件的版本号, 找出比较新的放入到local缓存配置里
// 3,下载version,确定是否需要更新最新的配置文件
// 4,下载project, 保存为temp, 但是内容放在remote, 确定需要下载的asset列表
// 5,上一次还没有处理完成的临时的资源文件,如果不比远程的最新的低,就处理上一次的临时的文件, 不然则处理最新的资源, 并把远程的赋予给临时
// 6,下载下来的资源,成功则设置临时资源为成功,失败则放入失败列表。
// 7,下载完成后
// ***************************************************************
using SLua;
using System.Collections.Generic;
[CustomLuaClass]
public enum AssetState
{
asUnchecked,
asRestart, //重启下载
asPreDownloadVersion, //准备下载version
asDownloadingVersion, //下载version
asLoadedVersion, //version已经被下载
asCheckPackage, //检查是否需要下载包
asPreDownloadManifest, //预下载manifest
asDownloadingManifest, //正在下载manifest
asLoadedManifest, //manifest已经被下载
asPreUpdate, //预处理更新
asNeedUpdate, //需要更新
asAllowUpdate, //允许更新
asUpdating, //正在更新
asUpdateToData, //更新到日期
asUpdateFailure, //失败的更新
asPreDownloadFailure, //失败检查
asDownloadingFailure, //下载失败
asPreUnZip,
asUnziping,
asUnziped,
};
[CustomLuaClass]
public class AssetStatusManager
{
protected static Logger log = LoggerFactory.GetInstance().GetLogger(typeof(AssetStatusManager));
public AssetConfProject packageConfProject;
public AssetConfProject localConfProject = new AssetConfProject();
public AssetConfProject remoteConfProject = new AssetConfProject();
public AssetConfProject tempConfProject = new AssetConfProject();
public string cacheVersionPath;
public string cacheManifestPath;
public string tempManifestPath;
public string remoteManifestPath;
protected string storagePath;
private string urlPath;
private AssetState updateState;
protected AssetResultHandler resultHandler;
private List<string> compressedFiles = new List<string>();
private int repeatCount = 0;
public void Initialize(string _urlPath, string manifestUrl, string _storagePath)
{
resultHandler = AssetResultHandler.Instance;
urlPath = _urlPath;
storagePath = _storagePath;
AssetUtility.MakeSureDirectory(ref storagePath);
cacheVersionPath = storagePath + AssetConstants.VERSION_FILENAME;
cacheManifestPath = storagePath + AssetConstants.MANIFEST_FILENAME;
tempManifestPath = storagePath + AssetConstants.TEMP_MANIFEST_FILENAME;
remoteManifestPath = storagePath + AssetConstants.Manifest_Filename_Remote;
LoadLocalManifest(manifestUrl);
LoadTempManifest();
}
public AssetState UpdateState
{
set
{
updateState = value;
log.Debug("Next UpdateState : " + updateState.ToString());
switch (updateState)
{
case AssetState.asUnchecked:
break;
case AssetState.asPreDownloadVersion:
CheckVersion();
break;
case AssetState.asDownloadingVersion:
DownloadVersion();
break;
case AssetState.asLoadedVersion:
ParseVersion();
break;
case AssetState.asCheckPackage:
CheckPackageUpdate();
break;
case AssetState.asPreDownloadManifest:
CheckManifest();
break;
case AssetState.asDownloadingManifest:
DownloadManifest();
break;
case AssetState.asLoadedManifest:
ParseManifest();
break;
case AssetState.asPreUpdate:
resultHandler.DispatchUpdateEvent(AssetEventCode.aecNewVersionFound);
CheckAssetList();
break;
case AssetState.asNeedUpdate: //检查允许更新
resultHandler.DispatchUpdateEvent(AssetEventCode.aecCheckAllowUpdate);
break;
case AssetState.asAllowUpdate:
DownloadAssetList();
break;
case AssetState.asUpdating:
break;
case AssetState.asUpdateToData:
resultHandler.DispatchUpdateEvent(AssetEventCode.aecAlreadyUpToDate);
UpdateState = AssetState.asPreUnZip;
break;
case AssetState.asUpdateFailure:
break;
case AssetState.asPreDownloadFailure:
CheckUpdateFailure();
break;
case AssetState.asDownloadingFailure:
DownloadFailureAssets();
break;
case AssetState.asPreUnZip:
PrepareZipFile();
break;
case AssetState.asUnziping:
DecompressZipFile();
break;
case AssetState.asUnziped:
AssetDownloadComplete();
break;
}
}
get
{
return updateState;
}
}
protected void LoadTempManifest()
{
tempConfProject.LoadAndParseFile(tempManifestPath);
if (!tempConfProject.IsLoaded())
{
FileUtility.DeleteFile(tempManifestPath);
}
}
protected void LoadLocalManifest(string manifestUrl)
{
AssetConfProject cachedManifest = null;
//载入缓存的配置
if (FileUtility.IsFileExist(cacheManifestPath))
{
log.Debug("load cache manifest file : " + cacheManifestPath);
cachedManifest = new AssetConfProject();
cachedManifest.LoadAndParseFile(cacheManifestPath);
if (!cachedManifest.IsLoaded())
{
log.Debug("Parse error cacheManifestPath : " + cacheManifestPath);
FileUtility.DeleteFile(cacheManifestPath);
cachedManifest = null;
}
}
//载入本地的配置
log.Debug("Load local manifest in app package" + manifestUrl);
localConfProject.LoadAndParseFile(manifestUrl);
if (localConfProject.IsLoaded())
{
packageConfProject = localConfProject;
if (cachedManifest != null)
{
if (localConfProject.ConfVersionInfo.resourcePatch > cachedManifest.ConfVersionInfo.resourcePatch) //检查当前缓存版本是否低于包体资源版本
{
log.Debug("Remove storagePath rease : " + cachedManifest.ConfVersionInfo.resourcePatch);
// Recreate storage, to empty the content
FileUtility.DeleteDirectory(storagePath);
FileUtility.CreateDirectory(storagePath);
cachedManifest = null;
}
else
{
localConfProject = cachedManifest;
}
}
PrepareLocalManifest();
}
if (!localConfProject.IsLoaded())
{
UnityEngine.Debug.Log("AssetsManagerEx : No local manifest file found error.\n");
resultHandler.DispatchUpdateEvent(AssetEventCode.aceErrorNoLocalManifest);
}
}
protected void PrepareLocalManifest()
{
localConfProject.PrependSearchPaths();
UpdateState = AssetState.asPreDownloadVersion;
}
private void CheckVersion()
{
if (repeatCount < AssetConstants.Max_Repeat_Count_Version)
{
repeatCount++;
resultHandler.DispatchUpdateEvent(AssetEventCode.aecVersionNotice, repeatCount.ToString());
UpdateState = AssetState.asDownloadingVersion;
}
else
{
resultHandler.DispatchUpdateEvent(AssetEventCode.aecVersionDownloadError);
UpdateState = AssetState.asRestart;
}
}
protected void DownloadVersion()
{
string versionUrl = urlPath + localConfProject.packageUrl + localConfProject.remoteVersionUrl;
if (!string.IsNullOrEmpty(versionUrl))
{
resultHandler.downloader.DownloadAsync(versionUrl, cacheVersionPath, AssetConstants.VERSION_ID);
}
}
protected void ParseVersion()
{
repeatCount = 0;
remoteConfProject.LoadAndParseFile(cacheVersionPath);
if (!remoteConfProject.IsLoaded())
{
log.Debug("AssetsManagerEx : Fail to parse version file, step skipped\n");//这里要改
resultHandler.DispatchUpdateEvent(AssetEventCode.aecVersionParseError);
UpdateState = AssetState.asPreDownloadManifest;
}
else
{
if (localConfProject.ConfVersionInfo.IsUpdatePackage(remoteConfProject.ConfVersionInfo))
{
UpdateState = AssetState.asCheckPackage;
}
else if (localConfProject.ConfVersionInfo.IsUpdateResource(remoteConfProject.ConfVersionInfo))
{
UpdateState = AssetState.asPreDownloadManifest;
}
else
{
UpdateState = AssetState.asUpdateToData;
}
}
}
private void CheckPackageUpdate()
{
resultHandler.DispatchUpdateEvent(AssetEventCode.aceErrorPackage, remoteConfProject.packageBodyURI);
UpdateState = AssetState.asRestart;
}
private void CheckManifest()
{
if (repeatCount < AssetConstants.Max_Repeat_Count_Manifest)
{
repeatCount++;
resultHandler.DispatchUpdateEvent(AssetEventCode.aecManifestNotice, repeatCount.ToString());
UpdateState = AssetState.asDownloadingManifest;
}
else
{
resultHandler.DispatchUpdateEvent(AssetEventCode.aecErrorDownloadManifest);
UpdateState = AssetState.asRestart;
}
}
protected void DownloadManifest()
{
string manifestUrl = urlPath + localConfProject.packageUrl + localConfProject.remoteManifestUrl;
if (!string.IsNullOrEmpty(manifestUrl))
{
resultHandler.downloader.DownloadAsync(manifestUrl, remoteManifestPath, AssetConstants.MANIFEST_ID);
}
}
protected void ParseManifest()
{
repeatCount = 0;
remoteConfProject.LoadAndParseFile(remoteManifestPath);
if (!remoteConfProject.IsLoaded())
{
log.Debug("AssetsManagerEx : Error parsing manifest file\n");
resultHandler.DispatchUpdateEvent(AssetEventCode.aecErrorParseManifest);
}
else
{
if (localConfProject.ConfVersionInfo.IsUpdateResource(remoteConfProject.ConfVersionInfo))
{
UpdateState = AssetState.asPreUpdate;
}
else
{
UpdateState = AssetState.asUpdateToData;
}
}
}
private void ValidateAssetList()
{
Dictionary<string, AssetConfDiff> diffMap = localConfProject.GenDiff(remoteConfProject);
}
protected void CheckAssetList()
{
compressedFiles.Clear();
if (tempConfProject.IsLoaded() && tempConfProject.ConfVersionInfo.IsUseTempResource(remoteConfProject.ConfVersionInfo))
{
tempConfProject.GenResumeAssetsList(urlPath, ref resultHandler.downloadUnits, ref resultHandler.downloadedSize, ref resultHandler.totalSize);
resultHandler.totalWaitToDownload = resultHandler.totalToDownload = resultHandler.downloadUnits.Count;
UpdateState = AssetState.asNeedUpdate;
}
else
{
tempConfProject = remoteConfProject;
Dictionary<string, AssetConfDiff> diffMap = localConfProject.GenDiff(remoteConfProject);
if (diffMap.Count == 0)
{
UpdateState = AssetState.asUpdateToData;
}
else
{
foreach (var it in diffMap)
{
AssetConfDiff diff = it.Value;
if (diff.type == AssetDiffType.adtDeleted)
{
FileUtility.DeleteFile(storagePath + diff.asset.path);
}
else
{
string path = diff.asset.path;
// Create path
FileUtility.CreateDirectory(storagePath + System.IO.Path.GetDirectoryName(path));
AssetDownloadUnit unit;
unit.customId = it.Key;
unit.srcUrl = urlPath + remoteConfProject.packageUrl + path;
unit.storagePath = storagePath + AssetUtility.GetNotVersionFileName(path);
unit.resumeDownload = false;
unit.downloaded = diff.asset.size;
resultHandler.downloadUnits.Add(unit.customId, unit);
if (!resultHandler.downloadedSize.ContainsKey(it.Key))
{
resultHandler.downloadedSize.Add(it.Key, 0);
resultHandler.totalSize += diff.asset.size;
}
}
}
resultHandler.totalWaitToDownload = resultHandler.totalToDownload = resultHandler.downloadUnits.Count;
UpdateState = AssetState.asNeedUpdate;
}
}
}
private void DownloadAssetList()
{
UpdateState = AssetState.asUpdating;
resultHandler.downloader.BatchDownloadAsync(storagePath, resultHandler.downloadUnits, AssetConstants.BATCH_UPDATE_ID);
}
public void CheckUpdateFailure()
{
if (resultHandler.failedUnits.Count == 0 && resultHandler.totalWaitToDownload == 0)
{
UpdateState = AssetState.asPreUnZip;
return;
}
if (repeatCount < AssetConstants.Max_Repeat_Count_Update)
{
repeatCount++;
UpdateState = AssetState.asDownloadingFailure;
}
else
{
resultHandler.DispatchUpdateEvent(AssetEventCode.aecUpdateFailure);
UpdateState = AssetState.asRestart;
}
}
public void DownloadFailureAssets()
{
log.Debug(string.Format("AssetsManager : Start update {0} failed assets.\n", resultHandler.failedUnits));
Dictionary<string, AssetDownloadUnit> copyFailedUnits = new Dictionary<string, AssetDownloadUnit>(resultHandler.failedUnits);
resultHandler.failedUnits.Clear();
resultHandler.downloadUnits.Clear();
resultHandler.downloadUnits = copyFailedUnits;
resultHandler.downloader.BatchDownloadAsync(storagePath, resultHandler.downloadUnits, AssetConstants.BATCH_UPDATE_ID);
}
protected void PrepareZipFile()
{
if (remoteConfProject.Assets != null)
{
Dictionary<string, AssetConf>.Enumerator enumerator = remoteConfProject.Assets.GetEnumerator();
while (enumerator.MoveNext())
{
AssetConf asset = enumerator.Current.Value;
if (asset.compressed)
{
compressedFiles.Add(storagePath + AssetUtility.GetNotVersionFileName(asset.path));
}
}
}
UpdateState = AssetState.asUnziping;
}
protected void DecompressZipFile()
{
for (int i = 0; i < compressedFiles.Count; i++)
{
string zipfile = compressedFiles[i];
if (FileUtility.IsFileExist(zipfile) == false)
continue;
if (!ZipUtility.UnZip(zipfile))
{
resultHandler.DispatchUpdateEvent(AssetEventCode.aecErrorDecompress, "", "Unable to decompress file " + zipfile);
}
FileUtility.DeleteFile(zipfile);
}
compressedFiles.Clear();
UpdateState = AssetState.asUnziped;
}
private void AssetDownloadComplete()
{
if (tempConfProject != null && tempConfProject.IsLoaded() == true) //如果进行了更新则使local=temp,用来做位置检测用
{
localConfProject = tempConfProject;
}
tempConfProject = null;
resultHandler.DispatchUpdateEvent(AssetEventCode.aecUpdateFinished);
}
public readonly static AssetStatusManager Instance = new AssetStatusManager();
}
| 33.997984 | 153 | 0.585602 | [
"Apache-2.0"
] | zhengguo07q/unity_core_lib | Script/Library/AssetsManager/AssetStatusManager.cs | 17,567 | C# |
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.Gcp.Compute
{
public static class GetNetblockIPRanges
{
/// <summary>
/// Use this data source to get the IP addresses from different special IP ranges on Google Cloud Platform.
///
/// {{% examples %}}
/// ## Example Usage
/// {{% example %}}
/// ### Cloud Ranges
///
/// ```csharp
/// using Pulumi;
/// using Gcp = Pulumi.Gcp;
///
/// class MyStack : Stack
/// {
/// public MyStack()
/// {
/// var netblock = Output.Create(Gcp.Compute.GetNetblockIPRanges.InvokeAsync());
/// this.CidrBlocks = netblock.Apply(netblock => netblock.CidrBlocks);
/// this.CidrBlocksIpv4 = netblock.Apply(netblock => netblock.CidrBlocksIpv4s);
/// this.CidrBlocksIpv6 = netblock.Apply(netblock => netblock.CidrBlocksIpv6s);
/// }
///
/// [Output("cidrBlocks")]
/// public Output<string> CidrBlocks { get; set; }
/// [Output("cidrBlocksIpv4")]
/// public Output<string> CidrBlocksIpv4 { get; set; }
/// [Output("cidrBlocksIpv6")]
/// public Output<string> CidrBlocksIpv6 { get; set; }
/// }
/// ```
/// {{% /example %}}
/// {{% example %}}
/// ### Allow Health Checks
///
/// ```csharp
/// using Pulumi;
/// using Gcp = Pulumi.Gcp;
///
/// class MyStack : Stack
/// {
/// public MyStack()
/// {
/// var legacy_hcs = Output.Create(Gcp.Compute.GetNetblockIPRanges.InvokeAsync(new Gcp.Compute.GetNetblockIPRangesArgs
/// {
/// RangeType = "legacy-health-checkers",
/// }));
/// var @default = new Gcp.Compute.Network("default", new Gcp.Compute.NetworkArgs
/// {
/// });
/// var allow_hcs = new Gcp.Compute.Firewall("allow-hcs", new Gcp.Compute.FirewallArgs
/// {
/// Network = @default.Name,
/// Allows =
/// {
/// new Gcp.Compute.Inputs.FirewallAllowArgs
/// {
/// Protocol = "tcp",
/// Ports =
/// {
/// "80",
/// },
/// },
/// },
/// SourceRanges = legacy_hcs.Apply(legacy_hcs => legacy_hcs.CidrBlocksIpv4s),
/// });
/// }
///
/// }
/// ```
/// {{% /example %}}
/// {{% /examples %}}
/// </summary>
public static Task<GetNetblockIPRangesResult> InvokeAsync(GetNetblockIPRangesArgs? args = null, InvokeOptions? options = null)
=> Pulumi.Deployment.Instance.InvokeAsync<GetNetblockIPRangesResult>("gcp:compute/getNetblockIPRanges:getNetblockIPRanges", args ?? new GetNetblockIPRangesArgs(), options.WithDefaults());
/// <summary>
/// Use this data source to get the IP addresses from different special IP ranges on Google Cloud Platform.
///
/// {{% examples %}}
/// ## Example Usage
/// {{% example %}}
/// ### Cloud Ranges
///
/// ```csharp
/// using Pulumi;
/// using Gcp = Pulumi.Gcp;
///
/// class MyStack : Stack
/// {
/// public MyStack()
/// {
/// var netblock = Output.Create(Gcp.Compute.GetNetblockIPRanges.InvokeAsync());
/// this.CidrBlocks = netblock.Apply(netblock => netblock.CidrBlocks);
/// this.CidrBlocksIpv4 = netblock.Apply(netblock => netblock.CidrBlocksIpv4s);
/// this.CidrBlocksIpv6 = netblock.Apply(netblock => netblock.CidrBlocksIpv6s);
/// }
///
/// [Output("cidrBlocks")]
/// public Output<string> CidrBlocks { get; set; }
/// [Output("cidrBlocksIpv4")]
/// public Output<string> CidrBlocksIpv4 { get; set; }
/// [Output("cidrBlocksIpv6")]
/// public Output<string> CidrBlocksIpv6 { get; set; }
/// }
/// ```
/// {{% /example %}}
/// {{% example %}}
/// ### Allow Health Checks
///
/// ```csharp
/// using Pulumi;
/// using Gcp = Pulumi.Gcp;
///
/// class MyStack : Stack
/// {
/// public MyStack()
/// {
/// var legacy_hcs = Output.Create(Gcp.Compute.GetNetblockIPRanges.InvokeAsync(new Gcp.Compute.GetNetblockIPRangesArgs
/// {
/// RangeType = "legacy-health-checkers",
/// }));
/// var @default = new Gcp.Compute.Network("default", new Gcp.Compute.NetworkArgs
/// {
/// });
/// var allow_hcs = new Gcp.Compute.Firewall("allow-hcs", new Gcp.Compute.FirewallArgs
/// {
/// Network = @default.Name,
/// Allows =
/// {
/// new Gcp.Compute.Inputs.FirewallAllowArgs
/// {
/// Protocol = "tcp",
/// Ports =
/// {
/// "80",
/// },
/// },
/// },
/// SourceRanges = legacy_hcs.Apply(legacy_hcs => legacy_hcs.CidrBlocksIpv4s),
/// });
/// }
///
/// }
/// ```
/// {{% /example %}}
/// {{% /examples %}}
/// </summary>
public static Output<GetNetblockIPRangesResult> Invoke(GetNetblockIPRangesInvokeArgs? args = null, InvokeOptions? options = null)
=> Pulumi.Deployment.Instance.Invoke<GetNetblockIPRangesResult>("gcp:compute/getNetblockIPRanges:getNetblockIPRanges", args ?? new GetNetblockIPRangesInvokeArgs(), options.WithDefaults());
}
public sealed class GetNetblockIPRangesArgs : Pulumi.InvokeArgs
{
/// <summary>
/// The type of range for which to provide results.
/// </summary>
[Input("rangeType")]
public string? RangeType { get; set; }
public GetNetblockIPRangesArgs()
{
}
}
public sealed class GetNetblockIPRangesInvokeArgs : Pulumi.InvokeArgs
{
/// <summary>
/// The type of range for which to provide results.
/// </summary>
[Input("rangeType")]
public Input<string>? RangeType { get; set; }
public GetNetblockIPRangesInvokeArgs()
{
}
}
[OutputType]
public sealed class GetNetblockIPRangesResult
{
/// <summary>
/// Retrieve list of all CIDR blocks.
/// </summary>
public readonly ImmutableArray<string> CidrBlocks;
/// <summary>
/// Retrieve list of the IPv4 CIDR blocks
/// </summary>
public readonly ImmutableArray<string> CidrBlocksIpv4s;
/// <summary>
/// Retrieve list of the IPv6 CIDR blocks, if available.
/// </summary>
public readonly ImmutableArray<string> CidrBlocksIpv6s;
/// <summary>
/// The provider-assigned unique ID for this managed resource.
/// </summary>
public readonly string Id;
public readonly string? RangeType;
[OutputConstructor]
private GetNetblockIPRangesResult(
ImmutableArray<string> cidrBlocks,
ImmutableArray<string> cidrBlocksIpv4s,
ImmutableArray<string> cidrBlocksIpv6s,
string id,
string? rangeType)
{
CidrBlocks = cidrBlocks;
CidrBlocksIpv4s = cidrBlocksIpv4s;
CidrBlocksIpv6s = cidrBlocksIpv6s;
Id = id;
RangeType = rangeType;
}
}
}
| 36.833333 | 200 | 0.486715 | [
"ECL-2.0",
"Apache-2.0"
] | pjbizon/pulumi-gcp | sdk/dotnet/Compute/GetNetblockIPRanges.cs | 8,619 | C# |
using System;
using System.Linq;
using System.Windows;
using System.Windows.Input;
using System.Data.Linq;
namespace kurscachWPF
{
/// <summary>
/// Логика взаимодействия для AddWorker.xaml
/// </summary>
public partial class AddWorker : Window
{
private applicant AddNew;
public R NewR;
public R2 NewR2;
private DataContext db;
private Table<applicant> ap;
private Table<R> rr;
private Table<R2> rr2;
public AddWorker()
{
InitializeComponent();
WindowStyle = System.Windows.WindowStyle.None;
AllowsTransparency = true;
MouseDown += Window_MouseDown;
db = new DataContext(entities.connectionString);
ap = db.GetTable<applicant>();
rr = db.GetTable<R>();
rr2= db.GetTable<R2>();
int id;
try { id= ap.OrderByDescending(ap => ap.idapplicant).FirstOrDefault().idapplicant.Value + 1; }
catch (Exception) { id = 1; }
AID.Text = id.ToString();
}
private void Window_MouseDown(object sender, MouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
DragMove();
}
private void Button_Click_2(object sender, RoutedEventArgs e)
{
//if (CurrentUser.type!=0)
{
try
{
AddNew = new applicant();
//fill applicant
AddNew.idapplicant = int.Parse(this.AID.Text);
if (this.AFIO.Text.Length > 20)
AddNew.FIO = this.AFIO.Text.Substring(0, 19);
else AddNew.FIO = this.AFIO.Text;
AddNew.position = this.APOSITION.Text;
AddNew.salary = int.Parse(this.ASALARY.Text);
AddNew.hired = false;
if (this.AINFO.Text.Length > 100)
AddNew.Info = this.AINFO.Text.Substring(0, 99);
else AddNew.Info = this.AINFO.Text;
//fill R
NewR.Idapplicant = AddNew.idapplicant;
NewR2.Idapplicant= AddNew.idapplicant;
rr2.InsertOnSubmit(NewR2);
rr.InsertOnSubmit(NewR);
ap.InsertOnSubmit(AddNew);
try
{
db.SubmitChanges();
MessageBox.Show("Резюме успешно добавлено!");
this.Close();
}
catch (Exception exx)
{
MessageBox.Show(exx.Message);
db.SubmitChanges();
this.ASALARY.Text = "0";
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
//else MessageBox.Show("Гости не могут добавлять резюме. Пожалуйста, залогиньтесь.");
}
private void Button_Click_3(object sender, RoutedEventArgs e)
{
this.Close();
}
}
}
| 35.88172 | 108 | 0.465388 | [
"MIT"
] | ereborDeveloper/WPF-LINQ-to-SQL-Applicaton | AddWorker.xaml.cs | 3,433 | C# |
/*
* ISO standards can be purchased through the ANSI webstore at https://webstore.ansi.org
*/
using AgGateway.ADAPT.ApplicationDataModel.ADM;
using AgGateway.ADAPT.ApplicationDataModel.Equipment;
using AgGateway.ADAPT.ApplicationDataModel.Representations;
using AgGateway.ADAPT.ISOv4Plugin.ExtensionMethods;
using AgGateway.ADAPT.ISOv4Plugin.ISOEnumerations;
using AgGateway.ADAPT.ISOv4Plugin.ISOModels;
using AgGateway.ADAPT.ISOv4Plugin.Representation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AgGateway.ADAPT.ISOv4Plugin.ObjectModel
{
public class DeviceElementHierarchies
{
public DeviceElementHierarchies(IEnumerable<ISODevice> devices, RepresentationMapper representationMapper)
{
Items = new Dictionary<string, DeviceElementHierarchy>();
foreach (ISODevice device in devices)
{
ISODeviceElement rootDeviceElement = device.DeviceElements.SingleOrDefault(det => det.DeviceElementType == ISODeviceElementType.Device);
if (rootDeviceElement != null)
{
Items.Add(device.DeviceId, new DeviceElementHierarchy(rootDeviceElement, 0, representationMapper));
}
}
}
public Dictionary<string, DeviceElementHierarchy> Items { get; set; }
public DeviceElementHierarchy GetRelevantHierarchy(string isoDeviceElementId)
{
foreach (DeviceElementHierarchy hierarchy in this.Items.Values)
{
DeviceElementHierarchy foundModel = hierarchy.FromDeviceElementID(isoDeviceElementId);
if (foundModel != null)
{
return foundModel;
}
}
return null;
}
public ISODeviceElement GetISODeviceElementFromID(string deviceElementID)
{
DeviceElementHierarchy hierarchy = GetRelevantHierarchy(deviceElementID);
if (hierarchy != null)
{
return hierarchy.DeviceElement;
}
return null;
}
}
/// <summary>
/// This utility class serves to map the hierarchies of ISO DeviceElements within a single ISO Device. Each ISODeviceElement will have a hierarchy object that references its parents and children.
/// Where the parent is null, it is the root device element in a device.
/// </summary>
public class DeviceElementHierarchy
{
private RepresentationMapper _representationMapper;
public DeviceElementHierarchy(ISODeviceElement deviceElement, int depth, RepresentationMapper representationMapper, HashSet<int> crawledElements = null, DeviceElementHierarchy parent = null)
{
_representationMapper = representationMapper;
//This Hashset will track that we don't build infinite hierarchies.
//The plugin does not support peer control at this time.
_crawledElements = crawledElements;
if (_crawledElements == null)
{
_crawledElements = new HashSet<int>();
}
if (_crawledElements.Add((int)deviceElement.DeviceElementObjectId))
{
Type = deviceElement.DeviceElementType;
DeviceElement = deviceElement;
Depth = depth;
Order = (int)deviceElement.DeviceElementNumber; //Using this number as analagous to this purpose. The ISO spec requires these numbers increment from left to right as in ADAPT. (See ISO11783-10:2015(E) B.3.2 Element number)
//DeviceProperty assigned Widths & Offsets
//DeviceProcessData assigned values will be assigned as the SectionMapper reads timelog data.
//Width
ISODeviceProperty widthProperty = deviceElement.DeviceProperties.FirstOrDefault(dpt => dpt.DDI == "0046");
if (widthProperty != null)
{
Width = widthProperty.Value;
WidthDDI = "0046";
}
else
{
widthProperty = deviceElement.DeviceProperties.FirstOrDefault(dpt => dpt.DDI == "0043");
if (widthProperty != null)
{
Width = widthProperty.Value;
WidthDDI = "0043";
}
}
//Offsets
ISODeviceProperty xOffsetProperty = deviceElement.DeviceProperties.FirstOrDefault(dpt => dpt.DDI == "0086");
if (xOffsetProperty != null)
{
XOffset = xOffsetProperty.Value;
}
ISODeviceProperty yOffsetProperty = deviceElement.DeviceProperties.FirstOrDefault(dpt => dpt.DDI == "0087");
if (yOffsetProperty != null)
{
YOffset = yOffsetProperty.Value;
}
ISODeviceProperty zOffsetProperty = deviceElement.DeviceProperties.FirstOrDefault(dpt => dpt.DDI == "0088");
if (zOffsetProperty != null)
{
ZOffset = zOffsetProperty.Value;
}
//Children
IEnumerable<ISODeviceElement> childDeviceElements = deviceElement.Device.DeviceElements.Where(det => det.ParentObjectId == deviceElement.DeviceElementObjectId);// && det.DeviceElementType == ISOEnumerations.ISODeviceElementType.Section);
if (childDeviceElements.Any())
{
int childDepth = depth + 1;
Children = new List<DeviceElementHierarchy>();
foreach (ISODeviceElement det in childDeviceElements)
{
DeviceElementHierarchy child = new DeviceElementHierarchy(det, childDepth, representationMapper, _crawledElements, this);
Children.Add(child);
}
}
//Parent
Parent = parent;
}
}
public ISODeviceElement DeviceElement { get; private set; }
public int Depth { get; set; }
public int Order { get; set; }
public ISODeviceElementType Type { get; set; }
private HashSet<int> _crawledElements;
public string WidthDDI { get; set; }
public int? Width { get; set; }
public int? XOffset { get; set; }
public int? YOffset { get; set; }
public int? ZOffset { get; set; }
public NumericRepresentationValue WidthRepresentation { get { return Width.HasValue ? Width.Value.AsNumericRepresentationValue(WidthDDI, _representationMapper) : null; } }
public NumericRepresentationValue XOffsetRepresentation { get { return XOffset.HasValue ? XOffset.Value.AsNumericRepresentationValue("0086", _representationMapper) : null; } } //TODO temporary
public NumericRepresentationValue YOffsetRepresentation { get { return YOffset.HasValue ? YOffset.Value.AsNumericRepresentationValue("0087", _representationMapper) : null; } }
public NumericRepresentationValue ZOffsetRepresentation { get { return ZOffset.HasValue ? ZOffset.Value.AsNumericRepresentationValue("0088", _representationMapper) : null; } }
public List<DeviceElementHierarchy> Children { get; set; }
public DeviceElementHierarchy Parent { get; set; }
public DeviceElementHierarchy FromDeviceElementID(string deviceElementID)
{
if (DeviceElement.DeviceElementId == deviceElementID)
{
return this;
}
else if (Children != null)
{
foreach (DeviceElementHierarchy child in Children)
{
DeviceElementHierarchy childModel = child.FromDeviceElementID(deviceElementID);
if (childModel != null)
{
return childModel;
}
}
}
return null;
}
public NumericRepresentationValue GetLowestLevelSectionWidth()
{
int maxDepth = GetMaxDepth();
IEnumerable<DeviceElementHierarchy> lowestLevelItems = GetElementsAtDepth(maxDepth);
if (lowestLevelItems.Any() && lowestLevelItems.All(i => i.WidthRepresentation != null && i.WidthRepresentation.Value != null && i.WidthRepresentation.Value.Value == lowestLevelItems.First().WidthRepresentation.Value.Value))
{
return lowestLevelItems.First().WidthRepresentation;
}
else
{
return null;
}
}
public int GetMaxDepth()
{
int maxDepth = 0;
FindMaxDepth(ref maxDepth);
return maxDepth;
}
private int FindMaxDepth(ref int maxDepth)
{
int depth = Depth;
if (Children != null)
{
foreach (DeviceElementHierarchy child in Children)
{
depth = child.FindMaxDepth(ref maxDepth);
if (depth > maxDepth)
{
maxDepth = depth;
}
}
}
return depth;
}
public IEnumerable<DeviceElementHierarchy> GetElementsAtDepth(int depth)
{
List<DeviceElementHierarchy> list = new List<DeviceElementHierarchy>();
if (depth == 0)
{
return new List<DeviceElementHierarchy>() { this };
}
if (Children != null)
{
foreach (DeviceElementHierarchy child in Children)
{
if (child.Depth == depth)
{
list.Add(child);
}
else if (child.Depth < depth)
{
list.AddRange(child.GetElementsAtDepth(depth));
}
}
}
return list;
}
public DeviceElementHierarchy GetRootDeviceElementHierarchy()
{
DeviceElementHierarchy item = this;
while (item.Parent != null)
{
item = item.Parent;
}
return item;
}
public void SetWidthsAndOffsetsFromSpatialData(IEnumerable<ISOSpatialRow> isoRecords, DeviceElementConfiguration config, RepresentationMapper representationMapper)
{
//Set values on this object and associated DeviceElementConfiguration
if (Width == null)
{
Width = GetWidthFromSpatialData(isoRecords, DeviceElement.DeviceElementId, representationMapper);
}
if (config.Offsets == null)
{
config.Offsets = new List<NumericRepresentationValue>();
}
if (XOffset == null)
{
XOffset = GetXOffsetFromSpatialData(isoRecords, DeviceElement.DeviceElementId, representationMapper);
if (XOffsetRepresentation != null)
{
config.Offsets.Add(XOffsetRepresentation);
}
}
if (YOffset == null)
{
YOffset = GetYOffsetFromSpatialData(isoRecords, DeviceElement.DeviceElementId, representationMapper);
if (YOffsetRepresentation != null)
{
config.Offsets.Add(YOffsetRepresentation);
}
}
if (ZOffset == null)
{
ZOffset = GetZOffsetFromSpatialData(isoRecords, DeviceElement.DeviceElementId, representationMapper);
if (ZOffsetRepresentation != null)
{
config.Offsets.Add(ZOffsetRepresentation);
}
}
//Update config values as appropriate
if (this.DeviceElement.DeviceElementType == ISODeviceElementType.Navigation)
{
MachineConfiguration machineConfig = config as MachineConfiguration;
if (machineConfig.GpsReceiverXOffset == null)
{
machineConfig.GpsReceiverXOffset = XOffsetRepresentation;
}
if (machineConfig.GpsReceiverYOffset == null)
{
machineConfig.GpsReceiverYOffset = YOffsetRepresentation;
}
if (machineConfig.GpsReceiverZOffset == null)
{
machineConfig.GpsReceiverZOffset = ZOffsetRepresentation;
}
}
else
{
if (config is SectionConfiguration)
{
SectionConfiguration sectionConfig = config as SectionConfiguration;
if (sectionConfig.SectionWidth == null)
{
sectionConfig.SectionWidth = WidthRepresentation;
}
if (sectionConfig.InlineOffset == null)
{
sectionConfig.InlineOffset = XOffsetRepresentation;
}
if (sectionConfig.LateralOffset == null)
{
sectionConfig.LateralOffset = YOffsetRepresentation;
}
}
else if (config is ImplementConfiguration)
{
ImplementConfiguration implementConfig = config as ImplementConfiguration;
if (implementConfig.Width == null)
{
implementConfig.Width = WidthRepresentation;
}
}
}
}
private int? GetWidthFromSpatialData(IEnumerable<ISOSpatialRow> isoRecords, string isoDeviceElementID, RepresentationMapper representationMapper)
{
double maxWidth = 0d;
string updatedWidthDDI = null;
ISOSpatialRow rowWithMaxWidth = isoRecords.FirstOrDefault(r => r.SpatialValues.Any(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0046"));
if (rowWithMaxWidth != null)
{
maxWidth = rowWithMaxWidth.SpatialValues.Single(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID && s.DataLogValue.ProcessDataDDI == "0046").Value;
updatedWidthDDI = "0046";
}
else
{
//Find the largest working width
IEnumerable<ISOSpatialRow> rows = isoRecords.Where(r => r.SpatialValues.Any(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0043"));
if (rows.Any())
{
foreach (ISOSpatialRow row in rows)
{
double value = row.SpatialValues.Single(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID && s.DataLogValue.ProcessDataDDI == "0043").Value;
if (value > maxWidth)
{
maxWidth = value;
}
}
updatedWidthDDI = "0043";
}
}
if (updatedWidthDDI != null)
{
WidthDDI = updatedWidthDDI;
return (int)maxWidth;
}
else
{
return null;
}
}
private int? GetYOffsetFromSpatialData(IEnumerable<ISOSpatialRow> isoRecords, string isoDeviceElementID, RepresentationMapper representationMapper)
{
double offset = 0d;
ISOSpatialRow firstYOffset = isoRecords.FirstOrDefault(r => r.SpatialValues.Any(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0087"));
if (firstYOffset != null)
{
offset = firstYOffset.SpatialValues.Single(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0087").Value;
return (int)offset;
}
else
{
return null;
}
}
private int? GetXOffsetFromSpatialData(IEnumerable<ISOSpatialRow> isoRecords, string isoDeviceElementID, RepresentationMapper representationMapper)
{
double offset = 0d;
ISOSpatialRow firstXOffset = isoRecords.FirstOrDefault(r => r.SpatialValues.Any(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0086"));
if (firstXOffset != null)
{
offset = firstXOffset.SpatialValues.Single(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0086").Value;
return (int)offset;
}
else
{
return null;
}
}
private int? GetZOffsetFromSpatialData(IEnumerable<ISOSpatialRow> isoRecords, string isoDeviceElementID, RepresentationMapper representationMapper)
{
double offset = 0d;
ISOSpatialRow firstZOffset = isoRecords.FirstOrDefault(r => r.SpatialValues.Any(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID &&
s.DataLogValue.ProcessDataDDI == "0088"));
if (firstZOffset != null)
{
offset = firstZOffset.SpatialValues.Single(s => s.DataLogValue.DeviceElementIdRef == isoDeviceElementID && s.DataLogValue.ProcessDataDDI == "0088").Value;
return (int)offset;
}
else
{
return null;
}
}
}
}
| 43.218894 | 253 | 0.543744 | [
"EPL-1.0"
] | ysykhmd/ISOv4Plugin | ISOv4Plugin/ObjectModel/DeviceElementHierarchy.cs | 18,759 | C# |
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[assembly: global::Android.Runtime.ResourceDesignerAttribute("Xfx.Controls.Example.Droid.Resource", IsApplication=true)]
namespace Xfx.Controls.Example.Droid
{
[System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Android.Build.Tasks", "1.0.0.0")]
public partial class Resource
{
static Resource()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
public static void UpdateIdValues()
{
global::Xamarin.Forms.Platform.Android.Resource.Attribute.actionBarSize = global::Xfx.Controls.Example.Droid.Resource.Attribute.actionBarSize;
}
public partial class Animation
{
// aapt resource value: 0x7f040000
public const int abc_fade_in = 2130968576;
// aapt resource value: 0x7f040001
public const int abc_fade_out = 2130968577;
// aapt resource value: 0x7f040002
public const int abc_grow_fade_in_from_bottom = 2130968578;
// aapt resource value: 0x7f040003
public const int abc_popup_enter = 2130968579;
// aapt resource value: 0x7f040004
public const int abc_popup_exit = 2130968580;
// aapt resource value: 0x7f040005
public const int abc_shrink_fade_out_from_bottom = 2130968581;
// aapt resource value: 0x7f040006
public const int abc_slide_in_bottom = 2130968582;
// aapt resource value: 0x7f040007
public const int abc_slide_in_top = 2130968583;
// aapt resource value: 0x7f040008
public const int abc_slide_out_bottom = 2130968584;
// aapt resource value: 0x7f040009
public const int abc_slide_out_top = 2130968585;
// aapt resource value: 0x7f04000a
public const int design_bottom_sheet_slide_in = 2130968586;
// aapt resource value: 0x7f04000b
public const int design_bottom_sheet_slide_out = 2130968587;
// aapt resource value: 0x7f04000c
public const int design_fab_in = 2130968588;
// aapt resource value: 0x7f04000d
public const int design_fab_out = 2130968589;
// aapt resource value: 0x7f04000e
public const int design_snackbar_in = 2130968590;
// aapt resource value: 0x7f04000f
public const int design_snackbar_out = 2130968591;
static Animation()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Animation()
{
}
}
public partial class Animator
{
// aapt resource value: 0x7f050000
public const int design_appbar_state_list_animator = 2131034112;
static Animator()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Animator()
{
}
}
public partial class Attribute
{
// aapt resource value: 0x7f01005f
public const int actionBarDivider = 2130772063;
// aapt resource value: 0x7f010060
public const int actionBarItemBackground = 2130772064;
// aapt resource value: 0x7f010059
public const int actionBarPopupTheme = 2130772057;
// aapt resource value: 0x7f01005e
public const int actionBarSize = 2130772062;
// aapt resource value: 0x7f01005b
public const int actionBarSplitStyle = 2130772059;
// aapt resource value: 0x7f01005a
public const int actionBarStyle = 2130772058;
// aapt resource value: 0x7f010055
public const int actionBarTabBarStyle = 2130772053;
// aapt resource value: 0x7f010054
public const int actionBarTabStyle = 2130772052;
// aapt resource value: 0x7f010056
public const int actionBarTabTextStyle = 2130772054;
// aapt resource value: 0x7f01005c
public const int actionBarTheme = 2130772060;
// aapt resource value: 0x7f01005d
public const int actionBarWidgetTheme = 2130772061;
// aapt resource value: 0x7f01007a
public const int actionButtonStyle = 2130772090;
// aapt resource value: 0x7f010076
public const int actionDropDownStyle = 2130772086;
// aapt resource value: 0x7f0100cc
public const int actionLayout = 2130772172;
// aapt resource value: 0x7f010061
public const int actionMenuTextAppearance = 2130772065;
// aapt resource value: 0x7f010062
public const int actionMenuTextColor = 2130772066;
// aapt resource value: 0x7f010065
public const int actionModeBackground = 2130772069;
// aapt resource value: 0x7f010064
public const int actionModeCloseButtonStyle = 2130772068;
// aapt resource value: 0x7f010067
public const int actionModeCloseDrawable = 2130772071;
// aapt resource value: 0x7f010069
public const int actionModeCopyDrawable = 2130772073;
// aapt resource value: 0x7f010068
public const int actionModeCutDrawable = 2130772072;
// aapt resource value: 0x7f01006d
public const int actionModeFindDrawable = 2130772077;
// aapt resource value: 0x7f01006a
public const int actionModePasteDrawable = 2130772074;
// aapt resource value: 0x7f01006f
public const int actionModePopupWindowStyle = 2130772079;
// aapt resource value: 0x7f01006b
public const int actionModeSelectAllDrawable = 2130772075;
// aapt resource value: 0x7f01006c
public const int actionModeShareDrawable = 2130772076;
// aapt resource value: 0x7f010066
public const int actionModeSplitBackground = 2130772070;
// aapt resource value: 0x7f010063
public const int actionModeStyle = 2130772067;
// aapt resource value: 0x7f01006e
public const int actionModeWebSearchDrawable = 2130772078;
// aapt resource value: 0x7f010057
public const int actionOverflowButtonStyle = 2130772055;
// aapt resource value: 0x7f010058
public const int actionOverflowMenuStyle = 2130772056;
// aapt resource value: 0x7f0100ce
public const int actionProviderClass = 2130772174;
// aapt resource value: 0x7f0100cd
public const int actionViewClass = 2130772173;
// aapt resource value: 0x7f010082
public const int activityChooserViewStyle = 2130772098;
// aapt resource value: 0x7f0100a7
public const int alertDialogButtonGroupStyle = 2130772135;
// aapt resource value: 0x7f0100a8
public const int alertDialogCenterButtons = 2130772136;
// aapt resource value: 0x7f0100a6
public const int alertDialogStyle = 2130772134;
// aapt resource value: 0x7f0100a9
public const int alertDialogTheme = 2130772137;
// aapt resource value: 0x7f0100bc
public const int allowStacking = 2130772156;
// aapt resource value: 0x7f0100bd
public const int alpha = 2130772157;
// aapt resource value: 0x7f0100c4
public const int arrowHeadLength = 2130772164;
// aapt resource value: 0x7f0100c5
public const int arrowShaftLength = 2130772165;
// aapt resource value: 0x7f0100ae
public const int autoCompleteTextViewStyle = 2130772142;
// aapt resource value: 0x7f010028
public const int background = 2130772008;
// aapt resource value: 0x7f01002a
public const int backgroundSplit = 2130772010;
// aapt resource value: 0x7f010029
public const int backgroundStacked = 2130772009;
// aapt resource value: 0x7f010101
public const int backgroundTint = 2130772225;
// aapt resource value: 0x7f010102
public const int backgroundTintMode = 2130772226;
// aapt resource value: 0x7f0100c6
public const int barLength = 2130772166;
// aapt resource value: 0x7f01012c
public const int behavior_autoHide = 2130772268;
// aapt resource value: 0x7f010109
public const int behavior_hideable = 2130772233;
// aapt resource value: 0x7f010135
public const int behavior_overlapTop = 2130772277;
// aapt resource value: 0x7f010108
public const int behavior_peekHeight = 2130772232;
// aapt resource value: 0x7f01010a
public const int behavior_skipCollapsed = 2130772234;
// aapt resource value: 0x7f01012a
public const int borderWidth = 2130772266;
// aapt resource value: 0x7f01007f
public const int borderlessButtonStyle = 2130772095;
// aapt resource value: 0x7f010124
public const int bottomSheetDialogTheme = 2130772260;
// aapt resource value: 0x7f010125
public const int bottomSheetStyle = 2130772261;
// aapt resource value: 0x7f01007c
public const int buttonBarButtonStyle = 2130772092;
// aapt resource value: 0x7f0100ac
public const int buttonBarNegativeButtonStyle = 2130772140;
// aapt resource value: 0x7f0100ad
public const int buttonBarNeutralButtonStyle = 2130772141;
// aapt resource value: 0x7f0100ab
public const int buttonBarPositiveButtonStyle = 2130772139;
// aapt resource value: 0x7f01007b
public const int buttonBarStyle = 2130772091;
// aapt resource value: 0x7f0100f6
public const int buttonGravity = 2130772214;
// aapt resource value: 0x7f01003d
public const int buttonPanelSideLayout = 2130772029;
// aapt resource value: 0x7f0100af
public const int buttonStyle = 2130772143;
// aapt resource value: 0x7f0100b0
public const int buttonStyleSmall = 2130772144;
// aapt resource value: 0x7f0100be
public const int buttonTint = 2130772158;
// aapt resource value: 0x7f0100bf
public const int buttonTintMode = 2130772159;
// aapt resource value: 0x7f010011
public const int cardBackgroundColor = 2130771985;
// aapt resource value: 0x7f010012
public const int cardCornerRadius = 2130771986;
// aapt resource value: 0x7f010013
public const int cardElevation = 2130771987;
// aapt resource value: 0x7f010014
public const int cardMaxElevation = 2130771988;
// aapt resource value: 0x7f010016
public const int cardPreventCornerOverlap = 2130771990;
// aapt resource value: 0x7f010015
public const int cardUseCompatPadding = 2130771989;
// aapt resource value: 0x7f0100b1
public const int checkboxStyle = 2130772145;
// aapt resource value: 0x7f0100b2
public const int checkedTextViewStyle = 2130772146;
// aapt resource value: 0x7f0100d9
public const int closeIcon = 2130772185;
// aapt resource value: 0x7f01003a
public const int closeItemLayout = 2130772026;
// aapt resource value: 0x7f0100f8
public const int collapseContentDescription = 2130772216;
// aapt resource value: 0x7f0100f7
public const int collapseIcon = 2130772215;
// aapt resource value: 0x7f010117
public const int collapsedTitleGravity = 2130772247;
// aapt resource value: 0x7f010111
public const int collapsedTitleTextAppearance = 2130772241;
// aapt resource value: 0x7f0100c0
public const int color = 2130772160;
// aapt resource value: 0x7f01009e
public const int colorAccent = 2130772126;
// aapt resource value: 0x7f0100a5
public const int colorBackgroundFloating = 2130772133;
// aapt resource value: 0x7f0100a2
public const int colorButtonNormal = 2130772130;
// aapt resource value: 0x7f0100a0
public const int colorControlActivated = 2130772128;
// aapt resource value: 0x7f0100a1
public const int colorControlHighlight = 2130772129;
// aapt resource value: 0x7f01009f
public const int colorControlNormal = 2130772127;
// aapt resource value: 0x7f01009c
public const int colorPrimary = 2130772124;
// aapt resource value: 0x7f01009d
public const int colorPrimaryDark = 2130772125;
// aapt resource value: 0x7f0100a3
public const int colorSwitchThumbNormal = 2130772131;
// aapt resource value: 0x7f0100de
public const int commitIcon = 2130772190;
// aapt resource value: 0x7f010033
public const int contentInsetEnd = 2130772019;
// aapt resource value: 0x7f010037
public const int contentInsetEndWithActions = 2130772023;
// aapt resource value: 0x7f010034
public const int contentInsetLeft = 2130772020;
// aapt resource value: 0x7f010035
public const int contentInsetRight = 2130772021;
// aapt resource value: 0x7f010032
public const int contentInsetStart = 2130772018;
// aapt resource value: 0x7f010036
public const int contentInsetStartWithNavigation = 2130772022;
// aapt resource value: 0x7f010017
public const int contentPadding = 2130771991;
// aapt resource value: 0x7f01001b
public const int contentPaddingBottom = 2130771995;
// aapt resource value: 0x7f010018
public const int contentPaddingLeft = 2130771992;
// aapt resource value: 0x7f010019
public const int contentPaddingRight = 2130771993;
// aapt resource value: 0x7f01001a
public const int contentPaddingTop = 2130771994;
// aapt resource value: 0x7f010112
public const int contentScrim = 2130772242;
// aapt resource value: 0x7f0100a4
public const int controlBackground = 2130772132;
// aapt resource value: 0x7f01014b
public const int counterEnabled = 2130772299;
// aapt resource value: 0x7f01014c
public const int counterMaxLength = 2130772300;
// aapt resource value: 0x7f01014e
public const int counterOverflowTextAppearance = 2130772302;
// aapt resource value: 0x7f01014d
public const int counterTextAppearance = 2130772301;
// aapt resource value: 0x7f01002b
public const int customNavigationLayout = 2130772011;
// aapt resource value: 0x7f0100d8
public const int defaultQueryHint = 2130772184;
// aapt resource value: 0x7f010074
public const int dialogPreferredPadding = 2130772084;
// aapt resource value: 0x7f010073
public const int dialogTheme = 2130772083;
// aapt resource value: 0x7f010021
public const int displayOptions = 2130772001;
// aapt resource value: 0x7f010027
public const int divider = 2130772007;
// aapt resource value: 0x7f010081
public const int dividerHorizontal = 2130772097;
// aapt resource value: 0x7f0100ca
public const int dividerPadding = 2130772170;
// aapt resource value: 0x7f010080
public const int dividerVertical = 2130772096;
// aapt resource value: 0x7f0100c2
public const int drawableSize = 2130772162;
// aapt resource value: 0x7f01001c
public const int drawerArrowStyle = 2130771996;
// aapt resource value: 0x7f010093
public const int dropDownListViewStyle = 2130772115;
// aapt resource value: 0x7f010077
public const int dropdownListPreferredItemHeight = 2130772087;
// aapt resource value: 0x7f010088
public const int editTextBackground = 2130772104;
// aapt resource value: 0x7f010087
public const int editTextColor = 2130772103;
// aapt resource value: 0x7f0100b3
public const int editTextStyle = 2130772147;
// aapt resource value: 0x7f010038
public const int elevation = 2130772024;
// aapt resource value: 0x7f010149
public const int errorEnabled = 2130772297;
// aapt resource value: 0x7f01014a
public const int errorTextAppearance = 2130772298;
// aapt resource value: 0x7f01003c
public const int expandActivityOverflowButtonDrawable = 2130772028;
// aapt resource value: 0x7f010103
public const int expanded = 2130772227;
// aapt resource value: 0x7f010118
public const int expandedTitleGravity = 2130772248;
// aapt resource value: 0x7f01010b
public const int expandedTitleMargin = 2130772235;
// aapt resource value: 0x7f01010f
public const int expandedTitleMarginBottom = 2130772239;
// aapt resource value: 0x7f01010e
public const int expandedTitleMarginEnd = 2130772238;
// aapt resource value: 0x7f01010c
public const int expandedTitleMarginStart = 2130772236;
// aapt resource value: 0x7f01010d
public const int expandedTitleMarginTop = 2130772237;
// aapt resource value: 0x7f010110
public const int expandedTitleTextAppearance = 2130772240;
// aapt resource value: 0x7f010010
public const int externalRouteEnabledDrawable = 2130771984;
// aapt resource value: 0x7f010128
public const int fabSize = 2130772264;
// aapt resource value: 0x7f01012d
public const int foregroundInsidePadding = 2130772269;
// aapt resource value: 0x7f0100c3
public const int gapBetweenBars = 2130772163;
// aapt resource value: 0x7f0100da
public const int goIcon = 2130772186;
// aapt resource value: 0x7f010133
public const int headerLayout = 2130772275;
// aapt resource value: 0x7f01001d
public const int height = 2130771997;
// aapt resource value: 0x7f010031
public const int hideOnContentScroll = 2130772017;
// aapt resource value: 0x7f01014f
public const int hintAnimationEnabled = 2130772303;
// aapt resource value: 0x7f010148
public const int hintEnabled = 2130772296;
// aapt resource value: 0x7f010147
public const int hintTextAppearance = 2130772295;
// aapt resource value: 0x7f010079
public const int homeAsUpIndicator = 2130772089;
// aapt resource value: 0x7f01002c
public const int homeLayout = 2130772012;
// aapt resource value: 0x7f010025
public const int icon = 2130772005;
// aapt resource value: 0x7f0100d6
public const int iconifiedByDefault = 2130772182;
// aapt resource value: 0x7f010089
public const int imageButtonStyle = 2130772105;
// aapt resource value: 0x7f01002e
public const int indeterminateProgressStyle = 2130772014;
// aapt resource value: 0x7f01003b
public const int initialActivityCount = 2130772027;
// aapt resource value: 0x7f010134
public const int insetForeground = 2130772276;
// aapt resource value: 0x7f01001e
public const int isLightTheme = 2130771998;
// aapt resource value: 0x7f010131
public const int itemBackground = 2130772273;
// aapt resource value: 0x7f01012f
public const int itemIconTint = 2130772271;
// aapt resource value: 0x7f010030
public const int itemPadding = 2130772016;
// aapt resource value: 0x7f010132
public const int itemTextAppearance = 2130772274;
// aapt resource value: 0x7f010130
public const int itemTextColor = 2130772272;
// aapt resource value: 0x7f01011c
public const int keylines = 2130772252;
// aapt resource value: 0x7f0100d5
public const int layout = 2130772181;
// aapt resource value: 0x7f010000
public const int layoutManager = 2130771968;
// aapt resource value: 0x7f01011f
public const int layout_anchor = 2130772255;
// aapt resource value: 0x7f010121
public const int layout_anchorGravity = 2130772257;
// aapt resource value: 0x7f01011e
public const int layout_behavior = 2130772254;
// aapt resource value: 0x7f01011a
public const int layout_collapseMode = 2130772250;
// aapt resource value: 0x7f01011b
public const int layout_collapseParallaxMultiplier = 2130772251;
// aapt resource value: 0x7f010123
public const int layout_dodgeInsetEdges = 2130772259;
// aapt resource value: 0x7f010122
public const int layout_insetEdge = 2130772258;
// aapt resource value: 0x7f010120
public const int layout_keyline = 2130772256;
// aapt resource value: 0x7f010106
public const int layout_scrollFlags = 2130772230;
// aapt resource value: 0x7f010107
public const int layout_scrollInterpolator = 2130772231;
// aapt resource value: 0x7f01009b
public const int listChoiceBackgroundIndicator = 2130772123;
// aapt resource value: 0x7f010075
public const int listDividerAlertDialog = 2130772085;
// aapt resource value: 0x7f010041
public const int listItemLayout = 2130772033;
// aapt resource value: 0x7f01003e
public const int listLayout = 2130772030;
// aapt resource value: 0x7f0100bb
public const int listMenuViewStyle = 2130772155;
// aapt resource value: 0x7f010094
public const int listPopupWindowStyle = 2130772116;
// aapt resource value: 0x7f01008e
public const int listPreferredItemHeight = 2130772110;
// aapt resource value: 0x7f010090
public const int listPreferredItemHeightLarge = 2130772112;
// aapt resource value: 0x7f01008f
public const int listPreferredItemHeightSmall = 2130772111;
// aapt resource value: 0x7f010091
public const int listPreferredItemPaddingLeft = 2130772113;
// aapt resource value: 0x7f010092
public const int listPreferredItemPaddingRight = 2130772114;
// aapt resource value: 0x7f010026
public const int logo = 2130772006;
// aapt resource value: 0x7f0100fb
public const int logoDescription = 2130772219;
// aapt resource value: 0x7f010136
public const int maxActionInlineWidth = 2130772278;
// aapt resource value: 0x7f0100f5
public const int maxButtonHeight = 2130772213;
// aapt resource value: 0x7f0100c8
public const int measureWithLargestChild = 2130772168;
// aapt resource value: 0x7f010004
public const int mediaRouteAudioTrackDrawable = 2130771972;
// aapt resource value: 0x7f010005
public const int mediaRouteButtonStyle = 2130771973;
// aapt resource value: 0x7f010006
public const int mediaRouteCloseDrawable = 2130771974;
// aapt resource value: 0x7f010007
public const int mediaRouteControlPanelThemeOverlay = 2130771975;
// aapt resource value: 0x7f010008
public const int mediaRouteDefaultIconDrawable = 2130771976;
// aapt resource value: 0x7f010009
public const int mediaRoutePauseDrawable = 2130771977;
// aapt resource value: 0x7f01000a
public const int mediaRoutePlayDrawable = 2130771978;
// aapt resource value: 0x7f01000b
public const int mediaRouteSpeakerGroupIconDrawable = 2130771979;
// aapt resource value: 0x7f01000c
public const int mediaRouteSpeakerIconDrawable = 2130771980;
// aapt resource value: 0x7f01000d
public const int mediaRouteStopDrawable = 2130771981;
// aapt resource value: 0x7f01000e
public const int mediaRouteTheme = 2130771982;
// aapt resource value: 0x7f01000f
public const int mediaRouteTvIconDrawable = 2130771983;
// aapt resource value: 0x7f01012e
public const int menu = 2130772270;
// aapt resource value: 0x7f01003f
public const int multiChoiceItemLayout = 2130772031;
// aapt resource value: 0x7f0100fa
public const int navigationContentDescription = 2130772218;
// aapt resource value: 0x7f0100f9
public const int navigationIcon = 2130772217;
// aapt resource value: 0x7f010020
public const int navigationMode = 2130772000;
// aapt resource value: 0x7f0100d1
public const int overlapAnchor = 2130772177;
// aapt resource value: 0x7f0100d3
public const int paddingBottomNoButtons = 2130772179;
// aapt resource value: 0x7f0100ff
public const int paddingEnd = 2130772223;
// aapt resource value: 0x7f0100fe
public const int paddingStart = 2130772222;
// aapt resource value: 0x7f0100d4
public const int paddingTopNoTitle = 2130772180;
// aapt resource value: 0x7f010098
public const int panelBackground = 2130772120;
// aapt resource value: 0x7f01009a
public const int panelMenuListTheme = 2130772122;
// aapt resource value: 0x7f010099
public const int panelMenuListWidth = 2130772121;
// aapt resource value: 0x7f010152
public const int passwordToggleContentDescription = 2130772306;
// aapt resource value: 0x7f010151
public const int passwordToggleDrawable = 2130772305;
// aapt resource value: 0x7f010150
public const int passwordToggleEnabled = 2130772304;
// aapt resource value: 0x7f010153
public const int passwordToggleTint = 2130772307;
// aapt resource value: 0x7f010154
public const int passwordToggleTintMode = 2130772308;
// aapt resource value: 0x7f010085
public const int popupMenuStyle = 2130772101;
// aapt resource value: 0x7f010039
public const int popupTheme = 2130772025;
// aapt resource value: 0x7f010086
public const int popupWindowStyle = 2130772102;
// aapt resource value: 0x7f0100cf
public const int preserveIconSpacing = 2130772175;
// aapt resource value: 0x7f010129
public const int pressedTranslationZ = 2130772265;
// aapt resource value: 0x7f01002f
public const int progressBarPadding = 2130772015;
// aapt resource value: 0x7f01002d
public const int progressBarStyle = 2130772013;
// aapt resource value: 0x7f0100e0
public const int queryBackground = 2130772192;
// aapt resource value: 0x7f0100d7
public const int queryHint = 2130772183;
// aapt resource value: 0x7f0100b4
public const int radioButtonStyle = 2130772148;
// aapt resource value: 0x7f0100b5
public const int ratingBarStyle = 2130772149;
// aapt resource value: 0x7f0100b6
public const int ratingBarStyleIndicator = 2130772150;
// aapt resource value: 0x7f0100b7
public const int ratingBarStyleSmall = 2130772151;
// aapt resource value: 0x7f010002
public const int reverseLayout = 2130771970;
// aapt resource value: 0x7f010127
public const int rippleColor = 2130772263;
// aapt resource value: 0x7f010116
public const int scrimAnimationDuration = 2130772246;
// aapt resource value: 0x7f010115
public const int scrimVisibleHeightTrigger = 2130772245;
// aapt resource value: 0x7f0100dc
public const int searchHintIcon = 2130772188;
// aapt resource value: 0x7f0100db
public const int searchIcon = 2130772187;
// aapt resource value: 0x7f01008d
public const int searchViewStyle = 2130772109;
// aapt resource value: 0x7f0100b8
public const int seekBarStyle = 2130772152;
// aapt resource value: 0x7f01007d
public const int selectableItemBackground = 2130772093;
// aapt resource value: 0x7f01007e
public const int selectableItemBackgroundBorderless = 2130772094;
// aapt resource value: 0x7f0100cb
public const int showAsAction = 2130772171;
// aapt resource value: 0x7f0100c9
public const int showDividers = 2130772169;
// aapt resource value: 0x7f0100ec
public const int showText = 2130772204;
// aapt resource value: 0x7f010042
public const int showTitle = 2130772034;
// aapt resource value: 0x7f010040
public const int singleChoiceItemLayout = 2130772032;
// aapt resource value: 0x7f010001
public const int spanCount = 2130771969;
// aapt resource value: 0x7f0100c1
public const int spinBars = 2130772161;
// aapt resource value: 0x7f010078
public const int spinnerDropDownItemStyle = 2130772088;
// aapt resource value: 0x7f0100b9
public const int spinnerStyle = 2130772153;
// aapt resource value: 0x7f0100eb
public const int splitTrack = 2130772203;
// aapt resource value: 0x7f010043
public const int srcCompat = 2130772035;
// aapt resource value: 0x7f010003
public const int stackFromEnd = 2130771971;
// aapt resource value: 0x7f0100d2
public const int state_above_anchor = 2130772178;
// aapt resource value: 0x7f010104
public const int state_collapsed = 2130772228;
// aapt resource value: 0x7f010105
public const int state_collapsible = 2130772229;
// aapt resource value: 0x7f01011d
public const int statusBarBackground = 2130772253;
// aapt resource value: 0x7f010113
public const int statusBarScrim = 2130772243;
// aapt resource value: 0x7f0100d0
public const int subMenuArrow = 2130772176;
// aapt resource value: 0x7f0100e1
public const int submitBackground = 2130772193;
// aapt resource value: 0x7f010022
public const int subtitle = 2130772002;
// aapt resource value: 0x7f0100ee
public const int subtitleTextAppearance = 2130772206;
// aapt resource value: 0x7f0100fd
public const int subtitleTextColor = 2130772221;
// aapt resource value: 0x7f010024
public const int subtitleTextStyle = 2130772004;
// aapt resource value: 0x7f0100df
public const int suggestionRowLayout = 2130772191;
// aapt resource value: 0x7f0100e9
public const int switchMinWidth = 2130772201;
// aapt resource value: 0x7f0100ea
public const int switchPadding = 2130772202;
// aapt resource value: 0x7f0100ba
public const int switchStyle = 2130772154;
// aapt resource value: 0x7f0100e8
public const int switchTextAppearance = 2130772200;
// aapt resource value: 0x7f01013a
public const int tabBackground = 2130772282;
// aapt resource value: 0x7f010139
public const int tabContentStart = 2130772281;
// aapt resource value: 0x7f01013c
public const int tabGravity = 2130772284;
// aapt resource value: 0x7f010137
public const int tabIndicatorColor = 2130772279;
// aapt resource value: 0x7f010138
public const int tabIndicatorHeight = 2130772280;
// aapt resource value: 0x7f01013e
public const int tabMaxWidth = 2130772286;
// aapt resource value: 0x7f01013d
public const int tabMinWidth = 2130772285;
// aapt resource value: 0x7f01013b
public const int tabMode = 2130772283;
// aapt resource value: 0x7f010146
public const int tabPadding = 2130772294;
// aapt resource value: 0x7f010145
public const int tabPaddingBottom = 2130772293;
// aapt resource value: 0x7f010144
public const int tabPaddingEnd = 2130772292;
// aapt resource value: 0x7f010142
public const int tabPaddingStart = 2130772290;
// aapt resource value: 0x7f010143
public const int tabPaddingTop = 2130772291;
// aapt resource value: 0x7f010141
public const int tabSelectedTextColor = 2130772289;
// aapt resource value: 0x7f01013f
public const int tabTextAppearance = 2130772287;
// aapt resource value: 0x7f010140
public const int tabTextColor = 2130772288;
// aapt resource value: 0x7f010049
public const int textAllCaps = 2130772041;
// aapt resource value: 0x7f010070
public const int textAppearanceLargePopupMenu = 2130772080;
// aapt resource value: 0x7f010095
public const int textAppearanceListItem = 2130772117;
// aapt resource value: 0x7f010096
public const int textAppearanceListItemSecondary = 2130772118;
// aapt resource value: 0x7f010097
public const int textAppearanceListItemSmall = 2130772119;
// aapt resource value: 0x7f010072
public const int textAppearancePopupMenuHeader = 2130772082;
// aapt resource value: 0x7f01008b
public const int textAppearanceSearchResultSubtitle = 2130772107;
// aapt resource value: 0x7f01008a
public const int textAppearanceSearchResultTitle = 2130772106;
// aapt resource value: 0x7f010071
public const int textAppearanceSmallPopupMenu = 2130772081;
// aapt resource value: 0x7f0100aa
public const int textColorAlertDialogListItem = 2130772138;
// aapt resource value: 0x7f010126
public const int textColorError = 2130772262;
// aapt resource value: 0x7f01008c
public const int textColorSearchUrl = 2130772108;
// aapt resource value: 0x7f010100
public const int theme = 2130772224;
// aapt resource value: 0x7f0100c7
public const int thickness = 2130772167;
// aapt resource value: 0x7f0100e7
public const int thumbTextPadding = 2130772199;
// aapt resource value: 0x7f0100e2
public const int thumbTint = 2130772194;
// aapt resource value: 0x7f0100e3
public const int thumbTintMode = 2130772195;
// aapt resource value: 0x7f010046
public const int tickMark = 2130772038;
// aapt resource value: 0x7f010047
public const int tickMarkTint = 2130772039;
// aapt resource value: 0x7f010048
public const int tickMarkTintMode = 2130772040;
// aapt resource value: 0x7f010044
public const int tint = 2130772036;
// aapt resource value: 0x7f010045
public const int tintMode = 2130772037;
// aapt resource value: 0x7f01001f
public const int title = 2130771999;
// aapt resource value: 0x7f010119
public const int titleEnabled = 2130772249;
// aapt resource value: 0x7f0100ef
public const int titleMargin = 2130772207;
// aapt resource value: 0x7f0100f3
public const int titleMarginBottom = 2130772211;
// aapt resource value: 0x7f0100f1
public const int titleMarginEnd = 2130772209;
// aapt resource value: 0x7f0100f0
public const int titleMarginStart = 2130772208;
// aapt resource value: 0x7f0100f2
public const int titleMarginTop = 2130772210;
// aapt resource value: 0x7f0100f4
public const int titleMargins = 2130772212;
// aapt resource value: 0x7f0100ed
public const int titleTextAppearance = 2130772205;
// aapt resource value: 0x7f0100fc
public const int titleTextColor = 2130772220;
// aapt resource value: 0x7f010023
public const int titleTextStyle = 2130772003;
// aapt resource value: 0x7f010114
public const int toolbarId = 2130772244;
// aapt resource value: 0x7f010084
public const int toolbarNavigationButtonStyle = 2130772100;
// aapt resource value: 0x7f010083
public const int toolbarStyle = 2130772099;
// aapt resource value: 0x7f0100e4
public const int track = 2130772196;
// aapt resource value: 0x7f0100e5
public const int trackTint = 2130772197;
// aapt resource value: 0x7f0100e6
public const int trackTintMode = 2130772198;
// aapt resource value: 0x7f01012b
public const int useCompatPadding = 2130772267;
// aapt resource value: 0x7f0100dd
public const int voiceIcon = 2130772189;
// aapt resource value: 0x7f01004a
public const int windowActionBar = 2130772042;
// aapt resource value: 0x7f01004c
public const int windowActionBarOverlay = 2130772044;
// aapt resource value: 0x7f01004d
public const int windowActionModeOverlay = 2130772045;
// aapt resource value: 0x7f010051
public const int windowFixedHeightMajor = 2130772049;
// aapt resource value: 0x7f01004f
public const int windowFixedHeightMinor = 2130772047;
// aapt resource value: 0x7f01004e
public const int windowFixedWidthMajor = 2130772046;
// aapt resource value: 0x7f010050
public const int windowFixedWidthMinor = 2130772048;
// aapt resource value: 0x7f010052
public const int windowMinWidthMajor = 2130772050;
// aapt resource value: 0x7f010053
public const int windowMinWidthMinor = 2130772051;
// aapt resource value: 0x7f01004b
public const int windowNoTitle = 2130772043;
static Attribute()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Attribute()
{
}
}
public partial class Boolean
{
// aapt resource value: 0x7f0d0000
public const int abc_action_bar_embed_tabs = 2131558400;
// aapt resource value: 0x7f0d0001
public const int abc_allow_stacked_button_bar = 2131558401;
// aapt resource value: 0x7f0d0002
public const int abc_config_actionMenuItemAllCaps = 2131558402;
// aapt resource value: 0x7f0d0003
public const int abc_config_closeDialogWhenTouchOutside = 2131558403;
// aapt resource value: 0x7f0d0004
public const int abc_config_showMenuShortcutsWhenKeyboardPresent = 2131558404;
static Boolean()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Boolean()
{
}
}
public partial class Color
{
// aapt resource value: 0x7f0c004a
public const int abc_background_cache_hint_selector_material_dark = 2131492938;
// aapt resource value: 0x7f0c004b
public const int abc_background_cache_hint_selector_material_light = 2131492939;
// aapt resource value: 0x7f0c004c
public const int abc_btn_colored_borderless_text_material = 2131492940;
// aapt resource value: 0x7f0c004d
public const int abc_btn_colored_text_material = 2131492941;
// aapt resource value: 0x7f0c004e
public const int abc_color_highlight_material = 2131492942;
// aapt resource value: 0x7f0c004f
public const int abc_hint_foreground_material_dark = 2131492943;
// aapt resource value: 0x7f0c0050
public const int abc_hint_foreground_material_light = 2131492944;
// aapt resource value: 0x7f0c0005
public const int abc_input_method_navigation_guard = 2131492869;
// aapt resource value: 0x7f0c0051
public const int abc_primary_text_disable_only_material_dark = 2131492945;
// aapt resource value: 0x7f0c0052
public const int abc_primary_text_disable_only_material_light = 2131492946;
// aapt resource value: 0x7f0c0053
public const int abc_primary_text_material_dark = 2131492947;
// aapt resource value: 0x7f0c0054
public const int abc_primary_text_material_light = 2131492948;
// aapt resource value: 0x7f0c0055
public const int abc_search_url_text = 2131492949;
// aapt resource value: 0x7f0c0006
public const int abc_search_url_text_normal = 2131492870;
// aapt resource value: 0x7f0c0007
public const int abc_search_url_text_pressed = 2131492871;
// aapt resource value: 0x7f0c0008
public const int abc_search_url_text_selected = 2131492872;
// aapt resource value: 0x7f0c0056
public const int abc_secondary_text_material_dark = 2131492950;
// aapt resource value: 0x7f0c0057
public const int abc_secondary_text_material_light = 2131492951;
// aapt resource value: 0x7f0c0058
public const int abc_tint_btn_checkable = 2131492952;
// aapt resource value: 0x7f0c0059
public const int abc_tint_default = 2131492953;
// aapt resource value: 0x7f0c005a
public const int abc_tint_edittext = 2131492954;
// aapt resource value: 0x7f0c005b
public const int abc_tint_seek_thumb = 2131492955;
// aapt resource value: 0x7f0c005c
public const int abc_tint_spinner = 2131492956;
// aapt resource value: 0x7f0c005d
public const int abc_tint_switch_thumb = 2131492957;
// aapt resource value: 0x7f0c005e
public const int abc_tint_switch_track = 2131492958;
// aapt resource value: 0x7f0c0009
public const int accent_material_dark = 2131492873;
// aapt resource value: 0x7f0c000a
public const int accent_material_light = 2131492874;
// aapt resource value: 0x7f0c000b
public const int background_floating_material_dark = 2131492875;
// aapt resource value: 0x7f0c000c
public const int background_floating_material_light = 2131492876;
// aapt resource value: 0x7f0c000d
public const int background_material_dark = 2131492877;
// aapt resource value: 0x7f0c000e
public const int background_material_light = 2131492878;
// aapt resource value: 0x7f0c000f
public const int bright_foreground_disabled_material_dark = 2131492879;
// aapt resource value: 0x7f0c0010
public const int bright_foreground_disabled_material_light = 2131492880;
// aapt resource value: 0x7f0c0011
public const int bright_foreground_inverse_material_dark = 2131492881;
// aapt resource value: 0x7f0c0012
public const int bright_foreground_inverse_material_light = 2131492882;
// aapt resource value: 0x7f0c0013
public const int bright_foreground_material_dark = 2131492883;
// aapt resource value: 0x7f0c0014
public const int bright_foreground_material_light = 2131492884;
// aapt resource value: 0x7f0c0015
public const int button_material_dark = 2131492885;
// aapt resource value: 0x7f0c0016
public const int button_material_light = 2131492886;
// aapt resource value: 0x7f0c0000
public const int cardview_dark_background = 2131492864;
// aapt resource value: 0x7f0c0001
public const int cardview_light_background = 2131492865;
// aapt resource value: 0x7f0c0002
public const int cardview_shadow_end_color = 2131492866;
// aapt resource value: 0x7f0c0003
public const int cardview_shadow_start_color = 2131492867;
// aapt resource value: 0x7f0c003f
public const int design_bottom_navigation_shadow_color = 2131492927;
// aapt resource value: 0x7f0c005f
public const int design_error = 2131492959;
// aapt resource value: 0x7f0c0040
public const int design_fab_shadow_end_color = 2131492928;
// aapt resource value: 0x7f0c0041
public const int design_fab_shadow_mid_color = 2131492929;
// aapt resource value: 0x7f0c0042
public const int design_fab_shadow_start_color = 2131492930;
// aapt resource value: 0x7f0c0043
public const int design_fab_stroke_end_inner_color = 2131492931;
// aapt resource value: 0x7f0c0044
public const int design_fab_stroke_end_outer_color = 2131492932;
// aapt resource value: 0x7f0c0045
public const int design_fab_stroke_top_inner_color = 2131492933;
// aapt resource value: 0x7f0c0046
public const int design_fab_stroke_top_outer_color = 2131492934;
// aapt resource value: 0x7f0c0047
public const int design_snackbar_background_color = 2131492935;
// aapt resource value: 0x7f0c0048
public const int design_textinput_error_color_dark = 2131492936;
// aapt resource value: 0x7f0c0049
public const int design_textinput_error_color_light = 2131492937;
// aapt resource value: 0x7f0c0060
public const int design_tint_password_toggle = 2131492960;
// aapt resource value: 0x7f0c0017
public const int dim_foreground_disabled_material_dark = 2131492887;
// aapt resource value: 0x7f0c0018
public const int dim_foreground_disabled_material_light = 2131492888;
// aapt resource value: 0x7f0c0019
public const int dim_foreground_material_dark = 2131492889;
// aapt resource value: 0x7f0c001a
public const int dim_foreground_material_light = 2131492890;
// aapt resource value: 0x7f0c001b
public const int foreground_material_dark = 2131492891;
// aapt resource value: 0x7f0c001c
public const int foreground_material_light = 2131492892;
// aapt resource value: 0x7f0c001d
public const int highlighted_text_material_dark = 2131492893;
// aapt resource value: 0x7f0c001e
public const int highlighted_text_material_light = 2131492894;
// aapt resource value: 0x7f0c001f
public const int material_blue_grey_800 = 2131492895;
// aapt resource value: 0x7f0c0020
public const int material_blue_grey_900 = 2131492896;
// aapt resource value: 0x7f0c0021
public const int material_blue_grey_950 = 2131492897;
// aapt resource value: 0x7f0c0022
public const int material_deep_teal_200 = 2131492898;
// aapt resource value: 0x7f0c0023
public const int material_deep_teal_500 = 2131492899;
// aapt resource value: 0x7f0c0024
public const int material_grey_100 = 2131492900;
// aapt resource value: 0x7f0c0025
public const int material_grey_300 = 2131492901;
// aapt resource value: 0x7f0c0026
public const int material_grey_50 = 2131492902;
// aapt resource value: 0x7f0c0027
public const int material_grey_600 = 2131492903;
// aapt resource value: 0x7f0c0028
public const int material_grey_800 = 2131492904;
// aapt resource value: 0x7f0c0029
public const int material_grey_850 = 2131492905;
// aapt resource value: 0x7f0c002a
public const int material_grey_900 = 2131492906;
// aapt resource value: 0x7f0c0004
public const int notification_action_color_filter = 2131492868;
// aapt resource value: 0x7f0c002b
public const int notification_icon_bg_color = 2131492907;
// aapt resource value: 0x7f0c002c
public const int notification_material_background_media_default_color = 2131492908;
// aapt resource value: 0x7f0c002d
public const int primary_dark_material_dark = 2131492909;
// aapt resource value: 0x7f0c002e
public const int primary_dark_material_light = 2131492910;
// aapt resource value: 0x7f0c002f
public const int primary_material_dark = 2131492911;
// aapt resource value: 0x7f0c0030
public const int primary_material_light = 2131492912;
// aapt resource value: 0x7f0c0031
public const int primary_text_default_material_dark = 2131492913;
// aapt resource value: 0x7f0c0032
public const int primary_text_default_material_light = 2131492914;
// aapt resource value: 0x7f0c0033
public const int primary_text_disabled_material_dark = 2131492915;
// aapt resource value: 0x7f0c0034
public const int primary_text_disabled_material_light = 2131492916;
// aapt resource value: 0x7f0c0035
public const int ripple_material_dark = 2131492917;
// aapt resource value: 0x7f0c0036
public const int ripple_material_light = 2131492918;
// aapt resource value: 0x7f0c0037
public const int secondary_text_default_material_dark = 2131492919;
// aapt resource value: 0x7f0c0038
public const int secondary_text_default_material_light = 2131492920;
// aapt resource value: 0x7f0c0039
public const int secondary_text_disabled_material_dark = 2131492921;
// aapt resource value: 0x7f0c003a
public const int secondary_text_disabled_material_light = 2131492922;
// aapt resource value: 0x7f0c003b
public const int switch_thumb_disabled_material_dark = 2131492923;
// aapt resource value: 0x7f0c003c
public const int switch_thumb_disabled_material_light = 2131492924;
// aapt resource value: 0x7f0c0061
public const int switch_thumb_material_dark = 2131492961;
// aapt resource value: 0x7f0c0062
public const int switch_thumb_material_light = 2131492962;
// aapt resource value: 0x7f0c003d
public const int switch_thumb_normal_material_dark = 2131492925;
// aapt resource value: 0x7f0c003e
public const int switch_thumb_normal_material_light = 2131492926;
static Color()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Color()
{
}
}
public partial class Dimension
{
// aapt resource value: 0x7f070018
public const int abc_action_bar_content_inset_material = 2131165208;
// aapt resource value: 0x7f070019
public const int abc_action_bar_content_inset_with_nav = 2131165209;
// aapt resource value: 0x7f07000d
public const int abc_action_bar_default_height_material = 2131165197;
// aapt resource value: 0x7f07001a
public const int abc_action_bar_default_padding_end_material = 2131165210;
// aapt resource value: 0x7f07001b
public const int abc_action_bar_default_padding_start_material = 2131165211;
// aapt resource value: 0x7f070021
public const int abc_action_bar_elevation_material = 2131165217;
// aapt resource value: 0x7f070022
public const int abc_action_bar_icon_vertical_padding_material = 2131165218;
// aapt resource value: 0x7f070023
public const int abc_action_bar_overflow_padding_end_material = 2131165219;
// aapt resource value: 0x7f070024
public const int abc_action_bar_overflow_padding_start_material = 2131165220;
// aapt resource value: 0x7f07000e
public const int abc_action_bar_progress_bar_size = 2131165198;
// aapt resource value: 0x7f070025
public const int abc_action_bar_stacked_max_height = 2131165221;
// aapt resource value: 0x7f070026
public const int abc_action_bar_stacked_tab_max_width = 2131165222;
// aapt resource value: 0x7f070027
public const int abc_action_bar_subtitle_bottom_margin_material = 2131165223;
// aapt resource value: 0x7f070028
public const int abc_action_bar_subtitle_top_margin_material = 2131165224;
// aapt resource value: 0x7f070029
public const int abc_action_button_min_height_material = 2131165225;
// aapt resource value: 0x7f07002a
public const int abc_action_button_min_width_material = 2131165226;
// aapt resource value: 0x7f07002b
public const int abc_action_button_min_width_overflow_material = 2131165227;
// aapt resource value: 0x7f07000c
public const int abc_alert_dialog_button_bar_height = 2131165196;
// aapt resource value: 0x7f07002c
public const int abc_button_inset_horizontal_material = 2131165228;
// aapt resource value: 0x7f07002d
public const int abc_button_inset_vertical_material = 2131165229;
// aapt resource value: 0x7f07002e
public const int abc_button_padding_horizontal_material = 2131165230;
// aapt resource value: 0x7f07002f
public const int abc_button_padding_vertical_material = 2131165231;
// aapt resource value: 0x7f070030
public const int abc_cascading_menus_min_smallest_width = 2131165232;
// aapt resource value: 0x7f070011
public const int abc_config_prefDialogWidth = 2131165201;
// aapt resource value: 0x7f070031
public const int abc_control_corner_material = 2131165233;
// aapt resource value: 0x7f070032
public const int abc_control_inset_material = 2131165234;
// aapt resource value: 0x7f070033
public const int abc_control_padding_material = 2131165235;
// aapt resource value: 0x7f070012
public const int abc_dialog_fixed_height_major = 2131165202;
// aapt resource value: 0x7f070013
public const int abc_dialog_fixed_height_minor = 2131165203;
// aapt resource value: 0x7f070014
public const int abc_dialog_fixed_width_major = 2131165204;
// aapt resource value: 0x7f070015
public const int abc_dialog_fixed_width_minor = 2131165205;
// aapt resource value: 0x7f070034
public const int abc_dialog_list_padding_bottom_no_buttons = 2131165236;
// aapt resource value: 0x7f070035
public const int abc_dialog_list_padding_top_no_title = 2131165237;
// aapt resource value: 0x7f070016
public const int abc_dialog_min_width_major = 2131165206;
// aapt resource value: 0x7f070017
public const int abc_dialog_min_width_minor = 2131165207;
// aapt resource value: 0x7f070036
public const int abc_dialog_padding_material = 2131165238;
// aapt resource value: 0x7f070037
public const int abc_dialog_padding_top_material = 2131165239;
// aapt resource value: 0x7f070038
public const int abc_dialog_title_divider_material = 2131165240;
// aapt resource value: 0x7f070039
public const int abc_disabled_alpha_material_dark = 2131165241;
// aapt resource value: 0x7f07003a
public const int abc_disabled_alpha_material_light = 2131165242;
// aapt resource value: 0x7f07003b
public const int abc_dropdownitem_icon_width = 2131165243;
// aapt resource value: 0x7f07003c
public const int abc_dropdownitem_text_padding_left = 2131165244;
// aapt resource value: 0x7f07003d
public const int abc_dropdownitem_text_padding_right = 2131165245;
// aapt resource value: 0x7f07003e
public const int abc_edit_text_inset_bottom_material = 2131165246;
// aapt resource value: 0x7f07003f
public const int abc_edit_text_inset_horizontal_material = 2131165247;
// aapt resource value: 0x7f070040
public const int abc_edit_text_inset_top_material = 2131165248;
// aapt resource value: 0x7f070041
public const int abc_floating_window_z = 2131165249;
// aapt resource value: 0x7f070042
public const int abc_list_item_padding_horizontal_material = 2131165250;
// aapt resource value: 0x7f070043
public const int abc_panel_menu_list_width = 2131165251;
// aapt resource value: 0x7f070044
public const int abc_progress_bar_height_material = 2131165252;
// aapt resource value: 0x7f070045
public const int abc_search_view_preferred_height = 2131165253;
// aapt resource value: 0x7f070046
public const int abc_search_view_preferred_width = 2131165254;
// aapt resource value: 0x7f070047
public const int abc_seekbar_track_background_height_material = 2131165255;
// aapt resource value: 0x7f070048
public const int abc_seekbar_track_progress_height_material = 2131165256;
// aapt resource value: 0x7f070049
public const int abc_select_dialog_padding_start_material = 2131165257;
// aapt resource value: 0x7f07001d
public const int abc_switch_padding = 2131165213;
// aapt resource value: 0x7f07004a
public const int abc_text_size_body_1_material = 2131165258;
// aapt resource value: 0x7f07004b
public const int abc_text_size_body_2_material = 2131165259;
// aapt resource value: 0x7f07004c
public const int abc_text_size_button_material = 2131165260;
// aapt resource value: 0x7f07004d
public const int abc_text_size_caption_material = 2131165261;
// aapt resource value: 0x7f07004e
public const int abc_text_size_display_1_material = 2131165262;
// aapt resource value: 0x7f07004f
public const int abc_text_size_display_2_material = 2131165263;
// aapt resource value: 0x7f070050
public const int abc_text_size_display_3_material = 2131165264;
// aapt resource value: 0x7f070051
public const int abc_text_size_display_4_material = 2131165265;
// aapt resource value: 0x7f070052
public const int abc_text_size_headline_material = 2131165266;
// aapt resource value: 0x7f070053
public const int abc_text_size_large_material = 2131165267;
// aapt resource value: 0x7f070054
public const int abc_text_size_medium_material = 2131165268;
// aapt resource value: 0x7f070055
public const int abc_text_size_menu_header_material = 2131165269;
// aapt resource value: 0x7f070056
public const int abc_text_size_menu_material = 2131165270;
// aapt resource value: 0x7f070057
public const int abc_text_size_small_material = 2131165271;
// aapt resource value: 0x7f070058
public const int abc_text_size_subhead_material = 2131165272;
// aapt resource value: 0x7f07000f
public const int abc_text_size_subtitle_material_toolbar = 2131165199;
// aapt resource value: 0x7f070059
public const int abc_text_size_title_material = 2131165273;
// aapt resource value: 0x7f070010
public const int abc_text_size_title_material_toolbar = 2131165200;
// aapt resource value: 0x7f070009
public const int cardview_compat_inset_shadow = 2131165193;
// aapt resource value: 0x7f07000a
public const int cardview_default_elevation = 2131165194;
// aapt resource value: 0x7f07000b
public const int cardview_default_radius = 2131165195;
// aapt resource value: 0x7f070076
public const int design_appbar_elevation = 2131165302;
// aapt resource value: 0x7f070077
public const int design_bottom_navigation_active_item_max_width = 2131165303;
// aapt resource value: 0x7f070078
public const int design_bottom_navigation_active_text_size = 2131165304;
// aapt resource value: 0x7f070079
public const int design_bottom_navigation_elevation = 2131165305;
// aapt resource value: 0x7f07007a
public const int design_bottom_navigation_height = 2131165306;
// aapt resource value: 0x7f07007b
public const int design_bottom_navigation_item_max_width = 2131165307;
// aapt resource value: 0x7f07007c
public const int design_bottom_navigation_item_min_width = 2131165308;
// aapt resource value: 0x7f07007d
public const int design_bottom_navigation_margin = 2131165309;
// aapt resource value: 0x7f07007e
public const int design_bottom_navigation_shadow_height = 2131165310;
// aapt resource value: 0x7f07007f
public const int design_bottom_navigation_text_size = 2131165311;
// aapt resource value: 0x7f070080
public const int design_bottom_sheet_modal_elevation = 2131165312;
// aapt resource value: 0x7f070081
public const int design_bottom_sheet_peek_height_min = 2131165313;
// aapt resource value: 0x7f070082
public const int design_fab_border_width = 2131165314;
// aapt resource value: 0x7f070083
public const int design_fab_elevation = 2131165315;
// aapt resource value: 0x7f070084
public const int design_fab_image_size = 2131165316;
// aapt resource value: 0x7f070085
public const int design_fab_size_mini = 2131165317;
// aapt resource value: 0x7f070086
public const int design_fab_size_normal = 2131165318;
// aapt resource value: 0x7f070087
public const int design_fab_translation_z_pressed = 2131165319;
// aapt resource value: 0x7f070088
public const int design_navigation_elevation = 2131165320;
// aapt resource value: 0x7f070089
public const int design_navigation_icon_padding = 2131165321;
// aapt resource value: 0x7f07008a
public const int design_navigation_icon_size = 2131165322;
// aapt resource value: 0x7f07006e
public const int design_navigation_max_width = 2131165294;
// aapt resource value: 0x7f07008b
public const int design_navigation_padding_bottom = 2131165323;
// aapt resource value: 0x7f07008c
public const int design_navigation_separator_vertical_padding = 2131165324;
// aapt resource value: 0x7f07006f
public const int design_snackbar_action_inline_max_width = 2131165295;
// aapt resource value: 0x7f070070
public const int design_snackbar_background_corner_radius = 2131165296;
// aapt resource value: 0x7f07008d
public const int design_snackbar_elevation = 2131165325;
// aapt resource value: 0x7f070071
public const int design_snackbar_extra_spacing_horizontal = 2131165297;
// aapt resource value: 0x7f070072
public const int design_snackbar_max_width = 2131165298;
// aapt resource value: 0x7f070073
public const int design_snackbar_min_width = 2131165299;
// aapt resource value: 0x7f07008e
public const int design_snackbar_padding_horizontal = 2131165326;
// aapt resource value: 0x7f07008f
public const int design_snackbar_padding_vertical = 2131165327;
// aapt resource value: 0x7f070074
public const int design_snackbar_padding_vertical_2lines = 2131165300;
// aapt resource value: 0x7f070090
public const int design_snackbar_text_size = 2131165328;
// aapt resource value: 0x7f070091
public const int design_tab_max_width = 2131165329;
// aapt resource value: 0x7f070075
public const int design_tab_scrollable_min_width = 2131165301;
// aapt resource value: 0x7f070092
public const int design_tab_text_size = 2131165330;
// aapt resource value: 0x7f070093
public const int design_tab_text_size_2line = 2131165331;
// aapt resource value: 0x7f07005a
public const int disabled_alpha_material_dark = 2131165274;
// aapt resource value: 0x7f07005b
public const int disabled_alpha_material_light = 2131165275;
// aapt resource value: 0x7f07005c
public const int highlight_alpha_material_colored = 2131165276;
// aapt resource value: 0x7f07005d
public const int highlight_alpha_material_dark = 2131165277;
// aapt resource value: 0x7f07005e
public const int highlight_alpha_material_light = 2131165278;
// aapt resource value: 0x7f07005f
public const int hint_alpha_material_dark = 2131165279;
// aapt resource value: 0x7f070060
public const int hint_alpha_material_light = 2131165280;
// aapt resource value: 0x7f070061
public const int hint_pressed_alpha_material_dark = 2131165281;
// aapt resource value: 0x7f070062
public const int hint_pressed_alpha_material_light = 2131165282;
// aapt resource value: 0x7f070000
public const int item_touch_helper_max_drag_scroll_per_frame = 2131165184;
// aapt resource value: 0x7f070001
public const int item_touch_helper_swipe_escape_max_velocity = 2131165185;
// aapt resource value: 0x7f070002
public const int item_touch_helper_swipe_escape_velocity = 2131165186;
// aapt resource value: 0x7f070003
public const int mr_controller_volume_group_list_item_height = 2131165187;
// aapt resource value: 0x7f070004
public const int mr_controller_volume_group_list_item_icon_size = 2131165188;
// aapt resource value: 0x7f070005
public const int mr_controller_volume_group_list_max_height = 2131165189;
// aapt resource value: 0x7f070008
public const int mr_controller_volume_group_list_padding_top = 2131165192;
// aapt resource value: 0x7f070006
public const int mr_dialog_fixed_width_major = 2131165190;
// aapt resource value: 0x7f070007
public const int mr_dialog_fixed_width_minor = 2131165191;
// aapt resource value: 0x7f070063
public const int notification_action_icon_size = 2131165283;
// aapt resource value: 0x7f070064
public const int notification_action_text_size = 2131165284;
// aapt resource value: 0x7f070065
public const int notification_big_circle_margin = 2131165285;
// aapt resource value: 0x7f07001e
public const int notification_content_margin_start = 2131165214;
// aapt resource value: 0x7f070066
public const int notification_large_icon_height = 2131165286;
// aapt resource value: 0x7f070067
public const int notification_large_icon_width = 2131165287;
// aapt resource value: 0x7f07001f
public const int notification_main_column_padding_top = 2131165215;
// aapt resource value: 0x7f070020
public const int notification_media_narrow_margin = 2131165216;
// aapt resource value: 0x7f070068
public const int notification_right_icon_size = 2131165288;
// aapt resource value: 0x7f07001c
public const int notification_right_side_padding_top = 2131165212;
// aapt resource value: 0x7f070069
public const int notification_small_icon_background_padding = 2131165289;
// aapt resource value: 0x7f07006a
public const int notification_small_icon_size_as_large = 2131165290;
// aapt resource value: 0x7f07006b
public const int notification_subtext_size = 2131165291;
// aapt resource value: 0x7f07006c
public const int notification_top_pad = 2131165292;
// aapt resource value: 0x7f07006d
public const int notification_top_pad_large_text = 2131165293;
static Dimension()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Dimension()
{
}
}
public partial class Drawable
{
// aapt resource value: 0x7f020000
public const int abc_ab_share_pack_mtrl_alpha = 2130837504;
// aapt resource value: 0x7f020001
public const int abc_action_bar_item_background_material = 2130837505;
// aapt resource value: 0x7f020002
public const int abc_btn_borderless_material = 2130837506;
// aapt resource value: 0x7f020003
public const int abc_btn_check_material = 2130837507;
// aapt resource value: 0x7f020004
public const int abc_btn_check_to_on_mtrl_000 = 2130837508;
// aapt resource value: 0x7f020005
public const int abc_btn_check_to_on_mtrl_015 = 2130837509;
// aapt resource value: 0x7f020006
public const int abc_btn_colored_material = 2130837510;
// aapt resource value: 0x7f020007
public const int abc_btn_default_mtrl_shape = 2130837511;
// aapt resource value: 0x7f020008
public const int abc_btn_radio_material = 2130837512;
// aapt resource value: 0x7f020009
public const int abc_btn_radio_to_on_mtrl_000 = 2130837513;
// aapt resource value: 0x7f02000a
public const int abc_btn_radio_to_on_mtrl_015 = 2130837514;
// aapt resource value: 0x7f02000b
public const int abc_btn_switch_to_on_mtrl_00001 = 2130837515;
// aapt resource value: 0x7f02000c
public const int abc_btn_switch_to_on_mtrl_00012 = 2130837516;
// aapt resource value: 0x7f02000d
public const int abc_cab_background_internal_bg = 2130837517;
// aapt resource value: 0x7f02000e
public const int abc_cab_background_top_material = 2130837518;
// aapt resource value: 0x7f02000f
public const int abc_cab_background_top_mtrl_alpha = 2130837519;
// aapt resource value: 0x7f020010
public const int abc_control_background_material = 2130837520;
// aapt resource value: 0x7f020011
public const int abc_dialog_material_background = 2130837521;
// aapt resource value: 0x7f020012
public const int abc_edit_text_material = 2130837522;
// aapt resource value: 0x7f020013
public const int abc_ic_ab_back_material = 2130837523;
// aapt resource value: 0x7f020014
public const int abc_ic_arrow_drop_right_black_24dp = 2130837524;
// aapt resource value: 0x7f020015
public const int abc_ic_clear_material = 2130837525;
// aapt resource value: 0x7f020016
public const int abc_ic_commit_search_api_mtrl_alpha = 2130837526;
// aapt resource value: 0x7f020017
public const int abc_ic_go_search_api_material = 2130837527;
// aapt resource value: 0x7f020018
public const int abc_ic_menu_copy_mtrl_am_alpha = 2130837528;
// aapt resource value: 0x7f020019
public const int abc_ic_menu_cut_mtrl_alpha = 2130837529;
// aapt resource value: 0x7f02001a
public const int abc_ic_menu_overflow_material = 2130837530;
// aapt resource value: 0x7f02001b
public const int abc_ic_menu_paste_mtrl_am_alpha = 2130837531;
// aapt resource value: 0x7f02001c
public const int abc_ic_menu_selectall_mtrl_alpha = 2130837532;
// aapt resource value: 0x7f02001d
public const int abc_ic_menu_share_mtrl_alpha = 2130837533;
// aapt resource value: 0x7f02001e
public const int abc_ic_search_api_material = 2130837534;
// aapt resource value: 0x7f02001f
public const int abc_ic_star_black_16dp = 2130837535;
// aapt resource value: 0x7f020020
public const int abc_ic_star_black_36dp = 2130837536;
// aapt resource value: 0x7f020021
public const int abc_ic_star_black_48dp = 2130837537;
// aapt resource value: 0x7f020022
public const int abc_ic_star_half_black_16dp = 2130837538;
// aapt resource value: 0x7f020023
public const int abc_ic_star_half_black_36dp = 2130837539;
// aapt resource value: 0x7f020024
public const int abc_ic_star_half_black_48dp = 2130837540;
// aapt resource value: 0x7f020025
public const int abc_ic_voice_search_api_material = 2130837541;
// aapt resource value: 0x7f020026
public const int abc_item_background_holo_dark = 2130837542;
// aapt resource value: 0x7f020027
public const int abc_item_background_holo_light = 2130837543;
// aapt resource value: 0x7f020028
public const int abc_list_divider_mtrl_alpha = 2130837544;
// aapt resource value: 0x7f020029
public const int abc_list_focused_holo = 2130837545;
// aapt resource value: 0x7f02002a
public const int abc_list_longpressed_holo = 2130837546;
// aapt resource value: 0x7f02002b
public const int abc_list_pressed_holo_dark = 2130837547;
// aapt resource value: 0x7f02002c
public const int abc_list_pressed_holo_light = 2130837548;
// aapt resource value: 0x7f02002d
public const int abc_list_selector_background_transition_holo_dark = 2130837549;
// aapt resource value: 0x7f02002e
public const int abc_list_selector_background_transition_holo_light = 2130837550;
// aapt resource value: 0x7f02002f
public const int abc_list_selector_disabled_holo_dark = 2130837551;
// aapt resource value: 0x7f020030
public const int abc_list_selector_disabled_holo_light = 2130837552;
// aapt resource value: 0x7f020031
public const int abc_list_selector_holo_dark = 2130837553;
// aapt resource value: 0x7f020032
public const int abc_list_selector_holo_light = 2130837554;
// aapt resource value: 0x7f020033
public const int abc_menu_hardkey_panel_mtrl_mult = 2130837555;
// aapt resource value: 0x7f020034
public const int abc_popup_background_mtrl_mult = 2130837556;
// aapt resource value: 0x7f020035
public const int abc_ratingbar_indicator_material = 2130837557;
// aapt resource value: 0x7f020036
public const int abc_ratingbar_material = 2130837558;
// aapt resource value: 0x7f020037
public const int abc_ratingbar_small_material = 2130837559;
// aapt resource value: 0x7f020038
public const int abc_scrubber_control_off_mtrl_alpha = 2130837560;
// aapt resource value: 0x7f020039
public const int abc_scrubber_control_to_pressed_mtrl_000 = 2130837561;
// aapt resource value: 0x7f02003a
public const int abc_scrubber_control_to_pressed_mtrl_005 = 2130837562;
// aapt resource value: 0x7f02003b
public const int abc_scrubber_primary_mtrl_alpha = 2130837563;
// aapt resource value: 0x7f02003c
public const int abc_scrubber_track_mtrl_alpha = 2130837564;
// aapt resource value: 0x7f02003d
public const int abc_seekbar_thumb_material = 2130837565;
// aapt resource value: 0x7f02003e
public const int abc_seekbar_tick_mark_material = 2130837566;
// aapt resource value: 0x7f02003f
public const int abc_seekbar_track_material = 2130837567;
// aapt resource value: 0x7f020040
public const int abc_spinner_mtrl_am_alpha = 2130837568;
// aapt resource value: 0x7f020041
public const int abc_spinner_textfield_background_material = 2130837569;
// aapt resource value: 0x7f020042
public const int abc_switch_thumb_material = 2130837570;
// aapt resource value: 0x7f020043
public const int abc_switch_track_mtrl_alpha = 2130837571;
// aapt resource value: 0x7f020044
public const int abc_tab_indicator_material = 2130837572;
// aapt resource value: 0x7f020045
public const int abc_tab_indicator_mtrl_alpha = 2130837573;
// aapt resource value: 0x7f020046
public const int abc_text_cursor_material = 2130837574;
// aapt resource value: 0x7f020047
public const int abc_text_select_handle_left_mtrl_dark = 2130837575;
// aapt resource value: 0x7f020048
public const int abc_text_select_handle_left_mtrl_light = 2130837576;
// aapt resource value: 0x7f020049
public const int abc_text_select_handle_middle_mtrl_dark = 2130837577;
// aapt resource value: 0x7f02004a
public const int abc_text_select_handle_middle_mtrl_light = 2130837578;
// aapt resource value: 0x7f02004b
public const int abc_text_select_handle_right_mtrl_dark = 2130837579;
// aapt resource value: 0x7f02004c
public const int abc_text_select_handle_right_mtrl_light = 2130837580;
// aapt resource value: 0x7f02004d
public const int abc_textfield_activated_mtrl_alpha = 2130837581;
// aapt resource value: 0x7f02004e
public const int abc_textfield_default_mtrl_alpha = 2130837582;
// aapt resource value: 0x7f02004f
public const int abc_textfield_search_activated_mtrl_alpha = 2130837583;
// aapt resource value: 0x7f020050
public const int abc_textfield_search_default_mtrl_alpha = 2130837584;
// aapt resource value: 0x7f020051
public const int abc_textfield_search_material = 2130837585;
// aapt resource value: 0x7f020052
public const int abc_vector_test = 2130837586;
// aapt resource value: 0x7f020053
public const int avd_hide_password = 2130837587;
// aapt resource value: 0x7f02010e
public const int avd_hide_password_1 = 2130837774;
// aapt resource value: 0x7f02010f
public const int avd_hide_password_2 = 2130837775;
// aapt resource value: 0x7f020110
public const int avd_hide_password_3 = 2130837776;
// aapt resource value: 0x7f020054
public const int avd_show_password = 2130837588;
// aapt resource value: 0x7f020111
public const int avd_show_password_1 = 2130837777;
// aapt resource value: 0x7f020112
public const int avd_show_password_2 = 2130837778;
// aapt resource value: 0x7f020113
public const int avd_show_password_3 = 2130837779;
// aapt resource value: 0x7f020055
public const int design_bottom_navigation_item_background = 2130837589;
// aapt resource value: 0x7f020056
public const int design_fab_background = 2130837590;
// aapt resource value: 0x7f020057
public const int design_ic_visibility = 2130837591;
// aapt resource value: 0x7f020058
public const int design_ic_visibility_off = 2130837592;
// aapt resource value: 0x7f020059
public const int design_password_eye = 2130837593;
// aapt resource value: 0x7f02005a
public const int design_snackbar_background = 2130837594;
// aapt resource value: 0x7f02005b
public const int ic_audiotrack_dark = 2130837595;
// aapt resource value: 0x7f02005c
public const int ic_audiotrack_light = 2130837596;
// aapt resource value: 0x7f02005d
public const int ic_dialog_close_dark = 2130837597;
// aapt resource value: 0x7f02005e
public const int ic_dialog_close_light = 2130837598;
// aapt resource value: 0x7f02005f
public const int ic_group_collapse_00 = 2130837599;
// aapt resource value: 0x7f020060
public const int ic_group_collapse_01 = 2130837600;
// aapt resource value: 0x7f020061
public const int ic_group_collapse_02 = 2130837601;
// aapt resource value: 0x7f020062
public const int ic_group_collapse_03 = 2130837602;
// aapt resource value: 0x7f020063
public const int ic_group_collapse_04 = 2130837603;
// aapt resource value: 0x7f020064
public const int ic_group_collapse_05 = 2130837604;
// aapt resource value: 0x7f020065
public const int ic_group_collapse_06 = 2130837605;
// aapt resource value: 0x7f020066
public const int ic_group_collapse_07 = 2130837606;
// aapt resource value: 0x7f020067
public const int ic_group_collapse_08 = 2130837607;
// aapt resource value: 0x7f020068
public const int ic_group_collapse_09 = 2130837608;
// aapt resource value: 0x7f020069
public const int ic_group_collapse_10 = 2130837609;
// aapt resource value: 0x7f02006a
public const int ic_group_collapse_11 = 2130837610;
// aapt resource value: 0x7f02006b
public const int ic_group_collapse_12 = 2130837611;
// aapt resource value: 0x7f02006c
public const int ic_group_collapse_13 = 2130837612;
// aapt resource value: 0x7f02006d
public const int ic_group_collapse_14 = 2130837613;
// aapt resource value: 0x7f02006e
public const int ic_group_collapse_15 = 2130837614;
// aapt resource value: 0x7f02006f
public const int ic_group_expand_00 = 2130837615;
// aapt resource value: 0x7f020070
public const int ic_group_expand_01 = 2130837616;
// aapt resource value: 0x7f020071
public const int ic_group_expand_02 = 2130837617;
// aapt resource value: 0x7f020072
public const int ic_group_expand_03 = 2130837618;
// aapt resource value: 0x7f020073
public const int ic_group_expand_04 = 2130837619;
// aapt resource value: 0x7f020074
public const int ic_group_expand_05 = 2130837620;
// aapt resource value: 0x7f020075
public const int ic_group_expand_06 = 2130837621;
// aapt resource value: 0x7f020076
public const int ic_group_expand_07 = 2130837622;
// aapt resource value: 0x7f020077
public const int ic_group_expand_08 = 2130837623;
// aapt resource value: 0x7f020078
public const int ic_group_expand_09 = 2130837624;
// aapt resource value: 0x7f020079
public const int ic_group_expand_10 = 2130837625;
// aapt resource value: 0x7f02007a
public const int ic_group_expand_11 = 2130837626;
// aapt resource value: 0x7f02007b
public const int ic_group_expand_12 = 2130837627;
// aapt resource value: 0x7f02007c
public const int ic_group_expand_13 = 2130837628;
// aapt resource value: 0x7f02007d
public const int ic_group_expand_14 = 2130837629;
// aapt resource value: 0x7f02007e
public const int ic_group_expand_15 = 2130837630;
// aapt resource value: 0x7f02007f
public const int ic_media_pause_dark = 2130837631;
// aapt resource value: 0x7f020080
public const int ic_media_pause_light = 2130837632;
// aapt resource value: 0x7f020081
public const int ic_media_play_dark = 2130837633;
// aapt resource value: 0x7f020082
public const int ic_media_play_light = 2130837634;
// aapt resource value: 0x7f020083
public const int ic_media_stop_dark = 2130837635;
// aapt resource value: 0x7f020084
public const int ic_media_stop_light = 2130837636;
// aapt resource value: 0x7f020085
public const int ic_mr_button_connected_00_dark = 2130837637;
// aapt resource value: 0x7f020086
public const int ic_mr_button_connected_00_light = 2130837638;
// aapt resource value: 0x7f020087
public const int ic_mr_button_connected_01_dark = 2130837639;
// aapt resource value: 0x7f020088
public const int ic_mr_button_connected_01_light = 2130837640;
// aapt resource value: 0x7f020089
public const int ic_mr_button_connected_02_dark = 2130837641;
// aapt resource value: 0x7f02008a
public const int ic_mr_button_connected_02_light = 2130837642;
// aapt resource value: 0x7f02008b
public const int ic_mr_button_connected_03_dark = 2130837643;
// aapt resource value: 0x7f02008c
public const int ic_mr_button_connected_03_light = 2130837644;
// aapt resource value: 0x7f02008d
public const int ic_mr_button_connected_04_dark = 2130837645;
// aapt resource value: 0x7f02008e
public const int ic_mr_button_connected_04_light = 2130837646;
// aapt resource value: 0x7f02008f
public const int ic_mr_button_connected_05_dark = 2130837647;
// aapt resource value: 0x7f020090
public const int ic_mr_button_connected_05_light = 2130837648;
// aapt resource value: 0x7f020091
public const int ic_mr_button_connected_06_dark = 2130837649;
// aapt resource value: 0x7f020092
public const int ic_mr_button_connected_06_light = 2130837650;
// aapt resource value: 0x7f020093
public const int ic_mr_button_connected_07_dark = 2130837651;
// aapt resource value: 0x7f020094
public const int ic_mr_button_connected_07_light = 2130837652;
// aapt resource value: 0x7f020095
public const int ic_mr_button_connected_08_dark = 2130837653;
// aapt resource value: 0x7f020096
public const int ic_mr_button_connected_08_light = 2130837654;
// aapt resource value: 0x7f020097
public const int ic_mr_button_connected_09_dark = 2130837655;
// aapt resource value: 0x7f020098
public const int ic_mr_button_connected_09_light = 2130837656;
// aapt resource value: 0x7f020099
public const int ic_mr_button_connected_10_dark = 2130837657;
// aapt resource value: 0x7f02009a
public const int ic_mr_button_connected_10_light = 2130837658;
// aapt resource value: 0x7f02009b
public const int ic_mr_button_connected_11_dark = 2130837659;
// aapt resource value: 0x7f02009c
public const int ic_mr_button_connected_11_light = 2130837660;
// aapt resource value: 0x7f02009d
public const int ic_mr_button_connected_12_dark = 2130837661;
// aapt resource value: 0x7f02009e
public const int ic_mr_button_connected_12_light = 2130837662;
// aapt resource value: 0x7f02009f
public const int ic_mr_button_connected_13_dark = 2130837663;
// aapt resource value: 0x7f0200a0
public const int ic_mr_button_connected_13_light = 2130837664;
// aapt resource value: 0x7f0200a1
public const int ic_mr_button_connected_14_dark = 2130837665;
// aapt resource value: 0x7f0200a2
public const int ic_mr_button_connected_14_light = 2130837666;
// aapt resource value: 0x7f0200a3
public const int ic_mr_button_connected_15_dark = 2130837667;
// aapt resource value: 0x7f0200a4
public const int ic_mr_button_connected_15_light = 2130837668;
// aapt resource value: 0x7f0200a5
public const int ic_mr_button_connected_16_dark = 2130837669;
// aapt resource value: 0x7f0200a6
public const int ic_mr_button_connected_16_light = 2130837670;
// aapt resource value: 0x7f0200a7
public const int ic_mr_button_connected_17_dark = 2130837671;
// aapt resource value: 0x7f0200a8
public const int ic_mr_button_connected_17_light = 2130837672;
// aapt resource value: 0x7f0200a9
public const int ic_mr_button_connected_18_dark = 2130837673;
// aapt resource value: 0x7f0200aa
public const int ic_mr_button_connected_18_light = 2130837674;
// aapt resource value: 0x7f0200ab
public const int ic_mr_button_connected_19_dark = 2130837675;
// aapt resource value: 0x7f0200ac
public const int ic_mr_button_connected_19_light = 2130837676;
// aapt resource value: 0x7f0200ad
public const int ic_mr_button_connected_20_dark = 2130837677;
// aapt resource value: 0x7f0200ae
public const int ic_mr_button_connected_20_light = 2130837678;
// aapt resource value: 0x7f0200af
public const int ic_mr_button_connected_21_dark = 2130837679;
// aapt resource value: 0x7f0200b0
public const int ic_mr_button_connected_21_light = 2130837680;
// aapt resource value: 0x7f0200b1
public const int ic_mr_button_connected_22_dark = 2130837681;
// aapt resource value: 0x7f0200b2
public const int ic_mr_button_connected_22_light = 2130837682;
// aapt resource value: 0x7f0200b3
public const int ic_mr_button_connecting_00_dark = 2130837683;
// aapt resource value: 0x7f0200b4
public const int ic_mr_button_connecting_00_light = 2130837684;
// aapt resource value: 0x7f0200b5
public const int ic_mr_button_connecting_01_dark = 2130837685;
// aapt resource value: 0x7f0200b6
public const int ic_mr_button_connecting_01_light = 2130837686;
// aapt resource value: 0x7f0200b7
public const int ic_mr_button_connecting_02_dark = 2130837687;
// aapt resource value: 0x7f0200b8
public const int ic_mr_button_connecting_02_light = 2130837688;
// aapt resource value: 0x7f0200b9
public const int ic_mr_button_connecting_03_dark = 2130837689;
// aapt resource value: 0x7f0200ba
public const int ic_mr_button_connecting_03_light = 2130837690;
// aapt resource value: 0x7f0200bb
public const int ic_mr_button_connecting_04_dark = 2130837691;
// aapt resource value: 0x7f0200bc
public const int ic_mr_button_connecting_04_light = 2130837692;
// aapt resource value: 0x7f0200bd
public const int ic_mr_button_connecting_05_dark = 2130837693;
// aapt resource value: 0x7f0200be
public const int ic_mr_button_connecting_05_light = 2130837694;
// aapt resource value: 0x7f0200bf
public const int ic_mr_button_connecting_06_dark = 2130837695;
// aapt resource value: 0x7f0200c0
public const int ic_mr_button_connecting_06_light = 2130837696;
// aapt resource value: 0x7f0200c1
public const int ic_mr_button_connecting_07_dark = 2130837697;
// aapt resource value: 0x7f0200c2
public const int ic_mr_button_connecting_07_light = 2130837698;
// aapt resource value: 0x7f0200c3
public const int ic_mr_button_connecting_08_dark = 2130837699;
// aapt resource value: 0x7f0200c4
public const int ic_mr_button_connecting_08_light = 2130837700;
// aapt resource value: 0x7f0200c5
public const int ic_mr_button_connecting_09_dark = 2130837701;
// aapt resource value: 0x7f0200c6
public const int ic_mr_button_connecting_09_light = 2130837702;
// aapt resource value: 0x7f0200c7
public const int ic_mr_button_connecting_10_dark = 2130837703;
// aapt resource value: 0x7f0200c8
public const int ic_mr_button_connecting_10_light = 2130837704;
// aapt resource value: 0x7f0200c9
public const int ic_mr_button_connecting_11_dark = 2130837705;
// aapt resource value: 0x7f0200ca
public const int ic_mr_button_connecting_11_light = 2130837706;
// aapt resource value: 0x7f0200cb
public const int ic_mr_button_connecting_12_dark = 2130837707;
// aapt resource value: 0x7f0200cc
public const int ic_mr_button_connecting_12_light = 2130837708;
// aapt resource value: 0x7f0200cd
public const int ic_mr_button_connecting_13_dark = 2130837709;
// aapt resource value: 0x7f0200ce
public const int ic_mr_button_connecting_13_light = 2130837710;
// aapt resource value: 0x7f0200cf
public const int ic_mr_button_connecting_14_dark = 2130837711;
// aapt resource value: 0x7f0200d0
public const int ic_mr_button_connecting_14_light = 2130837712;
// aapt resource value: 0x7f0200d1
public const int ic_mr_button_connecting_15_dark = 2130837713;
// aapt resource value: 0x7f0200d2
public const int ic_mr_button_connecting_15_light = 2130837714;
// aapt resource value: 0x7f0200d3
public const int ic_mr_button_connecting_16_dark = 2130837715;
// aapt resource value: 0x7f0200d4
public const int ic_mr_button_connecting_16_light = 2130837716;
// aapt resource value: 0x7f0200d5
public const int ic_mr_button_connecting_17_dark = 2130837717;
// aapt resource value: 0x7f0200d6
public const int ic_mr_button_connecting_17_light = 2130837718;
// aapt resource value: 0x7f0200d7
public const int ic_mr_button_connecting_18_dark = 2130837719;
// aapt resource value: 0x7f0200d8
public const int ic_mr_button_connecting_18_light = 2130837720;
// aapt resource value: 0x7f0200d9
public const int ic_mr_button_connecting_19_dark = 2130837721;
// aapt resource value: 0x7f0200da
public const int ic_mr_button_connecting_19_light = 2130837722;
// aapt resource value: 0x7f0200db
public const int ic_mr_button_connecting_20_dark = 2130837723;
// aapt resource value: 0x7f0200dc
public const int ic_mr_button_connecting_20_light = 2130837724;
// aapt resource value: 0x7f0200dd
public const int ic_mr_button_connecting_21_dark = 2130837725;
// aapt resource value: 0x7f0200de
public const int ic_mr_button_connecting_21_light = 2130837726;
// aapt resource value: 0x7f0200df
public const int ic_mr_button_connecting_22_dark = 2130837727;
// aapt resource value: 0x7f0200e0
public const int ic_mr_button_connecting_22_light = 2130837728;
// aapt resource value: 0x7f0200e1
public const int ic_mr_button_disabled_dark = 2130837729;
// aapt resource value: 0x7f0200e2
public const int ic_mr_button_disabled_light = 2130837730;
// aapt resource value: 0x7f0200e3
public const int ic_mr_button_disconnected_dark = 2130837731;
// aapt resource value: 0x7f0200e4
public const int ic_mr_button_disconnected_light = 2130837732;
// aapt resource value: 0x7f0200e5
public const int ic_mr_button_grey = 2130837733;
// aapt resource value: 0x7f0200e6
public const int ic_vol_type_speaker_dark = 2130837734;
// aapt resource value: 0x7f0200e7
public const int ic_vol_type_speaker_group_dark = 2130837735;
// aapt resource value: 0x7f0200e8
public const int ic_vol_type_speaker_group_light = 2130837736;
// aapt resource value: 0x7f0200e9
public const int ic_vol_type_speaker_light = 2130837737;
// aapt resource value: 0x7f0200ea
public const int ic_vol_type_tv_dark = 2130837738;
// aapt resource value: 0x7f0200eb
public const int ic_vol_type_tv_light = 2130837739;
// aapt resource value: 0x7f0200ec
public const int icon = 2130837740;
// aapt resource value: 0x7f0200ed
public const int mr_button_connected_dark = 2130837741;
// aapt resource value: 0x7f0200ee
public const int mr_button_connected_light = 2130837742;
// aapt resource value: 0x7f0200ef
public const int mr_button_connecting_dark = 2130837743;
// aapt resource value: 0x7f0200f0
public const int mr_button_connecting_light = 2130837744;
// aapt resource value: 0x7f0200f1
public const int mr_button_dark = 2130837745;
// aapt resource value: 0x7f0200f2
public const int mr_button_light = 2130837746;
// aapt resource value: 0x7f0200f3
public const int mr_dialog_close_dark = 2130837747;
// aapt resource value: 0x7f0200f4
public const int mr_dialog_close_light = 2130837748;
// aapt resource value: 0x7f0200f5
public const int mr_dialog_material_background_dark = 2130837749;
// aapt resource value: 0x7f0200f6
public const int mr_dialog_material_background_light = 2130837750;
// aapt resource value: 0x7f0200f7
public const int mr_group_collapse = 2130837751;
// aapt resource value: 0x7f0200f8
public const int mr_group_expand = 2130837752;
// aapt resource value: 0x7f0200f9
public const int mr_media_pause_dark = 2130837753;
// aapt resource value: 0x7f0200fa
public const int mr_media_pause_light = 2130837754;
// aapt resource value: 0x7f0200fb
public const int mr_media_play_dark = 2130837755;
// aapt resource value: 0x7f0200fc
public const int mr_media_play_light = 2130837756;
// aapt resource value: 0x7f0200fd
public const int mr_media_stop_dark = 2130837757;
// aapt resource value: 0x7f0200fe
public const int mr_media_stop_light = 2130837758;
// aapt resource value: 0x7f0200ff
public const int mr_vol_type_audiotrack_dark = 2130837759;
// aapt resource value: 0x7f020100
public const int mr_vol_type_audiotrack_light = 2130837760;
// aapt resource value: 0x7f020101
public const int navigation_empty_icon = 2130837761;
// aapt resource value: 0x7f020102
public const int notification_action_background = 2130837762;
// aapt resource value: 0x7f020103
public const int notification_bg = 2130837763;
// aapt resource value: 0x7f020104
public const int notification_bg_low = 2130837764;
// aapt resource value: 0x7f020105
public const int notification_bg_low_normal = 2130837765;
// aapt resource value: 0x7f020106
public const int notification_bg_low_pressed = 2130837766;
// aapt resource value: 0x7f020107
public const int notification_bg_normal = 2130837767;
// aapt resource value: 0x7f020108
public const int notification_bg_normal_pressed = 2130837768;
// aapt resource value: 0x7f020109
public const int notification_icon_background = 2130837769;
// aapt resource value: 0x7f02010c
public const int notification_template_icon_bg = 2130837772;
// aapt resource value: 0x7f02010d
public const int notification_template_icon_low_bg = 2130837773;
// aapt resource value: 0x7f02010a
public const int notification_tile_bg = 2130837770;
// aapt resource value: 0x7f02010b
public const int notify_panel_notification_icon_bg = 2130837771;
static Drawable()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Drawable()
{
}
}
public partial class Id
{
// aapt resource value: 0x7f08009e
public const int action0 = 2131230878;
// aapt resource value: 0x7f080064
public const int action_bar = 2131230820;
// aapt resource value: 0x7f080001
public const int action_bar_activity_content = 2131230721;
// aapt resource value: 0x7f080063
public const int action_bar_container = 2131230819;
// aapt resource value: 0x7f08005f
public const int action_bar_root = 2131230815;
// aapt resource value: 0x7f080002
public const int action_bar_spinner = 2131230722;
// aapt resource value: 0x7f080042
public const int action_bar_subtitle = 2131230786;
// aapt resource value: 0x7f080041
public const int action_bar_title = 2131230785;
// aapt resource value: 0x7f08009b
public const int action_container = 2131230875;
// aapt resource value: 0x7f080065
public const int action_context_bar = 2131230821;
// aapt resource value: 0x7f0800a2
public const int action_divider = 2131230882;
// aapt resource value: 0x7f08009c
public const int action_image = 2131230876;
// aapt resource value: 0x7f080003
public const int action_menu_divider = 2131230723;
// aapt resource value: 0x7f080004
public const int action_menu_presenter = 2131230724;
// aapt resource value: 0x7f080061
public const int action_mode_bar = 2131230817;
// aapt resource value: 0x7f080060
public const int action_mode_bar_stub = 2131230816;
// aapt resource value: 0x7f080043
public const int action_mode_close_button = 2131230787;
// aapt resource value: 0x7f08009d
public const int action_text = 2131230877;
// aapt resource value: 0x7f0800ab
public const int actions = 2131230891;
// aapt resource value: 0x7f080044
public const int activity_chooser_view_content = 2131230788;
// aapt resource value: 0x7f08001e
public const int add = 2131230750;
// aapt resource value: 0x7f080058
public const int alertTitle = 2131230808;
// aapt resource value: 0x7f08003d
public const int all = 2131230781;
// aapt resource value: 0x7f080023
public const int always = 2131230755;
// aapt resource value: 0x7f08002f
public const int auto = 2131230767;
// aapt resource value: 0x7f080020
public const int beginning = 2131230752;
// aapt resource value: 0x7f080028
public const int bottom = 2131230760;
// aapt resource value: 0x7f08004b
public const int buttonPanel = 2131230795;
// aapt resource value: 0x7f08009f
public const int cancel_action = 2131230879;
// aapt resource value: 0x7f080030
public const int center = 2131230768;
// aapt resource value: 0x7f080031
public const int center_horizontal = 2131230769;
// aapt resource value: 0x7f080032
public const int center_vertical = 2131230770;
// aapt resource value: 0x7f08005b
public const int checkbox = 2131230811;
// aapt resource value: 0x7f0800a7
public const int chronometer = 2131230887;
// aapt resource value: 0x7f080039
public const int clip_horizontal = 2131230777;
// aapt resource value: 0x7f08003a
public const int clip_vertical = 2131230778;
// aapt resource value: 0x7f080024
public const int collapseActionView = 2131230756;
// aapt resource value: 0x7f080075
public const int container = 2131230837;
// aapt resource value: 0x7f08004e
public const int contentPanel = 2131230798;
// aapt resource value: 0x7f080076
public const int coordinator = 2131230838;
// aapt resource value: 0x7f080055
public const int custom = 2131230805;
// aapt resource value: 0x7f080054
public const int customPanel = 2131230804;
// aapt resource value: 0x7f080062
public const int decor_content_parent = 2131230818;
// aapt resource value: 0x7f080047
public const int default_activity_button = 2131230791;
// aapt resource value: 0x7f080078
public const int design_bottom_sheet = 2131230840;
// aapt resource value: 0x7f08007f
public const int design_menu_item_action_area = 2131230847;
// aapt resource value: 0x7f08007e
public const int design_menu_item_action_area_stub = 2131230846;
// aapt resource value: 0x7f08007d
public const int design_menu_item_text = 2131230845;
// aapt resource value: 0x7f08007c
public const int design_navigation_view = 2131230844;
// aapt resource value: 0x7f080012
public const int disableHome = 2131230738;
// aapt resource value: 0x7f080066
public const int edit_query = 2131230822;
// aapt resource value: 0x7f080021
public const int end = 2131230753;
// aapt resource value: 0x7f0800b1
public const int end_padder = 2131230897;
// aapt resource value: 0x7f08002a
public const int enterAlways = 2131230762;
// aapt resource value: 0x7f08002b
public const int enterAlwaysCollapsed = 2131230763;
// aapt resource value: 0x7f08002c
public const int exitUntilCollapsed = 2131230764;
// aapt resource value: 0x7f080045
public const int expand_activities_button = 2131230789;
// aapt resource value: 0x7f08005a
public const int expanded_menu = 2131230810;
// aapt resource value: 0x7f08003b
public const int fill = 2131230779;
// aapt resource value: 0x7f08003c
public const int fill_horizontal = 2131230780;
// aapt resource value: 0x7f080033
public const int fill_vertical = 2131230771;
// aapt resource value: 0x7f08003f
public const int @fixed = 2131230783;
// aapt resource value: 0x7f080005
public const int home = 2131230725;
// aapt resource value: 0x7f080013
public const int homeAsUp = 2131230739;
// aapt resource value: 0x7f080049
public const int icon = 2131230793;
// aapt resource value: 0x7f0800ac
public const int icon_group = 2131230892;
// aapt resource value: 0x7f080025
public const int ifRoom = 2131230757;
// aapt resource value: 0x7f080046
public const int image = 2131230790;
// aapt resource value: 0x7f0800a8
public const int info = 2131230888;
// aapt resource value: 0x7f080000
public const int item_touch_helper_previous_elevation = 2131230720;
// aapt resource value: 0x7f080074
public const int largeLabel = 2131230836;
// aapt resource value: 0x7f080034
public const int left = 2131230772;
// aapt resource value: 0x7f0800ad
public const int line1 = 2131230893;
// aapt resource value: 0x7f0800af
public const int line3 = 2131230895;
// aapt resource value: 0x7f08000f
public const int listMode = 2131230735;
// aapt resource value: 0x7f080048
public const int list_item = 2131230792;
// aapt resource value: 0x7f0800b3
public const int masked = 2131230899;
// aapt resource value: 0x7f0800a1
public const int media_actions = 2131230881;
// aapt resource value: 0x7f080022
public const int middle = 2131230754;
// aapt resource value: 0x7f08003e
public const int mini = 2131230782;
// aapt resource value: 0x7f08008d
public const int mr_art = 2131230861;
// aapt resource value: 0x7f080082
public const int mr_chooser_list = 2131230850;
// aapt resource value: 0x7f080085
public const int mr_chooser_route_desc = 2131230853;
// aapt resource value: 0x7f080083
public const int mr_chooser_route_icon = 2131230851;
// aapt resource value: 0x7f080084
public const int mr_chooser_route_name = 2131230852;
// aapt resource value: 0x7f080081
public const int mr_chooser_title = 2131230849;
// aapt resource value: 0x7f08008a
public const int mr_close = 2131230858;
// aapt resource value: 0x7f080090
public const int mr_control_divider = 2131230864;
// aapt resource value: 0x7f080096
public const int mr_control_playback_ctrl = 2131230870;
// aapt resource value: 0x7f080099
public const int mr_control_subtitle = 2131230873;
// aapt resource value: 0x7f080098
public const int mr_control_title = 2131230872;
// aapt resource value: 0x7f080097
public const int mr_control_title_container = 2131230871;
// aapt resource value: 0x7f08008b
public const int mr_custom_control = 2131230859;
// aapt resource value: 0x7f08008c
public const int mr_default_control = 2131230860;
// aapt resource value: 0x7f080087
public const int mr_dialog_area = 2131230855;
// aapt resource value: 0x7f080086
public const int mr_expandable_area = 2131230854;
// aapt resource value: 0x7f08009a
public const int mr_group_expand_collapse = 2131230874;
// aapt resource value: 0x7f08008e
public const int mr_media_main_control = 2131230862;
// aapt resource value: 0x7f080089
public const int mr_name = 2131230857;
// aapt resource value: 0x7f08008f
public const int mr_playback_control = 2131230863;
// aapt resource value: 0x7f080088
public const int mr_title_bar = 2131230856;
// aapt resource value: 0x7f080091
public const int mr_volume_control = 2131230865;
// aapt resource value: 0x7f080092
public const int mr_volume_group_list = 2131230866;
// aapt resource value: 0x7f080094
public const int mr_volume_item_icon = 2131230868;
// aapt resource value: 0x7f080095
public const int mr_volume_slider = 2131230869;
// aapt resource value: 0x7f080019
public const int multiply = 2131230745;
// aapt resource value: 0x7f08007b
public const int navigation_header_container = 2131230843;
// aapt resource value: 0x7f080026
public const int never = 2131230758;
// aapt resource value: 0x7f080014
public const int none = 2131230740;
// aapt resource value: 0x7f080010
public const int normal = 2131230736;
// aapt resource value: 0x7f0800aa
public const int notification_background = 2131230890;
// aapt resource value: 0x7f0800a4
public const int notification_main_column = 2131230884;
// aapt resource value: 0x7f0800a3
public const int notification_main_column_container = 2131230883;
// aapt resource value: 0x7f080037
public const int parallax = 2131230775;
// aapt resource value: 0x7f08004d
public const int parentPanel = 2131230797;
// aapt resource value: 0x7f080038
public const int pin = 2131230776;
// aapt resource value: 0x7f080006
public const int progress_circular = 2131230726;
// aapt resource value: 0x7f080007
public const int progress_horizontal = 2131230727;
// aapt resource value: 0x7f08005d
public const int radio = 2131230813;
// aapt resource value: 0x7f080035
public const int right = 2131230773;
// aapt resource value: 0x7f0800a9
public const int right_icon = 2131230889;
// aapt resource value: 0x7f0800a5
public const int right_side = 2131230885;
// aapt resource value: 0x7f08001a
public const int screen = 2131230746;
// aapt resource value: 0x7f08002d
public const int scroll = 2131230765;
// aapt resource value: 0x7f080053
public const int scrollIndicatorDown = 2131230803;
// aapt resource value: 0x7f08004f
public const int scrollIndicatorUp = 2131230799;
// aapt resource value: 0x7f080050
public const int scrollView = 2131230800;
// aapt resource value: 0x7f080040
public const int scrollable = 2131230784;
// aapt resource value: 0x7f080068
public const int search_badge = 2131230824;
// aapt resource value: 0x7f080067
public const int search_bar = 2131230823;
// aapt resource value: 0x7f080069
public const int search_button = 2131230825;
// aapt resource value: 0x7f08006e
public const int search_close_btn = 2131230830;
// aapt resource value: 0x7f08006a
public const int search_edit_frame = 2131230826;
// aapt resource value: 0x7f080070
public const int search_go_btn = 2131230832;
// aapt resource value: 0x7f08006b
public const int search_mag_icon = 2131230827;
// aapt resource value: 0x7f08006c
public const int search_plate = 2131230828;
// aapt resource value: 0x7f08006d
public const int search_src_text = 2131230829;
// aapt resource value: 0x7f080071
public const int search_voice_btn = 2131230833;
// aapt resource value: 0x7f080072
public const int select_dialog_listview = 2131230834;
// aapt resource value: 0x7f08005c
public const int shortcut = 2131230812;
// aapt resource value: 0x7f080015
public const int showCustom = 2131230741;
// aapt resource value: 0x7f080016
public const int showHome = 2131230742;
// aapt resource value: 0x7f080017
public const int showTitle = 2131230743;
// aapt resource value: 0x7f080073
public const int smallLabel = 2131230835;
// aapt resource value: 0x7f08007a
public const int snackbar_action = 2131230842;
// aapt resource value: 0x7f080079
public const int snackbar_text = 2131230841;
// aapt resource value: 0x7f08002e
public const int snap = 2131230766;
// aapt resource value: 0x7f08004c
public const int spacer = 2131230796;
// aapt resource value: 0x7f080008
public const int split_action_bar = 2131230728;
// aapt resource value: 0x7f08001b
public const int src_atop = 2131230747;
// aapt resource value: 0x7f08001c
public const int src_in = 2131230748;
// aapt resource value: 0x7f08001d
public const int src_over = 2131230749;
// aapt resource value: 0x7f080036
public const int start = 2131230774;
// aapt resource value: 0x7f0800a0
public const int status_bar_latest_event_content = 2131230880;
// aapt resource value: 0x7f08005e
public const int submenuarrow = 2131230814;
// aapt resource value: 0x7f08006f
public const int submit_area = 2131230831;
// aapt resource value: 0x7f080011
public const int tabMode = 2131230737;
// aapt resource value: 0x7f0800b0
public const int text = 2131230896;
// aapt resource value: 0x7f0800ae
public const int text2 = 2131230894;
// aapt resource value: 0x7f080052
public const int textSpacerNoButtons = 2131230802;
// aapt resource value: 0x7f080051
public const int textSpacerNoTitle = 2131230801;
// aapt resource value: 0x7f080080
public const int text_input_password_toggle = 2131230848;
// aapt resource value: 0x7f08000c
public const int textinput_counter = 2131230732;
// aapt resource value: 0x7f08000d
public const int textinput_error = 2131230733;
// aapt resource value: 0x7f0800a6
public const int time = 2131230886;
// aapt resource value: 0x7f08004a
public const int title = 2131230794;
// aapt resource value: 0x7f080059
public const int titleDividerNoCustom = 2131230809;
// aapt resource value: 0x7f080057
public const int title_template = 2131230807;
// aapt resource value: 0x7f080029
public const int top = 2131230761;
// aapt resource value: 0x7f080056
public const int topPanel = 2131230806;
// aapt resource value: 0x7f080077
public const int touch_outside = 2131230839;
// aapt resource value: 0x7f08000a
public const int transition_current_scene = 2131230730;
// aapt resource value: 0x7f08000b
public const int transition_scene_layoutid_cache = 2131230731;
// aapt resource value: 0x7f080009
public const int up = 2131230729;
// aapt resource value: 0x7f080018
public const int useLogo = 2131230744;
// aapt resource value: 0x7f08000e
public const int view_offset_helper = 2131230734;
// aapt resource value: 0x7f0800b2
public const int visible = 2131230898;
// aapt resource value: 0x7f080093
public const int volume_item_container = 2131230867;
// aapt resource value: 0x7f080027
public const int withText = 2131230759;
// aapt resource value: 0x7f08001f
public const int wrap_content = 2131230751;
static Id()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Id()
{
}
}
public partial class Integer
{
// aapt resource value: 0x7f0a0003
public const int abc_config_activityDefaultDur = 2131361795;
// aapt resource value: 0x7f0a0004
public const int abc_config_activityShortDur = 2131361796;
// aapt resource value: 0x7f0a0008
public const int app_bar_elevation_anim_duration = 2131361800;
// aapt resource value: 0x7f0a0009
public const int bottom_sheet_slide_duration = 2131361801;
// aapt resource value: 0x7f0a0005
public const int cancel_button_image_alpha = 2131361797;
// aapt resource value: 0x7f0a0007
public const int design_snackbar_text_max_lines = 2131361799;
// aapt resource value: 0x7f0a000a
public const int hide_password_duration = 2131361802;
// aapt resource value: 0x7f0a0000
public const int mr_controller_volume_group_list_animation_duration_ms = 2131361792;
// aapt resource value: 0x7f0a0001
public const int mr_controller_volume_group_list_fade_in_duration_ms = 2131361793;
// aapt resource value: 0x7f0a0002
public const int mr_controller_volume_group_list_fade_out_duration_ms = 2131361794;
// aapt resource value: 0x7f0a000b
public const int show_password_duration = 2131361803;
// aapt resource value: 0x7f0a0006
public const int status_bar_notification_info_maxnum = 2131361798;
static Integer()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Integer()
{
}
}
public partial class Interpolator
{
// aapt resource value: 0x7f060000
public const int mr_fast_out_slow_in = 2131099648;
// aapt resource value: 0x7f060001
public const int mr_linear_out_slow_in = 2131099649;
static Interpolator()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Interpolator()
{
}
}
public partial class Layout
{
// aapt resource value: 0x7f030000
public const int abc_action_bar_title_item = 2130903040;
// aapt resource value: 0x7f030001
public const int abc_action_bar_up_container = 2130903041;
// aapt resource value: 0x7f030002
public const int abc_action_bar_view_list_nav_layout = 2130903042;
// aapt resource value: 0x7f030003
public const int abc_action_menu_item_layout = 2130903043;
// aapt resource value: 0x7f030004
public const int abc_action_menu_layout = 2130903044;
// aapt resource value: 0x7f030005
public const int abc_action_mode_bar = 2130903045;
// aapt resource value: 0x7f030006
public const int abc_action_mode_close_item_material = 2130903046;
// aapt resource value: 0x7f030007
public const int abc_activity_chooser_view = 2130903047;
// aapt resource value: 0x7f030008
public const int abc_activity_chooser_view_list_item = 2130903048;
// aapt resource value: 0x7f030009
public const int abc_alert_dialog_button_bar_material = 2130903049;
// aapt resource value: 0x7f03000a
public const int abc_alert_dialog_material = 2130903050;
// aapt resource value: 0x7f03000b
public const int abc_alert_dialog_title_material = 2130903051;
// aapt resource value: 0x7f03000c
public const int abc_dialog_title_material = 2130903052;
// aapt resource value: 0x7f03000d
public const int abc_expanded_menu_layout = 2130903053;
// aapt resource value: 0x7f03000e
public const int abc_list_menu_item_checkbox = 2130903054;
// aapt resource value: 0x7f03000f
public const int abc_list_menu_item_icon = 2130903055;
// aapt resource value: 0x7f030010
public const int abc_list_menu_item_layout = 2130903056;
// aapt resource value: 0x7f030011
public const int abc_list_menu_item_radio = 2130903057;
// aapt resource value: 0x7f030012
public const int abc_popup_menu_header_item_layout = 2130903058;
// aapt resource value: 0x7f030013
public const int abc_popup_menu_item_layout = 2130903059;
// aapt resource value: 0x7f030014
public const int abc_screen_content_include = 2130903060;
// aapt resource value: 0x7f030015
public const int abc_screen_simple = 2130903061;
// aapt resource value: 0x7f030016
public const int abc_screen_simple_overlay_action_mode = 2130903062;
// aapt resource value: 0x7f030017
public const int abc_screen_toolbar = 2130903063;
// aapt resource value: 0x7f030018
public const int abc_search_dropdown_item_icons_2line = 2130903064;
// aapt resource value: 0x7f030019
public const int abc_search_view = 2130903065;
// aapt resource value: 0x7f03001a
public const int abc_select_dialog_material = 2130903066;
// aapt resource value: 0x7f03001b
public const int design_bottom_navigation_item = 2130903067;
// aapt resource value: 0x7f03001c
public const int design_bottom_sheet_dialog = 2130903068;
// aapt resource value: 0x7f03001d
public const int design_layout_snackbar = 2130903069;
// aapt resource value: 0x7f03001e
public const int design_layout_snackbar_include = 2130903070;
// aapt resource value: 0x7f03001f
public const int design_layout_tab_icon = 2130903071;
// aapt resource value: 0x7f030020
public const int design_layout_tab_text = 2130903072;
// aapt resource value: 0x7f030021
public const int design_menu_item_action_area = 2130903073;
// aapt resource value: 0x7f030022
public const int design_navigation_item = 2130903074;
// aapt resource value: 0x7f030023
public const int design_navigation_item_header = 2130903075;
// aapt resource value: 0x7f030024
public const int design_navigation_item_separator = 2130903076;
// aapt resource value: 0x7f030025
public const int design_navigation_item_subheader = 2130903077;
// aapt resource value: 0x7f030026
public const int design_navigation_menu = 2130903078;
// aapt resource value: 0x7f030027
public const int design_navigation_menu_item = 2130903079;
// aapt resource value: 0x7f030028
public const int design_text_input_password_icon = 2130903080;
// aapt resource value: 0x7f030029
public const int mr_chooser_dialog = 2130903081;
// aapt resource value: 0x7f03002a
public const int mr_chooser_list_item = 2130903082;
// aapt resource value: 0x7f03002b
public const int mr_controller_material_dialog_b = 2130903083;
// aapt resource value: 0x7f03002c
public const int mr_controller_volume_item = 2130903084;
// aapt resource value: 0x7f03002d
public const int mr_playback_control = 2130903085;
// aapt resource value: 0x7f03002e
public const int mr_volume_control = 2130903086;
// aapt resource value: 0x7f03002f
public const int notification_action = 2130903087;
// aapt resource value: 0x7f030030
public const int notification_action_tombstone = 2130903088;
// aapt resource value: 0x7f030031
public const int notification_media_action = 2130903089;
// aapt resource value: 0x7f030032
public const int notification_media_cancel_action = 2130903090;
// aapt resource value: 0x7f030033
public const int notification_template_big_media = 2130903091;
// aapt resource value: 0x7f030034
public const int notification_template_big_media_custom = 2130903092;
// aapt resource value: 0x7f030035
public const int notification_template_big_media_narrow = 2130903093;
// aapt resource value: 0x7f030036
public const int notification_template_big_media_narrow_custom = 2130903094;
// aapt resource value: 0x7f030037
public const int notification_template_custom_big = 2130903095;
// aapt resource value: 0x7f030038
public const int notification_template_icon_group = 2130903096;
// aapt resource value: 0x7f030039
public const int notification_template_lines_media = 2130903097;
// aapt resource value: 0x7f03003a
public const int notification_template_media = 2130903098;
// aapt resource value: 0x7f03003b
public const int notification_template_media_custom = 2130903099;
// aapt resource value: 0x7f03003c
public const int notification_template_part_chronometer = 2130903100;
// aapt resource value: 0x7f03003d
public const int notification_template_part_time = 2130903101;
// aapt resource value: 0x7f03003e
public const int select_dialog_item_material = 2130903102;
// aapt resource value: 0x7f03003f
public const int select_dialog_multichoice_material = 2130903103;
// aapt resource value: 0x7f030040
public const int select_dialog_singlechoice_material = 2130903104;
// aapt resource value: 0x7f030041
public const int support_simple_spinner_dropdown_item = 2130903105;
static Layout()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Layout()
{
}
}
public partial class String
{
// aapt resource value: 0x7f090015
public const int abc_action_bar_home_description = 2131296277;
// aapt resource value: 0x7f090016
public const int abc_action_bar_home_description_format = 2131296278;
// aapt resource value: 0x7f090017
public const int abc_action_bar_home_subtitle_description_format = 2131296279;
// aapt resource value: 0x7f090018
public const int abc_action_bar_up_description = 2131296280;
// aapt resource value: 0x7f090019
public const int abc_action_menu_overflow_description = 2131296281;
// aapt resource value: 0x7f09001a
public const int abc_action_mode_done = 2131296282;
// aapt resource value: 0x7f09001b
public const int abc_activity_chooser_view_see_all = 2131296283;
// aapt resource value: 0x7f09001c
public const int abc_activitychooserview_choose_application = 2131296284;
// aapt resource value: 0x7f09001d
public const int abc_capital_off = 2131296285;
// aapt resource value: 0x7f09001e
public const int abc_capital_on = 2131296286;
// aapt resource value: 0x7f09002a
public const int abc_font_family_body_1_material = 2131296298;
// aapt resource value: 0x7f09002b
public const int abc_font_family_body_2_material = 2131296299;
// aapt resource value: 0x7f09002c
public const int abc_font_family_button_material = 2131296300;
// aapt resource value: 0x7f09002d
public const int abc_font_family_caption_material = 2131296301;
// aapt resource value: 0x7f09002e
public const int abc_font_family_display_1_material = 2131296302;
// aapt resource value: 0x7f09002f
public const int abc_font_family_display_2_material = 2131296303;
// aapt resource value: 0x7f090030
public const int abc_font_family_display_3_material = 2131296304;
// aapt resource value: 0x7f090031
public const int abc_font_family_display_4_material = 2131296305;
// aapt resource value: 0x7f090032
public const int abc_font_family_headline_material = 2131296306;
// aapt resource value: 0x7f090033
public const int abc_font_family_menu_material = 2131296307;
// aapt resource value: 0x7f090034
public const int abc_font_family_subhead_material = 2131296308;
// aapt resource value: 0x7f090035
public const int abc_font_family_title_material = 2131296309;
// aapt resource value: 0x7f09001f
public const int abc_search_hint = 2131296287;
// aapt resource value: 0x7f090020
public const int abc_searchview_description_clear = 2131296288;
// aapt resource value: 0x7f090021
public const int abc_searchview_description_query = 2131296289;
// aapt resource value: 0x7f090022
public const int abc_searchview_description_search = 2131296290;
// aapt resource value: 0x7f090023
public const int abc_searchview_description_submit = 2131296291;
// aapt resource value: 0x7f090024
public const int abc_searchview_description_voice = 2131296292;
// aapt resource value: 0x7f090025
public const int abc_shareactionprovider_share_with = 2131296293;
// aapt resource value: 0x7f090026
public const int abc_shareactionprovider_share_with_application = 2131296294;
// aapt resource value: 0x7f090027
public const int abc_toolbar_collapse_description = 2131296295;
// aapt resource value: 0x7f090036
public const int appbar_scrolling_view_behavior = 2131296310;
// aapt resource value: 0x7f090037
public const int bottom_sheet_behavior = 2131296311;
// aapt resource value: 0x7f090038
public const int character_counter_pattern = 2131296312;
// aapt resource value: 0x7f090000
public const int mr_button_content_description = 2131296256;
// aapt resource value: 0x7f090001
public const int mr_cast_button_connected = 2131296257;
// aapt resource value: 0x7f090002
public const int mr_cast_button_connecting = 2131296258;
// aapt resource value: 0x7f090003
public const int mr_cast_button_disconnected = 2131296259;
// aapt resource value: 0x7f090004
public const int mr_chooser_searching = 2131296260;
// aapt resource value: 0x7f090005
public const int mr_chooser_title = 2131296261;
// aapt resource value: 0x7f090006
public const int mr_controller_album_art = 2131296262;
// aapt resource value: 0x7f090007
public const int mr_controller_casting_screen = 2131296263;
// aapt resource value: 0x7f090008
public const int mr_controller_close_description = 2131296264;
// aapt resource value: 0x7f090009
public const int mr_controller_collapse_group = 2131296265;
// aapt resource value: 0x7f09000a
public const int mr_controller_disconnect = 2131296266;
// aapt resource value: 0x7f09000b
public const int mr_controller_expand_group = 2131296267;
// aapt resource value: 0x7f09000c
public const int mr_controller_no_info_available = 2131296268;
// aapt resource value: 0x7f09000d
public const int mr_controller_no_media_selected = 2131296269;
// aapt resource value: 0x7f09000e
public const int mr_controller_pause = 2131296270;
// aapt resource value: 0x7f09000f
public const int mr_controller_play = 2131296271;
// aapt resource value: 0x7f090014
public const int mr_controller_stop = 2131296276;
// aapt resource value: 0x7f090010
public const int mr_controller_stop_casting = 2131296272;
// aapt resource value: 0x7f090011
public const int mr_controller_volume_slider = 2131296273;
// aapt resource value: 0x7f090012
public const int mr_system_route_name = 2131296274;
// aapt resource value: 0x7f090013
public const int mr_user_route_category_name = 2131296275;
// aapt resource value: 0x7f090039
public const int password_toggle_content_description = 2131296313;
// aapt resource value: 0x7f09003a
public const int path_password_eye = 2131296314;
// aapt resource value: 0x7f09003b
public const int path_password_eye_mask_strike_through = 2131296315;
// aapt resource value: 0x7f09003c
public const int path_password_eye_mask_visible = 2131296316;
// aapt resource value: 0x7f09003d
public const int path_password_strike_through = 2131296317;
// aapt resource value: 0x7f090028
public const int search_menu_title = 2131296296;
// aapt resource value: 0x7f090029
public const int status_bar_notification_info_overflow = 2131296297;
static String()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private String()
{
}
}
public partial class Style
{
// aapt resource value: 0x7f0b00ae
public const int AlertDialog_AppCompat = 2131427502;
// aapt resource value: 0x7f0b00af
public const int AlertDialog_AppCompat_Light = 2131427503;
// aapt resource value: 0x7f0b00b0
public const int Animation_AppCompat_Dialog = 2131427504;
// aapt resource value: 0x7f0b00b1
public const int Animation_AppCompat_DropDownUp = 2131427505;
// aapt resource value: 0x7f0b0170
public const int Animation_Design_BottomSheetDialog = 2131427696;
// aapt resource value: 0x7f0b00b2
public const int Base_AlertDialog_AppCompat = 2131427506;
// aapt resource value: 0x7f0b00b3
public const int Base_AlertDialog_AppCompat_Light = 2131427507;
// aapt resource value: 0x7f0b00b4
public const int Base_Animation_AppCompat_Dialog = 2131427508;
// aapt resource value: 0x7f0b00b5
public const int Base_Animation_AppCompat_DropDownUp = 2131427509;
// aapt resource value: 0x7f0b000c
public const int Base_CardView = 2131427340;
// aapt resource value: 0x7f0b00b6
public const int Base_DialogWindowTitle_AppCompat = 2131427510;
// aapt resource value: 0x7f0b00b7
public const int Base_DialogWindowTitleBackground_AppCompat = 2131427511;
// aapt resource value: 0x7f0b004e
public const int Base_TextAppearance_AppCompat = 2131427406;
// aapt resource value: 0x7f0b004f
public const int Base_TextAppearance_AppCompat_Body1 = 2131427407;
// aapt resource value: 0x7f0b0050
public const int Base_TextAppearance_AppCompat_Body2 = 2131427408;
// aapt resource value: 0x7f0b0036
public const int Base_TextAppearance_AppCompat_Button = 2131427382;
// aapt resource value: 0x7f0b0051
public const int Base_TextAppearance_AppCompat_Caption = 2131427409;
// aapt resource value: 0x7f0b0052
public const int Base_TextAppearance_AppCompat_Display1 = 2131427410;
// aapt resource value: 0x7f0b0053
public const int Base_TextAppearance_AppCompat_Display2 = 2131427411;
// aapt resource value: 0x7f0b0054
public const int Base_TextAppearance_AppCompat_Display3 = 2131427412;
// aapt resource value: 0x7f0b0055
public const int Base_TextAppearance_AppCompat_Display4 = 2131427413;
// aapt resource value: 0x7f0b0056
public const int Base_TextAppearance_AppCompat_Headline = 2131427414;
// aapt resource value: 0x7f0b001a
public const int Base_TextAppearance_AppCompat_Inverse = 2131427354;
// aapt resource value: 0x7f0b0057
public const int Base_TextAppearance_AppCompat_Large = 2131427415;
// aapt resource value: 0x7f0b001b
public const int Base_TextAppearance_AppCompat_Large_Inverse = 2131427355;
// aapt resource value: 0x7f0b0058
public const int Base_TextAppearance_AppCompat_Light_Widget_PopupMenu_Large = 2131427416;
// aapt resource value: 0x7f0b0059
public const int Base_TextAppearance_AppCompat_Light_Widget_PopupMenu_Small = 2131427417;
// aapt resource value: 0x7f0b005a
public const int Base_TextAppearance_AppCompat_Medium = 2131427418;
// aapt resource value: 0x7f0b001c
public const int Base_TextAppearance_AppCompat_Medium_Inverse = 2131427356;
// aapt resource value: 0x7f0b005b
public const int Base_TextAppearance_AppCompat_Menu = 2131427419;
// aapt resource value: 0x7f0b00b8
public const int Base_TextAppearance_AppCompat_SearchResult = 2131427512;
// aapt resource value: 0x7f0b005c
public const int Base_TextAppearance_AppCompat_SearchResult_Subtitle = 2131427420;
// aapt resource value: 0x7f0b005d
public const int Base_TextAppearance_AppCompat_SearchResult_Title = 2131427421;
// aapt resource value: 0x7f0b005e
public const int Base_TextAppearance_AppCompat_Small = 2131427422;
// aapt resource value: 0x7f0b001d
public const int Base_TextAppearance_AppCompat_Small_Inverse = 2131427357;
// aapt resource value: 0x7f0b005f
public const int Base_TextAppearance_AppCompat_Subhead = 2131427423;
// aapt resource value: 0x7f0b001e
public const int Base_TextAppearance_AppCompat_Subhead_Inverse = 2131427358;
// aapt resource value: 0x7f0b0060
public const int Base_TextAppearance_AppCompat_Title = 2131427424;
// aapt resource value: 0x7f0b001f
public const int Base_TextAppearance_AppCompat_Title_Inverse = 2131427359;
// aapt resource value: 0x7f0b00a3
public const int Base_TextAppearance_AppCompat_Widget_ActionBar_Menu = 2131427491;
// aapt resource value: 0x7f0b0061
public const int Base_TextAppearance_AppCompat_Widget_ActionBar_Subtitle = 2131427425;
// aapt resource value: 0x7f0b0062
public const int Base_TextAppearance_AppCompat_Widget_ActionBar_Subtitle_Inverse = 2131427426;
// aapt resource value: 0x7f0b0063
public const int Base_TextAppearance_AppCompat_Widget_ActionBar_Title = 2131427427;
// aapt resource value: 0x7f0b0064
public const int Base_TextAppearance_AppCompat_Widget_ActionBar_Title_Inverse = 2131427428;
// aapt resource value: 0x7f0b0065
public const int Base_TextAppearance_AppCompat_Widget_ActionMode_Subtitle = 2131427429;
// aapt resource value: 0x7f0b0066
public const int Base_TextAppearance_AppCompat_Widget_ActionMode_Title = 2131427430;
// aapt resource value: 0x7f0b0067
public const int Base_TextAppearance_AppCompat_Widget_Button = 2131427431;
// aapt resource value: 0x7f0b00aa
public const int Base_TextAppearance_AppCompat_Widget_Button_Borderless_Colored = 2131427498;
// aapt resource value: 0x7f0b00ab
public const int Base_TextAppearance_AppCompat_Widget_Button_Colored = 2131427499;
// aapt resource value: 0x7f0b00a4
public const int Base_TextAppearance_AppCompat_Widget_Button_Inverse = 2131427492;
// aapt resource value: 0x7f0b00b9
public const int Base_TextAppearance_AppCompat_Widget_DropDownItem = 2131427513;
// aapt resource value: 0x7f0b0068
public const int Base_TextAppearance_AppCompat_Widget_PopupMenu_Header = 2131427432;
// aapt resource value: 0x7f0b0069
public const int Base_TextAppearance_AppCompat_Widget_PopupMenu_Large = 2131427433;
// aapt resource value: 0x7f0b006a
public const int Base_TextAppearance_AppCompat_Widget_PopupMenu_Small = 2131427434;
// aapt resource value: 0x7f0b006b
public const int Base_TextAppearance_AppCompat_Widget_Switch = 2131427435;
// aapt resource value: 0x7f0b006c
public const int Base_TextAppearance_AppCompat_Widget_TextView_SpinnerItem = 2131427436;
// aapt resource value: 0x7f0b00ba
public const int Base_TextAppearance_Widget_AppCompat_ExpandedMenu_Item = 2131427514;
// aapt resource value: 0x7f0b006d
public const int Base_TextAppearance_Widget_AppCompat_Toolbar_Subtitle = 2131427437;
// aapt resource value: 0x7f0b006e
public const int Base_TextAppearance_Widget_AppCompat_Toolbar_Title = 2131427438;
// aapt resource value: 0x7f0b006f
public const int Base_Theme_AppCompat = 2131427439;
// aapt resource value: 0x7f0b00bb
public const int Base_Theme_AppCompat_CompactMenu = 2131427515;
// aapt resource value: 0x7f0b0020
public const int Base_Theme_AppCompat_Dialog = 2131427360;
// aapt resource value: 0x7f0b0021
public const int Base_Theme_AppCompat_Dialog_Alert = 2131427361;
// aapt resource value: 0x7f0b00bc
public const int Base_Theme_AppCompat_Dialog_FixedSize = 2131427516;
// aapt resource value: 0x7f0b0022
public const int Base_Theme_AppCompat_Dialog_MinWidth = 2131427362;
// aapt resource value: 0x7f0b0010
public const int Base_Theme_AppCompat_DialogWhenLarge = 2131427344;
// aapt resource value: 0x7f0b0070
public const int Base_Theme_AppCompat_Light = 2131427440;
// aapt resource value: 0x7f0b00bd
public const int Base_Theme_AppCompat_Light_DarkActionBar = 2131427517;
// aapt resource value: 0x7f0b0023
public const int Base_Theme_AppCompat_Light_Dialog = 2131427363;
// aapt resource value: 0x7f0b0024
public const int Base_Theme_AppCompat_Light_Dialog_Alert = 2131427364;
// aapt resource value: 0x7f0b00be
public const int Base_Theme_AppCompat_Light_Dialog_FixedSize = 2131427518;
// aapt resource value: 0x7f0b0025
public const int Base_Theme_AppCompat_Light_Dialog_MinWidth = 2131427365;
// aapt resource value: 0x7f0b0011
public const int Base_Theme_AppCompat_Light_DialogWhenLarge = 2131427345;
// aapt resource value: 0x7f0b00bf
public const int Base_ThemeOverlay_AppCompat = 2131427519;
// aapt resource value: 0x7f0b00c0
public const int Base_ThemeOverlay_AppCompat_ActionBar = 2131427520;
// aapt resource value: 0x7f0b00c1
public const int Base_ThemeOverlay_AppCompat_Dark = 2131427521;
// aapt resource value: 0x7f0b00c2
public const int Base_ThemeOverlay_AppCompat_Dark_ActionBar = 2131427522;
// aapt resource value: 0x7f0b0026
public const int Base_ThemeOverlay_AppCompat_Dialog = 2131427366;
// aapt resource value: 0x7f0b0027
public const int Base_ThemeOverlay_AppCompat_Dialog_Alert = 2131427367;
// aapt resource value: 0x7f0b00c3
public const int Base_ThemeOverlay_AppCompat_Light = 2131427523;
// aapt resource value: 0x7f0b0028
public const int Base_V11_Theme_AppCompat_Dialog = 2131427368;
// aapt resource value: 0x7f0b0029
public const int Base_V11_Theme_AppCompat_Light_Dialog = 2131427369;
// aapt resource value: 0x7f0b002a
public const int Base_V11_ThemeOverlay_AppCompat_Dialog = 2131427370;
// aapt resource value: 0x7f0b0032
public const int Base_V12_Widget_AppCompat_AutoCompleteTextView = 2131427378;
// aapt resource value: 0x7f0b0033
public const int Base_V12_Widget_AppCompat_EditText = 2131427379;
// aapt resource value: 0x7f0b0071
public const int Base_V21_Theme_AppCompat = 2131427441;
// aapt resource value: 0x7f0b0072
public const int Base_V21_Theme_AppCompat_Dialog = 2131427442;
// aapt resource value: 0x7f0b0073
public const int Base_V21_Theme_AppCompat_Light = 2131427443;
// aapt resource value: 0x7f0b0074
public const int Base_V21_Theme_AppCompat_Light_Dialog = 2131427444;
// aapt resource value: 0x7f0b0075
public const int Base_V21_ThemeOverlay_AppCompat_Dialog = 2131427445;
// aapt resource value: 0x7f0b00a1
public const int Base_V22_Theme_AppCompat = 2131427489;
// aapt resource value: 0x7f0b00a2
public const int Base_V22_Theme_AppCompat_Light = 2131427490;
// aapt resource value: 0x7f0b00a5
public const int Base_V23_Theme_AppCompat = 2131427493;
// aapt resource value: 0x7f0b00a6
public const int Base_V23_Theme_AppCompat_Light = 2131427494;
// aapt resource value: 0x7f0b00c4
public const int Base_V7_Theme_AppCompat = 2131427524;
// aapt resource value: 0x7f0b00c5
public const int Base_V7_Theme_AppCompat_Dialog = 2131427525;
// aapt resource value: 0x7f0b00c6
public const int Base_V7_Theme_AppCompat_Light = 2131427526;
// aapt resource value: 0x7f0b00c7
public const int Base_V7_Theme_AppCompat_Light_Dialog = 2131427527;
// aapt resource value: 0x7f0b00c8
public const int Base_V7_ThemeOverlay_AppCompat_Dialog = 2131427528;
// aapt resource value: 0x7f0b00c9
public const int Base_V7_Widget_AppCompat_AutoCompleteTextView = 2131427529;
// aapt resource value: 0x7f0b00ca
public const int Base_V7_Widget_AppCompat_EditText = 2131427530;
// aapt resource value: 0x7f0b00cb
public const int Base_Widget_AppCompat_ActionBar = 2131427531;
// aapt resource value: 0x7f0b00cc
public const int Base_Widget_AppCompat_ActionBar_Solid = 2131427532;
// aapt resource value: 0x7f0b00cd
public const int Base_Widget_AppCompat_ActionBar_TabBar = 2131427533;
// aapt resource value: 0x7f0b0076
public const int Base_Widget_AppCompat_ActionBar_TabText = 2131427446;
// aapt resource value: 0x7f0b0077
public const int Base_Widget_AppCompat_ActionBar_TabView = 2131427447;
// aapt resource value: 0x7f0b0078
public const int Base_Widget_AppCompat_ActionButton = 2131427448;
// aapt resource value: 0x7f0b0079
public const int Base_Widget_AppCompat_ActionButton_CloseMode = 2131427449;
// aapt resource value: 0x7f0b007a
public const int Base_Widget_AppCompat_ActionButton_Overflow = 2131427450;
// aapt resource value: 0x7f0b00ce
public const int Base_Widget_AppCompat_ActionMode = 2131427534;
// aapt resource value: 0x7f0b00cf
public const int Base_Widget_AppCompat_ActivityChooserView = 2131427535;
// aapt resource value: 0x7f0b0034
public const int Base_Widget_AppCompat_AutoCompleteTextView = 2131427380;
// aapt resource value: 0x7f0b007b
public const int Base_Widget_AppCompat_Button = 2131427451;
// aapt resource value: 0x7f0b007c
public const int Base_Widget_AppCompat_Button_Borderless = 2131427452;
// aapt resource value: 0x7f0b007d
public const int Base_Widget_AppCompat_Button_Borderless_Colored = 2131427453;
// aapt resource value: 0x7f0b00d0
public const int Base_Widget_AppCompat_Button_ButtonBar_AlertDialog = 2131427536;
// aapt resource value: 0x7f0b00a7
public const int Base_Widget_AppCompat_Button_Colored = 2131427495;
// aapt resource value: 0x7f0b007e
public const int Base_Widget_AppCompat_Button_Small = 2131427454;
// aapt resource value: 0x7f0b007f
public const int Base_Widget_AppCompat_ButtonBar = 2131427455;
// aapt resource value: 0x7f0b00d1
public const int Base_Widget_AppCompat_ButtonBar_AlertDialog = 2131427537;
// aapt resource value: 0x7f0b0080
public const int Base_Widget_AppCompat_CompoundButton_CheckBox = 2131427456;
// aapt resource value: 0x7f0b0081
public const int Base_Widget_AppCompat_CompoundButton_RadioButton = 2131427457;
// aapt resource value: 0x7f0b00d2
public const int Base_Widget_AppCompat_CompoundButton_Switch = 2131427538;
// aapt resource value: 0x7f0b000f
public const int Base_Widget_AppCompat_DrawerArrowToggle = 2131427343;
// aapt resource value: 0x7f0b00d3
public const int Base_Widget_AppCompat_DrawerArrowToggle_Common = 2131427539;
// aapt resource value: 0x7f0b0082
public const int Base_Widget_AppCompat_DropDownItem_Spinner = 2131427458;
// aapt resource value: 0x7f0b0035
public const int Base_Widget_AppCompat_EditText = 2131427381;
// aapt resource value: 0x7f0b0083
public const int Base_Widget_AppCompat_ImageButton = 2131427459;
// aapt resource value: 0x7f0b00d4
public const int Base_Widget_AppCompat_Light_ActionBar = 2131427540;
// aapt resource value: 0x7f0b00d5
public const int Base_Widget_AppCompat_Light_ActionBar_Solid = 2131427541;
// aapt resource value: 0x7f0b00d6
public const int Base_Widget_AppCompat_Light_ActionBar_TabBar = 2131427542;
// aapt resource value: 0x7f0b0084
public const int Base_Widget_AppCompat_Light_ActionBar_TabText = 2131427460;
// aapt resource value: 0x7f0b0085
public const int Base_Widget_AppCompat_Light_ActionBar_TabText_Inverse = 2131427461;
// aapt resource value: 0x7f0b0086
public const int Base_Widget_AppCompat_Light_ActionBar_TabView = 2131427462;
// aapt resource value: 0x7f0b0087
public const int Base_Widget_AppCompat_Light_PopupMenu = 2131427463;
// aapt resource value: 0x7f0b0088
public const int Base_Widget_AppCompat_Light_PopupMenu_Overflow = 2131427464;
// aapt resource value: 0x7f0b00d7
public const int Base_Widget_AppCompat_ListMenuView = 2131427543;
// aapt resource value: 0x7f0b0089
public const int Base_Widget_AppCompat_ListPopupWindow = 2131427465;
// aapt resource value: 0x7f0b008a
public const int Base_Widget_AppCompat_ListView = 2131427466;
// aapt resource value: 0x7f0b008b
public const int Base_Widget_AppCompat_ListView_DropDown = 2131427467;
// aapt resource value: 0x7f0b008c
public const int Base_Widget_AppCompat_ListView_Menu = 2131427468;
// aapt resource value: 0x7f0b008d
public const int Base_Widget_AppCompat_PopupMenu = 2131427469;
// aapt resource value: 0x7f0b008e
public const int Base_Widget_AppCompat_PopupMenu_Overflow = 2131427470;
// aapt resource value: 0x7f0b00d8
public const int Base_Widget_AppCompat_PopupWindow = 2131427544;
// aapt resource value: 0x7f0b002b
public const int Base_Widget_AppCompat_ProgressBar = 2131427371;
// aapt resource value: 0x7f0b002c
public const int Base_Widget_AppCompat_ProgressBar_Horizontal = 2131427372;
// aapt resource value: 0x7f0b008f
public const int Base_Widget_AppCompat_RatingBar = 2131427471;
// aapt resource value: 0x7f0b00a8
public const int Base_Widget_AppCompat_RatingBar_Indicator = 2131427496;
// aapt resource value: 0x7f0b00a9
public const int Base_Widget_AppCompat_RatingBar_Small = 2131427497;
// aapt resource value: 0x7f0b00d9
public const int Base_Widget_AppCompat_SearchView = 2131427545;
// aapt resource value: 0x7f0b00da
public const int Base_Widget_AppCompat_SearchView_ActionBar = 2131427546;
// aapt resource value: 0x7f0b0090
public const int Base_Widget_AppCompat_SeekBar = 2131427472;
// aapt resource value: 0x7f0b00db
public const int Base_Widget_AppCompat_SeekBar_Discrete = 2131427547;
// aapt resource value: 0x7f0b0091
public const int Base_Widget_AppCompat_Spinner = 2131427473;
// aapt resource value: 0x7f0b0012
public const int Base_Widget_AppCompat_Spinner_Underlined = 2131427346;
// aapt resource value: 0x7f0b0092
public const int Base_Widget_AppCompat_TextView_SpinnerItem = 2131427474;
// aapt resource value: 0x7f0b00dc
public const int Base_Widget_AppCompat_Toolbar = 2131427548;
// aapt resource value: 0x7f0b0093
public const int Base_Widget_AppCompat_Toolbar_Button_Navigation = 2131427475;
// aapt resource value: 0x7f0b0171
public const int Base_Widget_Design_AppBarLayout = 2131427697;
// aapt resource value: 0x7f0b0172
public const int Base_Widget_Design_TabLayout = 2131427698;
// aapt resource value: 0x7f0b000b
public const int CardView = 2131427339;
// aapt resource value: 0x7f0b000d
public const int CardView_Dark = 2131427341;
// aapt resource value: 0x7f0b000e
public const int CardView_Light = 2131427342;
// aapt resource value: 0x7f0b002d
public const int Platform_AppCompat = 2131427373;
// aapt resource value: 0x7f0b002e
public const int Platform_AppCompat_Light = 2131427374;
// aapt resource value: 0x7f0b0094
public const int Platform_ThemeOverlay_AppCompat = 2131427476;
// aapt resource value: 0x7f0b0095
public const int Platform_ThemeOverlay_AppCompat_Dark = 2131427477;
// aapt resource value: 0x7f0b0096
public const int Platform_ThemeOverlay_AppCompat_Light = 2131427478;
// aapt resource value: 0x7f0b002f
public const int Platform_V11_AppCompat = 2131427375;
// aapt resource value: 0x7f0b0030
public const int Platform_V11_AppCompat_Light = 2131427376;
// aapt resource value: 0x7f0b0037
public const int Platform_V14_AppCompat = 2131427383;
// aapt resource value: 0x7f0b0038
public const int Platform_V14_AppCompat_Light = 2131427384;
// aapt resource value: 0x7f0b0097
public const int Platform_V21_AppCompat = 2131427479;
// aapt resource value: 0x7f0b0098
public const int Platform_V21_AppCompat_Light = 2131427480;
// aapt resource value: 0x7f0b00ac
public const int Platform_V25_AppCompat = 2131427500;
// aapt resource value: 0x7f0b00ad
public const int Platform_V25_AppCompat_Light = 2131427501;
// aapt resource value: 0x7f0b0031
public const int Platform_Widget_AppCompat_Spinner = 2131427377;
// aapt resource value: 0x7f0b0040
public const int RtlOverlay_DialogWindowTitle_AppCompat = 2131427392;
// aapt resource value: 0x7f0b0041
public const int RtlOverlay_Widget_AppCompat_ActionBar_TitleItem = 2131427393;
// aapt resource value: 0x7f0b0042
public const int RtlOverlay_Widget_AppCompat_DialogTitle_Icon = 2131427394;
// aapt resource value: 0x7f0b0043
public const int RtlOverlay_Widget_AppCompat_PopupMenuItem = 2131427395;
// aapt resource value: 0x7f0b0044
public const int RtlOverlay_Widget_AppCompat_PopupMenuItem_InternalGroup = 2131427396;
// aapt resource value: 0x7f0b0045
public const int RtlOverlay_Widget_AppCompat_PopupMenuItem_Text = 2131427397;
// aapt resource value: 0x7f0b0046
public const int RtlOverlay_Widget_AppCompat_Search_DropDown = 2131427398;
// aapt resource value: 0x7f0b0047
public const int RtlOverlay_Widget_AppCompat_Search_DropDown_Icon1 = 2131427399;
// aapt resource value: 0x7f0b0048
public const int RtlOverlay_Widget_AppCompat_Search_DropDown_Icon2 = 2131427400;
// aapt resource value: 0x7f0b0049
public const int RtlOverlay_Widget_AppCompat_Search_DropDown_Query = 2131427401;
// aapt resource value: 0x7f0b004a
public const int RtlOverlay_Widget_AppCompat_Search_DropDown_Text = 2131427402;
// aapt resource value: 0x7f0b004b
public const int RtlOverlay_Widget_AppCompat_SearchView_MagIcon = 2131427403;
// aapt resource value: 0x7f0b004c
public const int RtlUnderlay_Widget_AppCompat_ActionButton = 2131427404;
// aapt resource value: 0x7f0b004d
public const int RtlUnderlay_Widget_AppCompat_ActionButton_Overflow = 2131427405;
// aapt resource value: 0x7f0b00dd
public const int TextAppearance_AppCompat = 2131427549;
// aapt resource value: 0x7f0b00de
public const int TextAppearance_AppCompat_Body1 = 2131427550;
// aapt resource value: 0x7f0b00df
public const int TextAppearance_AppCompat_Body2 = 2131427551;
// aapt resource value: 0x7f0b00e0
public const int TextAppearance_AppCompat_Button = 2131427552;
// aapt resource value: 0x7f0b00e1
public const int TextAppearance_AppCompat_Caption = 2131427553;
// aapt resource value: 0x7f0b00e2
public const int TextAppearance_AppCompat_Display1 = 2131427554;
// aapt resource value: 0x7f0b00e3
public const int TextAppearance_AppCompat_Display2 = 2131427555;
// aapt resource value: 0x7f0b00e4
public const int TextAppearance_AppCompat_Display3 = 2131427556;
// aapt resource value: 0x7f0b00e5
public const int TextAppearance_AppCompat_Display4 = 2131427557;
// aapt resource value: 0x7f0b00e6
public const int TextAppearance_AppCompat_Headline = 2131427558;
// aapt resource value: 0x7f0b00e7
public const int TextAppearance_AppCompat_Inverse = 2131427559;
// aapt resource value: 0x7f0b00e8
public const int TextAppearance_AppCompat_Large = 2131427560;
// aapt resource value: 0x7f0b00e9
public const int TextAppearance_AppCompat_Large_Inverse = 2131427561;
// aapt resource value: 0x7f0b00ea
public const int TextAppearance_AppCompat_Light_SearchResult_Subtitle = 2131427562;
// aapt resource value: 0x7f0b00eb
public const int TextAppearance_AppCompat_Light_SearchResult_Title = 2131427563;
// aapt resource value: 0x7f0b00ec
public const int TextAppearance_AppCompat_Light_Widget_PopupMenu_Large = 2131427564;
// aapt resource value: 0x7f0b00ed
public const int TextAppearance_AppCompat_Light_Widget_PopupMenu_Small = 2131427565;
// aapt resource value: 0x7f0b00ee
public const int TextAppearance_AppCompat_Medium = 2131427566;
// aapt resource value: 0x7f0b00ef
public const int TextAppearance_AppCompat_Medium_Inverse = 2131427567;
// aapt resource value: 0x7f0b00f0
public const int TextAppearance_AppCompat_Menu = 2131427568;
// aapt resource value: 0x7f0b0039
public const int TextAppearance_AppCompat_Notification = 2131427385;
// aapt resource value: 0x7f0b0099
public const int TextAppearance_AppCompat_Notification_Info = 2131427481;
// aapt resource value: 0x7f0b009a
public const int TextAppearance_AppCompat_Notification_Info_Media = 2131427482;
// aapt resource value: 0x7f0b00f1
public const int TextAppearance_AppCompat_Notification_Line2 = 2131427569;
// aapt resource value: 0x7f0b00f2
public const int TextAppearance_AppCompat_Notification_Line2_Media = 2131427570;
// aapt resource value: 0x7f0b009b
public const int TextAppearance_AppCompat_Notification_Media = 2131427483;
// aapt resource value: 0x7f0b009c
public const int TextAppearance_AppCompat_Notification_Time = 2131427484;
// aapt resource value: 0x7f0b009d
public const int TextAppearance_AppCompat_Notification_Time_Media = 2131427485;
// aapt resource value: 0x7f0b003a
public const int TextAppearance_AppCompat_Notification_Title = 2131427386;
// aapt resource value: 0x7f0b009e
public const int TextAppearance_AppCompat_Notification_Title_Media = 2131427486;
// aapt resource value: 0x7f0b00f3
public const int TextAppearance_AppCompat_SearchResult_Subtitle = 2131427571;
// aapt resource value: 0x7f0b00f4
public const int TextAppearance_AppCompat_SearchResult_Title = 2131427572;
// aapt resource value: 0x7f0b00f5
public const int TextAppearance_AppCompat_Small = 2131427573;
// aapt resource value: 0x7f0b00f6
public const int TextAppearance_AppCompat_Small_Inverse = 2131427574;
// aapt resource value: 0x7f0b00f7
public const int TextAppearance_AppCompat_Subhead = 2131427575;
// aapt resource value: 0x7f0b00f8
public const int TextAppearance_AppCompat_Subhead_Inverse = 2131427576;
// aapt resource value: 0x7f0b00f9
public const int TextAppearance_AppCompat_Title = 2131427577;
// aapt resource value: 0x7f0b00fa
public const int TextAppearance_AppCompat_Title_Inverse = 2131427578;
// aapt resource value: 0x7f0b00fb
public const int TextAppearance_AppCompat_Widget_ActionBar_Menu = 2131427579;
// aapt resource value: 0x7f0b00fc
public const int TextAppearance_AppCompat_Widget_ActionBar_Subtitle = 2131427580;
// aapt resource value: 0x7f0b00fd
public const int TextAppearance_AppCompat_Widget_ActionBar_Subtitle_Inverse = 2131427581;
// aapt resource value: 0x7f0b00fe
public const int TextAppearance_AppCompat_Widget_ActionBar_Title = 2131427582;
// aapt resource value: 0x7f0b00ff
public const int TextAppearance_AppCompat_Widget_ActionBar_Title_Inverse = 2131427583;
// aapt resource value: 0x7f0b0100
public const int TextAppearance_AppCompat_Widget_ActionMode_Subtitle = 2131427584;
// aapt resource value: 0x7f0b0101
public const int TextAppearance_AppCompat_Widget_ActionMode_Subtitle_Inverse = 2131427585;
// aapt resource value: 0x7f0b0102
public const int TextAppearance_AppCompat_Widget_ActionMode_Title = 2131427586;
// aapt resource value: 0x7f0b0103
public const int TextAppearance_AppCompat_Widget_ActionMode_Title_Inverse = 2131427587;
// aapt resource value: 0x7f0b0104
public const int TextAppearance_AppCompat_Widget_Button = 2131427588;
// aapt resource value: 0x7f0b0105
public const int TextAppearance_AppCompat_Widget_Button_Borderless_Colored = 2131427589;
// aapt resource value: 0x7f0b0106
public const int TextAppearance_AppCompat_Widget_Button_Colored = 2131427590;
// aapt resource value: 0x7f0b0107
public const int TextAppearance_AppCompat_Widget_Button_Inverse = 2131427591;
// aapt resource value: 0x7f0b0108
public const int TextAppearance_AppCompat_Widget_DropDownItem = 2131427592;
// aapt resource value: 0x7f0b0109
public const int TextAppearance_AppCompat_Widget_PopupMenu_Header = 2131427593;
// aapt resource value: 0x7f0b010a
public const int TextAppearance_AppCompat_Widget_PopupMenu_Large = 2131427594;
// aapt resource value: 0x7f0b010b
public const int TextAppearance_AppCompat_Widget_PopupMenu_Small = 2131427595;
// aapt resource value: 0x7f0b010c
public const int TextAppearance_AppCompat_Widget_Switch = 2131427596;
// aapt resource value: 0x7f0b010d
public const int TextAppearance_AppCompat_Widget_TextView_SpinnerItem = 2131427597;
// aapt resource value: 0x7f0b0173
public const int TextAppearance_Design_CollapsingToolbar_Expanded = 2131427699;
// aapt resource value: 0x7f0b0174
public const int TextAppearance_Design_Counter = 2131427700;
// aapt resource value: 0x7f0b0175
public const int TextAppearance_Design_Counter_Overflow = 2131427701;
// aapt resource value: 0x7f0b0176
public const int TextAppearance_Design_Error = 2131427702;
// aapt resource value: 0x7f0b0177
public const int TextAppearance_Design_Hint = 2131427703;
// aapt resource value: 0x7f0b0178
public const int TextAppearance_Design_Snackbar_Message = 2131427704;
// aapt resource value: 0x7f0b0179
public const int TextAppearance_Design_Tab = 2131427705;
// aapt resource value: 0x7f0b0000
public const int TextAppearance_MediaRouter_PrimaryText = 2131427328;
// aapt resource value: 0x7f0b0001
public const int TextAppearance_MediaRouter_SecondaryText = 2131427329;
// aapt resource value: 0x7f0b0002
public const int TextAppearance_MediaRouter_Title = 2131427330;
// aapt resource value: 0x7f0b003b
public const int TextAppearance_StatusBar_EventContent = 2131427387;
// aapt resource value: 0x7f0b003c
public const int TextAppearance_StatusBar_EventContent_Info = 2131427388;
// aapt resource value: 0x7f0b003d
public const int TextAppearance_StatusBar_EventContent_Line2 = 2131427389;
// aapt resource value: 0x7f0b003e
public const int TextAppearance_StatusBar_EventContent_Time = 2131427390;
// aapt resource value: 0x7f0b003f
public const int TextAppearance_StatusBar_EventContent_Title = 2131427391;
// aapt resource value: 0x7f0b010e
public const int TextAppearance_Widget_AppCompat_ExpandedMenu_Item = 2131427598;
// aapt resource value: 0x7f0b010f
public const int TextAppearance_Widget_AppCompat_Toolbar_Subtitle = 2131427599;
// aapt resource value: 0x7f0b0110
public const int TextAppearance_Widget_AppCompat_Toolbar_Title = 2131427600;
// aapt resource value: 0x7f0b0111
public const int Theme_AppCompat = 2131427601;
// aapt resource value: 0x7f0b0112
public const int Theme_AppCompat_CompactMenu = 2131427602;
// aapt resource value: 0x7f0b0013
public const int Theme_AppCompat_DayNight = 2131427347;
// aapt resource value: 0x7f0b0014
public const int Theme_AppCompat_DayNight_DarkActionBar = 2131427348;
// aapt resource value: 0x7f0b0015
public const int Theme_AppCompat_DayNight_Dialog = 2131427349;
// aapt resource value: 0x7f0b0016
public const int Theme_AppCompat_DayNight_Dialog_Alert = 2131427350;
// aapt resource value: 0x7f0b0017
public const int Theme_AppCompat_DayNight_Dialog_MinWidth = 2131427351;
// aapt resource value: 0x7f0b0018
public const int Theme_AppCompat_DayNight_DialogWhenLarge = 2131427352;
// aapt resource value: 0x7f0b0019
public const int Theme_AppCompat_DayNight_NoActionBar = 2131427353;
// aapt resource value: 0x7f0b0113
public const int Theme_AppCompat_Dialog = 2131427603;
// aapt resource value: 0x7f0b0114
public const int Theme_AppCompat_Dialog_Alert = 2131427604;
// aapt resource value: 0x7f0b0115
public const int Theme_AppCompat_Dialog_MinWidth = 2131427605;
// aapt resource value: 0x7f0b0116
public const int Theme_AppCompat_DialogWhenLarge = 2131427606;
// aapt resource value: 0x7f0b0117
public const int Theme_AppCompat_Light = 2131427607;
// aapt resource value: 0x7f0b0118
public const int Theme_AppCompat_Light_DarkActionBar = 2131427608;
// aapt resource value: 0x7f0b0119
public const int Theme_AppCompat_Light_Dialog = 2131427609;
// aapt resource value: 0x7f0b011a
public const int Theme_AppCompat_Light_Dialog_Alert = 2131427610;
// aapt resource value: 0x7f0b011b
public const int Theme_AppCompat_Light_Dialog_MinWidth = 2131427611;
// aapt resource value: 0x7f0b011c
public const int Theme_AppCompat_Light_DialogWhenLarge = 2131427612;
// aapt resource value: 0x7f0b011d
public const int Theme_AppCompat_Light_NoActionBar = 2131427613;
// aapt resource value: 0x7f0b011e
public const int Theme_AppCompat_NoActionBar = 2131427614;
// aapt resource value: 0x7f0b017a
public const int Theme_Design = 2131427706;
// aapt resource value: 0x7f0b017b
public const int Theme_Design_BottomSheetDialog = 2131427707;
// aapt resource value: 0x7f0b017c
public const int Theme_Design_Light = 2131427708;
// aapt resource value: 0x7f0b017d
public const int Theme_Design_Light_BottomSheetDialog = 2131427709;
// aapt resource value: 0x7f0b017e
public const int Theme_Design_Light_NoActionBar = 2131427710;
// aapt resource value: 0x7f0b017f
public const int Theme_Design_NoActionBar = 2131427711;
// aapt resource value: 0x7f0b0003
public const int Theme_MediaRouter = 2131427331;
// aapt resource value: 0x7f0b0004
public const int Theme_MediaRouter_Light = 2131427332;
// aapt resource value: 0x7f0b0005
public const int Theme_MediaRouter_Light_DarkControlPanel = 2131427333;
// aapt resource value: 0x7f0b0006
public const int Theme_MediaRouter_LightControlPanel = 2131427334;
// aapt resource value: 0x7f0b011f
public const int ThemeOverlay_AppCompat = 2131427615;
// aapt resource value: 0x7f0b0120
public const int ThemeOverlay_AppCompat_ActionBar = 2131427616;
// aapt resource value: 0x7f0b0121
public const int ThemeOverlay_AppCompat_Dark = 2131427617;
// aapt resource value: 0x7f0b0122
public const int ThemeOverlay_AppCompat_Dark_ActionBar = 2131427618;
// aapt resource value: 0x7f0b0123
public const int ThemeOverlay_AppCompat_Dialog = 2131427619;
// aapt resource value: 0x7f0b0124
public const int ThemeOverlay_AppCompat_Dialog_Alert = 2131427620;
// aapt resource value: 0x7f0b0125
public const int ThemeOverlay_AppCompat_Light = 2131427621;
// aapt resource value: 0x7f0b0007
public const int ThemeOverlay_MediaRouter_Dark = 2131427335;
// aapt resource value: 0x7f0b0008
public const int ThemeOverlay_MediaRouter_Light = 2131427336;
// aapt resource value: 0x7f0b0126
public const int Widget_AppCompat_ActionBar = 2131427622;
// aapt resource value: 0x7f0b0127
public const int Widget_AppCompat_ActionBar_Solid = 2131427623;
// aapt resource value: 0x7f0b0128
public const int Widget_AppCompat_ActionBar_TabBar = 2131427624;
// aapt resource value: 0x7f0b0129
public const int Widget_AppCompat_ActionBar_TabText = 2131427625;
// aapt resource value: 0x7f0b012a
public const int Widget_AppCompat_ActionBar_TabView = 2131427626;
// aapt resource value: 0x7f0b012b
public const int Widget_AppCompat_ActionButton = 2131427627;
// aapt resource value: 0x7f0b012c
public const int Widget_AppCompat_ActionButton_CloseMode = 2131427628;
// aapt resource value: 0x7f0b012d
public const int Widget_AppCompat_ActionButton_Overflow = 2131427629;
// aapt resource value: 0x7f0b012e
public const int Widget_AppCompat_ActionMode = 2131427630;
// aapt resource value: 0x7f0b012f
public const int Widget_AppCompat_ActivityChooserView = 2131427631;
// aapt resource value: 0x7f0b0130
public const int Widget_AppCompat_AutoCompleteTextView = 2131427632;
// aapt resource value: 0x7f0b0131
public const int Widget_AppCompat_Button = 2131427633;
// aapt resource value: 0x7f0b0132
public const int Widget_AppCompat_Button_Borderless = 2131427634;
// aapt resource value: 0x7f0b0133
public const int Widget_AppCompat_Button_Borderless_Colored = 2131427635;
// aapt resource value: 0x7f0b0134
public const int Widget_AppCompat_Button_ButtonBar_AlertDialog = 2131427636;
// aapt resource value: 0x7f0b0135
public const int Widget_AppCompat_Button_Colored = 2131427637;
// aapt resource value: 0x7f0b0136
public const int Widget_AppCompat_Button_Small = 2131427638;
// aapt resource value: 0x7f0b0137
public const int Widget_AppCompat_ButtonBar = 2131427639;
// aapt resource value: 0x7f0b0138
public const int Widget_AppCompat_ButtonBar_AlertDialog = 2131427640;
// aapt resource value: 0x7f0b0139
public const int Widget_AppCompat_CompoundButton_CheckBox = 2131427641;
// aapt resource value: 0x7f0b013a
public const int Widget_AppCompat_CompoundButton_RadioButton = 2131427642;
// aapt resource value: 0x7f0b013b
public const int Widget_AppCompat_CompoundButton_Switch = 2131427643;
// aapt resource value: 0x7f0b013c
public const int Widget_AppCompat_DrawerArrowToggle = 2131427644;
// aapt resource value: 0x7f0b013d
public const int Widget_AppCompat_DropDownItem_Spinner = 2131427645;
// aapt resource value: 0x7f0b013e
public const int Widget_AppCompat_EditText = 2131427646;
// aapt resource value: 0x7f0b013f
public const int Widget_AppCompat_ImageButton = 2131427647;
// aapt resource value: 0x7f0b0140
public const int Widget_AppCompat_Light_ActionBar = 2131427648;
// aapt resource value: 0x7f0b0141
public const int Widget_AppCompat_Light_ActionBar_Solid = 2131427649;
// aapt resource value: 0x7f0b0142
public const int Widget_AppCompat_Light_ActionBar_Solid_Inverse = 2131427650;
// aapt resource value: 0x7f0b0143
public const int Widget_AppCompat_Light_ActionBar_TabBar = 2131427651;
// aapt resource value: 0x7f0b0144
public const int Widget_AppCompat_Light_ActionBar_TabBar_Inverse = 2131427652;
// aapt resource value: 0x7f0b0145
public const int Widget_AppCompat_Light_ActionBar_TabText = 2131427653;
// aapt resource value: 0x7f0b0146
public const int Widget_AppCompat_Light_ActionBar_TabText_Inverse = 2131427654;
// aapt resource value: 0x7f0b0147
public const int Widget_AppCompat_Light_ActionBar_TabView = 2131427655;
// aapt resource value: 0x7f0b0148
public const int Widget_AppCompat_Light_ActionBar_TabView_Inverse = 2131427656;
// aapt resource value: 0x7f0b0149
public const int Widget_AppCompat_Light_ActionButton = 2131427657;
// aapt resource value: 0x7f0b014a
public const int Widget_AppCompat_Light_ActionButton_CloseMode = 2131427658;
// aapt resource value: 0x7f0b014b
public const int Widget_AppCompat_Light_ActionButton_Overflow = 2131427659;
// aapt resource value: 0x7f0b014c
public const int Widget_AppCompat_Light_ActionMode_Inverse = 2131427660;
// aapt resource value: 0x7f0b014d
public const int Widget_AppCompat_Light_ActivityChooserView = 2131427661;
// aapt resource value: 0x7f0b014e
public const int Widget_AppCompat_Light_AutoCompleteTextView = 2131427662;
// aapt resource value: 0x7f0b014f
public const int Widget_AppCompat_Light_DropDownItem_Spinner = 2131427663;
// aapt resource value: 0x7f0b0150
public const int Widget_AppCompat_Light_ListPopupWindow = 2131427664;
// aapt resource value: 0x7f0b0151
public const int Widget_AppCompat_Light_ListView_DropDown = 2131427665;
// aapt resource value: 0x7f0b0152
public const int Widget_AppCompat_Light_PopupMenu = 2131427666;
// aapt resource value: 0x7f0b0153
public const int Widget_AppCompat_Light_PopupMenu_Overflow = 2131427667;
// aapt resource value: 0x7f0b0154
public const int Widget_AppCompat_Light_SearchView = 2131427668;
// aapt resource value: 0x7f0b0155
public const int Widget_AppCompat_Light_Spinner_DropDown_ActionBar = 2131427669;
// aapt resource value: 0x7f0b0156
public const int Widget_AppCompat_ListMenuView = 2131427670;
// aapt resource value: 0x7f0b0157
public const int Widget_AppCompat_ListPopupWindow = 2131427671;
// aapt resource value: 0x7f0b0158
public const int Widget_AppCompat_ListView = 2131427672;
// aapt resource value: 0x7f0b0159
public const int Widget_AppCompat_ListView_DropDown = 2131427673;
// aapt resource value: 0x7f0b015a
public const int Widget_AppCompat_ListView_Menu = 2131427674;
// aapt resource value: 0x7f0b009f
public const int Widget_AppCompat_NotificationActionContainer = 2131427487;
// aapt resource value: 0x7f0b00a0
public const int Widget_AppCompat_NotificationActionText = 2131427488;
// aapt resource value: 0x7f0b015b
public const int Widget_AppCompat_PopupMenu = 2131427675;
// aapt resource value: 0x7f0b015c
public const int Widget_AppCompat_PopupMenu_Overflow = 2131427676;
// aapt resource value: 0x7f0b015d
public const int Widget_AppCompat_PopupWindow = 2131427677;
// aapt resource value: 0x7f0b015e
public const int Widget_AppCompat_ProgressBar = 2131427678;
// aapt resource value: 0x7f0b015f
public const int Widget_AppCompat_ProgressBar_Horizontal = 2131427679;
// aapt resource value: 0x7f0b0160
public const int Widget_AppCompat_RatingBar = 2131427680;
// aapt resource value: 0x7f0b0161
public const int Widget_AppCompat_RatingBar_Indicator = 2131427681;
// aapt resource value: 0x7f0b0162
public const int Widget_AppCompat_RatingBar_Small = 2131427682;
// aapt resource value: 0x7f0b0163
public const int Widget_AppCompat_SearchView = 2131427683;
// aapt resource value: 0x7f0b0164
public const int Widget_AppCompat_SearchView_ActionBar = 2131427684;
// aapt resource value: 0x7f0b0165
public const int Widget_AppCompat_SeekBar = 2131427685;
// aapt resource value: 0x7f0b0166
public const int Widget_AppCompat_SeekBar_Discrete = 2131427686;
// aapt resource value: 0x7f0b0167
public const int Widget_AppCompat_Spinner = 2131427687;
// aapt resource value: 0x7f0b0168
public const int Widget_AppCompat_Spinner_DropDown = 2131427688;
// aapt resource value: 0x7f0b0169
public const int Widget_AppCompat_Spinner_DropDown_ActionBar = 2131427689;
// aapt resource value: 0x7f0b016a
public const int Widget_AppCompat_Spinner_Underlined = 2131427690;
// aapt resource value: 0x7f0b016b
public const int Widget_AppCompat_TextView_SpinnerItem = 2131427691;
// aapt resource value: 0x7f0b016c
public const int Widget_AppCompat_Toolbar = 2131427692;
// aapt resource value: 0x7f0b016d
public const int Widget_AppCompat_Toolbar_Button_Navigation = 2131427693;
// aapt resource value: 0x7f0b016f
public const int Widget_Design_AppBarLayout = 2131427695;
// aapt resource value: 0x7f0b0180
public const int Widget_Design_BottomNavigationView = 2131427712;
// aapt resource value: 0x7f0b0181
public const int Widget_Design_BottomSheet_Modal = 2131427713;
// aapt resource value: 0x7f0b0182
public const int Widget_Design_CollapsingToolbar = 2131427714;
// aapt resource value: 0x7f0b0183
public const int Widget_Design_CoordinatorLayout = 2131427715;
// aapt resource value: 0x7f0b0184
public const int Widget_Design_FloatingActionButton = 2131427716;
// aapt resource value: 0x7f0b0185
public const int Widget_Design_NavigationView = 2131427717;
// aapt resource value: 0x7f0b0186
public const int Widget_Design_ScrimInsetsFrameLayout = 2131427718;
// aapt resource value: 0x7f0b0187
public const int Widget_Design_Snackbar = 2131427719;
// aapt resource value: 0x7f0b016e
public const int Widget_Design_TabLayout = 2131427694;
// aapt resource value: 0x7f0b0188
public const int Widget_Design_TextInputLayout = 2131427720;
// aapt resource value: 0x7f0b0009
public const int Widget_MediaRouter_Light_MediaRouteButton = 2131427337;
// aapt resource value: 0x7f0b000a
public const int Widget_MediaRouter_MediaRouteButton = 2131427338;
static Style()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Style()
{
}
}
public partial class Styleable
{
public static int[] ActionBar = new int[] {
2130771997,
2130771999,
2130772000,
2130772001,
2130772002,
2130772003,
2130772004,
2130772005,
2130772006,
2130772007,
2130772008,
2130772009,
2130772010,
2130772011,
2130772012,
2130772013,
2130772014,
2130772015,
2130772016,
2130772017,
2130772018,
2130772019,
2130772020,
2130772021,
2130772022,
2130772023,
2130772024,
2130772025,
2130772089};
// aapt resource value: 10
public const int ActionBar_background = 10;
// aapt resource value: 12
public const int ActionBar_backgroundSplit = 12;
// aapt resource value: 11
public const int ActionBar_backgroundStacked = 11;
// aapt resource value: 21
public const int ActionBar_contentInsetEnd = 21;
// aapt resource value: 25
public const int ActionBar_contentInsetEndWithActions = 25;
// aapt resource value: 22
public const int ActionBar_contentInsetLeft = 22;
// aapt resource value: 23
public const int ActionBar_contentInsetRight = 23;
// aapt resource value: 20
public const int ActionBar_contentInsetStart = 20;
// aapt resource value: 24
public const int ActionBar_contentInsetStartWithNavigation = 24;
// aapt resource value: 13
public const int ActionBar_customNavigationLayout = 13;
// aapt resource value: 3
public const int ActionBar_displayOptions = 3;
// aapt resource value: 9
public const int ActionBar_divider = 9;
// aapt resource value: 26
public const int ActionBar_elevation = 26;
// aapt resource value: 0
public const int ActionBar_height = 0;
// aapt resource value: 19
public const int ActionBar_hideOnContentScroll = 19;
// aapt resource value: 28
public const int ActionBar_homeAsUpIndicator = 28;
// aapt resource value: 14
public const int ActionBar_homeLayout = 14;
// aapt resource value: 7
public const int ActionBar_icon = 7;
// aapt resource value: 16
public const int ActionBar_indeterminateProgressStyle = 16;
// aapt resource value: 18
public const int ActionBar_itemPadding = 18;
// aapt resource value: 8
public const int ActionBar_logo = 8;
// aapt resource value: 2
public const int ActionBar_navigationMode = 2;
// aapt resource value: 27
public const int ActionBar_popupTheme = 27;
// aapt resource value: 17
public const int ActionBar_progressBarPadding = 17;
// aapt resource value: 15
public const int ActionBar_progressBarStyle = 15;
// aapt resource value: 4
public const int ActionBar_subtitle = 4;
// aapt resource value: 6
public const int ActionBar_subtitleTextStyle = 6;
// aapt resource value: 1
public const int ActionBar_title = 1;
// aapt resource value: 5
public const int ActionBar_titleTextStyle = 5;
public static int[] ActionBarLayout = new int[] {
16842931};
// aapt resource value: 0
public const int ActionBarLayout_android_layout_gravity = 0;
public static int[] ActionMenuItemView = new int[] {
16843071};
// aapt resource value: 0
public const int ActionMenuItemView_android_minWidth = 0;
public static int[] ActionMenuView;
public static int[] ActionMode = new int[] {
2130771997,
2130772003,
2130772004,
2130772008,
2130772010,
2130772026};
// aapt resource value: 3
public const int ActionMode_background = 3;
// aapt resource value: 4
public const int ActionMode_backgroundSplit = 4;
// aapt resource value: 5
public const int ActionMode_closeItemLayout = 5;
// aapt resource value: 0
public const int ActionMode_height = 0;
// aapt resource value: 2
public const int ActionMode_subtitleTextStyle = 2;
// aapt resource value: 1
public const int ActionMode_titleTextStyle = 1;
public static int[] ActivityChooserView = new int[] {
2130772027,
2130772028};
// aapt resource value: 1
public const int ActivityChooserView_expandActivityOverflowButtonDrawable = 1;
// aapt resource value: 0
public const int ActivityChooserView_initialActivityCount = 0;
public static int[] AlertDialog = new int[] {
16842994,
2130772029,
2130772030,
2130772031,
2130772032,
2130772033,
2130772034};
// aapt resource value: 0
public const int AlertDialog_android_layout = 0;
// aapt resource value: 1
public const int AlertDialog_buttonPanelSideLayout = 1;
// aapt resource value: 5
public const int AlertDialog_listItemLayout = 5;
// aapt resource value: 2
public const int AlertDialog_listLayout = 2;
// aapt resource value: 3
public const int AlertDialog_multiChoiceItemLayout = 3;
// aapt resource value: 6
public const int AlertDialog_showTitle = 6;
// aapt resource value: 4
public const int AlertDialog_singleChoiceItemLayout = 4;
public static int[] AppBarLayout = new int[] {
16842964,
2130772024,
2130772227};
// aapt resource value: 0
public const int AppBarLayout_android_background = 0;
// aapt resource value: 1
public const int AppBarLayout_elevation = 1;
// aapt resource value: 2
public const int AppBarLayout_expanded = 2;
public static int[] AppBarLayoutStates = new int[] {
2130772228,
2130772229};
// aapt resource value: 0
public const int AppBarLayoutStates_state_collapsed = 0;
// aapt resource value: 1
public const int AppBarLayoutStates_state_collapsible = 1;
public static int[] AppBarLayout_Layout = new int[] {
2130772230,
2130772231};
// aapt resource value: 0
public const int AppBarLayout_Layout_layout_scrollFlags = 0;
// aapt resource value: 1
public const int AppBarLayout_Layout_layout_scrollInterpolator = 1;
public static int[] AppCompatImageView = new int[] {
16843033,
2130772035,
2130772036,
2130772037};
// aapt resource value: 0
public const int AppCompatImageView_android_src = 0;
// aapt resource value: 1
public const int AppCompatImageView_srcCompat = 1;
// aapt resource value: 2
public const int AppCompatImageView_tint = 2;
// aapt resource value: 3
public const int AppCompatImageView_tintMode = 3;
public static int[] AppCompatSeekBar = new int[] {
16843074,
2130772038,
2130772039,
2130772040};
// aapt resource value: 0
public const int AppCompatSeekBar_android_thumb = 0;
// aapt resource value: 1
public const int AppCompatSeekBar_tickMark = 1;
// aapt resource value: 2
public const int AppCompatSeekBar_tickMarkTint = 2;
// aapt resource value: 3
public const int AppCompatSeekBar_tickMarkTintMode = 3;
public static int[] AppCompatTextHelper = new int[] {
16842804,
16843117,
16843118,
16843119,
16843120,
16843666,
16843667};
// aapt resource value: 2
public const int AppCompatTextHelper_android_drawableBottom = 2;
// aapt resource value: 6
public const int AppCompatTextHelper_android_drawableEnd = 6;
// aapt resource value: 3
public const int AppCompatTextHelper_android_drawableLeft = 3;
// aapt resource value: 4
public const int AppCompatTextHelper_android_drawableRight = 4;
// aapt resource value: 5
public const int AppCompatTextHelper_android_drawableStart = 5;
// aapt resource value: 1
public const int AppCompatTextHelper_android_drawableTop = 1;
// aapt resource value: 0
public const int AppCompatTextHelper_android_textAppearance = 0;
public static int[] AppCompatTextView = new int[] {
16842804,
2130772041};
// aapt resource value: 0
public const int AppCompatTextView_android_textAppearance = 0;
// aapt resource value: 1
public const int AppCompatTextView_textAllCaps = 1;
public static int[] AppCompatTheme = new int[] {
16842839,
16842926,
2130772042,
2130772043,
2130772044,
2130772045,
2130772046,
2130772047,
2130772048,
2130772049,
2130772050,
2130772051,
2130772052,
2130772053,
2130772054,
2130772055,
2130772056,
2130772057,
2130772058,
2130772059,
2130772060,
2130772061,
2130772062,
2130772063,
2130772064,
2130772065,
2130772066,
2130772067,
2130772068,
2130772069,
2130772070,
2130772071,
2130772072,
2130772073,
2130772074,
2130772075,
2130772076,
2130772077,
2130772078,
2130772079,
2130772080,
2130772081,
2130772082,
2130772083,
2130772084,
2130772085,
2130772086,
2130772087,
2130772088,
2130772089,
2130772090,
2130772091,
2130772092,
2130772093,
2130772094,
2130772095,
2130772096,
2130772097,
2130772098,
2130772099,
2130772100,
2130772101,
2130772102,
2130772103,
2130772104,
2130772105,
2130772106,
2130772107,
2130772108,
2130772109,
2130772110,
2130772111,
2130772112,
2130772113,
2130772114,
2130772115,
2130772116,
2130772117,
2130772118,
2130772119,
2130772120,
2130772121,
2130772122,
2130772123,
2130772124,
2130772125,
2130772126,
2130772127,
2130772128,
2130772129,
2130772130,
2130772131,
2130772132,
2130772133,
2130772134,
2130772135,
2130772136,
2130772137,
2130772138,
2130772139,
2130772140,
2130772141,
2130772142,
2130772143,
2130772144,
2130772145,
2130772146,
2130772147,
2130772148,
2130772149,
2130772150,
2130772151,
2130772152,
2130772153,
2130772154,
2130772155};
// aapt resource value: 23
public const int AppCompatTheme_actionBarDivider = 23;
// aapt resource value: 24
public const int AppCompatTheme_actionBarItemBackground = 24;
// aapt resource value: 17
public const int AppCompatTheme_actionBarPopupTheme = 17;
// aapt resource value: 22
public const int AppCompatTheme_actionBarSize = 22;
// aapt resource value: 19
public const int AppCompatTheme_actionBarSplitStyle = 19;
// aapt resource value: 18
public const int AppCompatTheme_actionBarStyle = 18;
// aapt resource value: 13
public const int AppCompatTheme_actionBarTabBarStyle = 13;
// aapt resource value: 12
public const int AppCompatTheme_actionBarTabStyle = 12;
// aapt resource value: 14
public const int AppCompatTheme_actionBarTabTextStyle = 14;
// aapt resource value: 20
public const int AppCompatTheme_actionBarTheme = 20;
// aapt resource value: 21
public const int AppCompatTheme_actionBarWidgetTheme = 21;
// aapt resource value: 50
public const int AppCompatTheme_actionButtonStyle = 50;
// aapt resource value: 46
public const int AppCompatTheme_actionDropDownStyle = 46;
// aapt resource value: 25
public const int AppCompatTheme_actionMenuTextAppearance = 25;
// aapt resource value: 26
public const int AppCompatTheme_actionMenuTextColor = 26;
// aapt resource value: 29
public const int AppCompatTheme_actionModeBackground = 29;
// aapt resource value: 28
public const int AppCompatTheme_actionModeCloseButtonStyle = 28;
// aapt resource value: 31
public const int AppCompatTheme_actionModeCloseDrawable = 31;
// aapt resource value: 33
public const int AppCompatTheme_actionModeCopyDrawable = 33;
// aapt resource value: 32
public const int AppCompatTheme_actionModeCutDrawable = 32;
// aapt resource value: 37
public const int AppCompatTheme_actionModeFindDrawable = 37;
// aapt resource value: 34
public const int AppCompatTheme_actionModePasteDrawable = 34;
// aapt resource value: 39
public const int AppCompatTheme_actionModePopupWindowStyle = 39;
// aapt resource value: 35
public const int AppCompatTheme_actionModeSelectAllDrawable = 35;
// aapt resource value: 36
public const int AppCompatTheme_actionModeShareDrawable = 36;
// aapt resource value: 30
public const int AppCompatTheme_actionModeSplitBackground = 30;
// aapt resource value: 27
public const int AppCompatTheme_actionModeStyle = 27;
// aapt resource value: 38
public const int AppCompatTheme_actionModeWebSearchDrawable = 38;
// aapt resource value: 15
public const int AppCompatTheme_actionOverflowButtonStyle = 15;
// aapt resource value: 16
public const int AppCompatTheme_actionOverflowMenuStyle = 16;
// aapt resource value: 58
public const int AppCompatTheme_activityChooserViewStyle = 58;
// aapt resource value: 95
public const int AppCompatTheme_alertDialogButtonGroupStyle = 95;
// aapt resource value: 96
public const int AppCompatTheme_alertDialogCenterButtons = 96;
// aapt resource value: 94
public const int AppCompatTheme_alertDialogStyle = 94;
// aapt resource value: 97
public const int AppCompatTheme_alertDialogTheme = 97;
// aapt resource value: 1
public const int AppCompatTheme_android_windowAnimationStyle = 1;
// aapt resource value: 0
public const int AppCompatTheme_android_windowIsFloating = 0;
// aapt resource value: 102
public const int AppCompatTheme_autoCompleteTextViewStyle = 102;
// aapt resource value: 55
public const int AppCompatTheme_borderlessButtonStyle = 55;
// aapt resource value: 52
public const int AppCompatTheme_buttonBarButtonStyle = 52;
// aapt resource value: 100
public const int AppCompatTheme_buttonBarNegativeButtonStyle = 100;
// aapt resource value: 101
public const int AppCompatTheme_buttonBarNeutralButtonStyle = 101;
// aapt resource value: 99
public const int AppCompatTheme_buttonBarPositiveButtonStyle = 99;
// aapt resource value: 51
public const int AppCompatTheme_buttonBarStyle = 51;
// aapt resource value: 103
public const int AppCompatTheme_buttonStyle = 103;
// aapt resource value: 104
public const int AppCompatTheme_buttonStyleSmall = 104;
// aapt resource value: 105
public const int AppCompatTheme_checkboxStyle = 105;
// aapt resource value: 106
public const int AppCompatTheme_checkedTextViewStyle = 106;
// aapt resource value: 86
public const int AppCompatTheme_colorAccent = 86;
// aapt resource value: 93
public const int AppCompatTheme_colorBackgroundFloating = 93;
// aapt resource value: 90
public const int AppCompatTheme_colorButtonNormal = 90;
// aapt resource value: 88
public const int AppCompatTheme_colorControlActivated = 88;
// aapt resource value: 89
public const int AppCompatTheme_colorControlHighlight = 89;
// aapt resource value: 87
public const int AppCompatTheme_colorControlNormal = 87;
// aapt resource value: 84
public const int AppCompatTheme_colorPrimary = 84;
// aapt resource value: 85
public const int AppCompatTheme_colorPrimaryDark = 85;
// aapt resource value: 91
public const int AppCompatTheme_colorSwitchThumbNormal = 91;
// aapt resource value: 92
public const int AppCompatTheme_controlBackground = 92;
// aapt resource value: 44
public const int AppCompatTheme_dialogPreferredPadding = 44;
// aapt resource value: 43
public const int AppCompatTheme_dialogTheme = 43;
// aapt resource value: 57
public const int AppCompatTheme_dividerHorizontal = 57;
// aapt resource value: 56
public const int AppCompatTheme_dividerVertical = 56;
// aapt resource value: 75
public const int AppCompatTheme_dropDownListViewStyle = 75;
// aapt resource value: 47
public const int AppCompatTheme_dropdownListPreferredItemHeight = 47;
// aapt resource value: 64
public const int AppCompatTheme_editTextBackground = 64;
// aapt resource value: 63
public const int AppCompatTheme_editTextColor = 63;
// aapt resource value: 107
public const int AppCompatTheme_editTextStyle = 107;
// aapt resource value: 49
public const int AppCompatTheme_homeAsUpIndicator = 49;
// aapt resource value: 65
public const int AppCompatTheme_imageButtonStyle = 65;
// aapt resource value: 83
public const int AppCompatTheme_listChoiceBackgroundIndicator = 83;
// aapt resource value: 45
public const int AppCompatTheme_listDividerAlertDialog = 45;
// aapt resource value: 115
public const int AppCompatTheme_listMenuViewStyle = 115;
// aapt resource value: 76
public const int AppCompatTheme_listPopupWindowStyle = 76;
// aapt resource value: 70
public const int AppCompatTheme_listPreferredItemHeight = 70;
// aapt resource value: 72
public const int AppCompatTheme_listPreferredItemHeightLarge = 72;
// aapt resource value: 71
public const int AppCompatTheme_listPreferredItemHeightSmall = 71;
// aapt resource value: 73
public const int AppCompatTheme_listPreferredItemPaddingLeft = 73;
// aapt resource value: 74
public const int AppCompatTheme_listPreferredItemPaddingRight = 74;
// aapt resource value: 80
public const int AppCompatTheme_panelBackground = 80;
// aapt resource value: 82
public const int AppCompatTheme_panelMenuListTheme = 82;
// aapt resource value: 81
public const int AppCompatTheme_panelMenuListWidth = 81;
// aapt resource value: 61
public const int AppCompatTheme_popupMenuStyle = 61;
// aapt resource value: 62
public const int AppCompatTheme_popupWindowStyle = 62;
// aapt resource value: 108
public const int AppCompatTheme_radioButtonStyle = 108;
// aapt resource value: 109
public const int AppCompatTheme_ratingBarStyle = 109;
// aapt resource value: 110
public const int AppCompatTheme_ratingBarStyleIndicator = 110;
// aapt resource value: 111
public const int AppCompatTheme_ratingBarStyleSmall = 111;
// aapt resource value: 69
public const int AppCompatTheme_searchViewStyle = 69;
// aapt resource value: 112
public const int AppCompatTheme_seekBarStyle = 112;
// aapt resource value: 53
public const int AppCompatTheme_selectableItemBackground = 53;
// aapt resource value: 54
public const int AppCompatTheme_selectableItemBackgroundBorderless = 54;
// aapt resource value: 48
public const int AppCompatTheme_spinnerDropDownItemStyle = 48;
// aapt resource value: 113
public const int AppCompatTheme_spinnerStyle = 113;
// aapt resource value: 114
public const int AppCompatTheme_switchStyle = 114;
// aapt resource value: 40
public const int AppCompatTheme_textAppearanceLargePopupMenu = 40;
// aapt resource value: 77
public const int AppCompatTheme_textAppearanceListItem = 77;
// aapt resource value: 78
public const int AppCompatTheme_textAppearanceListItemSecondary = 78;
// aapt resource value: 79
public const int AppCompatTheme_textAppearanceListItemSmall = 79;
// aapt resource value: 42
public const int AppCompatTheme_textAppearancePopupMenuHeader = 42;
// aapt resource value: 67
public const int AppCompatTheme_textAppearanceSearchResultSubtitle = 67;
// aapt resource value: 66
public const int AppCompatTheme_textAppearanceSearchResultTitle = 66;
// aapt resource value: 41
public const int AppCompatTheme_textAppearanceSmallPopupMenu = 41;
// aapt resource value: 98
public const int AppCompatTheme_textColorAlertDialogListItem = 98;
// aapt resource value: 68
public const int AppCompatTheme_textColorSearchUrl = 68;
// aapt resource value: 60
public const int AppCompatTheme_toolbarNavigationButtonStyle = 60;
// aapt resource value: 59
public const int AppCompatTheme_toolbarStyle = 59;
// aapt resource value: 2
public const int AppCompatTheme_windowActionBar = 2;
// aapt resource value: 4
public const int AppCompatTheme_windowActionBarOverlay = 4;
// aapt resource value: 5
public const int AppCompatTheme_windowActionModeOverlay = 5;
// aapt resource value: 9
public const int AppCompatTheme_windowFixedHeightMajor = 9;
// aapt resource value: 7
public const int AppCompatTheme_windowFixedHeightMinor = 7;
// aapt resource value: 6
public const int AppCompatTheme_windowFixedWidthMajor = 6;
// aapt resource value: 8
public const int AppCompatTheme_windowFixedWidthMinor = 8;
// aapt resource value: 10
public const int AppCompatTheme_windowMinWidthMajor = 10;
// aapt resource value: 11
public const int AppCompatTheme_windowMinWidthMinor = 11;
// aapt resource value: 3
public const int AppCompatTheme_windowNoTitle = 3;
public static int[] BottomNavigationView = new int[] {
2130772024,
2130772270,
2130772271,
2130772272,
2130772273};
// aapt resource value: 0
public const int BottomNavigationView_elevation = 0;
// aapt resource value: 4
public const int BottomNavigationView_itemBackground = 4;
// aapt resource value: 2
public const int BottomNavigationView_itemIconTint = 2;
// aapt resource value: 3
public const int BottomNavigationView_itemTextColor = 3;
// aapt resource value: 1
public const int BottomNavigationView_menu = 1;
public static int[] BottomSheetBehavior_Layout = new int[] {
2130772232,
2130772233,
2130772234};
// aapt resource value: 1
public const int BottomSheetBehavior_Layout_behavior_hideable = 1;
// aapt resource value: 0
public const int BottomSheetBehavior_Layout_behavior_peekHeight = 0;
// aapt resource value: 2
public const int BottomSheetBehavior_Layout_behavior_skipCollapsed = 2;
public static int[] ButtonBarLayout = new int[] {
2130772156};
// aapt resource value: 0
public const int ButtonBarLayout_allowStacking = 0;
public static int[] CardView = new int[] {
16843071,
16843072,
2130771985,
2130771986,
2130771987,
2130771988,
2130771989,
2130771990,
2130771991,
2130771992,
2130771993,
2130771994,
2130771995};
// aapt resource value: 1
public const int CardView_android_minHeight = 1;
// aapt resource value: 0
public const int CardView_android_minWidth = 0;
// aapt resource value: 2
public const int CardView_cardBackgroundColor = 2;
// aapt resource value: 3
public const int CardView_cardCornerRadius = 3;
// aapt resource value: 4
public const int CardView_cardElevation = 4;
// aapt resource value: 5
public const int CardView_cardMaxElevation = 5;
// aapt resource value: 7
public const int CardView_cardPreventCornerOverlap = 7;
// aapt resource value: 6
public const int CardView_cardUseCompatPadding = 6;
// aapt resource value: 8
public const int CardView_contentPadding = 8;
// aapt resource value: 12
public const int CardView_contentPaddingBottom = 12;
// aapt resource value: 9
public const int CardView_contentPaddingLeft = 9;
// aapt resource value: 10
public const int CardView_contentPaddingRight = 10;
// aapt resource value: 11
public const int CardView_contentPaddingTop = 11;
public static int[] CollapsingToolbarLayout = new int[] {
2130771999,
2130772235,
2130772236,
2130772237,
2130772238,
2130772239,
2130772240,
2130772241,
2130772242,
2130772243,
2130772244,
2130772245,
2130772246,
2130772247,
2130772248,
2130772249};
// aapt resource value: 13
public const int CollapsingToolbarLayout_collapsedTitleGravity = 13;
// aapt resource value: 7
public const int CollapsingToolbarLayout_collapsedTitleTextAppearance = 7;
// aapt resource value: 8
public const int CollapsingToolbarLayout_contentScrim = 8;
// aapt resource value: 14
public const int CollapsingToolbarLayout_expandedTitleGravity = 14;
// aapt resource value: 1
public const int CollapsingToolbarLayout_expandedTitleMargin = 1;
// aapt resource value: 5
public const int CollapsingToolbarLayout_expandedTitleMarginBottom = 5;
// aapt resource value: 4
public const int CollapsingToolbarLayout_expandedTitleMarginEnd = 4;
// aapt resource value: 2
public const int CollapsingToolbarLayout_expandedTitleMarginStart = 2;
// aapt resource value: 3
public const int CollapsingToolbarLayout_expandedTitleMarginTop = 3;
// aapt resource value: 6
public const int CollapsingToolbarLayout_expandedTitleTextAppearance = 6;
// aapt resource value: 12
public const int CollapsingToolbarLayout_scrimAnimationDuration = 12;
// aapt resource value: 11
public const int CollapsingToolbarLayout_scrimVisibleHeightTrigger = 11;
// aapt resource value: 9
public const int CollapsingToolbarLayout_statusBarScrim = 9;
// aapt resource value: 0
public const int CollapsingToolbarLayout_title = 0;
// aapt resource value: 15
public const int CollapsingToolbarLayout_titleEnabled = 15;
// aapt resource value: 10
public const int CollapsingToolbarLayout_toolbarId = 10;
public static int[] CollapsingToolbarLayout_Layout = new int[] {
2130772250,
2130772251};
// aapt resource value: 0
public const int CollapsingToolbarLayout_Layout_layout_collapseMode = 0;
// aapt resource value: 1
public const int CollapsingToolbarLayout_Layout_layout_collapseParallaxMultiplier = 1;
public static int[] ColorStateListItem = new int[] {
16843173,
16843551,
2130772157};
// aapt resource value: 2
public const int ColorStateListItem_alpha = 2;
// aapt resource value: 1
public const int ColorStateListItem_android_alpha = 1;
// aapt resource value: 0
public const int ColorStateListItem_android_color = 0;
public static int[] CompoundButton = new int[] {
16843015,
2130772158,
2130772159};
// aapt resource value: 0
public const int CompoundButton_android_button = 0;
// aapt resource value: 1
public const int CompoundButton_buttonTint = 1;
// aapt resource value: 2
public const int CompoundButton_buttonTintMode = 2;
public static int[] CoordinatorLayout = new int[] {
2130772252,
2130772253};
// aapt resource value: 0
public const int CoordinatorLayout_keylines = 0;
// aapt resource value: 1
public const int CoordinatorLayout_statusBarBackground = 1;
public static int[] CoordinatorLayout_Layout = new int[] {
16842931,
2130772254,
2130772255,
2130772256,
2130772257,
2130772258,
2130772259};
// aapt resource value: 0
public const int CoordinatorLayout_Layout_android_layout_gravity = 0;
// aapt resource value: 2
public const int CoordinatorLayout_Layout_layout_anchor = 2;
// aapt resource value: 4
public const int CoordinatorLayout_Layout_layout_anchorGravity = 4;
// aapt resource value: 1
public const int CoordinatorLayout_Layout_layout_behavior = 1;
// aapt resource value: 6
public const int CoordinatorLayout_Layout_layout_dodgeInsetEdges = 6;
// aapt resource value: 5
public const int CoordinatorLayout_Layout_layout_insetEdge = 5;
// aapt resource value: 3
public const int CoordinatorLayout_Layout_layout_keyline = 3;
public static int[] DesignTheme = new int[] {
2130772260,
2130772261,
2130772262};
// aapt resource value: 0
public const int DesignTheme_bottomSheetDialogTheme = 0;
// aapt resource value: 1
public const int DesignTheme_bottomSheetStyle = 1;
// aapt resource value: 2
public const int DesignTheme_textColorError = 2;
public static int[] DrawerArrowToggle = new int[] {
2130772160,
2130772161,
2130772162,
2130772163,
2130772164,
2130772165,
2130772166,
2130772167};
// aapt resource value: 4
public const int DrawerArrowToggle_arrowHeadLength = 4;
// aapt resource value: 5
public const int DrawerArrowToggle_arrowShaftLength = 5;
// aapt resource value: 6
public const int DrawerArrowToggle_barLength = 6;
// aapt resource value: 0
public const int DrawerArrowToggle_color = 0;
// aapt resource value: 2
public const int DrawerArrowToggle_drawableSize = 2;
// aapt resource value: 3
public const int DrawerArrowToggle_gapBetweenBars = 3;
// aapt resource value: 1
public const int DrawerArrowToggle_spinBars = 1;
// aapt resource value: 7
public const int DrawerArrowToggle_thickness = 7;
public static int[] FloatingActionButton = new int[] {
2130772024,
2130772225,
2130772226,
2130772263,
2130772264,
2130772265,
2130772266,
2130772267};
// aapt resource value: 1
public const int FloatingActionButton_backgroundTint = 1;
// aapt resource value: 2
public const int FloatingActionButton_backgroundTintMode = 2;
// aapt resource value: 6
public const int FloatingActionButton_borderWidth = 6;
// aapt resource value: 0
public const int FloatingActionButton_elevation = 0;
// aapt resource value: 4
public const int FloatingActionButton_fabSize = 4;
// aapt resource value: 5
public const int FloatingActionButton_pressedTranslationZ = 5;
// aapt resource value: 3
public const int FloatingActionButton_rippleColor = 3;
// aapt resource value: 7
public const int FloatingActionButton_useCompatPadding = 7;
public static int[] FloatingActionButton_Behavior_Layout = new int[] {
2130772268};
// aapt resource value: 0
public const int FloatingActionButton_Behavior_Layout_behavior_autoHide = 0;
public static int[] ForegroundLinearLayout = new int[] {
16843017,
16843264,
2130772269};
// aapt resource value: 0
public const int ForegroundLinearLayout_android_foreground = 0;
// aapt resource value: 1
public const int ForegroundLinearLayout_android_foregroundGravity = 1;
// aapt resource value: 2
public const int ForegroundLinearLayout_foregroundInsidePadding = 2;
public static int[] LinearLayoutCompat = new int[] {
16842927,
16842948,
16843046,
16843047,
16843048,
2130772007,
2130772168,
2130772169,
2130772170};
// aapt resource value: 2
public const int LinearLayoutCompat_android_baselineAligned = 2;
// aapt resource value: 3
public const int LinearLayoutCompat_android_baselineAlignedChildIndex = 3;
// aapt resource value: 0
public const int LinearLayoutCompat_android_gravity = 0;
// aapt resource value: 1
public const int LinearLayoutCompat_android_orientation = 1;
// aapt resource value: 4
public const int LinearLayoutCompat_android_weightSum = 4;
// aapt resource value: 5
public const int LinearLayoutCompat_divider = 5;
// aapt resource value: 8
public const int LinearLayoutCompat_dividerPadding = 8;
// aapt resource value: 6
public const int LinearLayoutCompat_measureWithLargestChild = 6;
// aapt resource value: 7
public const int LinearLayoutCompat_showDividers = 7;
public static int[] LinearLayoutCompat_Layout = new int[] {
16842931,
16842996,
16842997,
16843137};
// aapt resource value: 0
public const int LinearLayoutCompat_Layout_android_layout_gravity = 0;
// aapt resource value: 2
public const int LinearLayoutCompat_Layout_android_layout_height = 2;
// aapt resource value: 3
public const int LinearLayoutCompat_Layout_android_layout_weight = 3;
// aapt resource value: 1
public const int LinearLayoutCompat_Layout_android_layout_width = 1;
public static int[] ListPopupWindow = new int[] {
16843436,
16843437};
// aapt resource value: 0
public const int ListPopupWindow_android_dropDownHorizontalOffset = 0;
// aapt resource value: 1
public const int ListPopupWindow_android_dropDownVerticalOffset = 1;
public static int[] MediaRouteButton = new int[] {
16843071,
16843072,
2130771984,
2130772158};
// aapt resource value: 1
public const int MediaRouteButton_android_minHeight = 1;
// aapt resource value: 0
public const int MediaRouteButton_android_minWidth = 0;
// aapt resource value: 3
public const int MediaRouteButton_buttonTint = 3;
// aapt resource value: 2
public const int MediaRouteButton_externalRouteEnabledDrawable = 2;
public static int[] MenuGroup = new int[] {
16842766,
16842960,
16843156,
16843230,
16843231,
16843232};
// aapt resource value: 5
public const int MenuGroup_android_checkableBehavior = 5;
// aapt resource value: 0
public const int MenuGroup_android_enabled = 0;
// aapt resource value: 1
public const int MenuGroup_android_id = 1;
// aapt resource value: 3
public const int MenuGroup_android_menuCategory = 3;
// aapt resource value: 4
public const int MenuGroup_android_orderInCategory = 4;
// aapt resource value: 2
public const int MenuGroup_android_visible = 2;
public static int[] MenuItem = new int[] {
16842754,
16842766,
16842960,
16843014,
16843156,
16843230,
16843231,
16843233,
16843234,
16843235,
16843236,
16843237,
16843375,
2130772171,
2130772172,
2130772173,
2130772174};
// aapt resource value: 14
public const int MenuItem_actionLayout = 14;
// aapt resource value: 16
public const int MenuItem_actionProviderClass = 16;
// aapt resource value: 15
public const int MenuItem_actionViewClass = 15;
// aapt resource value: 9
public const int MenuItem_android_alphabeticShortcut = 9;
// aapt resource value: 11
public const int MenuItem_android_checkable = 11;
// aapt resource value: 3
public const int MenuItem_android_checked = 3;
// aapt resource value: 1
public const int MenuItem_android_enabled = 1;
// aapt resource value: 0
public const int MenuItem_android_icon = 0;
// aapt resource value: 2
public const int MenuItem_android_id = 2;
// aapt resource value: 5
public const int MenuItem_android_menuCategory = 5;
// aapt resource value: 10
public const int MenuItem_android_numericShortcut = 10;
// aapt resource value: 12
public const int MenuItem_android_onClick = 12;
// aapt resource value: 6
public const int MenuItem_android_orderInCategory = 6;
// aapt resource value: 7
public const int MenuItem_android_title = 7;
// aapt resource value: 8
public const int MenuItem_android_titleCondensed = 8;
// aapt resource value: 4
public const int MenuItem_android_visible = 4;
// aapt resource value: 13
public const int MenuItem_showAsAction = 13;
public static int[] MenuView = new int[] {
16842926,
16843052,
16843053,
16843054,
16843055,
16843056,
16843057,
2130772175,
2130772176};
// aapt resource value: 4
public const int MenuView_android_headerBackground = 4;
// aapt resource value: 2
public const int MenuView_android_horizontalDivider = 2;
// aapt resource value: 5
public const int MenuView_android_itemBackground = 5;
// aapt resource value: 6
public const int MenuView_android_itemIconDisabledAlpha = 6;
// aapt resource value: 1
public const int MenuView_android_itemTextAppearance = 1;
// aapt resource value: 3
public const int MenuView_android_verticalDivider = 3;
// aapt resource value: 0
public const int MenuView_android_windowAnimationStyle = 0;
// aapt resource value: 7
public const int MenuView_preserveIconSpacing = 7;
// aapt resource value: 8
public const int MenuView_subMenuArrow = 8;
public static int[] NavigationView = new int[] {
16842964,
16842973,
16843039,
2130772024,
2130772270,
2130772271,
2130772272,
2130772273,
2130772274,
2130772275};
// aapt resource value: 0
public const int NavigationView_android_background = 0;
// aapt resource value: 1
public const int NavigationView_android_fitsSystemWindows = 1;
// aapt resource value: 2
public const int NavigationView_android_maxWidth = 2;
// aapt resource value: 3
public const int NavigationView_elevation = 3;
// aapt resource value: 9
public const int NavigationView_headerLayout = 9;
// aapt resource value: 7
public const int NavigationView_itemBackground = 7;
// aapt resource value: 5
public const int NavigationView_itemIconTint = 5;
// aapt resource value: 8
public const int NavigationView_itemTextAppearance = 8;
// aapt resource value: 6
public const int NavigationView_itemTextColor = 6;
// aapt resource value: 4
public const int NavigationView_menu = 4;
public static int[] PopupWindow = new int[] {
16843126,
16843465,
2130772177};
// aapt resource value: 1
public const int PopupWindow_android_popupAnimationStyle = 1;
// aapt resource value: 0
public const int PopupWindow_android_popupBackground = 0;
// aapt resource value: 2
public const int PopupWindow_overlapAnchor = 2;
public static int[] PopupWindowBackgroundState = new int[] {
2130772178};
// aapt resource value: 0
public const int PopupWindowBackgroundState_state_above_anchor = 0;
public static int[] RecycleListView = new int[] {
2130772179,
2130772180};
// aapt resource value: 0
public const int RecycleListView_paddingBottomNoButtons = 0;
// aapt resource value: 1
public const int RecycleListView_paddingTopNoTitle = 1;
public static int[] RecyclerView = new int[] {
16842948,
16842993,
2130771968,
2130771969,
2130771970,
2130771971};
// aapt resource value: 1
public const int RecyclerView_android_descendantFocusability = 1;
// aapt resource value: 0
public const int RecyclerView_android_orientation = 0;
// aapt resource value: 2
public const int RecyclerView_layoutManager = 2;
// aapt resource value: 4
public const int RecyclerView_reverseLayout = 4;
// aapt resource value: 3
public const int RecyclerView_spanCount = 3;
// aapt resource value: 5
public const int RecyclerView_stackFromEnd = 5;
public static int[] ScrimInsetsFrameLayout = new int[] {
2130772276};
// aapt resource value: 0
public const int ScrimInsetsFrameLayout_insetForeground = 0;
public static int[] ScrollingViewBehavior_Layout = new int[] {
2130772277};
// aapt resource value: 0
public const int ScrollingViewBehavior_Layout_behavior_overlapTop = 0;
public static int[] SearchView = new int[] {
16842970,
16843039,
16843296,
16843364,
2130772181,
2130772182,
2130772183,
2130772184,
2130772185,
2130772186,
2130772187,
2130772188,
2130772189,
2130772190,
2130772191,
2130772192,
2130772193};
// aapt resource value: 0
public const int SearchView_android_focusable = 0;
// aapt resource value: 3
public const int SearchView_android_imeOptions = 3;
// aapt resource value: 2
public const int SearchView_android_inputType = 2;
// aapt resource value: 1
public const int SearchView_android_maxWidth = 1;
// aapt resource value: 8
public const int SearchView_closeIcon = 8;
// aapt resource value: 13
public const int SearchView_commitIcon = 13;
// aapt resource value: 7
public const int SearchView_defaultQueryHint = 7;
// aapt resource value: 9
public const int SearchView_goIcon = 9;
// aapt resource value: 5
public const int SearchView_iconifiedByDefault = 5;
// aapt resource value: 4
public const int SearchView_layout = 4;
// aapt resource value: 15
public const int SearchView_queryBackground = 15;
// aapt resource value: 6
public const int SearchView_queryHint = 6;
// aapt resource value: 11
public const int SearchView_searchHintIcon = 11;
// aapt resource value: 10
public const int SearchView_searchIcon = 10;
// aapt resource value: 16
public const int SearchView_submitBackground = 16;
// aapt resource value: 14
public const int SearchView_suggestionRowLayout = 14;
// aapt resource value: 12
public const int SearchView_voiceIcon = 12;
public static int[] SnackbarLayout = new int[] {
16843039,
2130772024,
2130772278};
// aapt resource value: 0
public const int SnackbarLayout_android_maxWidth = 0;
// aapt resource value: 1
public const int SnackbarLayout_elevation = 1;
// aapt resource value: 2
public const int SnackbarLayout_maxActionInlineWidth = 2;
public static int[] Spinner = new int[] {
16842930,
16843126,
16843131,
16843362,
2130772025};
// aapt resource value: 3
public const int Spinner_android_dropDownWidth = 3;
// aapt resource value: 0
public const int Spinner_android_entries = 0;
// aapt resource value: 1
public const int Spinner_android_popupBackground = 1;
// aapt resource value: 2
public const int Spinner_android_prompt = 2;
// aapt resource value: 4
public const int Spinner_popupTheme = 4;
public static int[] SwitchCompat = new int[] {
16843044,
16843045,
16843074,
2130772194,
2130772195,
2130772196,
2130772197,
2130772198,
2130772199,
2130772200,
2130772201,
2130772202,
2130772203,
2130772204};
// aapt resource value: 1
public const int SwitchCompat_android_textOff = 1;
// aapt resource value: 0
public const int SwitchCompat_android_textOn = 0;
// aapt resource value: 2
public const int SwitchCompat_android_thumb = 2;
// aapt resource value: 13
public const int SwitchCompat_showText = 13;
// aapt resource value: 12
public const int SwitchCompat_splitTrack = 12;
// aapt resource value: 10
public const int SwitchCompat_switchMinWidth = 10;
// aapt resource value: 11
public const int SwitchCompat_switchPadding = 11;
// aapt resource value: 9
public const int SwitchCompat_switchTextAppearance = 9;
// aapt resource value: 8
public const int SwitchCompat_thumbTextPadding = 8;
// aapt resource value: 3
public const int SwitchCompat_thumbTint = 3;
// aapt resource value: 4
public const int SwitchCompat_thumbTintMode = 4;
// aapt resource value: 5
public const int SwitchCompat_track = 5;
// aapt resource value: 6
public const int SwitchCompat_trackTint = 6;
// aapt resource value: 7
public const int SwitchCompat_trackTintMode = 7;
public static int[] TabItem = new int[] {
16842754,
16842994,
16843087};
// aapt resource value: 0
public const int TabItem_android_icon = 0;
// aapt resource value: 1
public const int TabItem_android_layout = 1;
// aapt resource value: 2
public const int TabItem_android_text = 2;
public static int[] TabLayout = new int[] {
2130772279,
2130772280,
2130772281,
2130772282,
2130772283,
2130772284,
2130772285,
2130772286,
2130772287,
2130772288,
2130772289,
2130772290,
2130772291,
2130772292,
2130772293,
2130772294};
// aapt resource value: 3
public const int TabLayout_tabBackground = 3;
// aapt resource value: 2
public const int TabLayout_tabContentStart = 2;
// aapt resource value: 5
public const int TabLayout_tabGravity = 5;
// aapt resource value: 0
public const int TabLayout_tabIndicatorColor = 0;
// aapt resource value: 1
public const int TabLayout_tabIndicatorHeight = 1;
// aapt resource value: 7
public const int TabLayout_tabMaxWidth = 7;
// aapt resource value: 6
public const int TabLayout_tabMinWidth = 6;
// aapt resource value: 4
public const int TabLayout_tabMode = 4;
// aapt resource value: 15
public const int TabLayout_tabPadding = 15;
// aapt resource value: 14
public const int TabLayout_tabPaddingBottom = 14;
// aapt resource value: 13
public const int TabLayout_tabPaddingEnd = 13;
// aapt resource value: 11
public const int TabLayout_tabPaddingStart = 11;
// aapt resource value: 12
public const int TabLayout_tabPaddingTop = 12;
// aapt resource value: 10
public const int TabLayout_tabSelectedTextColor = 10;
// aapt resource value: 8
public const int TabLayout_tabTextAppearance = 8;
// aapt resource value: 9
public const int TabLayout_tabTextColor = 9;
public static int[] TextAppearance = new int[] {
16842901,
16842902,
16842903,
16842904,
16842906,
16843105,
16843106,
16843107,
16843108,
2130772041};
// aapt resource value: 5
public const int TextAppearance_android_shadowColor = 5;
// aapt resource value: 6
public const int TextAppearance_android_shadowDx = 6;
// aapt resource value: 7
public const int TextAppearance_android_shadowDy = 7;
// aapt resource value: 8
public const int TextAppearance_android_shadowRadius = 8;
// aapt resource value: 3
public const int TextAppearance_android_textColor = 3;
// aapt resource value: 4
public const int TextAppearance_android_textColorHint = 4;
// aapt resource value: 0
public const int TextAppearance_android_textSize = 0;
// aapt resource value: 2
public const int TextAppearance_android_textStyle = 2;
// aapt resource value: 1
public const int TextAppearance_android_typeface = 1;
// aapt resource value: 9
public const int TextAppearance_textAllCaps = 9;
public static int[] TextInputLayout = new int[] {
16842906,
16843088,
2130772295,
2130772296,
2130772297,
2130772298,
2130772299,
2130772300,
2130772301,
2130772302,
2130772303,
2130772304,
2130772305,
2130772306,
2130772307,
2130772308};
// aapt resource value: 1
public const int TextInputLayout_android_hint = 1;
// aapt resource value: 0
public const int TextInputLayout_android_textColorHint = 0;
// aapt resource value: 6
public const int TextInputLayout_counterEnabled = 6;
// aapt resource value: 7
public const int TextInputLayout_counterMaxLength = 7;
// aapt resource value: 9
public const int TextInputLayout_counterOverflowTextAppearance = 9;
// aapt resource value: 8
public const int TextInputLayout_counterTextAppearance = 8;
// aapt resource value: 4
public const int TextInputLayout_errorEnabled = 4;
// aapt resource value: 5
public const int TextInputLayout_errorTextAppearance = 5;
// aapt resource value: 10
public const int TextInputLayout_hintAnimationEnabled = 10;
// aapt resource value: 3
public const int TextInputLayout_hintEnabled = 3;
// aapt resource value: 2
public const int TextInputLayout_hintTextAppearance = 2;
// aapt resource value: 13
public const int TextInputLayout_passwordToggleContentDescription = 13;
// aapt resource value: 12
public const int TextInputLayout_passwordToggleDrawable = 12;
// aapt resource value: 11
public const int TextInputLayout_passwordToggleEnabled = 11;
// aapt resource value: 14
public const int TextInputLayout_passwordToggleTint = 14;
// aapt resource value: 15
public const int TextInputLayout_passwordToggleTintMode = 15;
public static int[] Toolbar = new int[] {
16842927,
16843072,
2130771999,
2130772002,
2130772006,
2130772018,
2130772019,
2130772020,
2130772021,
2130772022,
2130772023,
2130772025,
2130772205,
2130772206,
2130772207,
2130772208,
2130772209,
2130772210,
2130772211,
2130772212,
2130772213,
2130772214,
2130772215,
2130772216,
2130772217,
2130772218,
2130772219,
2130772220,
2130772221};
// aapt resource value: 0
public const int Toolbar_android_gravity = 0;
// aapt resource value: 1
public const int Toolbar_android_minHeight = 1;
// aapt resource value: 21
public const int Toolbar_buttonGravity = 21;
// aapt resource value: 23
public const int Toolbar_collapseContentDescription = 23;
// aapt resource value: 22
public const int Toolbar_collapseIcon = 22;
// aapt resource value: 6
public const int Toolbar_contentInsetEnd = 6;
// aapt resource value: 10
public const int Toolbar_contentInsetEndWithActions = 10;
// aapt resource value: 7
public const int Toolbar_contentInsetLeft = 7;
// aapt resource value: 8
public const int Toolbar_contentInsetRight = 8;
// aapt resource value: 5
public const int Toolbar_contentInsetStart = 5;
// aapt resource value: 9
public const int Toolbar_contentInsetStartWithNavigation = 9;
// aapt resource value: 4
public const int Toolbar_logo = 4;
// aapt resource value: 26
public const int Toolbar_logoDescription = 26;
// aapt resource value: 20
public const int Toolbar_maxButtonHeight = 20;
// aapt resource value: 25
public const int Toolbar_navigationContentDescription = 25;
// aapt resource value: 24
public const int Toolbar_navigationIcon = 24;
// aapt resource value: 11
public const int Toolbar_popupTheme = 11;
// aapt resource value: 3
public const int Toolbar_subtitle = 3;
// aapt resource value: 13
public const int Toolbar_subtitleTextAppearance = 13;
// aapt resource value: 28
public const int Toolbar_subtitleTextColor = 28;
// aapt resource value: 2
public const int Toolbar_title = 2;
// aapt resource value: 14
public const int Toolbar_titleMargin = 14;
// aapt resource value: 18
public const int Toolbar_titleMarginBottom = 18;
// aapt resource value: 16
public const int Toolbar_titleMarginEnd = 16;
// aapt resource value: 15
public const int Toolbar_titleMarginStart = 15;
// aapt resource value: 17
public const int Toolbar_titleMarginTop = 17;
// aapt resource value: 19
public const int Toolbar_titleMargins = 19;
// aapt resource value: 12
public const int Toolbar_titleTextAppearance = 12;
// aapt resource value: 27
public const int Toolbar_titleTextColor = 27;
public static int[] View = new int[] {
16842752,
16842970,
2130772222,
2130772223,
2130772224};
// aapt resource value: 1
public const int View_android_focusable = 1;
// aapt resource value: 0
public const int View_android_theme = 0;
// aapt resource value: 3
public const int View_paddingEnd = 3;
// aapt resource value: 2
public const int View_paddingStart = 2;
// aapt resource value: 4
public const int View_theme = 4;
public static int[] ViewBackgroundHelper = new int[] {
16842964,
2130772225,
2130772226};
// aapt resource value: 0
public const int ViewBackgroundHelper_android_background = 0;
// aapt resource value: 1
public const int ViewBackgroundHelper_backgroundTint = 1;
// aapt resource value: 2
public const int ViewBackgroundHelper_backgroundTintMode = 2;
public static int[] ViewStubCompat = new int[] {
16842960,
16842994,
16842995};
// aapt resource value: 0
public const int ViewStubCompat_android_id = 0;
// aapt resource value: 2
public const int ViewStubCompat_android_inflatedId = 2;
// aapt resource value: 1
public const int ViewStubCompat_android_layout = 1;
static Styleable()
{
global::Android.Runtime.ResourceIdManager.UpdateIdValues();
}
private Styleable()
{
}
}
}
}
#pragma warning restore 1591
| 31.886152 | 145 | 0.732656 | [
"MIT"
] | AlexeySidorov/Xfx.Controls | example/Xfx.Controls.Example.Droid/Resources/Resource.Designer.cs | 222,661 | C# |
/*
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the sqs-2012-11-05.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Serialization;
using Amazon.SQS.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
namespace Amazon.SQS.Model.Internal.MarshallTransformations
{
/// <summary>
/// Response Unmarshaller for QueueNameExistsException operation
/// </summary>
public class QueueNameExistsExceptionUnmarshaller : IErrorResponseUnmarshaller<QueueNameExistsException, XmlUnmarshallerContext>
{
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public QueueNameExistsException Unmarshall(XmlUnmarshallerContext context)
{
return this.Unmarshall(context, new ErrorResponse());
}
/// <summary>
/// Unmarshaller error response to exception.
/// </summary>
/// <param name="context"></param>
/// <param name="errorResponse"></param>
/// <returns></returns>
public QueueNameExistsException Unmarshall(XmlUnmarshallerContext context, ErrorResponse errorResponse)
{
QueueNameExistsException response = new QueueNameExistsException(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
int originalDepth = context.CurrentDepth;
int targetDepth = originalDepth + 1;
if (context.IsStartOfDocument)
targetDepth += 2;
while (context.ReadAtDepth(originalDepth))
{
if (context.IsStartElement || context.IsAttribute)
{
}
}
return response;
}
private static QueueNameExistsExceptionUnmarshaller _instance = new QueueNameExistsExceptionUnmarshaller();
/// <summary>
/// Gets the singleton.
/// </summary>
public static QueueNameExistsExceptionUnmarshaller Instance
{
get
{
return _instance;
}
}
}
} | 35.193182 | 132 | 0.648369 | [
"Apache-2.0"
] | DetlefGolze/aws-sdk-net | sdk/src/Services/SQS/Generated/Model/Internal/MarshallTransformations/QueueNameExistsExceptionUnmarshaller.cs | 3,097 | C# |
/*
* Copyright 2010-2014 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the ec2-2016-11-15.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Amazon.EC2.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
namespace Amazon.EC2.Model.Internal.MarshallTransformations
{
/// <summary>
/// BundleInstance Request Marshaller
/// </summary>
public class BundleInstanceRequestMarshaller : IMarshaller<IRequest, BundleInstanceRequest> , IMarshaller<IRequest,AmazonWebServiceRequest>
{
/// <summary>
/// Marshaller the request object to the HTTP request.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public IRequest Marshall(AmazonWebServiceRequest input)
{
return this.Marshall((BundleInstanceRequest)input);
}
/// <summary>
/// Marshaller the request object to the HTTP request.
/// </summary>
/// <param name="publicRequest"></param>
/// <returns></returns>
public IRequest Marshall(BundleInstanceRequest publicRequest)
{
IRequest request = new DefaultRequest(publicRequest, "Amazon.EC2");
request.Parameters.Add("Action", "BundleInstance");
request.Parameters.Add("Version", "2016-11-15");
if(publicRequest != null)
{
if(publicRequest.IsSetInstanceId())
{
request.Parameters.Add("InstanceId", StringUtils.FromString(publicRequest.InstanceId));
}
if(publicRequest.IsSetStorage())
{
if(publicRequest.Storage.IsSetS3())
{
if(publicRequest.Storage.S3.IsSetAWSAccessKeyId())
{
request.Parameters.Add("Storage" + "." + "S3" + "." + "AWSAccessKeyId", StringUtils.FromString(publicRequest.Storage.S3.AWSAccessKeyId));
}
if(publicRequest.Storage.S3.IsSetBucket())
{
request.Parameters.Add("Storage" + "." + "S3" + "." + "Bucket", StringUtils.FromString(publicRequest.Storage.S3.Bucket));
}
if(publicRequest.Storage.S3.IsSetPrefix())
{
request.Parameters.Add("Storage" + "." + "S3" + "." + "Prefix", StringUtils.FromString(publicRequest.Storage.S3.Prefix));
}
if(publicRequest.Storage.S3.IsSetUploadPolicy())
{
request.Parameters.Add("Storage" + "." + "S3" + "." + "UploadPolicy", StringUtils.FromString(publicRequest.Storage.S3.UploadPolicy));
}
if(publicRequest.Storage.S3.IsSetUploadPolicySignature())
{
request.Parameters.Add("Storage" + "." + "S3" + "." + "UploadPolicySignature", StringUtils.FromString(publicRequest.Storage.S3.UploadPolicySignature));
}
}
}
}
return request;
}
}
} | 42.442105 | 179 | 0.574405 | [
"Apache-2.0"
] | Bynder/aws-sdk-net | sdk/src/Services/EC2/Generated/Model/Internal/MarshallTransformations/BundleInstanceRequestMarshaller.cs | 4,032 | C# |
using System;
using CmnSoftwareBackend.Shared.Entities.Abstract;
namespace CmnSoftwareBackend.Entities.Concrete
{
public class UserNotification:EntityBase<int,Guid>,IEntity
{
public Guid UserId { get; set; }
public User User { get; set; }
public string Message { get; set; }
}
}
| 24.384615 | 62 | 0.684543 | [
"MIT"
] | YunusOzdemirr/BlogApi | src/v1/CmnSoftwareBackend.Entities/Concrete/UserNotification.cs | 319 | C# |
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
namespace FineUI.Examples.data
{
public partial class dropdownlist_simulate_tree : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindEnumrable();
}
}
#region JQueryFeature
public class JQueryFeature
{
private string _id;
public string Id
{
get { return _id; }
set { _id = value; }
}
private string _name;
public string Name
{
get { return _name; }
set { _name = value; }
}
private int _level;
public int Level
{
get { return _level; }
set { _level = value; }
}
private bool _enableSelect;
public bool EnableSelect
{
get { return _enableSelect; }
set { _enableSelect = value; }
}
public JQueryFeature(string id, string name, int level, bool enableSelect)
{
_id = id;
_name = name;
_level = level;
_enableSelect = enableSelect;
}
public override string ToString()
{
return String.Format("Name:{0}+Id:{1}", Name, Id);
}
}
#endregion
#region BindEnumrable
private void BindEnumrable()
{
List<JQueryFeature> myList = new List<JQueryFeature>();
myList.Add(new JQueryFeature("0", "jQuery", 0, false));
myList.Add(new JQueryFeature("1", "核心", 1, false));
myList.Add(new JQueryFeature("2", "选择符", 1, false));
myList.Add(new JQueryFeature("3", "基本选择符", 2, true));
myList.Add(new JQueryFeature("4", "内容选择符", 2, true));
myList.Add(new JQueryFeature("5", "属性选择符", 2, true));
myList.Add(new JQueryFeature("6", "筛选", 1, false));
myList.Add(new JQueryFeature("7", "过滤", 2, true));
myList.Add(new JQueryFeature("8", "查找", 2, true));
myList.Add(new JQueryFeature("9", "事件", 1, false));
myList.Add(new JQueryFeature("10", "页面载入", 2, true));
myList.Add(new JQueryFeature("11", "事件处理", 2, true));
myList.Add(new JQueryFeature("12", "事件委托", 2, true));
ddlBox.DataTextField = "Name";
ddlBox.DataValueField = "Id";
ddlBox.DataSimulateTreeLevelField = "Level";
ddlBox.DataEnableSelectField = "EnableSelect";
ddlBox.DataSource = myList;
ddlBox.DataBind();
ddlBox.SelectedValue = "3";
}
#endregion
#region Events
protected void Button1_Click(object sender, EventArgs e)
{
if (ddlBox.SelectedItem != null)
{
labResult.Text = String.Format("选中项:{0}(值:{1})", ddlBox.SelectedText, ddlBox.SelectedValue);
}
else
{
labResult.Text = "无选中项";
}
}
#endregion
}
}
| 29.717949 | 109 | 0.476273 | [
"Apache-2.0"
] | JesterWang/FineUI | FineUI.Examples/dropdownlist/dropdownlist_simulate_tree.aspx.cs | 3,583 | C# |
// Copyright (c) 2012, Event Store LLP
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the Event Store LLP nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
using System;
using EventStore.Common.Log;
using EventStore.Common.Utils;
using EventStore.Core.Bus;
using EventStore.Core.Messaging;
using EventStore.Transport.Http;
using EventStore.Transport.Http.Codecs;
using EventStore.Transport.Http.EntityManagement;
namespace EventStore.Core.Services.Transport.Http.Controllers
{
public abstract class CommunicationController : IHttpController
{
private static readonly ILogger Log = LogManager.GetLoggerFor<CommunicationController>();
private static readonly ICodec[] DefaultCodecs = new ICodec[] { Codec.Json, Codec.Xml };
private readonly IPublisher _publisher;
protected CommunicationController(IPublisher publisher)
{
Ensure.NotNull(publisher, "publisher");
_publisher = publisher;
}
public void Publish(Message message)
{
Ensure.NotNull(message, "message");
_publisher.Publish(message);
}
public void Subscribe(IHttpService service)
{
Ensure.NotNull(service, "service");
SubscribeCore(service);
}
protected abstract void SubscribeCore(IHttpService service);
protected RequestParams SendBadRequest(HttpEntityManager httpEntityManager, string reason)
{
httpEntityManager.ReplyStatus(HttpStatusCode.BadRequest,
reason,
e => Log.Debug("Error while closing http connection (bad request): {0}.", e.Message));
return new RequestParams(done: true);
}
protected RequestParams SendOk(HttpEntityManager httpEntityManager)
{
httpEntityManager.ReplyStatus(HttpStatusCode.OK,
"OK",
e => Log.Debug("Error while closing http connection (ok): {0}.", e.Message));
return new RequestParams(done: true);
}
protected void Register(IHttpService service, string uriTemplate, string httpMethod,
Action<HttpEntityManager, UriTemplateMatch> handler, ICodec[] requestCodecs, ICodec[] responseCodecs)
{
service.RegisterAction(new ControllerAction(uriTemplate, httpMethod, requestCodecs, responseCodecs), handler);
}
protected void RegisterCustom(IHttpService service, string uriTemplate, string httpMethod,
Func<HttpEntityManager, UriTemplateMatch, RequestParams> handler,
ICodec[] requestCodecs, ICodec[] responseCodecs)
{
service.RegisterCustomAction(new ControllerAction(uriTemplate, httpMethod, requestCodecs, responseCodecs), handler);
}
protected void RegisterTextBody(IHttpService service, string uriTemplate, string httpMethod,
Action<HttpEntityManager, string> action,
ICodec[] requestCodecs = null, ICodec[] responseCodecs = null)
{
Register(service, uriTemplate, httpMethod,
(http, match) => http.ReadTextRequestAsync(action, e => Log.Debug("Error on reading request: {0}.", e.Message)),
requestCodecs ?? DefaultCodecs, responseCodecs ?? DefaultCodecs);
}
protected void RegisterTextBody(IHttpService service, string uriTemplate, string httpMethod,
Action<HttpEntityManager, UriTemplateMatch, string> action,
ICodec[] requestCodecs = null, ICodec[] responseCodecs = null)
{
Register(service, uriTemplate, httpMethod,
(http, match) => http.ReadTextRequestAsync((manager, s) => action(manager, match, s),
e => Log.Debug("Error on reading request: {0}.", e.Message)),
requestCodecs ?? DefaultCodecs, responseCodecs ?? DefaultCodecs);
}
protected void RegisterUrlBased(IHttpService service, string uriTemplate, string httpMethod,
Action<HttpEntityManager, UriTemplateMatch> action)
{
Register(service, uriTemplate, httpMethod, action, Codec.NoCodecs, DefaultCodecs);
}
protected static string MakeUrl(HttpEntityManager http, string path)
{
var hostUri = http.RequestedUrl;
return new UriBuilder(hostUri.Scheme, hostUri.Host, hostUri.Port, path).Uri.AbsoluteUri;
}
}
} | 48.445313 | 133 | 0.650056 | [
"BSD-3-Clause"
] | ianbattersby/EventStore | src/EventStore/EventStore.Core/Services/Transport/Http/Controllers/CommunicationController.cs | 6,203 | C# |
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* Copyright 2019 (c) talsen team GmbH, http://talsen.team
*/
using System.Linq;
using Moq;
using NUnit.Framework;
using Appio.ObjectModel.CommandStrategies.NewCommands;
namespace Appio.ObjectModel.Tests
{
public class ParameterResolverWithArgumentsShould
{
public enum Subcommand { Sln, Opcuaapp }
private static Mock<ICommandFactory<NewStrategy>> _factoryMock;
private static Mock<ICommand<NewStrategy>> _opcuaAppMock;
private static Mock<ICommand<NewStrategy>> _slnMock;
private static object[] _goodData =
{
new object[] {new[] {"sln"}, Subcommand.Sln},
new object[] {new[] {"opcuaapp"}, Subcommand.Opcuaapp},
new object[] {new[] {"sln", "--server", "testServer", "-C", "exampleClient"}, Subcommand.Sln},
new object[] {new[] {"opcuaapp", "-C", "exampleClient", "--server", "testServer"}, Subcommand.Opcuaapp}
};
[SetUp]
public void Setup()
{
_factoryMock = new Mock<ICommandFactory<NewStrategy>>();
_opcuaAppMock = new Mock<ICommand<NewStrategy>>();
_slnMock = new Mock<ICommand<NewStrategy>>();
_opcuaAppMock.Setup(c => c.Execute(It.IsAny<string[]>())).Returns(new CommandResult(true, new MessageLines()));
_slnMock.Setup(c => c.Execute(It.IsAny<string[]>())).Returns(new CommandResult(true, new MessageLines()));
_factoryMock.Setup(f => f.GetCommand("opcuaapp")).Returns(_opcuaAppMock.Object);
_factoryMock.Setup(f => f.GetCommand("sln")).Returns(_slnMock.Object);
}
[TestCaseSource(nameof(_goodData))]
public void CallCorrectClassWithGoodInputs(string[] parameters, Subcommand expectedSubcommand)
{
var restParams = parameters.Skip(1).ToArray();
Assert.IsTrue(ParameterResolver.DelegateToSubcommands(_factoryMock.Object, parameters).Success);
var expectedCommandMock = expectedSubcommand == Subcommand.Sln ? _slnMock : _opcuaAppMock;
expectedCommandMock.Verify(c => c.Execute(restParams), Times.Once);
}
}
} | 43.648148 | 123 | 0.647857 | [
"MPL-2.0",
"MPL-2.0-no-copyleft-exception"
] | appioframework/APPIO-Terminal | src/appio-objectmodel.tests/ParameterResolverWithArguments.Tests.cs | 2,357 | C# |
//------------------------------------------------------------------------------
// <auto-generated />
//
// This file was automatically generated by SWIG (http://www.swig.org).
// Version 4.0.1
//
// Do not make changes to this file unless you know what you are doing--modify
// the SWIG interface file instead.
//------------------------------------------------------------------------------
namespace QuantLib {
public class Bbsw5M : Bbsw {
private global::System.Runtime.InteropServices.HandleRef swigCPtr;
private bool swigCMemOwnDerived;
internal Bbsw5M(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NQuantLibcPINVOKE.Bbsw5M_SWIGSmartPtrUpcast(cPtr), true) {
swigCMemOwnDerived = cMemoryOwn;
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
}
internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Bbsw5M obj) {
return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
}
protected override void Dispose(bool disposing) {
lock(this) {
if (swigCPtr.Handle != global::System.IntPtr.Zero) {
if (swigCMemOwnDerived) {
swigCMemOwnDerived = false;
NQuantLibcPINVOKE.delete_Bbsw5M(swigCPtr);
}
swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
}
base.Dispose(disposing);
}
}
public Bbsw5M(YieldTermStructureHandle h) : this(NQuantLibcPINVOKE.new_Bbsw5M__SWIG_0(YieldTermStructureHandle.getCPtr(h)), true) {
if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
}
public Bbsw5M() : this(NQuantLibcPINVOKE.new_Bbsw5M__SWIG_1(), true) {
if (NQuantLibcPINVOKE.SWIGPendingException.Pending) throw NQuantLibcPINVOKE.SWIGPendingException.Retrieve();
}
}
}
| 38.88 | 134 | 0.657407 | [
"Apache-2.0"
] | andrew-stakiwicz-r3/financial_derivatives_demo | quantlib_swig_bindings/CSharp/csharp/Bbsw5M.cs | 1,944 | C# |
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Game.Graphics;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Overlays.Profile.Sections
{
public abstract class DrawableProfileRow : Container
{
private const int fade_duration = 200;
private Box underscoreLine;
private readonly Box coloredBackground;
private readonly Container background;
/// <summary>
/// A visual element displayed to the left of <see cref="LeftFlowContainer"/> content.
/// </summary>
protected abstract Drawable CreateLeftVisual();
protected FillFlowContainer LeftFlowContainer { get; private set; }
protected FillFlowContainer RightFlowContainer { get; private set; }
protected override Container<Drawable> Content { get; }
protected DrawableProfileRow()
{
RelativeSizeAxes = Axes.X;
Height = 60;
InternalChildren = new Drawable[]
{
background = new Container
{
RelativeSizeAxes = Axes.Both,
Masking = true,
CornerRadius = 3,
Alpha = 0,
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Shadow,
Offset = new Vector2(0f, 1f),
Radius = 1f,
Colour = Color4.Black.Opacity(0.2f),
},
Child = coloredBackground = new Box { RelativeSizeAxes = Axes.Both }
},
Content = new Container
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
Width = 0.97f,
},
};
}
[BackgroundDependencyLoader(true)]
private void load(OsuColour colour)
{
AddRange(new Drawable[]
{
underscoreLine = new Box
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X,
Height = 1,
},
new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Children = new[]
{
CreateLeftVisual(),
LeftFlowContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Margin = new MarginPadding { Left = 10 },
Direction = FillDirection.Vertical,
},
}
},
RightFlowContainer = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Direction = FillDirection.Vertical,
},
});
coloredBackground.Colour = underscoreLine.Colour = colour.Gray4;
}
protected override bool OnClick(InputState state) => true;
protected override bool OnHover(InputState state)
{
background.FadeIn(fade_duration, Easing.OutQuint);
underscoreLine.FadeOut(fade_duration, Easing.OutQuint);
return true;
}
protected override void OnHoverLost(InputState state)
{
background.FadeOut(fade_duration, Easing.OutQuint);
underscoreLine.FadeIn(fade_duration, Easing.OutQuint);
base.OnHoverLost(state);
}
}
}
| 36.304 | 95 | 0.497576 | [
"MIT"
] | StefanYohansson/osu | osu.Game/Overlays/Profile/Sections/DrawableProfileRow.cs | 4,540 | C# |
using Amqp.Framing;
namespace NMS.AMQP.Test.TestAmqp.BasicTypes
{
public static class FrameCodes
{
public static readonly ulong TRANSFER = new Transfer().Descriptor.Code;
}
} | 21.666667 | 79 | 0.712821 | [
"Apache-2.0"
] | michaelpearce-gain/activemq-nms-amqp | test/Apache-NMS-AMQP-Test/TestAmqp/BasicTypes/FrameCodes.cs | 195 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
#nullable disable
using System;
using System.Linq;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.CSharp.Test.Utilities;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Roslyn.Utilities;
using Xunit;
namespace Microsoft.CodeAnalysis.CSharp.UnitTests;
public class PatternMatchingTests_ListPatterns : PatternMatchingTestBase
{
[Fact]
public void ListPattern()
{
static string testMethod(string type) =>
@"static bool Test(" + type + @" input)
{
switch (input)
{
case []:
case [_]:
return true;
case [var first, ..var others, var last] when first == last:
return Test(others);
default:
return false;
}
}";
var source = @"
using System;
public class X
{
" + testMethod("Span<char>") + @"
" + testMethod("char[]") + @"
" + testMethod("string") + @"
static void Check(int num)
{
Console.Write(Test((string)num.ToString()) ? 1 : 0);
Console.Write(Test((char[])num.ToString().ToCharArray()) ? 1 : 0);
Console.Write(Test((Span<char>)num.ToString().ToCharArray()) ? 1 : 0);
Console.WriteLine();
}
public static void Main()
{
Check(1);
Check(11);
Check(12);
Check(123);
Check(121);
Check(1221);
Check(1222);
}
}
" + TestSources.GetSubArray;
var compilation = CreateCompilationWithIndexAndRangeAndSpan(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
var expectedOutput = @"
111
111
000
000
111
111
000";
var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput);
AssertEx.Multiple(
() => verifier.VerifyIL("X.Test(System.Span<char>)", @"
{
// Code size 71 (0x47)
.maxstack 4
.locals init (char V_0, //first
System.Span<char> V_1, //others
char V_2, //last
System.Span<char> V_3,
int V_4)
IL_0000: ldarg.0
IL_0001: stloc.3
IL_0002: ldloca.s V_3
IL_0004: call ""int System.Span<char>.Length.get""
IL_0009: stloc.s V_4
IL_000b: ldloc.s V_4
IL_000d: ldc.i4.1
IL_000e: ble.un.s IL_0038
IL_0010: ldloca.s V_3
IL_0012: ldc.i4.0
IL_0013: call ""ref char System.Span<char>.this[int].get""
IL_0018: ldind.u2
IL_0019: stloc.0
IL_001a: ldloca.s V_3
IL_001c: ldc.i4.1
IL_001d: ldloc.s V_4
IL_001f: ldc.i4.1
IL_0020: sub
IL_0021: ldc.i4.1
IL_0022: sub
IL_0023: call ""System.Span<char> System.Span<char>.Slice(int, int)""
IL_0028: stloc.1
IL_0029: ldloca.s V_3
IL_002b: ldloc.s V_4
IL_002d: ldc.i4.1
IL_002e: sub
IL_002f: call ""ref char System.Span<char>.this[int].get""
IL_0034: ldind.u2
IL_0035: stloc.2
IL_0036: br.s IL_003a
IL_0038: ldc.i4.1
IL_0039: ret
IL_003a: ldloc.0
IL_003b: ldloc.2
IL_003c: bne.un.s IL_0045
IL_003e: ldloc.1
IL_003f: call ""bool X.Test(System.Span<char>)""
IL_0044: ret
IL_0045: ldc.i4.0
IL_0046: ret
}
"),
() => verifier.VerifyIL("X.Test(char[])", @"
{
// Code size 69 (0x45)
.maxstack 4
.locals init (char V_0, //first
char[] V_1, //others
char V_2, //last
char[] V_3,
int V_4)
IL_0000: ldarg.0
IL_0001: stloc.3
IL_0002: ldloc.3
IL_0003: brfalse.s IL_0043
IL_0005: ldloc.3
IL_0006: ldlen
IL_0007: conv.i4
IL_0008: stloc.s V_4
IL_000a: ldloc.s V_4
IL_000c: ldc.i4.1
IL_000d: ble.un.s IL_0036
IL_000f: ldloc.3
IL_0010: ldc.i4.0
IL_0011: ldelem.u2
IL_0012: stloc.0
IL_0013: ldloc.3
IL_0014: ldc.i4.1
IL_0015: ldc.i4.0
IL_0016: newobj ""System.Index..ctor(int, bool)""
IL_001b: ldc.i4.1
IL_001c: ldc.i4.1
IL_001d: newobj ""System.Index..ctor(int, bool)""
IL_0022: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_0027: call ""char[] System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray<char>(char[], System.Range)""
IL_002c: stloc.1
IL_002d: ldloc.3
IL_002e: ldloc.s V_4
IL_0030: ldc.i4.1
IL_0031: sub
IL_0032: ldelem.u2
IL_0033: stloc.2
IL_0034: br.s IL_0038
IL_0036: ldc.i4.1
IL_0037: ret
IL_0038: ldloc.0
IL_0039: ldloc.2
IL_003a: bne.un.s IL_0043
IL_003c: ldloc.1
IL_003d: call ""bool X.Test(char[])""
IL_0042: ret
IL_0043: ldc.i4.0
IL_0044: ret
}
"),
() => verifier.VerifyIL("X.Test(string)", @"
{
// Code size 68 (0x44)
.maxstack 4
.locals init (char V_0, //first
string V_1, //others
char V_2, //last
string V_3,
int V_4)
IL_0000: ldarg.0
IL_0001: stloc.3
IL_0002: ldloc.3
IL_0003: brfalse.s IL_0042
IL_0005: ldloc.3
IL_0006: callvirt ""int string.Length.get""
IL_000b: stloc.s V_4
IL_000d: ldloc.s V_4
IL_000f: ldc.i4.1
IL_0010: ble.un.s IL_0035
IL_0012: ldloc.3
IL_0013: ldc.i4.0
IL_0014: callvirt ""char string.this[int].get""
IL_0019: stloc.0
IL_001a: ldloc.3
IL_001b: ldc.i4.1
IL_001c: ldloc.s V_4
IL_001e: ldc.i4.1
IL_001f: sub
IL_0020: ldc.i4.1
IL_0021: sub
IL_0022: callvirt ""string string.Substring(int, int)""
IL_0027: stloc.1
IL_0028: ldloc.3
IL_0029: ldloc.s V_4
IL_002b: ldc.i4.1
IL_002c: sub
IL_002d: callvirt ""char string.this[int].get""
IL_0032: stloc.2
IL_0033: br.s IL_0037
IL_0035: ldc.i4.1
IL_0036: ret
IL_0037: ldloc.0
IL_0038: ldloc.2
IL_0039: bne.un.s IL_0042
IL_003b: ldloc.1
IL_003c: call ""bool X.Test(string)""
IL_0041: ret
IL_0042: ldc.i4.0
IL_0043: ret
}
")
);
}
[Fact]
[WorkItem(57731, "https://github.com/dotnet/roslyn/issues/57731")]
public void ListPattern_Codegen()
{
var source = @"
public class X
{
static int Test1(int[] x)
{
switch (x)
{
case [.., 1] and [1, ..]: return 0;
}
return 1;
}
static int Test2(int[] x)
{
switch (x)
{
case [2, ..] and [.., 1]: return 0;
}
return 3;
}
static int Test3(int[] x)
{
switch (x)
{
case [2, ..]: return 4;
case [.., 1]: return 5;
}
return 3;
}
static int Test4(int[] x)
{
switch (x)
{
case [2, ..]: return 4;
case [.., 1]: return 5;
case [6, .., 7]: return 8;
}
return 3;
}
}
";
var verifier = CompileAndVerify(new[] { source, TestSources.Index, TestSources.Range }, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseDll).VerifyDiagnostics();
AssertEx.Multiple(
() => verifier.VerifyIL("X.Test1", @"
{
// Code size 29 (0x1d)
.maxstack 3
.locals init (int V_0)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_001b
IL_0003: ldarg.0
IL_0004: ldlen
IL_0005: conv.i4
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: blt.s IL_001b
IL_000b: ldarg.0
IL_000c: ldloc.0
IL_000d: ldc.i4.1
IL_000e: sub
IL_000f: ldelem.i4
IL_0010: ldc.i4.1
IL_0011: bne.un.s IL_001b
IL_0013: ldarg.0
IL_0014: ldc.i4.0
IL_0015: ldelem.i4
IL_0016: ldc.i4.1
IL_0017: bne.un.s IL_001b
IL_0019: ldc.i4.0
IL_001a: ret
IL_001b: ldc.i4.1
IL_001c: ret
}"),
() => verifier.VerifyIL("X.Test2", @"
{
// Code size 29 (0x1d)
.maxstack 3
.locals init (int V_0)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_001b
IL_0003: ldarg.0
IL_0004: ldlen
IL_0005: conv.i4
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: blt.s IL_001b
IL_000b: ldarg.0
IL_000c: ldc.i4.0
IL_000d: ldelem.i4
IL_000e: ldc.i4.2
IL_000f: bne.un.s IL_001b
IL_0011: ldarg.0
IL_0012: ldloc.0
IL_0013: ldc.i4.1
IL_0014: sub
IL_0015: ldelem.i4
IL_0016: ldc.i4.1
IL_0017: bne.un.s IL_001b
IL_0019: ldc.i4.0
IL_001a: ret
IL_001b: ldc.i4.3
IL_001c: ret
}"),
() => verifier.VerifyIL("X.Test3", @"
{
// Code size 33 (0x21)
.maxstack 3
.locals init (int V_0)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_001f
IL_0003: ldarg.0
IL_0004: ldlen
IL_0005: conv.i4
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: blt.s IL_001f
IL_000b: ldarg.0
IL_000c: ldc.i4.0
IL_000d: ldelem.i4
IL_000e: ldc.i4.2
IL_000f: beq.s IL_001b
IL_0011: ldarg.0
IL_0012: ldloc.0
IL_0013: ldc.i4.1
IL_0014: sub
IL_0015: ldelem.i4
IL_0016: ldc.i4.1
IL_0017: beq.s IL_001d
IL_0019: br.s IL_001f
IL_001b: ldc.i4.4
IL_001c: ret
IL_001d: ldc.i4.5
IL_001e: ret
IL_001f: ldc.i4.3
IL_0020: ret
}"),
() => verifier.VerifyIL("X.Test4", @"
{
// Code size 51 (0x33)
.maxstack 3
.locals init (int V_0,
int V_1,
int V_2)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0031
IL_0003: ldarg.0
IL_0004: ldlen
IL_0005: conv.i4
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: blt.s IL_0031
IL_000b: ldarg.0
IL_000c: ldc.i4.0
IL_000d: ldelem.i4
IL_000e: stloc.1
IL_000f: ldloc.1
IL_0010: ldc.i4.2
IL_0011: beq.s IL_002b
IL_0013: ldarg.0
IL_0014: ldloc.0
IL_0015: ldc.i4.1
IL_0016: sub
IL_0017: ldelem.i4
IL_0018: stloc.2
IL_0019: ldloc.2
IL_001a: ldc.i4.1
IL_001b: beq.s IL_002d
IL_001d: ldloc.0
IL_001e: ldc.i4.2
IL_001f: blt.s IL_0031
IL_0021: ldloc.1
IL_0022: ldc.i4.6
IL_0023: bne.un.s IL_0031
IL_0025: ldloc.2
IL_0026: ldc.i4.7
IL_0027: beq.s IL_002f
IL_0029: br.s IL_0031
IL_002b: ldc.i4.4
IL_002c: ret
IL_002d: ldc.i4.5
IL_002e: ret
IL_002f: ldc.i4.8
IL_0030: ret
IL_0031: ldc.i4.3
IL_0032: ret
}
")
);
}
[Fact]
public void ListPattern_LangVer()
{
var source = @"
_ = new C() is [];
_ = new C() is [.. var x];
_ = new C() is .. var y;
class C
{
public int this[int i] => 1;
public int Length => 0;
public int Slice(int i, int j) => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.Regular10);
compilation.VerifyDiagnostics(
// (2,16): error CS8652: The feature 'list pattern' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.
// _ = new C() is [];
Diagnostic(ErrorCode.ERR_FeatureInPreview, "[]").WithArguments("list pattern").WithLocation(2, 16),
// (3,16): error CS8652: The feature 'list pattern' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.
// _ = new C() is [.. var x];
Diagnostic(ErrorCode.ERR_FeatureInPreview, "[.. var x]").WithArguments("list pattern").WithLocation(3, 16),
// (4,16): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = new C() is .. var y;
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, ".. var y").WithLocation(4, 16)
);
compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularNext);
compilation.VerifyDiagnostics(
// (4,16): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = new C() is .. var y;
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, ".. var y").WithLocation(4, 16)
);
}
[Fact]
public void ListPattern_Index()
{
var source = @"
using System;
class Test1
{
public int this[Index i] => 1;
public int Length => 1;
}
class Test2
{
public int this[Index i, int ignored = 5] => 1;
public int Length => 1;
}
class Test3
{
public int this[Index i, params int[] ignored] => 1;
public int Length => 1;
}
class Test4
{
public int this[params Index[] i] => 1;
public int Length => 1;
}
class Test5
{
public int this[int i] => 1;
public int Length => 1;
}
class X
{
void EnsureTypeIsIndexable()
{
_ = new Test1()[^1];
_ = new Test2()[^1];
_ = new Test3()[^1];
_ = new Test4()[^1];
_ = new Test5()[^1];
}
static bool Test1(Test1 t) => t is [1];
static bool Test2(Test2 t) => t is [1];
static bool Test3(Test3 t) => t is [1];
static bool Test4(Test4 t) => t is [1];
static bool Test5(Test5 t) => t is [1];
public static void Main()
{
Console.WriteLine(Test1(new()));
Console.WriteLine(Test2(new()));
Console.WriteLine(Test3(new()));
Console.WriteLine(Test4(new()));
Console.WriteLine(Test5(new()));
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
var expectedOutput = @"
True
True
True
True
True
";
var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput);
AssertEx.Multiple(
() => verifier.VerifyIL("X.Test1", @"
{
// Code size 31 (0x1f)
.maxstack 3
IL_0000: ldarg.0
IL_0001: brfalse.s IL_001d
IL_0003: ldarg.0
IL_0004: callvirt ""int Test1.Length.get""
IL_0009: ldc.i4.1
IL_000a: bne.un.s IL_001d
IL_000c: ldarg.0
IL_000d: ldc.i4.0
IL_000e: ldc.i4.0
IL_000f: newobj ""System.Index..ctor(int, bool)""
IL_0014: callvirt ""int Test1.this[System.Index].get""
IL_0019: ldc.i4.1
IL_001a: ceq
IL_001c: ret
IL_001d: ldc.i4.0
IL_001e: ret
}"),
() => verifier.VerifyIL("X.Test2", @"
{
// Code size 32 (0x20)
.maxstack 3
IL_0000: ldarg.0
IL_0001: brfalse.s IL_001e
IL_0003: ldarg.0
IL_0004: callvirt ""int Test2.Length.get""
IL_0009: ldc.i4.1
IL_000a: bne.un.s IL_001e
IL_000c: ldarg.0
IL_000d: ldc.i4.0
IL_000e: ldc.i4.0
IL_000f: newobj ""System.Index..ctor(int, bool)""
IL_0014: ldc.i4.5
IL_0015: callvirt ""int Test2.this[System.Index, int].get""
IL_001a: ldc.i4.1
IL_001b: ceq
IL_001d: ret
IL_001e: ldc.i4.0
IL_001f: ret
}"),
() => verifier.VerifyIL("X.Test3", @"
{
// Code size 36 (0x24)
.maxstack 3
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0022
IL_0003: ldarg.0
IL_0004: callvirt ""int Test3.Length.get""
IL_0009: ldc.i4.1
IL_000a: bne.un.s IL_0022
IL_000c: ldarg.0
IL_000d: ldc.i4.0
IL_000e: ldc.i4.0
IL_000f: newobj ""System.Index..ctor(int, bool)""
IL_0014: call ""int[] System.Array.Empty<int>()""
IL_0019: callvirt ""int Test3.this[System.Index, params int[]].get""
IL_001e: ldc.i4.1
IL_001f: ceq
IL_0021: ret
IL_0022: ldc.i4.0
IL_0023: ret
}"),
() => verifier.VerifyIL("X.Test4", @"
{
// Code size 44 (0x2c)
.maxstack 6
IL_0000: ldarg.0
IL_0001: brfalse.s IL_002a
IL_0003: ldarg.0
IL_0004: callvirt ""int Test4.Length.get""
IL_0009: ldc.i4.1
IL_000a: bne.un.s IL_002a
IL_000c: ldarg.0
IL_000d: ldc.i4.1
IL_000e: newarr ""System.Index""
IL_0013: dup
IL_0014: ldc.i4.0
IL_0015: ldc.i4.0
IL_0016: ldc.i4.0
IL_0017: newobj ""System.Index..ctor(int, bool)""
IL_001c: stelem ""System.Index""
IL_0021: callvirt ""int Test4.this[params System.Index[]].get""
IL_0026: ldc.i4.1
IL_0027: ceq
IL_0029: ret
IL_002a: ldc.i4.0
IL_002b: ret
}"),
() => verifier.VerifyIL("X.Test5", @"
{
// Code size 25 (0x19)
.maxstack 2
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0017
IL_0003: ldarg.0
IL_0004: callvirt ""int Test5.Length.get""
IL_0009: ldc.i4.1
IL_000a: bne.un.s IL_0017
IL_000c: ldarg.0
IL_000d: ldc.i4.0
IL_000e: callvirt ""int Test5.this[int].get""
IL_0013: ldc.i4.1
IL_0014: ceq
IL_0016: ret
IL_0017: ldc.i4.0
IL_0018: ret
}")
);
}
[Fact]
public void ListPattern_Range()
{
var source = @"
using System;
class Test1
{
public int this[Range i] => 1;
public int this[int i] => throw new();
public int Count => 1;
}
class Test2
{
public int this[Range i, int ignored = 5] => 1;
public int this[int i] => throw new();
public int Count => 1;
}
class Test3
{
public int this[Range i, params int[] ignored] => 1;
public int this[int i] => throw new();
public int Count => 1;
}
class Test4
{
public int this[params Range[] i] => 1;
public int this[int i] => throw new();
public int Count => 1;
}
class Test5
{
public int Slice(int i, int j) => 1;
public int this[int i] => throw new();
public int Count => 1;
}
class X
{
void EnsureTypeIsSliceable()
{
_ = new Test1()[..];
_ = new Test2()[..];
_ = new Test3()[..];
_ = new Test4()[..];
_ = new Test5()[..];
}
static bool Test1(Test1 t) => t is [.. 1];
static bool Test2(Test2 t) => t is [.. 1];
static bool Test3(Test3 t) => t is [.. 1];
static bool Test4(Test4 t) => t is [.. 1];
static bool Test5(Test5 t) => t is [.. 1];
public static void Main()
{
Console.WriteLine(Test1(new()));
Console.WriteLine(Test2(new()));
Console.WriteLine(Test3(new()));
Console.WriteLine(Test4(new()));
Console.WriteLine(Test5(new()));
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
var expectedOutput = @"
True
True
True
True
True
";
var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput);
AssertEx.Multiple(
() => verifier.VerifyIL("X.Test1", @"
{
// Code size 41 (0x29)
.maxstack 4
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0027
IL_0003: ldarg.0
IL_0004: callvirt ""int Test1.Count.get""
IL_0009: pop
IL_000a: ldarg.0
IL_000b: ldc.i4.0
IL_000c: ldc.i4.0
IL_000d: newobj ""System.Index..ctor(int, bool)""
IL_0012: ldc.i4.0
IL_0013: ldc.i4.1
IL_0014: newobj ""System.Index..ctor(int, bool)""
IL_0019: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_001e: callvirt ""int Test1.this[System.Range].get""
IL_0023: ldc.i4.1
IL_0024: ceq
IL_0026: ret
IL_0027: ldc.i4.0
IL_0028: ret
}"),
() => verifier.VerifyIL("X.Test2", @"
{
// Code size 42 (0x2a)
.maxstack 4
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0028
IL_0003: ldarg.0
IL_0004: callvirt ""int Test2.Count.get""
IL_0009: pop
IL_000a: ldarg.0
IL_000b: ldc.i4.0
IL_000c: ldc.i4.0
IL_000d: newobj ""System.Index..ctor(int, bool)""
IL_0012: ldc.i4.0
IL_0013: ldc.i4.1
IL_0014: newobj ""System.Index..ctor(int, bool)""
IL_0019: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_001e: ldc.i4.5
IL_001f: callvirt ""int Test2.this[System.Range, int].get""
IL_0024: ldc.i4.1
IL_0025: ceq
IL_0027: ret
IL_0028: ldc.i4.0
IL_0029: ret
}"),
() => verifier.VerifyIL("X.Test3", @"
{
// Code size 46 (0x2e)
.maxstack 4
IL_0000: ldarg.0
IL_0001: brfalse.s IL_002c
IL_0003: ldarg.0
IL_0004: callvirt ""int Test3.Count.get""
IL_0009: pop
IL_000a: ldarg.0
IL_000b: ldc.i4.0
IL_000c: ldc.i4.0
IL_000d: newobj ""System.Index..ctor(int, bool)""
IL_0012: ldc.i4.0
IL_0013: ldc.i4.1
IL_0014: newobj ""System.Index..ctor(int, bool)""
IL_0019: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_001e: call ""int[] System.Array.Empty<int>()""
IL_0023: callvirt ""int Test3.this[System.Range, params int[]].get""
IL_0028: ldc.i4.1
IL_0029: ceq
IL_002b: ret
IL_002c: ldc.i4.0
IL_002d: ret
}"),
() => verifier.VerifyIL("X.Test4", @"
{
// Code size 54 (0x36)
.maxstack 7
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0034
IL_0003: ldarg.0
IL_0004: callvirt ""int Test4.Count.get""
IL_0009: pop
IL_000a: ldarg.0
IL_000b: ldc.i4.1
IL_000c: newarr ""System.Range""
IL_0011: dup
IL_0012: ldc.i4.0
IL_0013: ldc.i4.0
IL_0014: ldc.i4.0
IL_0015: newobj ""System.Index..ctor(int, bool)""
IL_001a: ldc.i4.0
IL_001b: ldc.i4.1
IL_001c: newobj ""System.Index..ctor(int, bool)""
IL_0021: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_0026: stelem ""System.Range""
IL_002b: callvirt ""int Test4.this[params System.Range[]].get""
IL_0030: ldc.i4.1
IL_0031: ceq
IL_0033: ret
IL_0034: ldc.i4.0
IL_0035: ret
}"),
() => verifier.VerifyIL("X.Test5", @"
{
// Code size 24 (0x18)
.maxstack 3
.locals init (int V_0)
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0016
IL_0003: ldarg.0
IL_0004: callvirt ""int Test5.Count.get""
IL_0009: stloc.0
IL_000a: ldarg.0
IL_000b: ldc.i4.0
IL_000c: ldloc.0
IL_000d: callvirt ""int Test5.Slice(int, int)""
IL_0012: ldc.i4.1
IL_0013: ceq
IL_0015: ret
IL_0016: ldc.i4.0
IL_0017: ret
}
")
);
}
[Fact]
public void ListPattern_CallerInfo()
{
var source = @"
using System;
using System.Runtime.CompilerServices;
class Test1
{
public string this[Index i, [CallerMemberName] string member = null] => member;
public int Count => 1;
}
class Test2
{
public string this[Range i, [CallerMemberName] string member = null] => member;
public int this[int i] => throw new();
public int Count => 1;
}
class Test3
{
public int this[Index i, [CallerLineNumber] int line = 0] => line;
public int Count => 1;
}
class Test4
{
public int this[Range i, [CallerLineNumber] int line = 0] => line;
public int this[int i] => throw new();
public int Count => 1;
}
class X
{
static bool Test1(Test1 t) => t is [nameof(Test1)];
static bool Test2(Test2 t) => t is [.. nameof(Test2)];
#line 42
static bool Test3(Test3 t) => t is [42];
static bool Test4(Test4 t) => t is [.. 43];
public static void Main()
{
Console.WriteLine(Test1(new()));
Console.WriteLine(Test2(new()));
Console.WriteLine(Test3(new()));
Console.WriteLine(Test4(new()));
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
var expectedOutput = @"
True
True
True
True
";
CompileAndVerify(compilation, expectedOutput: expectedOutput);
}
[Theory]
[CombinatorialData]
public void ListPattern_UnsupportedTypes([CombinatorialValues("0", "..", ".._")] string subpattern)
{
var listPattern = $"[{subpattern}]";
var source = @"
class X
{
void M(object o)
{
_ = o is " + listPattern + @";
}
}
";
var expectedDiagnostics = new[]
{
// error CS0021: Cannot apply indexing with [] to an expression of type 'object'
Diagnostic(ErrorCode.ERR_BadIndexLHS, listPattern).WithArguments("object"),
// error CS0021: Cannot apply indexing with [] to an expression of type 'object'
subpattern == ".._" ? Diagnostic(ErrorCode.ERR_BadIndexLHS, subpattern).WithArguments("object") : null
};
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(expectedDiagnostics.WhereNotNull().ToArray());
}
[Fact]
public void ListPattern_MissingMembers_Constructors()
{
var source = @"
using System;
namespace System
{
public struct Index
{
}
public struct Range
{
}
}
class X
{
public int this[Range i] => 1;
public int this[Index i] => 1;
public int Length => 1;
public static void Main()
{
_ = new X() is [1];
_ = new X() is [.. 1];
_ = new X()[^1];
}
}
";
var compilation = CreateCompilation(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(
// (20,24): error CS0656: Missing compiler required member 'System.Index..ctor'
// _ = new X() is [1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[1]").WithArguments("System.Index", ".ctor").WithLocation(20, 24),
// (21,24): error CS0656: Missing compiler required member 'System.Index..ctor'
// _ = new X() is [.. 1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[.. 1]").WithArguments("System.Index", ".ctor").WithLocation(21, 24),
// (21,25): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = new X() is [.. 1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. 1").WithArguments("System.Range", ".ctor").WithLocation(21, 25),
// (22,21): error CS0656: Missing compiler required member 'System.Index..ctor'
// _ = new X()[^1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "^1").WithArguments("System.Index", ".ctor").WithLocation(22, 21)
);
}
[Fact]
public void ListPattern_MissingMembers_ArrayLength()
{
var source = @"
class X
{
public void M(int[] a)
{
_ = a is [0];
_ = a is [.._];
_ = a[^1];
_ = a[..];
}
}
" + TestSources.GetSubArray;
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.MakeMemberMissing(SpecialMember.System_Array__Length);
compilation.VerifyEmitDiagnostics(
// (6,18): error CS0656: Missing compiler required member 'System.Array.Length'
// _ = a is [0];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[0]").WithArguments("System.Array", "Length").WithLocation(6, 18),
// (7,18): error CS0656: Missing compiler required member 'System.Array.Length'
// _ = a is [.._];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[.._]").WithArguments("System.Array", "Length").WithLocation(7, 18));
}
[Fact]
public void ListPattern_MissingMembers_IndexCtor()
{
var source = @"
class X
{
public int Length => throw null;
public int this[System.Index i] => throw null;
public int this[System.Range r] => throw null;
public void M()
{
_ = this is [0];
_ = this is [.., 0];
_ = this[^1];
_ = this[..];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.MakeMemberMissing(WellKnownMember.System_Index__ctor);
compilation.VerifyEmitDiagnostics(
// (10,21): error CS0656: Missing compiler required member 'System.Index..ctor'
// _ = this is [0];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[0]").WithArguments("System.Index", ".ctor").WithLocation(10, 21),
// (11,21): error CS0656: Missing compiler required member 'System.Index..ctor'
// _ = this is [.., 0];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[.., 0]").WithArguments("System.Index", ".ctor").WithLocation(11, 21),
// (12,18): error CS0656: Missing compiler required member 'System.Index..ctor'
// _ = this[^1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "^1").WithArguments("System.Index", ".ctor").WithLocation(12, 18)
);
}
[Fact]
public void ListPattern_MissingMembers_RangeCtor()
{
var source = @"
class X
{
public int Length => throw null;
public int this[System.Index i] => throw null;
public int this[System.Range r] => throw null;
public void M()
{
_ = this is [0];
_ = this is [.._];
_ = this is [0, .._];
_ = this is [.._, 0];
_ = this is [0, .._, 0];
_ = this[^1];
_ = this[..];
_ = this[1..];
_ = this[..^1];
_ = this[1..^1];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.MakeMemberMissing(WellKnownMember.System_Range__ctor);
compilation.MakeMemberMissing(WellKnownMember.System_Range__get_All);
compilation.MakeMemberMissing(WellKnownMember.System_Range__StartAt);
compilation.MakeMemberMissing(WellKnownMember.System_Range__EndAt);
// Note: slice patterns always use range expressions with start and end.
// But range syntax binds differently depending whether start/end are there and depending on what members are available.
compilation.VerifyEmitDiagnostics(
// (12,22): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this is [.._];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".._").WithArguments("System.Range", ".ctor").WithLocation(12, 22),
// (13,25): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this is [0, .._];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".._").WithArguments("System.Range", ".ctor").WithLocation(13, 25),
// (14,22): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this is [.._, 0];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".._").WithArguments("System.Range", ".ctor").WithLocation(14, 22),
// (15,25): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this is [0, .._, 0];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".._").WithArguments("System.Range", ".ctor").WithLocation(15, 25),
// (19,18): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this[..];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "..").WithArguments("System.Range", ".ctor").WithLocation(19, 18),
// (20,18): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this[1..];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "1..").WithArguments("System.Range", ".ctor").WithLocation(20, 18),
// (21,18): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this[..^1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "..^1").WithArguments("System.Range", ".ctor").WithLocation(21, 18),
// (22,18): error CS0656: Missing compiler required member 'System.Range..ctor'
// _ = this[1..^1];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "1..^1").WithArguments("System.Range", ".ctor").WithLocation(22, 18)
);
}
[Fact]
public void ListPattern_MissingMembers_Substring()
{
var source = @"
class X
{
public void M(string s)
{
_ = s is [.. var slice];
_ = s[..];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.MakeMemberMissing(SpecialMember.System_String__Substring);
compilation.VerifyEmitDiagnostics(
// (6,19): error CS0656: Missing compiler required member 'System.String.Substring'
// _ = s is [.. var slice];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. var slice").WithArguments("System.String", "Substring").WithLocation(6, 19),
// (6,19): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = s is [.. var slice];
Diagnostic(ErrorCode.ERR_BadArgType, ".. var slice").WithArguments("1", "System.Range", "int").WithLocation(6, 19),
// (7,13): error CS0656: Missing compiler required member 'System.String.Substring'
// _ = s[..];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "s[..]").WithArguments("System.String", "Substring").WithLocation(7, 13),
// (7,15): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = s[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(7, 15)
);
}
[Fact]
public void ListPattern_MissingMembers_GetSubArray_01()
{
var source = @"
class X
{
public void M(int[] a)
{
_ = a is [.. var slice];
_ = a[..];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(
// (6,19): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray'
// _ = a is [.. var slice];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. var slice").WithArguments("System.Runtime.CompilerServices.RuntimeHelpers", "GetSubArray").WithLocation(6, 19),
// (7,15): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray'
// _ = a[..];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "..").WithArguments("System.Runtime.CompilerServices.RuntimeHelpers", "GetSubArray").WithLocation(7, 15)
);
}
[Fact]
public void ListPattern_MissingMembers_GetSubArray_02()
{
var source = @"
class X
{
public void M(int[] a)
{
_ = a is [.. var slice];
_ = a[..];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(
// (6,19): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray'
// _ = a is [.. var slice];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. var slice").WithArguments("System.Runtime.CompilerServices.RuntimeHelpers", "GetSubArray").WithLocation(6, 19),
// (7,15): error CS0656: Missing compiler required member 'System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray'
// _ = a[..];
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "..").WithArguments("System.Runtime.CompilerServices.RuntimeHelpers", "GetSubArray").WithLocation(7, 15)
);
}
[Fact]
public void ListPattern_ObsoleteMembers()
{
var source = @"
using System;
class Test1
{
[Obsolete(""error1"", error: true)]
public int Slice(int i, int j) => 0;
[Obsolete(""error2"", error: true)]
public int this[int i] => 0;
[Obsolete(""error3"", error: true)]
public int Count => 0;
}
class Test2
{
[Obsolete(""error4"", error: true)]
public int this[Index i] => 0;
[Obsolete(""error5"", error: true)]
public int this[Range i] => 0;
[Obsolete(""error6"", error: true)]
public int Length => 0;
}
class X
{
public void M()
{
_ = new Test1() is [0];
_ = new Test1() is [..0];
_ = new Test2() is [0];
_ = new Test2() is [..0];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(
// (25,28): error CS0619: 'Test1.Count' is obsolete: 'error3'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test1.Count", "error3").WithLocation(25, 28),
// (25,28): error CS0619: 'Test1.Count' is obsolete: 'error3'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test1.Count", "error3").WithLocation(25, 28),
// (25,28): error CS0619: 'Test1.this[int]' is obsolete: 'error2'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test1.this[int]", "error2").WithLocation(25, 28),
// (26,28): error CS0619: 'Test1.Count' is obsolete: 'error3'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test1.Count", "error3").WithLocation(26, 28),
// (26,28): error CS0619: 'Test1.Count' is obsolete: 'error3'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test1.Count", "error3").WithLocation(26, 28),
// (26,28): error CS0619: 'Test1.this[int]' is obsolete: 'error2'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test1.this[int]", "error2").WithLocation(26, 28),
// (26,29): error CS0619: 'Test1.Count' is obsolete: 'error3'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Test1.Count", "error3").WithLocation(26, 29),
// (26,29): error CS0619: 'Test1.Slice(int, int)' is obsolete: 'error1'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Test1.Slice(int, int)", "error1").WithLocation(26, 29),
// (27,28): error CS0619: 'Test2.Length' is obsolete: 'error6'
// _ = new Test2() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test2.Length", "error6").WithLocation(27, 28),
// (27,28): error CS0619: 'Test2.this[Index]' is obsolete: 'error4'
// _ = new Test2() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test2.this[System.Index]", "error4").WithLocation(27, 28),
// (28,28): error CS0619: 'Test2.Length' is obsolete: 'error6'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test2.Length", "error6").WithLocation(28, 28),
// (28,28): error CS0619: 'Test2.this[Index]' is obsolete: 'error4'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test2.this[System.Index]", "error4").WithLocation(28, 28),
// (28,29): error CS0619: 'Test2.this[Range]' is obsolete: 'error5'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Test2.this[System.Range]", "error5").WithLocation(28, 29)
);
}
[Fact]
public void ListPattern_ObsoleteAccessors()
{
var source = @"
using System;
class Test1
{
[Obsolete(""error1"", error: true)]
public int Slice(int i, int j) => 0;
public int this[int i]
{
[Obsolete(""error1"", error: true)]
get => 0;
}
public int Count
{
[Obsolete(""error2"", error: true)]
get => 0;
}
}
class Test2
{
public int this[Index i]
{
[Obsolete(""error3"", error: true)]
get => 0;
}
public int this[Range i]
{
[Obsolete(""error4"", error: true)]
get => 0;
}
public int Length
{
[Obsolete(""error5"", error: true)]
get => 0;
}
}
class X
{
public void M()
{
_ = new Test1() is [0];
_ = new Test1()[^1];
_ = new Test1() is [..0];
_ = new Test1()[..0];
_ = new Test2() is [0];
_ = new Test2()[^1];
_ = new Test2() is [..0];
_ = new Test2()[..0];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (40,28): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test1.Count.get", "error2").WithLocation(40, 28),
// (40,28): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test1.Count.get", "error2").WithLocation(40, 28),
// (40,28): error CS0619: 'Test1.this[int].get' is obsolete: 'error1'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test1.this[int].get", "error1").WithLocation(40, 28),
// (41,13): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[^1]").WithArguments("Test1.Count.get", "error2").WithLocation(41, 13),
// (41,13): error CS0619: 'Test1.this[int].get' is obsolete: 'error1'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[^1]").WithArguments("Test1.this[int].get", "error1").WithLocation(41, 13),
// (43,28): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test1.Count.get", "error2").WithLocation(43, 28),
// (43,28): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test1.Count.get", "error2").WithLocation(43, 28),
// (43,28): error CS0619: 'Test1.this[int].get' is obsolete: 'error1'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test1.this[int].get", "error1").WithLocation(43, 28),
// (43,29): error CS0619: 'Test1.Slice(int, int)' is obsolete: 'error1'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Test1.Slice(int, int)", "error1").WithLocation(43, 29),
// (43,29): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Test1.Count.get", "error2").WithLocation(43, 29),
// (44,13): error CS0619: 'Test1.Slice(int, int)' is obsolete: 'error1'
// _ = new Test1()[..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[..0]").WithArguments("Test1.Slice(int, int)", "error1").WithLocation(44, 13),
// (44,13): error CS0619: 'Test1.Count.get' is obsolete: 'error2'
// _ = new Test1()[..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[..0]").WithArguments("Test1.Count.get", "error2").WithLocation(44, 13),
// (46,28): error CS0619: 'Test2.Length.get' is obsolete: 'error5'
// _ = new Test2() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test2.Length.get", "error5").WithLocation(46, 28),
// (46,28): error CS0619: 'Test2.this[Index].get' is obsolete: 'error3'
// _ = new Test2() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Test2.this[System.Index].get", "error3").WithLocation(46, 28),
// (47,13): error CS0619: 'Test2.this[Index].get' is obsolete: 'error3'
// _ = new Test2()[^1];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test2()[^1]").WithArguments("Test2.this[System.Index].get", "error3").WithLocation(47, 13),
// (49,28): error CS0619: 'Test2.Length.get' is obsolete: 'error5'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test2.Length.get", "error5").WithLocation(49, 28),
// (49,28): error CS0619: 'Test2.this[Index].get' is obsolete: 'error3'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Test2.this[System.Index].get", "error3").WithLocation(49, 28),
// (49,29): error CS0619: 'Test2.this[Range].get' is obsolete: 'error4'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Test2.this[System.Range].get", "error4").WithLocation(49, 29),
// (50,13): error CS0619: 'Test2.this[Range].get' is obsolete: 'error4'
// _ = new Test2()[..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test2()[..0]").WithArguments("Test2.this[System.Range].get", "error4").WithLocation(50, 13)
);
}
[Fact]
public void ListPattern_ObsoleteAccessors_OnBase()
{
var source = @"
using System;
class Base1
{
[Obsolete(""error1"", error: true)]
public int Slice(int i, int j) => 0;
public virtual int this[int i]
{
[Obsolete(""error2"", error: true)]
get => 0;
set { }
}
public virtual int Count
{
[Obsolete(""error3"", error: true)]
get => 0;
set { }
}
}
class Test1 : Base1
{
public override int this[int i]
{
set { }
}
public override int Count
{
set { }
}
}
class Base2
{
public virtual int this[Index i]
{
[Obsolete(""error4"", error: true)]
get => 0;
set { }
}
public virtual int this[Range i]
{
[Obsolete(""error5"", error: true)]
get => 0;
set { }
}
public virtual int Length
{
[Obsolete(""error6"", error: true)]
get => 0;
set { }
}
}
class Test2 : Base2
{
public override int this[Index i]
{
set { }
}
public override int this[Range i]
{
set { }
}
public override int Length
{
set { }
}
}
class X
{
public void M()
{
_ = new Test1() is [0];
_ = new Test1() is [..0];
_ = new Test2() is [0];
_ = new Test2() is [..0];
_ = new Test1()[^1];
_ = new Test1()[..0];
_ = new Test2()[^1];
_ = new Test2()[..0];
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (73,28): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Base1.Count.get", "error3").WithLocation(73, 28),
// (73,28): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Base1.Count.get", "error3").WithLocation(73, 28),
// (73,28): error CS0619: 'Base1.this[int].get' is obsolete: 'error2'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Base1.this[int].get", "error2").WithLocation(73, 28),
// (74,28): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Base1.Count.get", "error3").WithLocation(74, 28),
// (74,28): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Base1.Count.get", "error3").WithLocation(74, 28),
// (74,28): error CS0619: 'Base1.this[int].get' is obsolete: 'error2'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Base1.this[int].get", "error2").WithLocation(74, 28),
// (74,29): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Base1.Count.get", "error3").WithLocation(74, 29),
// (74,29): error CS0619: 'Base1.Slice(int, int)' is obsolete: 'error1'
// _ = new Test1() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Base1.Slice(int, int)", "error1").WithLocation(74, 29),
// (75,28): error CS0619: 'Base2.Length.get' is obsolete: 'error6'
// _ = new Test2() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Base2.Length.get", "error6").WithLocation(75, 28),
// (75,28): error CS0619: 'Base2.this[Index].get' is obsolete: 'error4'
// _ = new Test2() is [0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[0]").WithArguments("Base2.this[System.Index].get", "error4").WithLocation(75, 28),
// (76,28): error CS0619: 'Base2.Length.get' is obsolete: 'error6'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Base2.Length.get", "error6").WithLocation(76, 28),
// (76,28): error CS0619: 'Base2.this[Index].get' is obsolete: 'error4'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "[..0]").WithArguments("Base2.this[System.Index].get", "error4").WithLocation(76, 28),
// (76,29): error CS0619: 'Base2.this[Range].get' is obsolete: 'error5'
// _ = new Test2() is [..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "..0").WithArguments("Base2.this[System.Range].get", "error5").WithLocation(76, 29),
// (78,13): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[^1]").WithArguments("Base1.Count.get", "error3").WithLocation(78, 13),
// (78,13): error CS0619: 'Base1.this[int].get' is obsolete: 'error2'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[^1]").WithArguments("Base1.this[int].get", "error2").WithLocation(78, 13),
// (79,13): error CS0619: 'Base1.Count.get' is obsolete: 'error3'
// _ = new Test1()[..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[..0]").WithArguments("Base1.Count.get", "error3").WithLocation(79, 13),
// (79,13): error CS0619: 'Base1.Slice(int, int)' is obsolete: 'error1'
// _ = new Test1()[..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test1()[..0]").WithArguments("Base1.Slice(int, int)", "error1").WithLocation(79, 13),
// (80,13): error CS0619: 'Base2.this[Index].get' is obsolete: 'error4'
// _ = new Test2()[^1];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test2()[^1]").WithArguments("Base2.this[System.Index].get", "error4").WithLocation(80, 13),
// (81,13): error CS0619: 'Base2.this[Range].get' is obsolete: 'error5'
// _ = new Test2()[..0];
Diagnostic(ErrorCode.ERR_DeprecatedSymbolStr, "new Test2()[..0]").WithArguments("Base2.this[System.Range].get", "error5").WithLocation(81, 13)
);
}
[Fact]
public void SlicePattern_Misplaced()
{
var source = @"
class X
{
public void M(int[] a)
{
_ = a is [.., ..];
_ = a is [1, .., 2, .., 3];
_ = a is [(..)];
_ = a is ..;
_ = a is [..];
_ = a switch { .. => 0, _ => 0 };
switch (a) { case ..: break; }
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(
// (6,23): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = a is [.., ..];
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(6, 23),
// (7,29): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = a is [1, .., 2, .., 3];
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(7, 29),
// (8,20): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = a is [(..)];
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(8, 20),
// (9,18): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = a is ..;
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(9, 18),
// (11,24): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// _ = a switch { .. => 0, _ => 0 };
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(11, 24),
// (12,27): error CS9002: Slice patterns may only be used once and directly inside a list pattern.
// switch (a) { case ..: break; }
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(12, 27)
);
}
[Fact]
public void SlicePattern_NullValue()
{
var source = @"
#nullable enable
class C
{
public int Length => 3;
public int this[int i] => 0;
public int[]? Slice(int i, int j) => null;
public static void Main()
{
if (new C() is [.. var s0] && s0 == null)
System.Console.Write(1);
if (new C() is [.. null])
System.Console.Write(2);
if (new C() is not [.. {}])
System.Console.Write(3);
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
CompileAndVerify(compilation, expectedOutput: "12");
}
[Fact]
public void ListPattern_MemberLookup_StaticIndexer()
{
var vbSource = @"
Namespace System
Public Structure Index
Public Sub New(ByVal value As Integer, ByVal Optional fromEnd As Boolean = False)
End Sub
Public Shared Widening Operator CType(ByVal i As Integer) As Index
Return Nothing
End Operator
End Structure
End Namespace
Public Class Test1
Public Shared ReadOnly Property Item(i As System.Index) As Integer
Get
Return 0
End Get
End Property
Public Property Length As Integer = 0
End Class
";
var csSource = @"
class X
{
public static void Main()
{
_ = new Test1() is [0];
_ = new Test1()[0];
}
}
";
var vbCompilation = CreateVisualBasicCompilation(vbSource);
var csCompilation = CreateCompilation(csSource, references: new[] { vbCompilation.EmitToImageReference() });
// Note: the VB indexer's name is "Item" but C# looks for "this[]", but we can't put Default on Shared indexer declaration
csCompilation.VerifyEmitDiagnostics(
// (6,28): error CS0021: Cannot apply indexing with [] to an expression of type 'Test1'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "[0]").WithArguments("Test1").WithLocation(6, 28),
// (7,13): error CS0021: Cannot apply indexing with [] to an expression of type 'Test1'
// _ = new Test1()[0];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "new Test1()[0]").WithArguments("Test1").WithLocation(7, 13));
}
[Fact]
public void ListPattern_MemberLookup_StaticDefaultIndexer()
{
var ilSource = @"
.class public sequential ansi sealed System.Index
extends [mscorlib]System.ValueType
{
.method public specialname rtspecialname instance void .ctor ( int32 'value', [opt] bool fromEnd ) cil managed
{
.param [2] = bool(false)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: initobj System.Index
IL_0008: ret
}
.method public specialname static valuetype System.Index op_Implicit ( int32 i ) cil managed
{
.locals init (
[0] valuetype System.Index
)
IL_0000: nop
IL_0001: ldloca.s 0
IL_0003: initobj System.Index
IL_0009: br.s IL_000b
IL_000b: ldloc.0
IL_000c: ret
}
}
.class public auto ansi Test1
extends [mscorlib]System.Object
{
.custom instance void [mscorlib]System.Reflection.DefaultMemberAttribute::.ctor(string) = (
01 00 04 49 74 65 6d 00 00
)
.field private int32 _Length
.method public specialname rtspecialname instance void .ctor () cil managed
{
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ldarg.0
IL_0008: ldc.i4.0
IL_0009: call instance void Test1::set_Length(int32)
IL_000e: nop
IL_000f: ret
}
.method public specialname static int32 get_Item ( valuetype System.Index i ) cil managed
{
.locals init (
[0] int32 Item
)
IL_0000: nop
IL_0001: ldc.i4.0
IL_0002: stloc.0
IL_0003: br.s IL_0005
IL_0005: ldloc.0
IL_0006: ret
}
.method public specialname instance int32 get_Length () cil managed
{
IL_0000: ldarg.0
IL_0001: ldfld int32 Test1::_Length
IL_0006: br.s IL_0008
IL_0008: ret
}
.method public specialname instance void set_Length ( int32 AutoPropertyValue ) cil managed
{
IL_0000: ldarg.0
IL_0001: ldarg.1
IL_0002: stfld int32 Test1::_Length
IL_0007: ret
}
.property int32 Item( valuetype System.Index i )
{
.get int32 Test1::get_Item(valuetype System.Index)
}
.property instance int32 Length()
{
.get instance int32 Test1::get_Length()
.set instance void Test1::set_Length(int32)
}
}
";
var csSource = @"
System.Console.Write((new Test1() is [42], new Test1()[0]));
";
var csCompilation = CreateCompilationWithIL(csSource, ilSource);
csCompilation.VerifyEmitDiagnostics(
// (2,38): error CS0176: Member 'Test1.this[Index]' cannot be accessed with an instance reference; qualify it with a type name instead
// System.Console.Write((new Test1() is [42], new Test1()[0]));
Diagnostic(ErrorCode.ERR_ObjectProhibited, "[42]").WithArguments("Test1.this[System.Index]").WithLocation(2, 38),
// (2,44): error CS0176: Member 'Test1.this[Index]' cannot be accessed with an instance reference; qualify it with a type name instead
// System.Console.Write((new Test1() is [42], new Test1()[0]));
Diagnostic(ErrorCode.ERR_ObjectProhibited, "new Test1()[0]").WithArguments("Test1.this[System.Index]").WithLocation(2, 44)
);
}
[Fact]
public void ListPattern_MemberLookup_DefaultIndexerWithDifferentName()
{
var vbSource = @"
Namespace System
Public Structure Index
Public Sub New(ByVal value As Integer, ByVal Optional fromEnd As Boolean = False)
End Sub
Public Shared Widening Operator CType(ByVal i As Integer) As Index
Return Nothing
End Operator
End Structure
End Namespace
Public Class Test1
Public Default ReadOnly Property Name(i As System.Index) As Integer
Get
Return 42
End Get
End Property
Public Property Length As Integer = 1
End Class
";
var csSource = @"
System.Console.Write((new Test1() is [42], new Test1()[0]));
";
var vbCompilation = CreateVisualBasicCompilation(vbSource);
var csCompilation = CreateCompilation(csSource, references: new[] { vbCompilation.EmitToImageReference() });
CompileAndVerify(csCompilation, expectedOutput: "(True, 42)").VerifyDiagnostics();
}
[Fact]
public void ListPattern_MemberLookup_NonDefaultIndexerNamedItem()
{
var vbSource = @"
Namespace System
Public Structure Index
Public Sub New(ByVal value As Integer, ByVal Optional fromEnd As Boolean = False)
End Sub
Public Shared Widening Operator CType(ByVal i As Integer) As Index
Return Nothing
End Operator
End Structure
End Namespace
Public Class Test1
Public ReadOnly Property Item(i As System.Index) As Integer
Get
Return 0
End Get
End Property
Public Property Length As Integer = 0
End Class
";
var csSource = @"
System.Console.Write((new Test1() is [42], new Test1()[0]));
";
var vbCompilation = CreateVisualBasicCompilation(vbSource);
var csCompilation = CreateCompilation(csSource, references: new[] { vbCompilation.EmitToImageReference() });
csCompilation.VerifyEmitDiagnostics(
// (2,38): error CS0021: Cannot apply indexing with [] to an expression of type 'Test1'
// System.Console.Write((new Test1() is [42], new Test1()[0]));
Diagnostic(ErrorCode.ERR_BadIndexLHS, "[42]").WithArguments("Test1").WithLocation(2, 38),
// (2,44): error CS0021: Cannot apply indexing with [] to an expression of type 'Test1'
// System.Console.Write((new Test1() is [42], new Test1()[0]));
Diagnostic(ErrorCode.ERR_BadIndexLHS, "new Test1()[0]").WithArguments("Test1").WithLocation(2, 44)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_1()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
public int this[Index i] { set {} }
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS0154: The property or indexer 'Test1.this[Index]' cannot be used in this context because it lacks the get accessor
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "[0]").WithArguments("Test1.this[System.Index]").WithLocation(4, 20),
// (5,5): error CS0154: The property or indexer 'Test1.this[Index]' cannot be used in this context because it lacks the get accessor
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "new Test1()[^1]").WithArguments("Test1.this[System.Index]").WithLocation(5, 5)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_2()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
public int this[Index i] { private get => 0; set {} }
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS0271: The property or indexer 'Test1.this[Index]' cannot be used in this context because the get accessor is inaccessible
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_InaccessibleGetter, "[0]").WithArguments("Test1.this[System.Index]").WithLocation(4, 20),
// (5,5): error CS0271: The property or indexer 'Test1.this[Index]' cannot be used in this context because the get accessor is inaccessible
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_InaccessibleGetter, "new Test1()[^1]").WithArguments("Test1.this[System.Index]").WithLocation(5, 5)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_3()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
public int this[int i, int ignored = 0] => 0;
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_BadArgType, "[0]").WithArguments("1", "System.Index", "int").WithLocation(4, 20),
// (5,17): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(5, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_4()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
public int this[long i, int ignored = 0] => 0;
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS1503: Argument 1: cannot convert from 'System.Index' to 'long'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_BadArgType, "[0]").WithArguments("1", "System.Index", "long").WithLocation(4, 20),
// (5,17): error CS1503: Argument 1: cannot convert from 'System.Index' to 'long'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "long").WithLocation(5, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_5()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
public int this[long i] => 0;
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS1503: Argument 1: cannot convert from 'System.Index' to 'long'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_BadArgType, "[0]").WithArguments("1", "System.Index", "long").WithLocation(4, 20),
// (5,17): error CS1503: Argument 1: cannot convert from 'System.Index' to 'long'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "long").WithLocation(5, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_6()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
public int this[params int[] i] => 0;
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_BadArgType, "[0]").WithArguments("1", "System.Index", "int").WithLocation(4, 20),
// (5,17): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(5, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Index_ErrorCases_7()
{
var source = @"
using System;
_ = new Test1() is [0];
_ = new Test1()[^1];
class Test1
{
private int this[Index i] => 0;
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,20): error CS0122: 'Test1.this[Index]' is inaccessible due to its protection level
// _ = new Test1() is [0];
Diagnostic(ErrorCode.ERR_BadAccess, "[0]").WithArguments("Test1.this[System.Index]").WithLocation(4, 20),
// (5,5): error CS0122: 'Test1.this[Index]' is inaccessible due to its protection level
// _ = new Test1()[^1];
Diagnostic(ErrorCode.ERR_BadAccess, "new Test1()[^1]").WithArguments("Test1.this[System.Index]").WithLocation(5, 5)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_1()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public int this[Range i] { set {} }
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS0154: The property or indexer 'Test1.this[Range]' cannot be used in this context because it lacks the get accessor
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "..var p").WithArguments("Test1.this[System.Range]").WithLocation(4, 21),
// (6,5): error CS0154: The property or indexer 'Test1.this[Range]' cannot be used in this context because it lacks the get accessor
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "new Test1()[..]").WithArguments("Test1.this[System.Range]").WithLocation(6, 5)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_2()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public int this[Range i] { private get => 0; set {} }
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS0271: The property or indexer 'Test1.this[Range]' cannot be used in this context because the get accessor is inaccessible
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_InaccessibleGetter, "..var p").WithArguments("Test1.this[System.Range]").WithLocation(4, 21),
// (6,5): error CS0271: The property or indexer 'Test1.this[Range]' cannot be used in this context because the get accessor is inaccessible
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_InaccessibleGetter, "new Test1()[..]").WithArguments("Test1.this[System.Range]").WithLocation(6, 5)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_3()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public int Slice(int i, int j, int ignored = 0) => 0;
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_BadArgType, "..var p").WithArguments("1", "System.Range", "int").WithLocation(4, 21),
// (6,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(6, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_4()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public int Slice(int i, int j, params int[] ignored) => 0;
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_BadArgType, "..var p").WithArguments("1", "System.Range", "int").WithLocation(4, 21),
// (6,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(6, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_5()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public int Slice(long i, long j) => 0;
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_BadArgType, "..var p").WithArguments("1", "System.Range", "int").WithLocation(4, 21),
// (6,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(6, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_6()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public int Slice(params int[] i) => 0;
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_BadArgType, "..var p").WithArguments("1", "System.Range", "int").WithLocation(4, 21),
// (6,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(6, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_7()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
private int Slice(int i, int j) => 0;
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_BadArgType, "..var p").WithArguments("1", "System.Range", "int").WithLocation(4, 21),
// (6,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(6, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_Range_ErrorCases_8()
{
var source = @"
using System;
_ = new Test1() is [..var p];
_ = new Test1() is [..];
_ = new Test1()[..];
class Test1
{
public void Slice(int i, int j) {}
public int this[int i] => throw new();
public int Length => 0;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (4,21): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1() is [..var p];
Diagnostic(ErrorCode.ERR_BadArgType, "..var p").WithArguments("1", "System.Range", "int").WithLocation(4, 21),
// (6,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new Test1()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(6, 17)
);
}
[Fact]
public void ListPattern_MemberLookup_OverridenIndexer()
{
var source = @"
using System;
class Test1
{
public virtual int this[Index i] => 1;
public virtual int Count => 1;
}
class Test2 : Test1
{
}
class Test3 : Test2
{
public override int this[Index i] => 2;
public override int Count => 2;
}
class X
{
public static void Main()
{
Console.WriteLine(new Test1() is [1]);
Console.WriteLine(new Test2() is [1]);
Console.WriteLine(new Test3() is [1]);
Console.WriteLine(new Test1() is [2, 2]);
Console.WriteLine(new Test2() is [2, 2]);
Console.WriteLine(new Test3() is [2, 2]);
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
string expectedOutput = @"
True
True
False
False
False
True";
CompileAndVerify(compilation, expectedOutput: expectedOutput);
}
[Fact]
public void ListPattern_MemberLookup_Fallback_InaccessibleIndexer()
{
var source = @"
using System;
class Test1
{
private int this[Index i] => throw new();
private int this[Range i] => throw new();
private int Length => throw new();
public int this[int i] => 1;
public int Slice(int i, int j) => 2;
public int Count => 1;
}
class X
{
public static void Main()
{
Console.WriteLine(new Test1() is [1, ..2]);
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
CompileAndVerify(compilation, expectedOutput: "True");
}
[Fact]
public void ListPattern_RefReturns()
{
var source = @"
using System;
class Test1
{
int value = 1;
public ref int this[Index i] => ref value;
public ref int this[Range i] => ref value;
public int Count => 1;
}
class X
{
public static void Main()
{
Console.WriteLine(new Test1() is [1] and [..1]);
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
var verifier = CompileAndVerify(compilation, expectedOutput: "True");
verifier.VerifyIL("X.Main", @"
{
// Code size 73 (0x49)
.maxstack 4
.locals init (Test1 V_0)
IL_0000: newobj ""Test1..ctor()""
IL_0005: stloc.0
IL_0006: ldloc.0
IL_0007: brfalse.s IL_0042
IL_0009: ldloc.0
IL_000a: callvirt ""int Test1.Count.get""
IL_000f: ldc.i4.1
IL_0010: bne.un.s IL_0042
IL_0012: ldloc.0
IL_0013: ldc.i4.0
IL_0014: ldc.i4.0
IL_0015: newobj ""System.Index..ctor(int, bool)""
IL_001a: callvirt ""ref int Test1.this[System.Index].get""
IL_001f: ldind.i4
IL_0020: ldc.i4.1
IL_0021: bne.un.s IL_0042
IL_0023: ldloc.0
IL_0024: ldc.i4.0
IL_0025: ldc.i4.0
IL_0026: newobj ""System.Index..ctor(int, bool)""
IL_002b: ldc.i4.0
IL_002c: ldc.i4.1
IL_002d: newobj ""System.Index..ctor(int, bool)""
IL_0032: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_0037: callvirt ""ref int Test1.this[System.Range].get""
IL_003c: ldind.i4
IL_003d: ldc.i4.1
IL_003e: ceq
IL_0040: br.s IL_0043
IL_0042: ldc.i4.0
IL_0043: call ""void System.Console.WriteLine(bool)""
IL_0048: ret
}");
}
[Fact]
public void SlicePattern_SliceValue()
{
var source = @"
using System;
class X
{
public static void Main()
{
var arr = new[] { 1, 2, 3, 4 };
if (arr is [.. var start, _])
Console.WriteLine(string.Join("", "", start));
if (arr is [_, .. var end])
Console.WriteLine(string.Join("", "", end));
if (arr is [_, .. var middle, _])
Console.WriteLine(string.Join("", "", middle));
if (arr is [.. var all])
Console.WriteLine(string.Join("", "", all));
}
}
" + TestSources.GetSubArray;
var compilation = CreateCompilationWithIndexAndRangeAndSpan(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
string expectedOutput = @"
1, 2, 3
2, 3, 4
2, 3
1, 2, 3, 4";
CompileAndVerify(compilation, expectedOutput: expectedOutput);
}
[Fact]
public void SlicePattern_Subpattern()
{
var source = @"
using System;
class C
{
private int length;
public C(int length) => this.length = length;
public int this[int i] => 1;
public int Slice(int i, int j) => throw new();
public int Length { get { Console.WriteLine(nameof(Length)); return length; } }
}
class X
{
public static bool Test1(C c) => c is [..];
public static bool Test2(C c) => c is [.._];
public static void Main()
{
Console.WriteLine(Test1(null));
Console.WriteLine(Test2(null));
Console.WriteLine(Test1(new(-1)));
Console.WriteLine(Test1(new(0)));
Console.WriteLine(Test1(new(1)));
Console.WriteLine(Test2(new(-1)));
Console.WriteLine(Test2(new(0)));
Console.WriteLine(Test2(new(1)));
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
string expectedOutput = @"
False
False
True
True
True
Length
True
Length
True
Length
True
";
var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput);
AssertEx.Multiple(
() => verifier.VerifyIL("X.Test1", @"
{
// Code size 5 (0x5)
.maxstack 2
IL_0000: ldarg.0
IL_0001: ldnull
IL_0002: cgt.un
IL_0004: ret
}"),
() => verifier.VerifyIL("X.Test2", @"
{
// Code size 14 (0xe)
.maxstack 1
IL_0000: ldarg.0
IL_0001: brfalse.s IL_000c
IL_0003: ldarg.0
IL_0004: callvirt ""int C.Length.get""
IL_0009: pop
IL_000a: ldc.i4.1
IL_000b: ret
IL_000c: ldc.i4.0
IL_000d: ret
}")
);
}
[Fact]
public void ListPattern_OrderOfEvaluation()
{
var source = @"
using System;
class X
{
int this[int i]
{
get
{
Console.Write(i);
return i;
}
}
int Count
{
get
{
Console.Write(-1);
return 3;
}
}
public static void Main()
{
Console.Write(new X() is [0, 1, 2] ? 1 : 0);
}
}
";
var compilation = CreateCompilationWithIndexAndRangeAndSpan(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
CompileAndVerify(compilation, expectedOutput: "-10121");
}
[Theory]
[InlineData(
"{ null, null, new(0, 0) }",
"[..{ Length: >=2 }, { X: 0, Y: 0 }]",
"e.Length, e[0..^1], e[0..^1].Length, e[^1], e[^1].X, e[^1].Y, True")]
[InlineData(
"{ null, null, new(0, 0) }",
"[.., { X: 0, Y: 0 }]",
"e.Length, e[^1], e[^1].X, e[^1].Y, True")]
[InlineData(
"{ new(0, 5) }",
"[.., { X:0, Y:0 }] or [{ X:0, Y:5 }]",
"e.Length, e[^1], e[^1].X, e[^1].Y, e[0], e[0].X, e[0].Y, True")]
[InlineData(
"{ new(0, 1), new(0, 5) }",
"[.., { X:0, Y:0 }] or [{ X:0, Y:5 }]",
"e.Length, e[^1], e[^1].X, e[^1].Y, False")]
[InlineData(
"{ null, new(0, 5) }",
"[.., { X:0, Y:0 }] or [{ X:0, Y:5 }]",
"e.Length, e[^1], e[^1].X, e[^1].Y, False")]
public void SlicePattern_OrderOfEvaluation(string array, string pattern, string expectedOutput)
{
var source = @"
using static System.Console;
Write(new MyArray(new MyPoint[] " + array + @") is " + pattern + @");
class MyPoint
{
public Point point;
public string source;
public MyPoint(int x, int y) : this(new(x, y)) { }
public MyPoint(Point point, string source = ""e"") => (this.point, this.source) = (point, source);
public int X { get { Write($""{source}.{nameof(X)}, ""); return point.X; } }
public int Y { get { Write($""{source}.{nameof(Y)}, ""); return point.Y; } }
}
class MyArray
{
public MyPoint[] array;
public string source;
public MyArray(MyPoint[] array, string source = ""e"") => (this.array, this.source) = (array, source);
public MyPoint this[System.Index index] { get { Write($""{source}[{index}], ""); return new(array[index].point, $""{source}[{index}]""); } }
public MyArray this[System.Range range] { get { Write($""{source}[{range}], ""); return new(array[range], $""{source}[{range}]""); } }
public int Length { get { Write($""{source}.{nameof(Length)}, ""); return array.Length; } }
}
struct Point
{
public int X, Y;
public Point(int x, int y) => (X, Y) = (x, y);
}
" + TestSources.GetSubArray;
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
CompileAndVerify(compilation, expectedOutput: expectedOutput).VerifyDiagnostics();
}
[Fact]
public void ListPattern_NarrowedTypes()
{
var source = @"
using System;
class X
{
static int Test(object o)
{
return o switch
{
int[] and [1,2,3] => 1,
double[] and [1,2,3] => 2,
float[] and [_,_,_] => 3,
_ => -1,
};
}
public static void Main()
{
Console.Write(Test(new int[] { 1, 2, 3 }));
Console.Write(Test(new double[] { 1, 2, 3 }));
Console.Write(Test(new float[] { 1, 2, 3 }));
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index }, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
CompileAndVerify(compilation, expectedOutput: "123");
}
[Fact]
public void ImpossiblePattern_01()
{
var source = @"
using System;
class X
{
public void M(int[] a, int[,] mdarray)
{
_ = a is [] and [1]; // 1
_ = a is [1] and [1];
_ = a is {Length:0} and [1]; // 2
_ = a is {Length:1} and [1];
_ = a is [1,2,3] and [1,2,4]; // 3
_ = a is [1,2,3] and [1,2,3];
_ = a is ([>0]) and ([<0]); // 4
_ = a is ([>0]) and ([>=0]);
_ = a is [>0] and [<0]; // 5
_ = a is [>0] and [>=0];
_ = a is {Length:-1}; // 6
_ = a is [.., >0] and [<0]; // 7
_ = a is [.., >0, _] and [_, <=0, ..];
_ = new { a } is { a.Length:-1 }; // 8
_ = a is [..{ Length: -1 }]; // 9
_ = a is [..{ Length: < -1 }]; // 10
_ = a is [..{ Length: <= -1 }]; // 11
_ = a is [..{ Length: >= -1 }];
_ = a is [..{ Length: > -1 }];
_ = a is [_, _, ..{ Length: int.MaxValue - 1 }]; // 12
_ = a is [_, _, ..{ Length: <= int.MaxValue - 1 }];
_ = a is [_, _, ..{ Length: >= int.MaxValue - 1 }]; // 13
_ = a is [_, _, ..{ Length: < int.MaxValue - 1 }];
_ = a is [_, _, ..{ Length: > int.MaxValue - 1 }]; // 14
_ = a is { LongLength: -1 };
_ = (Array)a is { Length: -1 };
_ = mdarray is { Length: -1 };
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (7,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [] and [1]; // 1
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [] and [1]").WithArguments("int[]").WithLocation(7, 13),
// (9,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is {Length:0} and [1]; // 2
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is {Length:0} and [1]").WithArguments("int[]").WithLocation(9, 13),
// (11,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [1,2,3] and [1,2,4]; // 3
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [1,2,3] and [1,2,4]").WithArguments("int[]").WithLocation(11, 13),
// (13,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is ([>0]) and ([<0]); // 4
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is ([>0]) and ([<0])").WithArguments("int[]").WithLocation(13, 13),
// (15,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [>0] and [<0]; // 5
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [>0] and [<0]").WithArguments("int[]").WithLocation(15, 13),
// (17,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is {Length:-1}; // 6
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is {Length:-1}").WithArguments("int[]").WithLocation(17, 13),
// (18,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [.., >0] and [<0]; // 7
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [.., >0] and [<0]").WithArguments("int[]").WithLocation(18, 13),
// _ = new { a } is { a.Length:-1 }; // 8
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "new { a } is { a.Length:-1 }").WithArguments("<anonymous type: int[] a>").WithLocation(20, 13),
// (21,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [..{ Length: -1 }]; // 9
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [..{ Length: -1 }]").WithArguments("int[]").WithLocation(21, 13),
// (22,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [..{ Length: < -1 }]; // 10
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [..{ Length: < -1 }]").WithArguments("int[]").WithLocation(22, 13),
// (23,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [..{ Length: <= -1 }]; // 11
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [..{ Length: <= -1 }]").WithArguments("int[]").WithLocation(23, 13),
// (26,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [_, _, ..{ Length: int.MaxValue - 1 }]; // 12
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [_, _, ..{ Length: int.MaxValue - 1 }]").WithArguments("int[]").WithLocation(26, 13),
// (28,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [_, _, ..{ Length: >= int.MaxValue - 1 }]; // 13
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [_, _, ..{ Length: >= int.MaxValue - 1 }]").WithArguments("int[]").WithLocation(28, 13),
// (30,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is [_, _, ..{ Length: > int.MaxValue - 1 }]; // 14
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [_, _, ..{ Length: > int.MaxValue - 1 }]").WithArguments("int[]").WithLocation(30, 13)
);
}
[Fact]
public void ImpossiblePattern_02()
{
var source = @"
interface IIndexable
{
int this[int i] { get; }
}
interface ICountableViaCount
{
int Count { get; }
}
interface ICountableViaLength
{
int Length { get; }
}
class X
{
public static void Test1<T>(T t) where T : ICountableViaCount
{
_ = t is { Count: -1 };
_ = new { t } is { t.Count: -1 };
_ = t[^1]; // 1
}
public static void Test2<T>(T t) where T : ICountableViaLength
{
_ = t is { Length: -1 };
_ = new { t } is { t.Length: -1 };
_ = t[^1]; // 2
}
public static void Test3<T>(T t) where T : IIndexable, ICountableViaCount
{
_ = t is { Count: -1 }; // 3
_ = new { t } is { t.Count: -1 }; // 4
_ = t[^1];
}
public static void Test4<T>(T t) where T : IIndexable, ICountableViaLength
{
_ = t is { Length: -1 }; // 5
_ = new { t } is { t.Length: -1 }; // 6
_ = t[^1];
}
public static void Test5<T>(T t) where T : IIndexable, ICountableViaLength, ICountableViaCount
{
_ = t is { Length: -1 }; // 7
_ = t is { Count: -1 };
_ = new { t } is { t.Length: -1 }; // 8
_ = new { t } is { t.Count: -1 };
_ = t[^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (20,13): error CS0021: Cannot apply indexing with [] to an expression of type 'T'
// _ = t[^1]; // 1
Diagnostic(ErrorCode.ERR_BadIndexLHS, "t[^1]").WithArguments("T").WithLocation(20, 13),
// (26,13): error CS0021: Cannot apply indexing with [] to an expression of type 'T'
// _ = t[^1]; // 2
Diagnostic(ErrorCode.ERR_BadIndexLHS, "t[^1]").WithArguments("T").WithLocation(26, 13),
// (30,13): error CS8518: An expression of type 'T' can never match the provided pattern.
// _ = t is { Count: -1 }; // 3
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "t is { Count: -1 }").WithArguments("T").WithLocation(30, 13),
// (31,13): error CS8518: An expression of type '<anonymous type: T t>' can never match the provided pattern.
// _ = new { t } is { t.Count: -1 }; // 4
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "new { t } is { t.Count: -1 }").WithArguments("<anonymous type: T t>").WithLocation(31, 13),
// (36,13): error CS8518: An expression of type 'T' can never match the provided pattern.
// _ = t is { Length: -1 }; // 5
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "t is { Length: -1 }").WithArguments("T").WithLocation(36, 13),
// (37,13): error CS8518: An expression of type '<anonymous type: T t>' can never match the provided pattern.
// _ = new { t } is { t.Length: -1 }; // 6
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "new { t } is { t.Length: -1 }").WithArguments("<anonymous type: T t>").WithLocation(37, 13),
// (42,13): error CS8518: An expression of type 'T' can never match the provided pattern.
// _ = t is { Length: -1 }; // 7
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "t is { Length: -1 }").WithArguments("T").WithLocation(42, 13),
// (44,13): error CS8518: An expression of type '<anonymous type: T t>' can never match the provided pattern.
// _ = new { t } is { t.Length: -1 }; // 8
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "new { t } is { t.Length: -1 }").WithArguments("<anonymous type: T t>").WithLocation(44, 13)
);
}
[Fact]
public void ListPattern_ValEscape()
{
CreateCompilationWithIndexAndRangeAndSpan(@"
using System;
public ref struct R
{
public int Length => throw null;
public R this[int i] => throw null;
public R Slice(int i, int j) => throw null;
public static implicit operator R(Span<int> span) => throw null;
}
public class C
{
public void M1(ref Span<int> s)
{
Span<int> outer = stackalloc int[100];
if (outer is [] list) s = list; // error 1
}
public void M2(ref R r)
{
R outer = stackalloc int[100];
if (outer is [var element, .. var slice] list)
{
r = element; // error 2
r = slice; // error 3
r = list; // error 4
}
}
public void M1b(ref Span<int> s)
{
Span<int> outer = default;
if (outer is [] list) s = list; // OK
}
public void M2b(ref R r)
{
R outer = default;
if (outer is [var element, .. var slice] list)
{
r = element; // OK
r = slice; // OK
r = list; // OK
}
}
}").VerifyDiagnostics(
// (15,35): error CS8352: Cannot use local 'list' in this context because it may expose referenced variables outside of their declaration scope
// if (outer is [] list) s = list; // error 1
Diagnostic(ErrorCode.ERR_EscapeLocal, "list").WithArguments("list").WithLocation(15, 35),
// (22,17): error CS8352: Cannot use local 'element' in this context because it may expose referenced variables outside of their declaration scope
// r = element; // error 2
Diagnostic(ErrorCode.ERR_EscapeLocal, "element").WithArguments("element").WithLocation(22, 17),
// (23,17): error CS8352: Cannot use local 'slice' in this context because it may expose referenced variables outside of their declaration scope
// r = slice; // error 3
Diagnostic(ErrorCode.ERR_EscapeLocal, "slice").WithArguments("slice").WithLocation(23, 17),
// (24,17): error CS8352: Cannot use local 'list' in this context because it may expose referenced variables outside of their declaration scope
// r = list; // error 4
Diagnostic(ErrorCode.ERR_EscapeLocal, "list").WithArguments("list").WithLocation(24, 17));
}
[Fact]
public void BadConstant()
{
var source = @"
using System;
class X
{
public void M(int[] a)
{
const int bad = a;
_ = a is { Length: bad };
_ = new { a } is { a.Length: bad };
_ = a is [..{ Length: bad }];
_ = a is [..{ Length: < bad }];
_ = a is [..{ Length: <= bad }];
_ = a is [..{ Length: >= bad }];
_ = a is [..{ Length: > bad }];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (7,25): error CS0029: Cannot implicitly convert type 'int[]' to 'int'
// const int bad = a;
Diagnostic(ErrorCode.ERR_NoImplicitConv, "a").WithArguments("int[]", "int").WithLocation(7, 25));
}
[Fact]
public void ListPattern_Interface()
{
var source = @"
D.M(new C());
interface I
{
int Length { get; }
int this[int i] { get; }
string Slice(int i, int j);
}
class C : I
{
public int Length => 1;
public int this[int i] => 42;
public string Slice(int i, int j) => ""slice"";
}
class D
{
public static void M<T>(T t) where T : I
{
if (t is not [var item, ..var rest]) return;
System.Console.WriteLine(item);
System.Console.WriteLine(rest);
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics();
string expectedOutput = @"
42
slice
";
CompileAndVerify(compilation, expectedOutput: expectedOutput);
}
[Fact]
public void ListPattern_NullableValueType()
{
var source = @"
using System;
struct S
{
public int Length => 1;
public int this[int i] => 42;
public static bool Test(S? s)
{
return s is [42];
}
public static void Main()
{
Console.WriteLine(Test(new S()));
Console.WriteLine(Test(null));
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics();
string expectedOutput = @"
True
False
";
var verifier = CompileAndVerify(compilation, expectedOutput: expectedOutput);
verifier.VerifyIL("S.Test", @"
{
// Code size 42 (0x2a)
.maxstack 2
.locals init (S V_0)
IL_0000: ldarga.s V_0
IL_0002: call ""bool S?.HasValue.get""
IL_0007: brfalse.s IL_0028
IL_0009: ldarga.s V_0
IL_000b: call ""S S?.GetValueOrDefault()""
IL_0010: stloc.0
IL_0011: ldloca.s V_0
IL_0013: call ""int S.Length.get""
IL_0018: ldc.i4.1
IL_0019: bne.un.s IL_0028
IL_001b: ldloca.s V_0
IL_001d: ldc.i4.0
IL_001e: call ""int S.this[int].get""
IL_0023: ldc.i4.s 42
IL_0025: ceq
IL_0027: ret
IL_0028: ldc.i4.0
IL_0029: ret
}
");
}
[Fact]
public void ListPattern_Negated_01()
{
var source = @"
class X
{
public void Test1(int[] a)
{
switch (a)
{
case not [{} y, .. {} z] x: _ = (x, y, z); break;
case [not {} y, .. not {} z] x: _ = (x, y, z); break;
}
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (8,26): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// case not [{} y, .. {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "y").WithLocation(8, 26),
// (8,35): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// case not [{} y, .. {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "z").WithLocation(8, 35),
// (8,38): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// case not [{} y, .. {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "x").WithLocation(8, 38),
// (8,46): error CS0165: Use of unassigned local variable 'x'
// case not [{} y, .. {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_UseDefViolation, "x").WithArguments("x").WithLocation(8, 46),
// (8,49): error CS0165: Use of unassigned local variable 'y'
// case not [{} y, .. {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_UseDefViolation, "y").WithArguments("y").WithLocation(8, 49),
// (8,52): error CS0165: Use of unassigned local variable 'z'
// case not [{} y, .. {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_UseDefViolation, "z").WithArguments("z").WithLocation(8, 52),
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [not {} y, .. not {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[not {} y, .. not {} z] x").WithLocation(9, 18),
// (9,26): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// case [not {} y, .. not {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "y").WithLocation(9, 26),
// (9,39): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// case [not {} y, .. not {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "z").WithLocation(9, 39),
// (9,53): error CS0165: Use of unassigned local variable 'y'
// case [not {} y, .. not {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_UseDefViolation, "y").WithArguments("y").WithLocation(9, 53),
// (9,56): error CS0165: Use of unassigned local variable 'z'
// case [not {} y, .. not {} z] x: _ = (x, y, z); break;
Diagnostic(ErrorCode.ERR_UseDefViolation, "z").WithArguments("z").WithLocation(9, 56)
);
}
[Fact]
public void ListPattern_Negated_02()
{
var source = @"
class X
{
public void Test1(int[] a)
{
if (a is not [{} y, .. {} z] x)
_ = (x, y, z); // 1
else
_ = (x, y, z);
}
public void Test2(int[] a)
{
if (a is [not {} y, .. not {} z] x)
_ = (x, y, z);
else
_ = (x, y, z); // 2
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (7,19): error CS0165: Use of unassigned local variable 'x'
// _ = (x, y, z); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "x").WithArguments("x").WithLocation(7, 19),
// (7,22): error CS0165: Use of unassigned local variable 'y'
// _ = (x, y, z); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "y").WithArguments("y").WithLocation(7, 22),
// (7,25): error CS0165: Use of unassigned local variable 'z'
// _ = (x, y, z); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "z").WithArguments("z").WithLocation(7, 25),
// (13,13): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// if (a is [not {} y, .. not {} z] x)
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is [not {} y, .. not {} z] x").WithArguments("int[]").WithLocation(13, 13),
// (13,26): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// if (a is [not {} y, .. not {} z] x)
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "y").WithLocation(13, 26),
// (13,39): error CS8780: A variable may not be declared within a 'not' or 'or' pattern.
// if (a is [not {} y, .. not {} z] x)
Diagnostic(ErrorCode.ERR_DesignatorBeneathPatternCombinator, "z").WithLocation(13, 39),
// (16,19): error CS0165: Use of unassigned local variable 'x'
// _ = (x, y, z); // 2
Diagnostic(ErrorCode.ERR_UseDefViolation, "x").WithArguments("x").WithLocation(16, 19),
// (16,22): error CS0165: Use of unassigned local variable 'y'
// _ = (x, y, z); // 2
Diagnostic(ErrorCode.ERR_UseDefViolation, "y").WithArguments("y").WithLocation(16, 22),
// (16,25): error CS0165: Use of unassigned local variable 'z'
// _ = (x, y, z); // 2
Diagnostic(ErrorCode.ERR_UseDefViolation, "z").WithArguments("z").WithLocation(16, 25)
);
}
[Fact]
public void ListPattern_UseSiteErrorOnIndexerAndSlice()
{
var missing_cs = @"
public class Missing
{
}
";
var missingRef = CreateCompilation(missing_cs, assemblyName: "missing")
.EmitToImageReference();
var lib2_cs = @"
public class C
{
public int Length => 0;
public Missing this[int i] => throw null;
public Missing Slice(int i, int j) => throw null;
}
";
var lib2Ref = CreateCompilation(lib2_cs, references: new[] { missingRef })
.EmitToImageReference();
var source = @"
class D
{
void M(C c)
{
_ = c is [var item];
_ = c is [..var rest];
var index = c[^1];
var range = c[1..^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range },
references: new[] { lib2Ref }, parseOptions: TestOptions.RegularWithListPatterns);
compilation.VerifyEmitDiagnostics(
// (6,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [var item];
Diagnostic(ErrorCode.ERR_NoTypeDef, "[var item]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 18),
// (6,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [var item];
Diagnostic(ErrorCode.ERR_NoTypeDef, "[var item]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 18),
// (7,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [..var rest];
Diagnostic(ErrorCode.ERR_NoTypeDef, "[..var rest]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 18),
// (7,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [..var rest];
Diagnostic(ErrorCode.ERR_NoTypeDef, "[..var rest]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 18),
// (7,19): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [..var rest];
Diagnostic(ErrorCode.ERR_NoTypeDef, "..var rest").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 19),
// (7,19): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [..var rest];
Diagnostic(ErrorCode.ERR_NoTypeDef, "..var rest").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 19),
// (8,21): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var index = c[^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(8, 21),
// (8,21): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var index = c[^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(8, 21),
// (9,21): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var range = c[1..^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[1..^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(9, 21),
// (9,21): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var range = c[1..^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[1..^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(9, 21)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var declarations = tree.GetRoot().DescendantNodes().OfType<VarPatternSyntax>().ToArray();
verify(declarations[0], "item", "Missing?");
verify(declarations[1], "rest", "Missing?");
var localDeclarations = tree.GetRoot().DescendantNodes().OfType<VariableDeclaratorSyntax>().ToArray();
verify2(localDeclarations[0], "index", "Missing");
verify2(localDeclarations[1], "range", "Missing");
void verify(VarPatternSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration.Designation)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
void verify2(VariableDeclaratorSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
}
[Fact]
public void ListPattern_UseSiteErrorOnIndexAndRangeIndexers_WithFallback()
{
var missing_cs = @"
public class Missing
{
}
";
var missingRef = CreateCompilation(missing_cs, assemblyName: "missing")
.EmitToImageReference();
var lib2_cs = @"
using System;
public class C
{
public int Length => 1;
public Missing this[Index i] => throw null;
public Missing this[Range r] => throw null;
public int this[int i] => 42;
public int Slice(int i, int j) => 43;
}
";
var lib2Ref = CreateCompilation(new[] { lib2_cs, TestSources.Index, TestSources.Range }, references: new[] { missingRef })
.EmitToImageReference();
var source = @"
var c = new C();
if (c is [var item] && c is [..var slice])
{
var item2 = c[^1];
var slice2 = c[..];
System.Console.Write((item, slice, item2, slice2));
}
";
var compilation = CreateCompilation(source, references: new[] { lib2Ref });
compilation.VerifyEmitDiagnostics(
// (4,10): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// if (c is [var item] && c is [..var slice])
Diagnostic(ErrorCode.ERR_NoTypeDef, "[var item]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(4, 10),
// (4,29): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// if (c is [var item] && c is [..var slice])
Diagnostic(ErrorCode.ERR_NoTypeDef, "[..var slice]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(4, 29),
// (4,30): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// if (c is [var item] && c is [..var slice])
Diagnostic(ErrorCode.ERR_NoTypeDef, "..var slice").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(4, 30),
// (6,17): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var item2 = c[^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 17),
// (7,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var slice2 = c[..];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[..]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 18)
);
}
[Fact]
public void ListPattern_RangeTypeWithMissingInterface()
{
var missing_cs = @"
public interface IMissing { }
";
var range_cs = @"
namespace System;
public struct Range : IMissing
{
public Index Start { get; }
public Index End { get; }
public Range(Index start, Index end) => throw null;
public static Range StartAt(Index start) => throw null;
public static Range EndAt(Index end) => throw null;
public static Range All => throw null;
}
";
var lib_cs = @"
public class C
{
public int Length => 0;
public int this[System.Index i] => 0;
public int this[System.Range r] => 0;
}
";
var missingComp = CreateCompilation(missing_cs, assemblyName: "missing");
missingComp.VerifyDiagnostics();
var rangeComp = CreateCompilation(new[] { range_cs, TestSources.Index }, references: new[] { missingComp.EmitToImageReference() }, assemblyName: "range");
rangeComp.VerifyDiagnostics();
var rangeRef = rangeComp.EmitToImageReference();
var libComp = CreateCompilation(lib_cs, references: new[] { rangeRef }, assemblyName: "lib");
libComp.VerifyDiagnostics();
var sources = new[]
{
"_ = ^1;",
"_ = ..;",
"_ = new C() is [var x];",
"_ = new C() is [..var y];",
"_ = new C()[^1];",
"_ = new C()[..];"
};
foreach (var source in sources)
{
var comp = CreateCompilation(source, references: new[] { libComp.EmitToImageReference(), rangeRef });
comp.VerifyDiagnostics();
var used = comp.GetUsedAssemblyReferences();
Assert.True(used.Any(r => r.Display == "range"));
}
}
[Fact]
public void ListPattern_ObsoleteLengthAndIndexerAndSlice()
{
var source = @"
_ = new C() is [var x]; // 1, 2, 3
_ = new C() is [.. var y]; // 4, 5, 6, 7, 8
new C().Slice(0, 0); // 9
_ = new C()[^1]; // 10, 11
_ = new C()[..]; // 12, 13
class C
{
[System.Obsolete]
public int Length => 0;
[System.Obsolete]
public int this[int i] => 0;
[System.Obsolete]
public int Slice(int i, int j) => 0;
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
// Note: duplicate diagnostics are reported on Length because both the list pattern
// and the implicit indexer need it.
comp.VerifyDiagnostics(
// (2,16): warning CS0612: 'C.Length' is obsolete
// _ = new C() is [var x]; // 1, 2, 3
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "[var x]").WithArguments("C.Length").WithLocation(2, 16),
// (2,16): warning CS0612: 'C.Length' is obsolete
// _ = new C() is [var x]; // 1, 2, 3
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "[var x]").WithArguments("C.Length").WithLocation(2, 16),
// (2,16): warning CS0612: 'C.this[int]' is obsolete
// _ = new C() is [var x]; // 1, 2, 3
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "[var x]").WithArguments("C.this[int]").WithLocation(2, 16),
// (3,16): warning CS0612: 'C.Length' is obsolete
// _ = new C() is [.. var y]; // 4, 5, 6, 7, 8
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "[.. var y]").WithArguments("C.Length").WithLocation(3, 16),
// (3,16): warning CS0612: 'C.Length' is obsolete
// _ = new C() is [.. var y]; // 4, 5, 6, 7, 8
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "[.. var y]").WithArguments("C.Length").WithLocation(3, 16),
// (3,16): warning CS0612: 'C.this[int]' is obsolete
// _ = new C() is [.. var y]; // 4, 5, 6, 7, 8
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "[.. var y]").WithArguments("C.this[int]").WithLocation(3, 16),
// (3,17): warning CS0612: 'C.Length' is obsolete
// _ = new C() is [.. var y]; // 4, 5, 6, 7, 8
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, ".. var y").WithArguments("C.Length").WithLocation(3, 17),
// (3,17): warning CS0612: 'C.Slice(int, int)' is obsolete
// _ = new C() is [.. var y]; // 4, 5, 6, 7, 8
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, ".. var y").WithArguments("C.Slice(int, int)").WithLocation(3, 17),
// (4,1): warning CS0612: 'C.Slice(int, int)' is obsolete
// new C().Slice(0, 0); // 9
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new C().Slice(0, 0)").WithArguments("C.Slice(int, int)").WithLocation(4, 1),
// (5,5): warning CS0612: 'C.Length' is obsolete
// _ = new C()[^1]; // 10, 11
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new C()[^1]").WithArguments("C.Length").WithLocation(5, 5),
// (5,5): warning CS0612: 'C.this[int]' is obsolete
// _ = new C()[^1]; // 10, 11
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new C()[^1]").WithArguments("C.this[int]").WithLocation(5, 5),
// (6,5): warning CS0612: 'C.Length' is obsolete
// _ = new C()[..]; // 12, 13
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new C()[..]").WithArguments("C.Length").WithLocation(6, 5),
// (6,5): warning CS0612: 'C.Slice(int, int)' is obsolete
// _ = new C()[..]; // 12, 13
Diagnostic(ErrorCode.WRN_DeprecatedSymbol, "new C()[..]").WithArguments("C.Slice(int, int)").WithLocation(6, 5)
);
}
[Fact]
public void ListPattern_IndexAndSliceReturnMissingTypes()
{
var missing_cs = @"
public class Missing { }
public class Missing2 { }
";
var lib_cs = @"
public class C
{
public int Length => throw null;
public Missing this[int i] => throw null;
public Missing2 Slice(int i, int j) => throw null;
}
";
var source = @"
_ = new C() is [var x]; // 1, 2
_ = new C() is [.. var y]; // 3, 4, 5, 6
new C().Slice(0, 0); // 7
_ = new C()[^1]; // 8, 9
_ = new C()[..]; // 10, 11
";
var missingComp = CreateCompilation(missing_cs, assemblyName: "missing");
missingComp.VerifyDiagnostics();
var libComp = CreateCompilation(lib_cs, references: new[] { missingComp.EmitToImageReference() }, assemblyName: "lib");
libComp.VerifyDiagnostics();
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range }, references: new[] { libComp.EmitToImageReference() });
comp.VerifyDiagnostics(
// (2,16): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C() is [var x]; // 1, 2
Diagnostic(ErrorCode.ERR_NoTypeDef, "[var x]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(2, 16),
// (2,16): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C() is [var x]; // 1, 2
Diagnostic(ErrorCode.ERR_NoTypeDef, "[var x]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(2, 16),
// (3,16): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C() is [.. var y]; // 3, 4, 5, 6
Diagnostic(ErrorCode.ERR_NoTypeDef, "[.. var y]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(3, 16),
// (3,16): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C() is [.. var y]; // 3, 4, 5, 6
Diagnostic(ErrorCode.ERR_NoTypeDef, "[.. var y]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(3, 16),
// (3,17): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C() is [.. var y]; // 3, 4, 5, 6
Diagnostic(ErrorCode.ERR_NoTypeDef, ".. var y").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(3, 17),
// (3,17): error CS0012: The type 'Missing2' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C() is [.. var y]; // 3, 4, 5, 6
Diagnostic(ErrorCode.ERR_NoTypeDef, ".. var y").WithArguments("Missing2", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(3, 17),
// (4,1): error CS0012: The type 'Missing2' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// new C().Slice(0, 0); // 7
Diagnostic(ErrorCode.ERR_NoTypeDef, "new C().Slice").WithArguments("Missing2", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(4, 1),
// (5,5): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C()[^1]; // 8, 9
Diagnostic(ErrorCode.ERR_NoTypeDef, "new C()[^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(5, 5),
// (5,5): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C()[^1]; // 8, 9
Diagnostic(ErrorCode.ERR_NoTypeDef, "new C()[^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(5, 5),
// (6,5): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C()[..]; // 10, 11
Diagnostic(ErrorCode.ERR_NoTypeDef, "new C()[..]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 5),
// (6,5): error CS0012: The type 'Missing2' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = new C()[..]; // 10, 11
Diagnostic(ErrorCode.ERR_NoTypeDef, "new C()[..]").WithArguments("Missing2", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 5)
);
}
[Fact]
public void ListPattern_Symbols_01()
{
var source = @"
#nullable enable
class X
{
public void Test(string[]? strings, int[] integers)
{
_ = strings is [var element1] list1a;
_ = strings is [..var slice1] list1b;
_ = integers is [var element2] list2a;
_ = integers is [..var slice2] list2b;
_ = strings is [string element3] list3a;
_ = strings is [..string[] slice3] list3b;
_ = integers is [int element4] list4a;
_ = integers is [..int[] slice4] list4b;
}
}";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyDiagnostics();
var tree = compilation.SyntaxTrees[0];
var nodes = tree.GetRoot().DescendantNodes().OfType<SingleVariableDesignationSyntax>();
Assert.Collection(nodes,
d => verify(d, "element1", "string?", "string"),
d => verify(d, "list1a", "string[]?", "string[]"),
d => verify(d, "slice1", "string[]?", "string[]"),
d => verify(d, "list1b", "string[]?", "string[]"),
d => verify(d, "element2", "int", "int"),
d => verify(d, "list2a", "int[]?", "int[]"),
d => verify(d, "slice2", "int[]?", "int[]"),
d => verify(d, "list2b", "int[]?", "int[]"),
d => verify(d, "element3", "string", "string"),
d => verify(d, "list3a", "string[]?", "string[]"),
d => verify(d, "slice3", "string[]", "string[]"),
d => verify(d, "list3b", "string[]?", "string[]"),
d => verify(d, "element4", "int", "int"),
d => verify(d, "list4a", "int[]?", "int[]"),
d => verify(d, "slice4", "int[]", "int[]"),
d => verify(d, "list4b", "int[]?", "int[]")
);
void verify(SyntaxNode designation, string syntax, string declaredType, string type)
{
Assert.Equal(syntax, designation.ToString());
var model = compilation.GetSemanticModel(tree);
var symbol = model.GetDeclaredSymbol(designation);
Assert.Equal(SymbolKind.Local, symbol.Kind);
Assert.Equal(declaredType, ((ILocalSymbol)symbol).Type.ToDisplayString());
var typeInfo = model.GetTypeInfo(designation);
Assert.Null(typeInfo.Type);
Assert.Null(typeInfo.ConvertedType);
typeInfo = model.GetTypeInfo(designation.Parent);
Assert.Equal(type, typeInfo.Type.ToDisplayString());
Assert.Equal(type, typeInfo.ConvertedType.ToDisplayString());
}
}
[Fact]
public void ListPattern_Symbols_02()
{
var source =
@"class X
{
public void Test(string[] strings, int[] integers)
{
_ = strings is [{}];
_ = strings is [..{}];
_ = integers is [{}];
_ = integers is [..{}];
}
}";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyDiagnostics();
var tree = compilation.SyntaxTrees[0];
var nodes = tree.GetRoot().DescendantNodes()
.OfType<PropertyPatternClauseSyntax>()
.Where(p => p.IsKind(SyntaxKind.PropertyPatternClause));
Assert.Collection(nodes,
d => verify(d, "[{}]", "string"),
d => verify(d, "..{}", "string[]"),
d => verify(d, "[{}]", "int"),
d => verify(d, "..{}", "int[]")
);
void verify(PropertyPatternClauseSyntax clause, string syntax, string type)
{
Assert.Equal(syntax, clause.Parent.Parent.ToString());
var model = compilation.GetSemanticModel(tree);
var typeInfo = model.GetTypeInfo(clause.Parent); // inner {} pattern
Assert.Equal(type, typeInfo.Type.ToDisplayString());
Assert.Equal(type, typeInfo.ConvertedType.ToDisplayString());
}
}
[Fact]
public void ListPattern_Symbols_WithoutIndexOrRangeOrGetSubArray()
{
var source = @"
#nullable enable
class X
{
public void Test(int[] integers)
{
_ = integers is [var item, ..var slice];
}
}";
var compilation = CreateCompilation(source);
compilation.VerifyDiagnostics(
// (7,25): error CS0518: Predefined type 'System.Index' is not defined or imported
// _ = integers is [var item, ..var slice];
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[var item, ..var slice]").WithArguments("System.Index").WithLocation(7, 25),
// (7,36): error CS0518: Predefined type 'System.Range' is not defined or imported
// _ = integers is [var item, ..var slice];
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "..var slice").WithArguments("System.Range").WithLocation(7, 36)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree);
var designations = tree.GetRoot().DescendantNodes().OfType<SingleVariableDesignationSyntax>().ToArray();
var itemDesignation = designations[0];
Assert.Equal("item", itemDesignation.ToString());
var symbol = model.GetDeclaredSymbol(itemDesignation);
Assert.Equal(SymbolKind.Local, symbol.Kind);
Assert.Equal("System.Int32", ((ILocalSymbol)symbol).Type.ToTestDisplayString());
var typeInfo = model.GetTypeInfo(itemDesignation);
Assert.Null(typeInfo.Type);
Assert.Null(typeInfo.ConvertedType);
typeInfo = model.GetTypeInfo(itemDesignation.Parent);
Assert.Equal("System.Int32", typeInfo.Type.ToTestDisplayString());
Assert.Equal("System.Int32", typeInfo.ConvertedType.ToTestDisplayString());
var sliceDesignation = designations[1];
Assert.Equal("slice", sliceDesignation.ToString());
symbol = model.GetDeclaredSymbol(sliceDesignation);
Assert.Equal(SymbolKind.Local, symbol.Kind);
Assert.Equal("System.Int32", ((ILocalSymbol)symbol).Type.ToTestDisplayString());
typeInfo = model.GetTypeInfo(sliceDesignation);
Assert.Null(typeInfo.Type);
Assert.Null(typeInfo.ConvertedType);
typeInfo = model.GetTypeInfo(sliceDesignation.Parent);
Assert.Equal("System.Int32", typeInfo.Type.ToTestDisplayString());
Assert.Equal("System.Int32", typeInfo.ConvertedType.ToTestDisplayString());
}
[Fact]
public void PatternIndexRangeReadOnly_01()
{
// Relates to https://github.com/dotnet/roslyn/pull/37194
var src = @"
using System;
struct S
{
public int this[int i] => 0;
public int Length => 0;
public int Slice(int x, int y) => 0;
readonly void M(Index i, Range r)
{
_ = this[i]; // 1, 2
_ = this[r]; // 3, 4
_ = this is [1];
_ = this is [2, ..var rest];
}
}";
var comp = CreateCompilationWithIndexAndRange(src);
comp.VerifyDiagnostics(
// (11,13): warning CS8656: Call to non-readonly member 'S.Length.get' from a 'readonly' member results in an implicit copy of 'this'.
// _ = this[i]; // 1, 2
Diagnostic(ErrorCode.WRN_ImplicitCopyInReadOnlyMember, "this").WithArguments("S.Length.get", "this").WithLocation(11, 13),
// (11,13): warning CS8656: Call to non-readonly member 'S.this[int].get' from a 'readonly' member results in an implicit copy of 'this'.
// _ = this[i]; // 1, 2
Diagnostic(ErrorCode.WRN_ImplicitCopyInReadOnlyMember, "this").WithArguments("S.this[int].get", "this").WithLocation(11, 13),
// (12,13): warning CS8656: Call to non-readonly member 'S.Length.get' from a 'readonly' member results in an implicit copy of 'this'.
// _ = this[r]; // 3, 4
Diagnostic(ErrorCode.WRN_ImplicitCopyInReadOnlyMember, "this").WithArguments("S.Length.get", "this").WithLocation(12, 13),
// (12,13): warning CS8656: Call to non-readonly member 'S.Slice(int, int)' from a 'readonly' member results in an implicit copy of 'this'.
// _ = this[r]; // 3, 4
Diagnostic(ErrorCode.WRN_ImplicitCopyInReadOnlyMember, "this").WithArguments("S.Slice(int, int)", "this").WithLocation(12, 13)
);
}
[Fact]
public void PatternIndexRangeReadOnly_02()
{
var src = @"
using System;
struct S
{
public readonly int this[int i] => 0;
public readonly int Length => 0;
public readonly int Slice(int x, int y) => 0;
readonly void M(Index i, Range r)
{
_ = this[i];
_ = this[r];
_ = this is [1];
_ = this is [2, ..var rest];
}
}";
var comp = CreateCompilationWithIndexAndRange(src);
comp.VerifyDiagnostics();
}
[Fact]
public void ListPattern_VoidLength()
{
var source = @"
class C
{
public void Length => throw null;
public int this[int i] => throw null;
public void M()
{
_ = this is [1];
_ = this[^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (4,17): error CS0547: 'C.Length': property or indexer cannot have void type
// public void Length => throw null;
Diagnostic(ErrorCode.ERR_PropertyCantHaveVoidType, "Length").WithArguments("C.Length").WithLocation(4, 17),
// (8,21): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = this is [1];
Diagnostic(ErrorCode.ERR_BadArgType, "[1]").WithArguments("1", "System.Index", "int").WithLocation(8, 21),
// (9,18): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = this[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(9, 18)
);
}
[Fact]
public void ListPattern_StringLength()
{
var source = @"
class C
{
public string Length => throw null;
public int this[int i] => throw null;
public void M()
{
_ = this is [1];
_ = this[^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (9,21): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = this is [1];
Diagnostic(ErrorCode.ERR_BadArgType, "[1]").WithArguments("1", "System.Index", "int").WithLocation(9, 21),
// (10,18): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = this[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(10, 18)
);
}
[Fact]
public void SlicePattern_VoidReturn()
{
var source = @"
class C
{
public int Length => throw null;
public int this[int i] => throw null;
public void Slice(int i, int j) => throw null;
public void M()
{
_ = this is [..];
_ = this is [.._];
_ = this is [..var unused];
if (this is [..var used])
{
System.Console.Write(used);
}
_ = this[..];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (11,22): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = this is [.._];
Diagnostic(ErrorCode.ERR_BadArgType, ".._").WithArguments("1", "System.Range", "int").WithLocation(11, 22),
// (12,22): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = this is [..var unused];
Diagnostic(ErrorCode.ERR_BadArgType, "..var unused").WithArguments("1", "System.Range", "int").WithLocation(12, 22),
// (13,22): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// if (this is [..var used])
Diagnostic(ErrorCode.ERR_BadArgType, "..var used").WithArguments("1", "System.Range", "int").WithLocation(13, 22),
// (17,18): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = this[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(17, 18)
);
}
[Theory]
[InlineData("[.._]", "Length True")]
[InlineData("[..]", "True")]
[InlineData("[..var unused]", "Length Slice True")]
[InlineData("[42, ..]", "Length Index True")]
[InlineData("[42, .._]", "Length Index True")]
[InlineData("[42, ..var unused]", "Length Index Slice True")]
public void ListPattern_OnlyCallApisRequiredByPattern(string pattern, string expectedOutput)
{
var source = $@"
System.Console.Write(new C() is {pattern});
public class C
{{
public int Length {{ get {{ System.Console.Write(""Length ""); return 1; }} }}
public int this[int i] {{ get {{ System.Console.Write(""Index ""); return 42; }} }}
public int Slice(int i, int j) {{ System.Console.Write(""Slice ""); return 0; }}
}}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyDiagnostics();
CompileAndVerify(compilation, expectedOutput: expectedOutput);
}
[Fact]
public void ListPattern_GenericIndexingParameter()
{
var source = @"
#nullable enable
class C<T>
{
public int Length => throw null!;
public int this[T i] => throw null!;
public void M()
{
if (new C<int>() is [var item]) // 1
item.ToString();
if (new C<int?>() is [var item2]) // 2
item2.Value.ToString(); // 3
var item22 = new C<int?>()[^1]; // 4
item22.Value.ToString(); // 5
if (new C<System.Index>() is [var item3])
item3.ToString();
_ = new C<System.Index>()[^1];
if (new C<System.Index?>() is [var item4])
item4.ToString();
_ = new C<System.Index?>()[^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (10,29): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// if (new C<int>() is [var item]) // 1
Diagnostic(ErrorCode.ERR_BadArgType, "[var item]").WithArguments("1", "System.Index", "int").WithLocation(10, 29),
// (13,30): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int?'
// if (new C<int?>() is [var item2]) // 2
Diagnostic(ErrorCode.ERR_BadArgType, "[var item2]").WithArguments("1", "System.Index", "int?").WithLocation(13, 30),
// (14,19): error CS1061: 'int' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
// item2.Value.ToString(); // 3
Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "Value").WithArguments("int", "Value").WithLocation(14, 19),
// (15,36): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int?'
// var item22 = new C<int?>()[^1]; // 4
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int?").WithLocation(15, 36),
// (16,16): error CS1061: 'int' does not contain a definition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)
// item22.Value.ToString(); // 5
Diagnostic(ErrorCode.ERR_NoSuchMemberOrExtension, "Value").WithArguments("int", "Value").WithLocation(16, 16)
);
}
[Fact]
public void ListPattern_Nullability()
{
var source = @"
#nullable enable
class C<T>
{
public int Length => throw null!;
public T this[int i] => throw null!;
public void M()
{
if (new C<int>() is [var item])
item.ToString();
else
item.ToString(); // 1
if (new C<int?>() is [var item2])
item2.Value.ToString(); // 2
else
item2.Value.ToString(); // 3, 4
if (new C<string?>() is [var item3])
item3.ToString(); // 5
else
item3.ToString(); // 6, 7
if (new C<string>() is [var item4])
{
item4.ToString();
item4 = null;
}
else
item4.ToString(); // 8, 9
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (13,13): error CS0165: Use of unassigned local variable 'item'
// item.ToString(); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "item").WithArguments("item").WithLocation(13, 13),
// (16,13): warning CS8629: Nullable value type may be null.
// item2.Value.ToString(); // 2
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "item2").WithLocation(16, 13),
// (18,13): warning CS8629: Nullable value type may be null.
// item2.Value.ToString(); // 3, 4
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "item2").WithLocation(18, 13),
// (18,13): error CS0165: Use of unassigned local variable 'item2'
// item2.Value.ToString(); // 3, 4
Diagnostic(ErrorCode.ERR_UseDefViolation, "item2").WithArguments("item2").WithLocation(18, 13),
// (21,13): warning CS8602: Dereference of a possibly null reference.
// item3.ToString(); // 5
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item3").WithLocation(21, 13),
// (23,13): warning CS8602: Dereference of a possibly null reference.
// item3.ToString(); // 6, 7
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item3").WithLocation(23, 13),
// (23,13): error CS0165: Use of unassigned local variable 'item3'
// item3.ToString(); // 6, 7
Diagnostic(ErrorCode.ERR_UseDefViolation, "item3").WithArguments("item3").WithLocation(23, 13),
// (31,13): warning CS8602: Dereference of a possibly null reference.
// item4.ToString(); // 8, 9
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item4").WithLocation(31, 13),
// (31,13): error CS0165: Use of unassigned local variable 'item4'
// item4.ToString(); // 8, 9
Diagnostic(ErrorCode.ERR_UseDefViolation, "item4").WithArguments("item4").WithLocation(31, 13)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var declarations = tree.GetRoot().DescendantNodes().OfType<VarPatternSyntax>().ToArray();
Assert.Equal(4, declarations.Length);
verify(declarations[0], "item", "System.Int32");
verify(declarations[1], "item2", "System.Int32?");
verify(declarations[2], "item3", "System.String?");
verify(declarations[3], "item4", "System.String?");
void verify(VarPatternSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration.Designation)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
}
[Fact]
public void ListPattern_Nullability_IndexIndexer()
{
var source = @"
using System;
#nullable enable
class C<T>
{
public int Length => throw null!;
public T this[Index i] => throw null!;
public void M()
{
if (new C<int>() is [var item])
item.ToString();
else
item.ToString(); // 1
if (new C<int?>() is [var item2])
item2.Value.ToString(); // 2
else
item2.Value.ToString(); // 3, 4
if (new C<string?>() is [var item3])
item3.ToString(); // 5
else
item3.ToString(); // 6, 7
if (new C<string>() is [var item4])
{
item4.ToString();
item4 = null;
}
else
item4.ToString(); // 8, 9
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (14,13): error CS0165: Use of unassigned local variable 'item'
// item.ToString(); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "item").WithArguments("item").WithLocation(14, 13),
// (17,13): warning CS8629: Nullable value type may be null.
// item2.Value.ToString(); // 2
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "item2").WithLocation(17, 13),
// (19,13): warning CS8629: Nullable value type may be null.
// item2.Value.ToString(); // 3, 4
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "item2").WithLocation(19, 13),
// (19,13): error CS0165: Use of unassigned local variable 'item2'
// item2.Value.ToString(); // 3, 4
Diagnostic(ErrorCode.ERR_UseDefViolation, "item2").WithArguments("item2").WithLocation(19, 13),
// (22,13): warning CS8602: Dereference of a possibly null reference.
// item3.ToString(); // 5
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item3").WithLocation(22, 13),
// (24,13): warning CS8602: Dereference of a possibly null reference.
// item3.ToString(); // 6, 7
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item3").WithLocation(24, 13),
// (24,13): error CS0165: Use of unassigned local variable 'item3'
// item3.ToString(); // 6, 7
Diagnostic(ErrorCode.ERR_UseDefViolation, "item3").WithArguments("item3").WithLocation(24, 13),
// (32,13): warning CS8602: Dereference of a possibly null reference.
// item4.ToString(); // 8, 9
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item4").WithLocation(32, 13),
// (32,13): error CS0165: Use of unassigned local variable 'item4'
// item4.ToString(); // 8, 9
Diagnostic(ErrorCode.ERR_UseDefViolation, "item4").WithArguments("item4").WithLocation(32, 13)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var declarations = tree.GetRoot().DescendantNodes().OfType<VarPatternSyntax>().ToArray();
Assert.Equal(4, declarations.Length);
verify(declarations[0], "item", "System.Int32");
verify(declarations[1], "item2", "System.Int32?");
verify(declarations[2], "item3", "System.String?");
verify(declarations[3], "item4", "System.String?");
void verify(VarPatternSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration.Designation)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
}
[Fact]
public void ListPattern_Nullability_Array()
{
var source = @"
#nullable enable
class C
{
public void M()
{
if (new int[0] is [var item])
item.ToString();
else
item.ToString(); // 1
if (new int?[0] is [var item2])
item2.ToString();
else
item2.ToString(); // 2
if (new string?[0] is [var item3])
item3.ToString(); // 3
else
item3.ToString(); // 4, 5
if (new string[0] is [var item4])
{
item4.ToString();
item4 = null;
}
else
item4.ToString(); // 6, 7
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (10,13): error CS0165: Use of unassigned local variable 'item'
// item.ToString(); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "item").WithArguments("item").WithLocation(10, 13),
// (15,13): error CS0165: Use of unassigned local variable 'item2'
// item2.ToString(); // 2
Diagnostic(ErrorCode.ERR_UseDefViolation, "item2").WithArguments("item2").WithLocation(15, 13),
// (18,13): warning CS8602: Dereference of a possibly null reference.
// item3.ToString(); // 3
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item3").WithLocation(18, 13),
// (20,13): warning CS8602: Dereference of a possibly null reference.
// item3.ToString(); // 4, 5
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item3").WithLocation(20, 13),
// (20,13): error CS0165: Use of unassigned local variable 'item3'
// item3.ToString(); // 4, 5
Diagnostic(ErrorCode.ERR_UseDefViolation, "item3").WithArguments("item3").WithLocation(20, 13),
// (28,13): warning CS8602: Dereference of a possibly null reference.
// item4.ToString(); // 6, 7
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "item4").WithLocation(28, 13),
// (28,13): error CS0165: Use of unassigned local variable 'item4'
// item4.ToString(); // 6, 7
Diagnostic(ErrorCode.ERR_UseDefViolation, "item4").WithArguments("item4").WithLocation(28, 13)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var declarations = tree.GetRoot().DescendantNodes().OfType<VarPatternSyntax>().ToArray();
Assert.Equal(4, declarations.Length);
verify(declarations[0], "item", "System.Int32");
verify(declarations[1], "item2", "System.Int32?");
verify(declarations[2], "item3", "System.String?");
verify(declarations[3], "item4", "System.String?");
void verify(VarPatternSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration.Designation)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
}
[Fact]
public void ListPattern_Nullability_MaybeNullReceiver()
{
var source = @"
#nullable enable
class C<T>
{
public int Length => throw null!;
public T this[int i] => throw null!;
public void M(C<int>? c)
{
if (c is [var item])
item.ToString();
_ = c[^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (13,13): warning CS8602: Dereference of a possibly null reference.
// _ = c[^1];
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "c").WithLocation(13, 13)
);
}
[Fact]
public void SlicePattern_Nullability()
{
var source = @"
#nullable enable
class C<T>
{
public int Length => throw null!;
public int this[int i] => throw null!;
public T Slice(int i, int j) => throw null!;
public void M()
{
if (new C<int>() is [1, ..var rest])
rest.ToString();
else
rest.ToString(); // 1
if (new C<int?>() is [1, ..var rest2])
rest2.Value.ToString(); // (assumed not-null)
else
rest2.Value.ToString(); // 2, 3
if (new C<string?>() is [1, ..var rest3])
rest3.ToString(); // (assumed not-null)
else
rest3.ToString(); // 4, 5
if (new C<string>() is [1, ..var rest4])
{
rest4.ToString();
rest4 = null;
}
else
rest4.ToString(); // 6, 7
if (new C<T>() is [1, ..var rest5])
{
rest5.ToString(); // (assumed not-null)
rest5 = default;
}
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (14,13): error CS0165: Use of unassigned local variable 'rest'
// rest.ToString(); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest").WithArguments("rest").WithLocation(14, 13),
// (19,13): warning CS8629: Nullable value type may be null.
// rest2.Value.ToString(); // 2, 3
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "rest2").WithLocation(19, 13),
// (19,13): error CS0165: Use of unassigned local variable 'rest2'
// rest2.Value.ToString(); // 2, 3
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest2").WithArguments("rest2").WithLocation(19, 13),
// (24,13): warning CS8602: Dereference of a possibly null reference.
// rest3.ToString(); // 4, 5
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest3").WithLocation(24, 13),
// (24,13): error CS0165: Use of unassigned local variable 'rest3'
// rest3.ToString(); // 4, 5
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest3").WithArguments("rest3").WithLocation(24, 13),
// (32,13): warning CS8602: Dereference of a possibly null reference.
// rest4.ToString(); // 6, 7
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest4").WithLocation(32, 13),
// (32,13): error CS0165: Use of unassigned local variable 'rest4'
// rest4.ToString(); // 6, 7
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest4").WithArguments("rest4").WithLocation(32, 13)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var declarations = tree.GetRoot().DescendantNodes().OfType<VarPatternSyntax>().ToArray();
Assert.Equal(5, declarations.Length);
verify(declarations[0], "rest", "System.Int32");
verify(declarations[1], "rest2", "System.Int32?");
verify(declarations[2], "rest3", "System.String?");
verify(declarations[3], "rest4", "System.String?");
verify(declarations[4], "rest5", "T?");
void verify(VarPatternSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration.Designation)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
}
[Fact]
public void SlicePattern_Nullability_Annotation()
{
var source = @"
#nullable enable
class C
{
public int Length => throw null!;
public int this[int i] => throw null!;
public int[]? Slice(int i, int j) => throw null!;
public void M()
{
if (this is [1, ..var slice])
slice.ToString();
if (this is [1, ..[] list])
list.ToString();
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics();
var tree = compilation.SyntaxTrees.Single();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var nodes = tree.GetRoot().DescendantNodes().OfType<SingleVariableDesignationSyntax>();
Assert.Collection(nodes,
d => verify(d, "slice", "int[]?", "int[]"),
d => verify(d, "list", "int[]?", "int[]")
);
void verify(SyntaxNode designation, string syntax, string declaredType, string type)
{
Assert.Equal(syntax, designation.ToString());
var model = compilation.GetSemanticModel(tree);
var symbol = model.GetDeclaredSymbol(designation);
Assert.Equal(SymbolKind.Local, symbol.Kind);
Assert.Equal(declaredType, ((ILocalSymbol)symbol).Type.ToDisplayString());
var typeInfo = model.GetTypeInfo(designation);
Assert.Null(typeInfo.Type);
Assert.Null(typeInfo.ConvertedType);
typeInfo = model.GetTypeInfo(designation.Parent);
Assert.Equal(type, typeInfo.Type.ToDisplayString());
Assert.Equal(type, typeInfo.ConvertedType.ToDisplayString());
}
}
[Fact]
public void SlicePattern_Nullability_RangeIndexer()
{
var source = @"
#nullable enable
using System;
class C<T>
{
public int Length => throw null!;
public int this[Index i] => throw null!;
public T this[Range r] => throw null!;
public void M()
{
if (new C<int>() is [1, ..var rest])
rest.ToString();
else
rest.ToString(); // 1
if (new C<int?>() is [1, ..var rest2])
rest2.Value.ToString(); // (assumed not-null)
else
rest2.Value.ToString(); // 2, 3
if (new C<string?>() is [1, ..var rest3])
rest3.ToString(); // (assumed not-null)
else
rest3.ToString(); // 4, 5
if (new C<string>() is [1, ..var rest4])
{
rest4.ToString();
rest4 = null;
}
else
rest4.ToString(); // 6, 7
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (15,13): error CS0165: Use of unassigned local variable 'rest'
// rest.ToString(); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest").WithArguments("rest").WithLocation(15, 13),
// (20,13): warning CS8629: Nullable value type may be null.
// rest2.Value.ToString(); // 2, 3
Diagnostic(ErrorCode.WRN_NullableValueTypeMayBeNull, "rest2").WithLocation(20, 13),
// (20,13): error CS0165: Use of unassigned local variable 'rest2'
// rest2.Value.ToString(); // 2, 3
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest2").WithArguments("rest2").WithLocation(20, 13),
// (25,13): warning CS8602: Dereference of a possibly null reference.
// rest3.ToString(); // 4, 5
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest3").WithLocation(25, 13),
// (25,13): error CS0165: Use of unassigned local variable 'rest3'
// rest3.ToString(); // 4, 5
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest3").WithArguments("rest3").WithLocation(25, 13),
// (33,13): warning CS8602: Dereference of a possibly null reference.
// rest4.ToString(); // 6, 7
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest4").WithLocation(33, 13),
// (33,13): error CS0165: Use of unassigned local variable 'rest4'
// rest4.ToString(); // 6, 7
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest4").WithArguments("rest4").WithLocation(33, 13)
);
}
[Fact]
public void SlicePattern_Nullability_Array()
{
var source = @"
#nullable enable
class C
{
public void M()
{
if (new int[0] is [1, ..var rest])
{
rest.ToString();
rest = null;
}
else
rest.ToString(); // 1, 2
if (new int?[0] is [1, ..var rest2])
rest2.ToString();
else
rest2.ToString(); // 3, 4
if (new string?[0] is [null, ..var rest3])
rest3.ToString();
else
rest3.ToString(); // 5, 6
if (new string[0] is [null, ..var rest4])
rest4.ToString();
else
rest4.ToString(); // 7, 8
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (13,13): warning CS8602: Dereference of a possibly null reference.
// rest.ToString(); // 1, 2
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest").WithLocation(13, 13),
// (13,13): error CS0165: Use of unassigned local variable 'rest'
// rest.ToString(); // 1, 2
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest").WithArguments("rest").WithLocation(13, 13),
// (18,13): warning CS8602: Dereference of a possibly null reference.
// rest2.ToString(); // 3, 4
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest2").WithLocation(18, 13),
// (18,13): error CS0165: Use of unassigned local variable 'rest2'
// rest2.ToString(); // 3, 4
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest2").WithArguments("rest2").WithLocation(18, 13),
// (23,13): warning CS8602: Dereference of a possibly null reference.
// rest3.ToString(); // 5, 6
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest3").WithLocation(23, 13),
// (23,13): error CS0165: Use of unassigned local variable 'rest3'
// rest3.ToString(); // 5, 6
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest3").WithArguments("rest3").WithLocation(23, 13),
// (28,13): warning CS8602: Dereference of a possibly null reference.
// rest4.ToString(); // 7, 8
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "rest4").WithLocation(28, 13),
// (28,13): error CS0165: Use of unassigned local variable 'rest4'
// rest4.ToString(); // 7, 8
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest4").WithArguments("rest4").WithLocation(28, 13)
);
var tree = compilation.SyntaxTrees.First();
var model = compilation.GetSemanticModel(tree, ignoreAccessibility: false);
var declarations = tree.GetRoot().DescendantNodes().OfType<VarPatternSyntax>().ToArray();
Assert.Equal(4, declarations.Length);
verify(declarations[0], "rest", "System.Int32[]?");
verify(declarations[1], "rest2", "System.Int32?[]?");
verify(declarations[2], "rest3", "System.String?[]?");
verify(declarations[3], "rest4", "System.String![]?");
void verify(VarPatternSyntax declaration, string name, string expectedType)
{
var local = (ILocalSymbol)model.GetDeclaredSymbol(declaration.Designation)!;
Assert.Equal(name, local.Name);
Assert.Equal(expectedType, local.Type.ToTestDisplayString(includeNonNullable: true));
}
}
[Fact]
public void SlicePattern_Nullability_MaybeNullReceiver()
{
var source = @"
#nullable enable
class C<T>
{
public int Length => throw null!;
public T this[int i] => throw null!;
public T Slice(int i, int j) => throw null!;
public void M(C<int>? c)
{
if (c is [.. var item])
item.ToString();
_ = c[..];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (14,13): warning CS8602: Dereference of a possibly null reference.
// _ = c[..];
Diagnostic(ErrorCode.WRN_NullReferenceReceiver, "c").WithLocation(14, 13)
);
}
[Fact]
public void SlicePattern_DefiniteAssignment()
{
var source = @"
class C
{
public int Length => throw null!;
public int this[int i] => throw null!;
public int Slice(int i, int j) => throw null!;
public void M()
{
if (new C() is [var item, ..var rest])
{
item.ToString();
rest.ToString();
}
else
{
item.ToString(); // 1
rest.ToString(); // 2
}
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (17,13): error CS0165: Use of unassigned local variable 'item'
// item.ToString(); // 1
Diagnostic(ErrorCode.ERR_UseDefViolation, "item").WithArguments("item").WithLocation(17, 13),
// (18,13): error CS0165: Use of unassigned local variable 'rest'
// rest.ToString(); // 2
Diagnostic(ErrorCode.ERR_UseDefViolation, "rest").WithArguments("rest").WithLocation(18, 13)
);
}
[Fact]
public void SlicePattern_LengthAndIndexAndSliceAreStatic()
{
// Length, indexer and Slice are static
var il = @"
.class public auto ansi beforefieldinit C extends [mscorlib]System.Object
{
.method public hidebysig specialname static int32 get_Length () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static specialname int32 get_Item ( int32 i ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static int32 Slice ( int32 i, int32 j ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname rtspecialname instance void .ctor () cil managed
{
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
}
.property int32 Length()
{
.get int32 C::get_Length()
}
.property int32 Item( int32 i )
{
.get int32 C::get_Item(int32)
}
}
";
var source = @"
class D
{
public void M()
{
_ = new C() is [var item, ..var rest];
_ = new C()[^1];
_ = new C()[..];
}
}
";
var compilation = CreateCompilationWithIL(new[] { source, TestSources.Index, TestSources.Range }, il);
compilation.VerifyEmitDiagnostics(
// (6,24): error CS0021: Cannot apply indexing with [] to an expression of type 'C'
// _ = new C() is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "[var item, ..var rest]").WithArguments("C").WithLocation(6, 24),
// (6,35): error CS0021: Cannot apply indexing with [] to an expression of type 'C'
// _ = new C() is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "..var rest").WithArguments("C").WithLocation(6, 35),
// (7,13): error CS0021: Cannot apply indexing with [] to an expression of type 'C'
// _ = new C()[^1];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "new C()[^1]").WithArguments("C").WithLocation(7, 13),
// (8,13): error CS0021: Cannot apply indexing with [] to an expression of type 'C'
// _ = new C()[..];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "new C()[..]").WithArguments("C").WithLocation(8, 13)
);
}
[Fact]
public void SlicePattern_LengthAndIndexAndSliceAreStatic_IndexAndRange()
{
// Length, [Index] and [Range] are static
var il = @"
.class public auto ansi beforefieldinit C extends [mscorlib]System.Object
{
.method public hidebysig specialname static int32 get_Length () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static specialname int32 get_Item ( valuetype System.Index i ) cil managed // static this[System.Index]
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static specialname int32 get_Item ( valuetype System.Range i ) cil managed // static this[System.Range]
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname rtspecialname instance void .ctor () cil managed
{
IL_0000: ldarg.0
IL_0001: call instance void [mscorlib]System.Object::.ctor()
IL_0006: nop
IL_0007: ret
}
.property int32 Length()
{
.get int32 C::get_Length()
}
.property int32 Item( valuetype System.Index i )
{
.get int32 C::get_Item( valuetype System.Index )
}
.property int32 Item( valuetype System.Range i )
{
.get int32 C::get_Item( valuetype System.Range )
}
}
.class public sequential ansi sealed beforefieldinit System.Index
extends [mscorlib]System.ValueType
implements class [mscorlib]System.IEquatable`1<valuetype System.Index>
{
.pack 0
.size 1
.method public hidebysig specialname rtspecialname instance void .ctor ( int32 'value', [opt] bool fromEnd ) cil managed
{
.param [2] = bool(false)
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname static valuetype System.Index get_Start () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname static valuetype System.Index get_End () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static valuetype System.Index FromStart ( int32 'value' ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static valuetype System.Index FromEnd ( int32 'value' ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname instance int32 get_Value () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname instance bool get_IsFromEnd () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig instance int32 GetOffset ( int32 length ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig virtual instance bool Equals ( object 'value' ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public final hidebysig newslot virtual instance bool Equals ( valuetype System.Index other ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig virtual instance int32 GetHashCode () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname static valuetype System.Index op_Implicit ( int32 'value' ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.property valuetype System.Index Start()
{
.get valuetype System.Index System.Index::get_Start()
}
.property valuetype System.Index End()
{
.get valuetype System.Index System.Index::get_End()
}
.property instance int32 Value()
{
.get instance int32 System.Index::get_Value()
}
.property instance bool IsFromEnd()
{
.get instance bool System.Index::get_IsFromEnd()
}
}
.class public sequential ansi sealed beforefieldinit System.Range
extends [mscorlib]System.ValueType
{
.method public hidebysig specialname instance valuetype System.Index get_Start () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname instance valuetype System.Index get_End () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname rtspecialname instance void .ctor ( valuetype System.Index start, valuetype System.Index end ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static valuetype System.Range StartAt ( valuetype System.Index start ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig static valuetype System.Range EndAt ( valuetype System.Index end ) cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.method public hidebysig specialname static valuetype System.Range get_All () cil managed
{
IL_0000: ldnull
IL_0001: throw
}
.property instance valuetype System.Index Start()
{
.get instance valuetype System.Index System.Range::get_Start()
}
.property instance valuetype System.Index End()
{
.get instance valuetype System.Index System.Range::get_End()
}
.property valuetype System.Range All()
{
.get valuetype System.Range System.Range::get_All()
}
}
";
var source = @"
class D
{
public void M()
{
_ = new C() is [var item, ..var rest];
}
}
";
var compilation = CreateCompilationWithIL(source, il);
compilation.VerifyEmitDiagnostics(
// (6,24): error CS0021: Cannot apply indexing with [] to an expression of type 'C'
// _ = new C() is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "[var item, ..var rest]").WithArguments("C").WithLocation(6, 24),
// (6,35): error CS0021: Cannot apply indexing with [] to an expression of type 'C'
// _ = new C() is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "..var rest").WithArguments("C").WithLocation(6, 35)
);
}
[Fact]
public void Pattern_Nullability_Exhaustiveness()
{
var source = @"
#nullable enable
object?[]? o = null;
_ = o switch
{
null => 0,
[null] => 0,
[not null] => 0,
{ Length: 0 or > 1 } => 0,
};
_ = o switch // 1, didn't test for null
{
[null] => 0,
[not null] => 0,
{ Length: 0 or > 1 } => 0,
};
_ = o switch // 2, didn't test for [null]
{
null => 0,
[not null] => 0,
{ Length: 0 or > 1 } => 0,
};
_ = o switch // 3, didn't test for [not null]
{
null => 0,
[null] => 0,
{ Length: 0 or > 1 } => 0,
};
_ = o switch
{
null => 0,
[] => 0,
[.., null] => 0,
[.., not null] => 0,
};
_ = o switch // 4, didn't test for [null]
{
null => 0,
[] => 0,
[.., not null] => 0,
};
_ = o switch // 5, didn't test for [not null]
{
null => 0,
[] => 0,
[.., null] => 0,
};
_ = o switch
{
null => 0,
[.., null] => 0,
[not null, ..] => 0,
{ Length: 0 or > 1 } => 0,
};
_ = o switch // 6, didn't test for [_, null]
{
null => 0,
[] => 0,
[_] => 0,
[.., not null] => 0,
};
_ = o switch // 7, didn't test for [null, _]
{
null => 0,
[] => 0,
[_] => 0,
[not null, ..] => 0,
};
_ = o switch // 8, didn't test for { Length: 0 }
{
null => 0,
[_, ..] => 0,
};
_ = o switch // 9, didn't test for [null]
{
null => 0,
[] => 0,
[..var x, not null] => 0,
};
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
compilation.VerifyEmitDiagnostics(
// (13,7): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern 'null' is not covered.
// _ = o switch // 1, didn't test for null
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("null").WithLocation(13, 7),
// (20,7): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[null]' is not covered.
// _ = o switch // 2, didn't test for [null]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[null]").WithLocation(20, 7),
// (27,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[not null]' is not covered.
// _ = o switch // 3, didn't test for [not null]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[not null]").WithLocation(27, 7),
// (42,7): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[null]' is not covered.
// _ = o switch // 4, didn't test for [null]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[null]").WithLocation(42, 7),
// (49,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[not null]' is not covered.
// _ = o switch // 5, didn't test for [not null]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[not null]").WithLocation(49, 7),
// (64,7): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[_, null]' is not covered.
// _ = o switch // 6, didn't test for [_, null]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[_, null]").WithLocation(64, 7),
// (72,7): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[null, _]' is not covered.
// _ = o switch // 7, didn't test for [null, _]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[null, _]").WithLocation(72, 7),
// (80,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 0 }' is not covered.
// _ = o switch // 8, didn't test for { Length: 0 }
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 0 }").WithLocation(80, 7),
// (86,7): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[null]' is not covered.
// _ = o switch // 9, didn't test for [null]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[null]").WithLocation(86, 7)
);
}
[Fact]
public void SlicePattern_Nullability_Exhaustiveness()
{
var source = @"
#nullable enable
using System;
class C
{
public int Length => throw null!;
public object? this[Index i] => throw null!;
public object? this[Range r] => throw null!;
public void M()
{
_ = this switch
{
null => 0,
[] => 0,
[.. null] => 0,
[.. not null] => 0,
};
_ = this switch // no tests for [.. null, _]
{
null => 0,
[] => 0,
[.. not null] => 0,
};
_ = this switch // no test for [.. not null, _]
{
null => 0,
[] => 0,
[.. null] => 0,
};
_ = this switch
{
null => 0,
[] => 0,
[.. not null] => 0,
[..] => 0,
};
_ = this switch
{
null => 0,
[] => 0,
[.. null] => 0,
[..] => 0,
};
_ = this switch
{
null => 0,
[] => 0,
[null, .. null] => 0,
[..] => 0,
};
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (20,18): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[.. null, _]' is not covered.
// _ = this switch // no tests for [.. null, _]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[.. null, _]").WithLocation(20, 18),
// (27,18): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[.. not null, _]' is not covered.
// _ = this switch // no test for [.. not null, _]
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[.. not null, _]").WithLocation(27, 18)
);
}
[Fact]
public void SlicePattern_Nullability_Exhaustiveness_WithNestedPropertyTest()
{
var source = @"
#nullable enable
using System;
class C
{
public int Length => throw null!;
public D? this[Index i] => throw null!;
public D? this[Range r] => throw null!;
public void M()
{
_ = this switch
{
null => 0,
[] => 0,
[_, _, ..] => 0,
[.. null] => 0,
[.. { Property: < 0 }] => 0,
};
}
}
class D
{
public int Property { get; set; }
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (12,18): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(12, 18)
);
}
[Fact]
public void SlicePattern_Nullability_Exhaustiveness_NestedSlice()
{
var source = @"
#nullable enable
using System;
class C
{
public int Length => throw null!;
public object? this[Index i] => throw null!;
public C? this[Range r] => throw null!;
public void M()
{
_ = this switch
{
null or { Length: not 1 } => 0,
[.. null] => 0,
[.. [null]] => 0,
[not null] => 0,
};
_ = this switch // didn't test for [.. null] but the slice is assumed not-null
{
null or { Length: not 1 } => 0,
[.. [null]] => 0,
[not null] => 0,
};
_ = this switch // didn't test for [.. [not null]] // 1
{
null or { Length: not 1 } => 0,
[.. [null]] => 0,
};
_ = this switch // didn't test for [.. [not null]] // 2
{
null or { Length: not 1 } => 0,
[.. null] => 0,
[.. [null]] => 0,
};
_ = this switch // didn't test for [.. null, _] // we're trying to construct an example with Length=1, the slice may not be null // 3
{
null or { Length: not 1 } => 0,
[.. [not null]] => 0,
};
_ = this switch // didn't test for [_, .. null, _, _, _] // we're trying to construct an example with Length=4, the slice may not be null // 4
{
null or { Length: not 4 } => 0,
[_, .. [_, not null], _] => 0,
};
_ = this switch // exhaustive
{
null or { Length: not 4 } => 0,
[_, .. [_, _], _] => 0,
};
_ = this switch // didn't test for [_, .. [_, null], _] // 5
{
null or { Length: not 4 } => 0,
[_, .. null or [_, not null], _] => 0,
};
_ = this switch // didn't test for [_, .. [_, null], _, _] // 6
{
null or { Length: not 5 } => 0,
[_, .. null or [_, not null], _, _] => 0,
};
_ = this switch // didn't test for [_, .. [_, null, _], _] // 7
{
null or { Length: not 5 } => 0,
[_, .. null or [_, not null, _], _] => 0,
};
_ = this switch // didn't test for [.. null, _] but the slice is assumed not-null
{
null or { Length: not 1 } => 0,
[.. { Length: 1 }] => 0,
};
}
}
";
// Note: we don't try to explain nested slice patterns right now so all these just produce a fallback example
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (27,18): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [.. [not null]] // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(27, 18),
// (33,18): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [.. [not null]] // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(33, 18),
// (40,18): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [.. null, _] // we're trying to construct an example with Length=1, the slice may not be null // 3
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("_").WithLocation(40, 18),
// (46,18): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [_, .. null, _, _, _] // we're trying to construct an example with Length=4, the slice may not be null // 4
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("_").WithLocation(46, 18),
// (58,18): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [_, .. [_, null], _] // 5
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("_").WithLocation(58, 18),
// (64,18): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [_, .. [_, null], _, _] // 6
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("_").WithLocation(64, 18),
// (70,18): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = this switch // didn't test for [_, .. [_, null, _], _] // 7
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("_").WithLocation(70, 18)
);
}
[Fact]
public void SlicePattern_Nullability_Exhaustiveness_Multiple()
{
var source = @"
#nullable enable
using System;
class C
{
public int Length => throw null!;
public object? this[Index i] => throw null!;
public C? this[Range r] => throw null!;
public void M()
{
_ = this switch
{
null => 0,
[] => 0,
[1, .., 2, .., 3] => 0,
{ Length: > 1 } => 0,
};
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (16,24): error CS9202: Slice patterns may only be used once and directly inside a list pattern.
// [1, .., 2, .., 3] => 0,
Diagnostic(ErrorCode.ERR_MisplacedSlicePattern, "..").WithLocation(16, 24)
);
}
[Fact]
public void ListPattern_Dynamic()
{
var source = @"
#nullable enable
class C
{
void M(dynamic d)
{
_ = d is [_, .._];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (7,18): error CS8979: List patterns may not be used for a value of type 'dynamic'.
// _ = d is [_, .._];
Diagnostic(ErrorCode.ERR_UnsupportedTypeForListPattern, "[_, .._]").WithArguments("dynamic").WithLocation(7, 18),
// (7,22): error CS0518: Predefined type 'System.Range' is not defined or imported
// _ = d is [_, .._];
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, ".._").WithArguments("System.Range").WithLocation(7, 22)
);
}
[Fact]
public void ListPattern_UseSiteErrorOnIndexAndRangeIndexers()
{
var missing_cs = @"
public class Missing
{
}
";
var missingRef = CreateCompilation(missing_cs, assemblyName: "missing")
.EmitToImageReference();
var lib2_cs = @"
using System;
public class C
{
public int Length => 0;
public Missing this[Index i] => throw null;
public Missing this[Range r] => throw null;
}
";
var lib2Ref = CreateCompilation(new[] { lib2_cs, TestSources.Index, TestSources.Range }, references: new[] { missingRef })
.EmitToImageReference();
var source = @"
class D
{
void M(C c)
{
_ = c is [var item];
_ = c is [..var rest];
var index = c[^1];
var range = c[1..^1];
}
}
";
var compilation = CreateCompilation(source, references: new[] { lib2Ref });
compilation.VerifyEmitDiagnostics(
// (6,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [var item];
Diagnostic(ErrorCode.ERR_NoTypeDef, "[var item]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(6, 18),
// (7,18): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [..var rest];
Diagnostic(ErrorCode.ERR_NoTypeDef, "[..var rest]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 18),
// (7,19): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// _ = c is [..var rest];
Diagnostic(ErrorCode.ERR_NoTypeDef, "..var rest").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(7, 19),
// (8,21): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var index = c[^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(8, 21),
// (9,21): error CS0012: The type 'Missing' is defined in an assembly that is not referenced. You must add a reference to assembly 'missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'.
// var range = c[1..^1];
Diagnostic(ErrorCode.ERR_NoTypeDef, "c[1..^1]").WithArguments("Missing", "missing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null").WithLocation(9, 21)
);
}
[Fact]
public void ListPattern_RefParameters()
{
var source = @"
class C
{
public int Length => 0;
public int this[ref int i] => 0;
public int Slice(ref int i, ref int j) => 0;
void M()
{
_ = this is [var item, ..var rest];
_ = this[^1];
_ = this[1..^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (5,21): error CS0631: ref and out are not valid in this context
// public int this[ref int i] => 0;
Diagnostic(ErrorCode.ERR_IllegalRefParam, "ref").WithLocation(5, 21),
// (10,21): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadArgRef, "[var item, ..var rest]").WithArguments("1", "ref").WithLocation(10, 21),
// (10,32): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadArgRef, "..var rest").WithArguments("1", "ref").WithLocation(10, 32),
// (11,18): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this[^1];
Diagnostic(ErrorCode.ERR_BadArgRef, "^1").WithArguments("1", "ref").WithLocation(11, 18),
// (12,18): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this[1..^1];
Diagnostic(ErrorCode.ERR_BadArgRef, "1..^1").WithArguments("1", "ref").WithLocation(12, 18)
);
}
[Fact]
public void ListPattern_RefParametersInIndexAndRangeIndexers()
{
var source = @"
using System;
class C
{
public int Length => 0;
public int this[ref Index i] => 0;
public int this[ref Range r] => 0;
void M()
{
_ = this is [var item, ..var rest];
_ = this[^1];
_ = this[1..^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics(
// (6,21): error CS0631: ref and out are not valid in this context
// public int this[ref Index i] => 0;
Diagnostic(ErrorCode.ERR_IllegalRefParam, "ref").WithLocation(6, 21),
// (7,21): error CS0631: ref and out are not valid in this context
// public int this[ref Range r] => 0;
Diagnostic(ErrorCode.ERR_IllegalRefParam, "ref").WithLocation(7, 21),
// (11,21): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadArgRef, "[var item, ..var rest]").WithArguments("1", "ref").WithLocation(11, 21),
// (11,32): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadArgRef, "..var rest").WithArguments("1", "ref").WithLocation(11, 32),
// (12,18): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this[^1];
Diagnostic(ErrorCode.ERR_BadArgRef, "^1").WithArguments("1", "ref").WithLocation(12, 18),
// (13,18): error CS1620: Argument 1 must be passed with the 'ref' keyword
// _ = this[1..^1];
Diagnostic(ErrorCode.ERR_BadArgRef, "1..^1").WithArguments("1", "ref").WithLocation(13, 18)
);
}
[Fact]
public void ListPattern_InParameters()
{
var source = @"
class C
{
public int Length => 0;
public int this[in int i] => 0;
public int Slice(in int i, in int j) => 0;
void M()
{
_ = this is [var item, ..var rest];
_ = this[^1];
_ = this[1..^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (10,21): error CS1503: Argument 1: cannot convert from 'System.Index' to 'in int'
// _ = this is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_BadArgType, "[var item, ..var rest]").WithArguments("1", "System.Index", "in int").WithLocation(10, 21),
// (10,32): error CS0518: Predefined type 'System.Range' is not defined or imported
// _ = this is [var item, ..var rest];
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "..var rest").WithArguments("System.Range").WithLocation(10, 32),
// (11,18): error CS1503: Argument 1: cannot convert from 'System.Index' to 'in int'
// _ = this[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "in int").WithLocation(11, 18),
// (12,18): error CS0518: Predefined type 'System.Range' is not defined or imported
// _ = this[1..^1];
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "1..^1").WithArguments("System.Range").WithLocation(12, 18)
);
}
[Fact]
public void ListPattern_InParametersInIndexAndRangeIndexers()
{
var source = @"
new C().M();
public class C
{
public int Length => 2;
public string this[in System.Index i] => ""item value"";
public string this[in System.Range r] => ""rest value"";
public void M()
{
if (this is [var item, ..var rest])
{
System.Console.Write((item, rest));
}
}
void M2()
{
_ = this[^1];
_ = this[1..^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics();
var verifier = CompileAndVerify(compilation, expectedOutput: "(item value, rest value)");
verifier.VerifyIL("C.M", @"
{
// Code size 79 (0x4f)
.maxstack 4
.locals init (string V_0, //item
string V_1, //rest
C V_2,
System.Index V_3,
System.Range V_4)
IL_0000: ldarg.0
IL_0001: stloc.2
IL_0002: ldloc.2
IL_0003: brfalse.s IL_004e
IL_0005: ldloc.2
IL_0006: callvirt ""int C.Length.get""
IL_000b: ldc.i4.1
IL_000c: blt.s IL_004e
IL_000e: ldloc.2
IL_000f: ldc.i4.0
IL_0010: ldc.i4.0
IL_0011: newobj ""System.Index..ctor(int, bool)""
IL_0016: stloc.3
IL_0017: ldloca.s V_3
IL_0019: callvirt ""string C.this[in System.Index].get""
IL_001e: stloc.0
IL_001f: ldloc.2
IL_0020: ldc.i4.1
IL_0021: ldc.i4.0
IL_0022: newobj ""System.Index..ctor(int, bool)""
IL_0027: ldc.i4.0
IL_0028: ldc.i4.1
IL_0029: newobj ""System.Index..ctor(int, bool)""
IL_002e: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_0033: stloc.s V_4
IL_0035: ldloca.s V_4
IL_0037: callvirt ""string C.this[in System.Range].get""
IL_003c: stloc.1
IL_003d: ldloc.0
IL_003e: ldloc.1
IL_003f: newobj ""System.ValueTuple<string, string>..ctor(string, string)""
IL_0044: box ""System.ValueTuple<string, string>""
IL_0049: call ""void System.Console.Write(object)""
IL_004e: ret
}
");
}
[Fact]
public void ListPattern_ImplicitlyConvertibleFromIndexAndRange()
{
var source = @"
new C().M();
public class MyIndex
{
public static implicit operator MyIndex(System.Index i) => new MyIndex();
}
public class MyRange
{
public static implicit operator MyRange(System.Range i) => new MyRange();
}
public class C
{
public int Length => 2;
public string this[MyIndex i] => ""item value"";
public string this[MyRange r] => ""rest value"";
public void M()
{
if (this is [var item, ..var rest])
{
System.Console.Write((item, rest));
}
}
void M2()
{
_ = this[^1];
_ = this[1..^1];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
compilation.VerifyEmitDiagnostics();
var verifier = CompileAndVerify(compilation, expectedOutput: "(item value, rest value)");
verifier.VerifyIL("C.M", @"
{
// Code size 82 (0x52)
.maxstack 4
.locals init (string V_0, //item
string V_1, //rest
C V_2)
IL_0000: ldarg.0
IL_0001: stloc.2
IL_0002: ldloc.2
IL_0003: brfalse.s IL_0051
IL_0005: ldloc.2
IL_0006: callvirt ""int C.Length.get""
IL_000b: ldc.i4.1
IL_000c: blt.s IL_0051
IL_000e: ldloc.2
IL_000f: ldc.i4.0
IL_0010: ldc.i4.0
IL_0011: newobj ""System.Index..ctor(int, bool)""
IL_0016: call ""MyIndex MyIndex.op_Implicit(System.Index)""
IL_001b: callvirt ""string C.this[MyIndex].get""
IL_0020: stloc.0
IL_0021: ldloc.2
IL_0022: ldc.i4.1
IL_0023: ldc.i4.0
IL_0024: newobj ""System.Index..ctor(int, bool)""
IL_0029: ldc.i4.0
IL_002a: ldc.i4.1
IL_002b: newobj ""System.Index..ctor(int, bool)""
IL_0030: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_0035: call ""MyRange MyRange.op_Implicit(System.Range)""
IL_003a: callvirt ""string C.this[MyRange].get""
IL_003f: stloc.1
IL_0040: ldloc.0
IL_0041: ldloc.1
IL_0042: newobj ""System.ValueTuple<string, string>..ctor(string, string)""
IL_0047: box ""System.ValueTuple<string, string>""
IL_004c: call ""void System.Console.Write(object)""
IL_0051: ret
}
");
}
[Fact]
public void ListPattern_ExpressionTree()
{
var source = @"
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
class C
{
void M(int[] array)
{
Expression<Func<bool>> ok1 = () => array is [_, ..];
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index });
compilation.VerifyEmitDiagnostics(
// (9,44): error CS8122: An expression tree may not contain an 'is' pattern-matching operator.
// Expression<Func<bool>> ok1 = () => array is [_, ..];
Diagnostic(ErrorCode.ERR_ExpressionTreeContainsIsMatch, "array is [_, ..]").WithLocation(9, 44)
);
}
[Fact]
public void RealIndexersPreferredToPattern()
{
var src = @"
using System;
class C
{
public int Count => 2;
public int this[int i] => throw null;
public int this[Index i] { get { Console.Write(""Index ""); return 42; } }
public int Slice(int i, int j) => throw null;
public int this[Range r] { get { Console.Write(""Range ""); return 43; } }
static void Main()
{
if (new C() is [var x, .. var y])
Console.Write((x, y));
}
}";
CompileAndVerify(new[] { src, TestSources.Index, TestSources.Range }, expectedOutput: "Index Range (42, 43)");
}
[Fact]
public void SlicePattern_ExtensionIgnored()
{
var src = @"
_ = new C() is [..var y];
_ = new C()[..];
static class Extensions
{
public static int Slice(this C c, int i, int j) => throw null;
}
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics(
// (2,17): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new C() is [..var y];
Diagnostic(ErrorCode.ERR_BadArgType, "..var y").WithArguments("1", "System.Range", "int").WithLocation(2, 17),
// (3,13): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = new C()[..];
Diagnostic(ErrorCode.ERR_BadArgType, "..").WithArguments("1", "System.Range", "int").WithLocation(3, 13)
);
}
[Fact]
public void SlicePattern_String()
{
var src = @"
if (""abc"" is [var first, ..var rest])
{
System.Console.Write((first, rest).ToString());
}
";
CompileAndVerify(new[] { src, TestSources.Index, TestSources.Range }, expectedOutput: "(a, bc)");
}
[Fact]
public void ListPattern_Exhaustiveness_Count()
{
var src = @"
_ = new C() switch // 1
{
{ Count: 0 } => 0,
[_] => 1,
// missing
};
_ = new C() switch // 2
{
{ Count: 0 } => 0,
// missing
[ _, _, .. ] => 2,
};
_ = new C() switch // 3
{
{ Count: 0 } => 0,
// missing
[_, _] => 2,
[_, _, ..] => 3,
};
_ = new C() switch
{
{ Count: 0 } => 0,
{ Count: 1 } => 1,
[_, _] => 2,
{ Count: > 2 } => 3,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 2 }' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 2 }").WithLocation(2, 13),
// (9,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 1 }' is not covered.
// _ = new C() switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 1 }").WithLocation(9, 13),
// (16,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 1 }' is not covered.
// _ = new C() switch // 3
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 1 }").WithLocation(16, 13)
);
comp = CreateCompilation(src);
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 2 }' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 2 }").WithLocation(2, 13),
// (5,5): error CS0518: Predefined type 'System.Index' is not defined or imported
// [_] => 1,
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[_]").WithArguments("System.Index").WithLocation(5, 5),
// (5,5): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// [_] => 1,
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[_]").WithArguments("System.Index", "GetOffset").WithLocation(5, 5),
// (9,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 1 }' is not covered.
// _ = new C() switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 1 }").WithLocation(9, 13),
// (13,5): error CS0518: Predefined type 'System.Index' is not defined or imported
// [ _, _, .. ] => 2,
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[ _, _, .. ]").WithArguments("System.Index").WithLocation(13, 5),
// (13,5): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// [ _, _, .. ] => 2,
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[ _, _, .. ]").WithArguments("System.Index", "GetOffset").WithLocation(13, 5),
// (16,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 1 }' is not covered.
// _ = new C() switch // 3
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 1 }").WithLocation(16, 13),
// (20,5): error CS0518: Predefined type 'System.Index' is not defined or imported
// [_, _] => 2,
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[_, _]").WithArguments("System.Index").WithLocation(20, 5),
// (20,5): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// [_, _] => 2,
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[_, _]").WithArguments("System.Index", "GetOffset").WithLocation(20, 5),
// (21,5): error CS0518: Predefined type 'System.Index' is not defined or imported
// [_, _, ..] => 3,
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[_, _, ..]").WithArguments("System.Index").WithLocation(21, 5),
// (21,5): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// [_, _, ..] => 3,
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[_, _, ..]").WithArguments("System.Index", "GetOffset").WithLocation(21, 5),
// (28,5): error CS0518: Predefined type 'System.Index' is not defined or imported
// [_, _] => 2,
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[_, _]").WithArguments("System.Index").WithLocation(28, 5),
// (28,5): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// [_, _] => 2,
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[_, _]").WithArguments("System.Index", "GetOffset").WithLocation(28, 5)
);
}
[Fact]
public void ListPattern_Exhaustiveness_FirstPosition()
{
var src = @"
_ = new C() switch // 1
{
[> 0] => 1,
[< 0] => 2,
};
_ = new C() switch // 2
{
[> 0] => 1,
[< 0] => 2,
{ Count: 0 or > 1 } => 3,
};
_ = new C() switch
{
[> 0] => 1,
[< 0] => 2,
{ Count: 0 or > 1 } => 3,
[0] => 4,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Count: 0 }' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Count: 0 }").WithLocation(2, 13),
// (8,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[0]' is not covered.
// _ = new C() switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[0]").WithLocation(8, 13)
);
}
[Fact]
public void ListPattern_Exhaustiveness_FirstPosition_Nullability()
{
var src = @"
#nullable enable
_ = new C() switch // 1
{
null => 0,
[not null] => 1,
{ Count: 0 or > 1 } => 2,
};
_ = new C() switch
{
null => 0,
[not null] => 1,
[null] => 2,
{ Count: 0 or > 1 } => 3,
};
_ = new C() switch // 2
{
[not null] => 1,
{ Count: 0 or > 1 } => 2,
};
_ = new C() switch
{
[not null] => 1,
[null] => 2,
{ Count: 0 or > 1 } => 3,
};
class C
{
public int Count => throw null!;
public string? this[int i] => throw null!;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (3,13): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern '[null]' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("[null]").WithLocation(3, 13),
// (18,13): warning CS8655: The switch expression does not handle some null inputs (it is not exhaustive). For example, the pattern 'null' is not covered.
// _ = new C() switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustiveForNull, "switch").WithArguments("null").WithLocation(18, 13)
);
}
[Fact]
public void ListPattern_Exhaustiveness_SecondPosition()
{
var src = @"
_ = new C() switch // 1
{
[_, > 0] => 1,
[_, < 0] => 2,
{ Count: <= 1 or > 2 } => 3,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[_, 0]' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[_, 0]").WithLocation(2, 13)
);
}
[Fact]
public void ListPattern_Exhaustiveness_SecondToLastPosition()
{
var src = @"
_ = new C() switch // 1
{
[.., > 0, _] => 1,
[.., < 0, _] => 2,
{ Count: <= 1 } => 3,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[0, _]' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[0, _]").WithLocation(2, 13)
);
}
[Fact]
public void ListPattern_Exhaustiveness_LastPosition()
{
var src = @"
_ = new C() switch // 1
{
[.., > 0] => 1,
[.., < 0] => 2,
{ Count: 0 } => 3,
};
_ = new C() switch // 2
{
{ Count: <= 2 } => 1,
[.., > 0] => 2,
[.., < 0] => 3,
};
_ = new C() switch // 3
{
{ Count: <= 2 } => 1,
[0, ..] => 2,
[.., > 0] => 3,
[.., < 0] => 4,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[0]' is not covered.
// _ = new C() switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[0]").WithLocation(2, 13),
// (9,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[_, _, 0]' is not covered.
// _ = new C() switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[_, _, 0]").WithLocation(9, 13),
// (16,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '[1, _, 0]' is not covered.
// _ = new C() switch // 3
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("[1, _, 0]").WithLocation(16, 13)
);
}
[Fact]
public void ListPattern_Exhaustiveness_Slice()
{
var src = @"
_ = new C() switch
{
null or { Length: 4 } => 0,
[_, .., _] => 0
};
class C
{
public int Length => throw null;
public int this[int i] => throw null;
}
";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 0 }' is not covered.
// _ = new C() switch
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 0 }").WithLocation(2, 13)
);
}
[Fact]
public void ListPattern_Exhaustiveness_StartAndEndPatternsOverlap()
{
var src = @"
_ = new C() switch
{
[.., >= 0] => 1,
[< 0] => 2,
{ Count: 0 or > 1 } => 3,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics();
}
[Fact]
public void ListPattern_Exhaustiveness_NestedSlice()
{
var src = @"
_ = new C() switch
{
[>= 0] => 1,
[..[< 0]] => 2,
{ Count: 0 or > 1 } => 3,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
public C Slice(int i, int j) => throw null;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
}
[Fact]
public void ListPattern_Exhaustiveness_Conjunction()
{
var src = @"
_ = new C() switch
{
{ Count: not 1 } => 0,
[0] or not Derived => 0,
};
class C
{
public int Count => throw null;
public int this[int i] => throw null;
public C Slice(int i, int j) => throw null;
}
class Derived : C { }
";
// Note: we don't know how to explain `Derived and [1]`
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = new C() switch
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(2, 13)
);
}
[Fact]
public void ListPattern_UintCount()
{
var src = @"
_ = new C() switch // 1
{
[..] => 1,
};
_ = new C()[^1]; // 2
class C
{
public uint Count => throw null!;
public int this[int i] => throw null!;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (4,5): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// [..] => 1,
Diagnostic(ErrorCode.ERR_BadArgType, "[..]").WithArguments("1", "System.Index", "int").WithLocation(4, 5),
// (7,13): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new C()[^1]; // 2
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(7, 13)
);
}
[Fact]
public void ListPattern_NintCount()
{
var src = @"
_ = new C() switch // 1
{
[..] => 1,
};
_ = new C()[^1]; // 2, 3
class C
{
public nint Count => throw null!;
public int this[int i] => throw null!;
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (4,5): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// [..] => 1,
Diagnostic(ErrorCode.ERR_BadArgType, "[..]").WithArguments("1", "System.Index", "int").WithLocation(4, 5),
// (7,13): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new C()[^1]; // 2, 3
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(7, 13)
);
}
[Fact]
public void Subsumption_01()
{
var src = @"
class C
{
void Test(int[] a)
{
switch (a)
{
case [..,42]:
case [42]:
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [42]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[42]").WithLocation(9, 18)
);
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [9]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 1 ? [3] : [9]
[3]: t2 = t0[-1]; [4]
[4]: t2 == 42 ? [5] : [6]
[5]: leaf `case [..,42]:`
[6]: t1 == 1 ? [7] : [9]
[7]: t3 = t0[0]; [8]
[8]: t3 <-- t2; [9]
[9]: leaf <break> `switch (a)
{
case [..,42]:
case [42]:
break;
}`
");
}
[Fact]
public void Subsumption_02()
{
var src = @"
class C
{
void Test(int[] a, int[] b)
{
switch (a, b)
{
case ([.., 42], [.., 43]):
case ([42], [43]):
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case ([42], [43]):
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "([42], [43])").WithLocation(9, 18));
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t1 = t0.a; [1]
[1]: t1 != null ? [2] : [22]
[2]: t2 = t1.Length; [3]
[3]: t2 >= 1 ? [4] : [22]
[4]: t3 = t1[-1]; [5]
[5]: t3 == 42 ? [6] : [19]
[6]: t4 = t0.b; [7]
[7]: t4 != null ? [8] : [22]
[8]: t5 = t4.Length; [9]
[9]: t5 >= 1 ? [10] : [22]
[10]: t6 = t4[-1]; [11]
[11]: t6 == 43 ? [12] : [13]
[12]: leaf `case ([.., 42], [.., 43]):`
[13]: t2 == 1 ? [14] : [22]
[14]: t7 = t1[0]; [15]
[15]: t7 <-- t3; [16]
[16]: t5 == 1 ? [17] : [22]
[17]: t9 = t4[0]; [18]
[18]: t9 <-- t6; [22]
[19]: t2 == 1 ? [20] : [22]
[20]: t7 = t1[0]; [21]
[21]: t7 <-- t3; [22]
[22]: leaf <break> `switch (a, b)
{
case ([.., 42], [.., 43]):
case ([42], [43]):
break;
}`
");
}
[Fact]
public void Subsumption_03()
{
var src = @"
class C
{
void Test(int[] a)
{
switch (a)
{
case { Length: 1 } and [.., 1]:
case { Length: 1 } and [1, ..]:
break;
}
switch (a)
{
case { Length: 1 } and [1, ..]:
case { Length: 1 } and [.., 1]:
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case { Length: 1 } and [1, ..]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "{ Length: 1 } and [1, ..]").WithLocation(9, 18),
// (15,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case { Length: 1 } and [.., 1]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "{ Length: 1 } and [.., 1]").WithLocation(15, 18)
);
}
[Fact]
public void Subsumption_04()
{
var src = @"
class C
{
void Test(int[] a)
{
switch (a)
{
case [1, .., 3]:
case [1, 2, 3]:
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [1, 2, 3]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[1, 2, 3]").WithLocation(9, 18)
);
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [13]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 2 ? [3] : [13]
[3]: t2 = t0[0]; [4]
[4]: t2 == 1 ? [5] : [13]
[5]: t3 = t0[-1]; [6]
[6]: t3 == 3 ? [7] : [8]
[7]: leaf `case [1, .., 3]:`
[8]: t1 == 3 ? [9] : [13]
[9]: t4 = t0[1]; [10]
[10]: t4 == 2 ? [11] : [13]
[11]: t5 = t0[2]; [12]
[12]: t5 <-- t3; [13]
[13]: leaf <break> `switch (a)
{
case [1, .., 3]:
case [1, 2, 3]:
break;
}`
");
}
[Fact]
public void Subsumption_05()
{
var src = @"
using System;
class C
{
static int Test(int[] a)
{
switch (a)
{
case [1, 2, 3]: return 1;
case [1, .., 3]: return 2;
default: return 3;
}
}
static void Main()
{
Console.WriteLine(Test(new[]{1,2,3}));
Console.WriteLine(Test(new[]{1,0,3}));
Console.WriteLine(Test(new[]{1,2,0}));
}
}";
var expectedOutput = @"
1
2
3
";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: expectedOutput);
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [16]
[1]: t1 = t0.Length; [2]
[2]: t1 == 3 ? [3] : [10]
[3]: t2 = t0[0]; [4]
[4]: t2 == 1 ? [5] : [16]
[5]: t3 = t0[1]; [6]
[6]: t3 == 2 ? [7] : [13]
[7]: t4 = t0[2]; [8]
[8]: t4 == 3 ? [9] : [16]
[9]: leaf `case [1, 2, 3]:`
[10]: t1 >= 2 ? [11] : [16]
[11]: t2 = t0[0]; [12]
[12]: t2 == 1 ? [13] : [16]
[13]: t5 = t0[-1]; [14]
[14]: t5 == 3 ? [15] : [16]
[15]: leaf `case [1, .., 3]:`
[16]: leaf `default`
");
}
[Fact]
public void Subsumption_06()
{
var src = @"
using System;
class C
{
static int Test(int[] a)
{
switch (a)
{
case [42]: return 1;
case [..,42]: return 2;
default: return 3;
}
}
static void Main()
{
Console.WriteLine(Test(new[]{42}));
Console.WriteLine(Test(new[]{42, 42}));
Console.WriteLine(Test(new[]{42, 43}));
}
}";
var expectedOutput = @"
1
2
3
";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: expectedOutput);
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [10]
[1]: t1 = t0.Length; [2]
[2]: t1 == 1 ? [3] : [6]
[3]: t2 = t0[0]; [4]
[4]: t2 == 42 ? [5] : [10]
[5]: leaf `case [42]:`
[6]: t1 >= 1 ? [7] : [10]
[7]: t3 = t0[-1]; [8]
[8]: t3 == 42 ? [9] : [10]
[9]: leaf `case [..,42]:`
[10]: leaf `default`
");
}
[Fact]
public void Subsumption_07()
{
var src = @"
class C
{
void Test(int[] a)
{
switch (a)
{
case [>0, ..]:
case [.., <=0]:
case [var unreachable]:
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (10,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [var unreachable]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[var unreachable]").WithLocation(10, 18));
}
[Fact]
public void Subsumption_08()
{
var src = @"
class C
{
void Test(object[] a)
{
switch (a)
{
case [null, ..]:
case [.., not null]:
case [var unreachable]:
break;
}
switch (a)
{
case [string, ..]:
case [.., not string]:
case [var unreachable]:
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (10,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [var unreachable]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[var unreachable]").WithLocation(10, 18),
// (17,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [var unreachable]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[var unreachable]").WithLocation(17, 18));
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [10]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 1 ? [3] : [10]
[3]: t2 = t0[0]; [4]
[4]: t2 == null ? [5] : [6]
[5]: leaf `case [null, ..]:`
[6]: t3 = t0[-1]; [7]
[7]: t1 == 1 ? [8] : [9]
[8]: t3 <-- t2; [11]
[9]: t3 == null ? [10] : [11]
[10]: leaf <break> `switch (a)
{
case [null, ..]:
case [.., not null]:
case [var unreachable]:
break;
}`
[11]: leaf `case [.., not null]:`
");
}
[Fact]
public void Subsumption_09()
{
var src = @"
C.Test(new[] { 42, -1, 0, 42 });
class C
{
public static void Test(int[] a)
{
switch (a)
{
case [_, > 0, ..]:
System.Console.Write(1);
break;
case [.., <= 0, _]:
System.Console.Write(2);
break;
default:
System.Console.Write(3);
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "2");
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [11]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 2 ? [3] : [11]
[3]: t2 = t0[1]; [4]
[4]: t2 > 0 ? [5] : [6]
[5]: leaf `case [_, > 0, ..]:`
[6]: t3 = t0[-2]; [7]
[7]: t1 == 3 ? [8] : [9]
[8]: t3 <-- t2; [10]
[9]: t3 <= 0 ? [10] : [11]
[10]: leaf `case [.., <= 0, _]:`
[11]: leaf `default`
");
}
[Fact]
public void Subsumption_10()
{
var src = @"
class C
{
public int X { get; }
public int Y { get; }
public C F { get; }
static void Test(C[] a)
{
switch (a)
{
case [.., {X:> 0, Y:0}]:
case [{Y:0, X:> 0}]:
break;
}
switch (a)
{
case [.., {X:> 0, F.Y: 0}]:
case [..[{F.Y: 0, X:> 0}]]:
break;
}
}
}
";
var comp = CreateCompilation(new[] { src, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
comp.VerifyEmitDiagnostics(
// (12,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [{Y:0, X:> 0}]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[{Y:0, X:> 0}]").WithLocation(12, 18),
// (18,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [..[{F.Y: 0, X:> 0}]]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[..[{F.Y: 0, X:> 0}]]").WithLocation(18, 18)
);
}
[Fact]
public void Subsumption_11()
{
var src = @"
class C
{
public int X { get; }
public int Y { get; }
public void Deconstruct(out C c1, out C c2) => throw null;
static void Test(C[] a)
{
switch (a)
{
case [.., (_, { X: 0 })]:
case [({ X: 0 }, _)]: // ok
break;
}
switch (a)
{
case [.., (_, { X: 0 })]:
case [(_, { X: 0 })]: // err
break;
}
}
}
";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (20,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [(_, { X: 0 })]: // err
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[(_, { X: 0 })]").WithLocation(20, 18));
}
[Fact]
public void Subsumption_12()
{
var src = @"
class C
{
void Test(int[] a)
{
_ = a switch
{
{ Length: not 1 } => 0,
[<0, ..] => 0,
[..[>= 0]] or [..null] => 1,
[_] => 2, // unreachable 1
};
_ = a switch
{
{ Length: not 1 } => 0,
[<0, ..] => 0,
[..[>= 0]] => 1,
[_] => 2, // unreachable 2
};
}
}" + TestSources.GetSubArray;
var comp = CreateCompilationWithIndexAndRange(src);
comp.VerifyEmitDiagnostics(
// (11,13): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// [_] => 2, // unreachable 1
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "[_]").WithLocation(11, 13),
// (18,13): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// [_] => 2, // unreachable 2
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "[_]").WithLocation(18, 13)
);
AssertEx.Multiple(
() => VerifyDecisionDagDump<SwitchExpressionSyntax>(comp,
@"[0]: t0 != null ? [1] : [11]
[1]: t1 = t0.Length; [2]
[2]: t1 == 1 ? [3] : [10]
[3]: t2 = t0[0]; [4]
[4]: t2 < 0 ? [5] : [6]
[5]: leaf <arm> `[<0, ..] => 0`
[6]: t3 = DagSliceEvaluation(t0); [7]
[7]: t4 = t3.Length; [8]
[8]: t5 = t3[0]; [9]
[9]: leaf <arm> `[..[>= 0]] or [..null] => 1`
[10]: leaf <arm> `{ Length: not 1 } => 0`
[11]: leaf <default> `a switch
{
{ Length: not 1 } => 0,
[<0, ..] => 0,
[..[>= 0]] or [..null] => 1,
[_] => 2, // unreachable 1
}`
", index: 0),
() => VerifyDecisionDagDump<SwitchExpressionSyntax>(comp,
@"[0]: t0 != null ? [1] : [11]
[1]: t1 = t0.Length; [2]
[2]: t1 == 1 ? [3] : [10]
[3]: t2 = t0[0]; [4]
[4]: t2 < 0 ? [5] : [6]
[5]: leaf <arm> `[<0, ..] => 0`
[6]: t3 = DagSliceEvaluation(t0); [7]
[7]: t4 = t3.Length; [8]
[8]: t5 = t3[0]; [9]
[9]: leaf <arm> `[..[>= 0]] => 1`
[10]: leaf <arm> `{ Length: not 1 } => 0`
[11]: leaf <default> `a switch
{
{ Length: not 1 } => 0,
[<0, ..] => 0,
[..[>= 0]] => 1,
[_] => 2, // unreachable 2
}`
", index: 1)
);
}
[Fact]
public void Subsumption_13()
{
var src = @"
class C
{
void Test(int[] a)
{
_ = a switch
{
[.., >0] => 1,
[<0, ..] => 2,
[0, ..] => 3,
{ Length: not 1 } => 4,
[var unreachable] => 5,
};
}
}" + TestSources.GetSubArray;
var comp = CreateCompilationWithIndexAndRange(src);
comp.VerifyEmitDiagnostics(
// (12,13): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// [var unreachable] => 5,
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "[var unreachable]").WithLocation(12, 13));
VerifyDecisionDagDump<SwitchExpressionSyntax>(comp,
@"[0]: t0 != null ? [1] : [15]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 1 ? [3] : [14]
[3]: t2 = t0[-1]; [4]
[4]: t2 > 0 ? [5] : [6]
[5]: leaf <arm> `[.., >0] => 1`
[6]: t3 = t0[0]; [7]
[7]: t1 == 1 ? [8] : [10]
[8]: t3 <-- t2; [9]
[9]: t3 < 0 ? [11] : [13]
[10]: t3 < 0 ? [11] : [12]
[11]: leaf <arm> `[<0, ..] => 2`
[12]: t3 == 0 ? [13] : [14]
[13]: leaf <arm> `[0, ..] => 3`
[14]: leaf <arm> `{ Length: not 1 } => 4`
[15]: leaf <default> `a switch
{
[.., >0] => 1,
[<0, ..] => 2,
[0, ..] => 3,
{ Length: not 1 } => 4,
[var unreachable] => 5,
}`
");
}
[Fact]
public void Subsumption_14()
{
var src = @"
class C
{
void Test(int[] a)
{
_ = a switch
{
[.., >=0, >0] => 0,
[.., <0, >=0] => 0,
[<=0, <0, ..] => 1,
[>0, <=0, ..] => 1,
[0, 0] => 1,
{ Length: not 2 } => 2,
[var unreachable, var unreachable2] => 3,
};
}
}";
var comp = CreateCompilationWithIndexAndRange(src);
comp.VerifyEmitDiagnostics(
// (14,13): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// [var unreachable, var unreachable2] => 3,
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "[var unreachable, var unreachable2]").WithLocation(14, 13));
}
[Fact]
public void Subsumption_15()
{
// testing the scenario where we have multiple preconditions for indexers to relate.
var src = @"
class C
{
void Test(int[][] a)
{
switch (a)
{
case [.., [.., 42]]:
case [[42]]:
break;
};
}
}";
var comp = CreateCompilationWithIndexAndRange(src);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [[42]]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[[42]]").WithLocation(9, 18));
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [26]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 1 ? [3] : [26]
[3]: t2 = t0[-1]; [4]
[4]: t2 != null ? [5] : [23]
[5]: t3 = t2.Length; [6]
[6]: t3 >= 1 ? [7] : [18]
[7]: t4 = t2[-1]; [8]
[8]: t4 == 42 ? [9] : [10]
[9]: leaf `case [.., [.., 42]]:`
[10]: t1 == 1 ? [11] : [26]
[11]: t5 = t0[0]; [12]
[12]: t5 <-- t2; [13]
[13]: t7 = t5.Length; [14]
[14]: t7 <-- t3; [15]
[15]: t7 == 1 ? [16] : [26]
[16]: t9 = t5[0]; [17]
[17]: t9 <-- t4; [26]
[18]: t1 == 1 ? [19] : [26]
[19]: t5 = t0[0]; [20]
[20]: t5 <-- t2; [21]
[21]: t7 = t5.Length; [22]
[22]: t7 <-- t3; [26]
[23]: t1 == 1 ? [24] : [26]
[24]: t5 = t0[0]; [25]
[25]: t5 <-- t2; [26]
[26]: leaf <break> `switch (a)
{
case [.., [.., 42]]:
case [[42]]:
break;
}`
");
}
[Fact]
public void Subsumption_16()
{
var src = @"
using System;
class C
{
static int Test(int[][] a)
{
switch (a)
{
case [.., [.., <0]]:
return 1;
case [[>=0]]:
return 2;
}
return -1;
}
static void Main()
{
Console.WriteLine(Test(new[] { new[] { 0, -1 }}));
Console.WriteLine(Test(new[] { new[] { 0 }, new[] { -1 }}));
Console.WriteLine(Test(new[] { new[] { 0 }}));
}
}";
var expectedOutput = @"
1
1
2
";
var comp = CreateCompilationWithIndexAndRange(src, parseOptions: TestOptions.RegularWithListPatterns, options: TestOptions.ReleaseExe);
CompileAndVerify(comp, expectedOutput: expectedOutput).VerifyDiagnostics();
}
[Fact]
[WorkItem(51192, "https://github.com/dotnet/roslyn/issues/51192")]
public void Subsumption_17()
{
var source =
@"using System;
public class X
{
public static void Main()
{
object[] o = null;
switch (o)
{
case [.., I1 and Base]:
break;
case [Derived s]: // 1
break;
}
switch (o)
{
case [.., Base and I1]:
break;
case [Derived s]: // 2
break;
}
switch (o)
{
case [.., Base and not null]:
break;
case [Derived s]: // 3
break;
}
switch (o) {
case [.., ValueType and int and 1]:
break;
case [int and 1]: // 4
break;
}
switch (o) {
case [.., int and 1]:
break;
case [ValueType and int and 1]: // 5
break;
}
switch (o)
{
case [.., I2 and Base]:
break;
case [Derived s]: // 6
break;
}
switch (o)
{
case [.., I2 and Base { F1: 1 }]:
break;
case [Derived { F2: 1 }]:
break;
case [Derived { P1: 1 }]:
break;
case [Derived { F1: 1 } s]: // 7
break;
}
switch (o)
{
case [.., I2 and Base { P1: 1 }]:
break;
case [Derived { F1: 1 }]:
break;
case [Derived { P2: 1 }]:
break;
case [Derived { P1: 1 } s]: // 8
break;
}
switch (o)
{
case [.., I2 and Base(1, _)]:
break;
case [Derived(2, _)]:
break;
case [Derived(1, _, _)]:
break;
case [Derived(1, _) s]: // 9
break;
}
switch (o)
{
case [.., I2 and Base { F3: (1, _) }]:
break;
case [Derived { F3: (_, 1) }]:
break;
case [Derived { F3: (1, _) } s]: // 10
break;
}
switch (o)
{
case [.., I2 and Base]:
break;
case [Base and I2]: // 11
break;
}
switch (o)
{
case [.., Base and I2]:
break;
case [I2 and Base]: // 12
break;
}
object obj = null;
switch (obj)
{
case I1 and Base and [.., I1 and Base]:
break;
case Derived and [Derived s]: // 13
break;
}
switch (obj)
{
case Base and I1 and [.., Base and I1]:
break;
case Derived and [Derived s]: // OK, we're calling into different indexers
break;
}
switch (obj)
{
case Base and not null and [.., Base and not null]:
break;
case Derived and [Derived s]: // 14
break;
}
object[][] a = null;
switch (a)
{
case [.., [.., I1 and Base]]:
break;
case [[Derived]]: // 15
break;
}
}
}
interface I1 : System.Collections.IList {}
interface I2 {}
class Base : System.Collections.ArrayList, I1
{
public int F1 = 0;
public int F2 = 0;
public object F3 = null;
public int P1 {get; set;}
public int P2 {get; set;}
public void Deconstruct(out int x, out int y) => throw null;
public void Deconstruct(out int x, out int y, out int z) => throw null;
}
class Derived : Base, I2
{
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, _iTupleSource }, options: TestOptions.DebugExe);
compilation.VerifyDiagnostics(
// (11,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived s]: // 1
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived s]").WithLocation(11, 18),
// (19,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived s]: // 2
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived s]").WithLocation(19, 18),
// (27,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived s]: // 3
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived s]").WithLocation(27, 18),
// (34,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [int and 1]: // 4
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[int and 1]").WithLocation(34, 18),
// (41,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [ValueType and int and 1]: // 5
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[ValueType and int and 1]").WithLocation(41, 18),
// (49,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived s]: // 6
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived s]").WithLocation(49, 18),
// (61,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived { F1: 1 } s]: // 7
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived { F1: 1 } s]").WithLocation(61, 18),
// (73,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived { P1: 1 } s]: // 8
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived { P1: 1 } s]").WithLocation(73, 18),
// (85,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived(1, _) s]: // 9
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived(1, _) s]").WithLocation(85, 18),
// (95,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Derived { F3: (1, _) } s]: // 10
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Derived { F3: (1, _) } s]").WithLocation(95, 18),
// (103,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [Base and I2]: // 11
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[Base and I2]").WithLocation(103, 18),
// (111,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [I2 and Base]: // 12
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[I2 and Base]").WithLocation(111, 18),
// (120,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case Derived and [Derived s]: // 13
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "Derived and [Derived s]").WithLocation(120, 18),
// (136,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case Derived and [Derived s]: // 14
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "Derived and [Derived s]").WithLocation(136, 18),
// (145,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [[Derived]]: // 15
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[[Derived]]").WithLocation(145, 18)
);
}
[Fact]
public void Subsumption_18()
{
var src = @"
class C
{
void Test(int[] a)
{
switch (a)
{
case [.., 0]:
case [<0, ..]:
case [.., >0]:
case [_]:
break;
};
}
}";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyEmitDiagnostics(
// (11,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [_]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[_]").WithLocation(11, 18));
VerifyDecisionDagDump<SwitchStatementSyntax>(comp,
@"[0]: t0 != null ? [1] : [14]
[1]: t1 = t0.Length; [2]
[2]: t1 >= 1 ? [3] : [14]
[3]: t2 = t0[-1]; [4]
[4]: t2 == 0 ? [5] : [6]
[5]: leaf `case [.., 0]:`
[6]: t3 = t0[0]; [7]
[7]: t1 == 1 ? [8] : [10]
[8]: t3 <-- t2; [9]
[9]: t3 < 0 ? [11] : [13]
[10]: t3 < 0 ? [11] : [12]
[11]: leaf `case [<0, ..]:`
[12]: t2 > 0 ? [13] : [14]
[13]: leaf `case [.., >0]:`
[14]: leaf <break> `switch (a)
{
case [.., 0]:
case [<0, ..]:
case [.., >0]:
case [_]:
break;
}`
");
}
[Fact]
public void Subsumption_Slice_00()
{
const int Count = 18;
var cases = new string[Count]
{
"[1,2,3]",
"[1,2,3,..[]]",
"[1,2,..[],3]",
"[1,..[],2,3]",
"[..[],1,2,3]",
"[1,..[2,3]]",
"[..[1,2],3]",
"[..[1,2,3]]",
"[..[..[1,2,3]]]",
"[..[1,2,3,..[]]]",
"[..[1,2,..[],3]]",
"[..[1,..[],2,3]]",
"[..[..[],1,2,3]]",
"[..[1,..[2,3]]]",
"[..[..[1,2],3]]",
"[1, ..[2], 3]",
"[1, ..[2, ..[3]]]",
"[1, ..[2, ..[], 3]]"
};
// testing every possible combination takes too long,
// covering a random subset instead.
var r = new Random();
for (int i = 0; i < 50; i++)
{
var case1 = cases[r.Next(Count)];
var case2 = cases[r.Next(Count)];
var type = r.Next(2) == 0 ? "System.Span<int>" : "int[]";
var src = @"
class C
{
void Test(" + type + @" a)
{
switch (a)
{
case " + case1 + @":
case " + case2 + @":
break;
}
}
}";
var comp = CreateCompilationWithIndexAndRangeAndSpan(new[] { src, TestSources.GetSubArray }, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, case2).WithLocation(9, 18)
);
}
}
[Fact]
public void Subsumption_Slice_01()
{
var src = @"
class C
{
public static void Test(System.Span<int> a)
{
switch (a)
{
case [var v]: break;
case [..[var v]]: break;
}
}
}";
var comp = CreateCompilationWithIndexAndRangeAndSpan(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics(
// (9,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [..[var v]]: break;
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[..[var v]]").WithLocation(9, 18));
}
[Fact]
public void Subsumption_Slice_02()
{
var source = @"
using System;
IOuter outer = null;
switch (outer)
{
case [..[..[10],20]]:
break;
case [..[10],20]: // 1
break;
}
interface IOuter
{
int Length { get; }
IInner Slice(int a, int b);
object this[int i] { get; }
}
interface IInner
{
int Count { get; }
IOuter this[Range r] { get; }
object this[Index i] { get; }
}
";
var comp = CreateCompilationWithIndexAndRangeAndSpan(new[] { source, TestSources.GetSubArray }, options: TestOptions.DebugExe);
comp.VerifyEmitDiagnostics(
// (9,10): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [..[10],20]: // 1
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[..[10],20]").WithLocation(9, 10)
);
}
[Fact]
public void Subsumption_Slice_03()
{
var source = @"
#nullable enable
class C
{
public int Length => 3;
public int this[int i] => 0;
public int[]? Slice(int i, int j) => null;
public static void Main()
{
switch (new C())
{
case [.. {}]:
break;
case [.. null]:
break;
}
}
}
";
var compilation = CreateCompilationWithIndexAndRange(source, options: TestOptions.ReleaseExe);
compilation.VerifyEmitDiagnostics(
// (15,18): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [.. null]:
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[.. null]").WithLocation(15, 18)
);
}
[Fact]
public void Exhaustiveness_01()
{
var src = @"
using System;
class C
{
public int X = 0, Y = 0;
public static void Test(Span<int> a, Span<C> b)
{
_ = a switch
{
[.., >=0] or [<0] or { Length: 0 or >1 } => 0
};
_ = a switch
{
[.., >=0] or [..[.., <0]] or [] => 0
};
_ = a switch
{
[..[>=0]] or [<0] or
{ Length: 0 or >1 } => 0
};
_ = a switch
{
[..[.., <0]] or [..] => 0
};
_ = a switch
{
[_, ..{ Length: < int.MaxValue - 1 }] or [] or { Length: int.MaxValue } => 0
};
_ = a switch
{
[..{ Length: <= int.MaxValue - 1 }, _] or [] => 0
};
_ = a switch
{
[_, ..{ Length: <= int.MaxValue - 2 }, _] or { Length: 0 or 1 } => 0
};
_ = b switch
{
[.., { X: >=0, Y: >0 }] => 0,
[.., { X: <0, Y: >=0 }] => 0,
[{ X: <=0, Y: <0 }, ..] => 1,
[{ X: >0, Y: <=0 }, ..] => 1,
[{ X:0, Y:0 }] => 1,
{ Length: not 1 } => 0
};
}
}";
var comp = CreateCompilationWithIndexAndRangeAndSpan(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics();
}
[Fact]
public void Exhaustiveness_02()
{
var src = @"
using System;
class C
{
public static void Test1(Span<int> a)
{
_ = a switch
{
[] => 1,
[_] => 2,
[_,..] => 3,
};
}
public static void Test2(Span<int> a)
{
_ = a switch
{
{ Length: 0 } => 1,
{ Length: 1 } => 2,
{ Length: >=1 } => 3,
};
}
}";
var comp = CreateCompilationWithIndexAndRangeAndSpan(src, parseOptions: TestOptions.RegularWithListPatterns);
comp.VerifyEmitDiagnostics();
var verifier = CompileAndVerify(comp);
string expectedIl = @"
{
// Code size 26 (0x1a)
.maxstack 2
.locals init (int V_0)
IL_0000: ldarga.s V_0
IL_0002: call ""int System.Span<int>.Length.get""
IL_0007: stloc.0
IL_0008: ldloc.0
IL_0009: brfalse.s IL_0011
IL_000b: ldloc.0
IL_000c: ldc.i4.1
IL_000d: beq.s IL_0014
IL_000f: br.s IL_0017
IL_0011: ldc.i4.1
IL_0012: pop
IL_0013: ret
IL_0014: ldc.i4.2
IL_0015: pop
IL_0016: ret
IL_0017: ldc.i4.3
IL_0018: pop
IL_0019: ret
}
";
verifier.VerifyIL("C.Test1", expectedIl);
verifier.VerifyIL("C.Test2", expectedIl);
}
[Fact]
public void LengthPattern_NegativeLengthTest_MissingIndex()
{
var src = @"
int[] a = null;
_ = a is { Length: -1 };
";
var comp = CreateCompilation(src);
comp.MakeTypeMissing(WellKnownType.System_Index);
comp.VerifyDiagnostics();
}
[Fact]
public void LengthPattern_NegativeLengthTest()
{
var src = @"
int[] a = null;
_ = a is { Length: -1 }; // 1
_ = a is { Length: -1 or 1 };
_ = a is { Length: -1 } or { Length: 1 };
_ = a switch // 2
{
{ Length: -1 } => 0, // 3
};
_ = a switch // 4
{
{ Length: -1 or 1 } => 0,
};
_ = a switch // 5
{
{ Length: -1 } or { Length: 1 } => 0,
};
_ = a switch // 6
{
{ Length: -1 } => 0, // 7
{ Length: 1 } => 0,
};
";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyDiagnostics(
// (3,5): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is { Length: -1 }; // 1
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is { Length: -1 }").WithArguments("int[]").WithLocation(3, 5),
// (7,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = a switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(7, 7),
// (9,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: -1 } => 0, // 3
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: -1 }").WithLocation(9, 5),
// (12,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 0 }' is not covered.
// _ = a switch // 4
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 0 }").WithLocation(12, 7),
// (17,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 0 }' is not covered.
// _ = a switch // 5
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 0 }").WithLocation(17, 7),
// (22,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 0 }' is not covered.
// _ = a switch // 6
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 0 }").WithLocation(22, 7),
// (24,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: -1 } => 0, // 7
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: -1 }").WithLocation(24, 5)
);
}
[Fact]
public void LengthPattern_NegativeNullHandling_WithNullHandling()
{
var src = @"
int[] a = null;
_ = a is null or { Length: -1 };
_ = a switch // 1
{
null => 0,
{ Length: -1 } => 0, // 2
};
";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyDiagnostics(
// (5,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern 'not null' is not covered.
// _ = a switch // 1
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("not null").WithLocation(5, 7),
// (8,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: -1 } => 0, // 2
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: -1 }").WithLocation(8, 5)
);
}
[Fact]
public void LengthPattern_NegativeNullHandling_DuplicateTest()
{
var src = @"
int[] a = null;
_ = a is { Length: -1 } or { Length: -1 };
_ = a switch
{
{ Length: -1 } => 1,
{ Length: -1 } => 2,
_ => 3,
};
";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyDiagnostics(
// (3,5): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is { Length: -1 } or { Length: -1 };
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is { Length: -1 } or { Length: -1 }").WithArguments("int[]").WithLocation(3, 5),
// (7,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: -1 } => 1,
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: -1 }").WithLocation(7, 5),
// (8,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: -1 } => 2,
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: -1 }").WithLocation(8, 5)
);
}
[Fact]
public void LengthPattern_NegativeRangeTest()
{
var src = @"
int[] a = null;
_ = a is { Length: < 0 }; // 1
_ = a switch // 2
{
{ Length: < 0 } => 0, // 3
};
";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyDiagnostics(
// (3,5): error CS8518: An expression of type 'int[]' can never match the provided pattern.
// _ = a is { Length: < 0 }; // 1
Diagnostic(ErrorCode.ERR_IsPatternImpossible, "a is { Length: < 0 }").WithArguments("int[]").WithLocation(3, 5),
// (5,7): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '_' is not covered.
// _ = a switch // 2
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("_").WithLocation(5, 7),
// (7,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: < 0 } => 0, // 3
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: < 0 }").WithLocation(7, 5)
);
}
[Fact]
public void LengthPattern_Switch_NegativeRangeTestByElimination()
{
var src = @"
int[] a = null;
_ = a switch
{
{ Length: 0 } => 1,
{ Length: <= 0 } => 2,
_ => 3,
};
";
var comp = CreateCompilation(new[] { src, TestSources.Index });
comp.VerifyDiagnostics(
// (6,5): error CS8510: The pattern is unreachable. It has already been handled by a previous arm of the switch expression or it is impossible to match.
// { Length: <= 0 } => 2,
Diagnostic(ErrorCode.ERR_SwitchArmSubsumed, "{ Length: <= 0 }").WithLocation(6, 5)
);
comp = CreateCompilation(src);
comp.VerifyDiagnostics();
}
[Fact, WorkItem(51801, "https://github.com/dotnet/roslyn/issues/51801")]
public void IndexerOverrideLacksAccessor()
{
var source = @"
#nullable enable
using System.Runtime.CompilerServices;
class Base
{
public virtual object this[int i] { get { return 1; } set { } }
}
class C : Base
{
public override object this[int i] { set { } }
public int Length => 2;
public string? Value { get; }
public string M()
{
switch (this)
{
case [1, 1]:
return Value;
default:
return Value;
}
}
}
";
var verifier = CompileAndVerify(new[] { source, TestSources.Index }, options: TestOptions.DebugDll);
verifier.VerifyIL("C.M", @"
{
// Code size 105 (0x69)
.maxstack 2
.locals init (C V_0,
int V_1,
object V_2,
int V_3,
object V_4,
int V_5,
C V_6,
string V_7)
IL_0000: nop
IL_0001: ldarg.0
IL_0002: stloc.s V_6
IL_0004: ldloc.s V_6
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: brfalse.s IL_005c
IL_000a: ldloc.0
IL_000b: callvirt ""int C.Length.get""
IL_0010: stloc.1
IL_0011: ldloc.1
IL_0012: ldc.i4.2
IL_0013: bne.un.s IL_005c
IL_0015: ldloc.0
IL_0016: ldc.i4.0
IL_0017: callvirt ""object Base.this[int].get""
IL_001c: stloc.2
IL_001d: ldloc.2
IL_001e: isinst ""int""
IL_0023: brfalse.s IL_005c
IL_0025: ldloc.2
IL_0026: unbox.any ""int""
IL_002b: stloc.3
IL_002c: ldloc.3
IL_002d: ldc.i4.1
IL_002e: bne.un.s IL_005c
IL_0030: ldloc.0
IL_0031: ldc.i4.1
IL_0032: callvirt ""object Base.this[int].get""
IL_0037: stloc.s V_4
IL_0039: ldloc.s V_4
IL_003b: isinst ""int""
IL_0040: brfalse.s IL_005c
IL_0042: ldloc.s V_4
IL_0044: unbox.any ""int""
IL_0049: stloc.s V_5
IL_004b: ldloc.s V_5
IL_004d: ldc.i4.1
IL_004e: beq.s IL_0052
IL_0050: br.s IL_005c
IL_0052: ldarg.0
IL_0053: call ""string C.Value.get""
IL_0058: stloc.s V_7
IL_005a: br.s IL_0066
IL_005c: ldarg.0
IL_005d: call ""string C.Value.get""
IL_0062: stloc.s V_7
IL_0064: br.s IL_0066
IL_0066: ldloc.s V_7
IL_0068: ret
}");
}
[Fact, WorkItem(51801, "https://github.com/dotnet/roslyn/issues/51801")]
public void LengthOverrideLacksAccessor()
{
var source = @"
#nullable enable
using System.Runtime.CompilerServices;
class Base
{
public virtual int Length { get { return 2; } set { } }
}
class C : Base
{
public override int Length { set { } }
public object this[int i] { get { return 1; } set { } }
public string? Value { get; }
public string M()
{
switch (this)
{
case [1, 1]:
return Value;
default:
return Value;
}
}
}
";
var verifier = CompileAndVerify(new[] { source, TestSources.Index });
verifier.VerifyIL("C.M", @"
{
// Code size 78 (0x4e)
.maxstack 2
.locals init (C V_0,
object V_1,
object V_2)
IL_0000: ldarg.0
IL_0001: stloc.0
IL_0002: ldloc.0
IL_0003: brfalse.s IL_0047
IL_0005: ldloc.0
IL_0006: callvirt ""int Base.Length.get""
IL_000b: ldc.i4.2
IL_000c: bne.un.s IL_0047
IL_000e: ldloc.0
IL_000f: ldc.i4.0
IL_0010: callvirt ""object C.this[int].get""
IL_0015: stloc.1
IL_0016: ldloc.1
IL_0017: isinst ""int""
IL_001c: brfalse.s IL_0047
IL_001e: ldloc.1
IL_001f: unbox.any ""int""
IL_0024: ldc.i4.1
IL_0025: bne.un.s IL_0047
IL_0027: ldloc.0
IL_0028: ldc.i4.1
IL_0029: callvirt ""object C.this[int].get""
IL_002e: stloc.2
IL_002f: ldloc.2
IL_0030: isinst ""int""
IL_0035: brfalse.s IL_0047
IL_0037: ldloc.2
IL_0038: unbox.any ""int""
IL_003d: ldc.i4.1
IL_003e: pop
IL_003f: pop
IL_0040: ldarg.0
IL_0041: call ""string C.Value.get""
IL_0046: ret
IL_0047: ldarg.0
IL_0048: call ""string C.Value.get""
IL_004d: ret
}");
}
[Fact]
public void ListPattern_LengthAndCountAreOrthogonal()
{
var source = @"
_ = new C() switch
{
[] => 0,
{ Length: 1 } => 0,
{ Count: > 1 } => 0
};
class C
{
public int this[System.Index i] => 1;
public int Length => 1;
public int Count => 1;
}
";
var compilation = CreateCompilationWithIndexAndRange(source);
compilation.VerifyEmitDiagnostics(
// (2,13): warning CS8509: The switch expression does not handle all possible values of its input type (it is not exhaustive). For example, the pattern '{ Length: 2, Count: 0 }' is not covered.
// _ = new C() switch
Diagnostic(ErrorCode.WRN_SwitchExpressionNotExhaustive, "switch").WithArguments("{ Length: 2, Count: 0 }").WithLocation(2, 13)
);
}
[Fact]
public void ListPattern_LengthFieldNotApplicable()
{
var source = @"
_ = new C() is [];
_ = new C()[^1];
class C
{
public int this[int i] => 1;
public int Length = 0;
}
";
var compilation = CreateCompilationWithIndex(source);
compilation.VerifyEmitDiagnostics(
// (2,16): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new C() is [];
Diagnostic(ErrorCode.ERR_BadArgType, "[]").WithArguments("1", "System.Index", "int").WithLocation(2, 16),
// (3,13): error CS1503: Argument 1: cannot convert from 'System.Index' to 'int'
// _ = new C()[^1];
Diagnostic(ErrorCode.ERR_BadArgType, "^1").WithArguments("1", "System.Index", "int").WithLocation(3, 13)
);
}
[Fact]
public void ListPattern_IndexAndRangeAreNecessaryButOptimizedAway()
{
var source = @"
new C().M();
public class C
{
public int this[int i] => 2;
public int Length => 1;
public int Slice(int i, int j) => 3;
public void M()
{
if (this is [var x] && this is [.. var y])
System.Console.Write((x, y));
}
}
";
var compilation = CreateCompilation(source);
compilation.MakeTypeMissing(WellKnownType.System_Index);
compilation.MakeTypeMissing(WellKnownType.System_Range);
compilation.VerifyDiagnostics(
// (12,21): error CS0518: Predefined type 'System.Index' is not defined or imported
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[var x]").WithArguments("System.Index").WithLocation(12, 21),
// (12,21): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[var x]").WithArguments("System.Index", "GetOffset").WithLocation(12, 21),
// (12,40): error CS0518: Predefined type 'System.Index' is not defined or imported
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[.. var y]").WithArguments("System.Index").WithLocation(12, 40),
// (12,40): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[.. var y]").WithArguments("System.Index", "GetOffset").WithLocation(12, 40),
// (12,41): error CS0518: Predefined type 'System.Range' is not defined or imported
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, ".. var y").WithArguments("System.Range").WithLocation(12, 41),
// (12,41): error CS0656: Missing compiler required member 'System.Range.get_Start'
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. var y").WithArguments("System.Range", "get_Start").WithLocation(12, 41),
// (12,41): error CS0656: Missing compiler required member 'System.Range.get_End'
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. var y").WithArguments("System.Range", "get_End").WithLocation(12, 41),
// (12,41): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// if (this is [var x] && this is [.. var y])
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, ".. var y").WithArguments("System.Index", "GetOffset").WithLocation(12, 41)
);
compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
var verifier = CompileAndVerify(compilation, expectedOutput: "(2, 3)");
verifier.VerifyDiagnostics();
// Note: no Index or Range involved
verifier.VerifyIL("C.M", @"
{
// Code size 61 (0x3d)
.maxstack 3
.locals init (int V_0, //x
int V_1, //y
C V_2,
int V_3)
IL_0000: ldarg.0
IL_0001: stloc.2
IL_0002: ldloc.2
IL_0003: brfalse.s IL_003c
IL_0005: ldloc.2
IL_0006: callvirt ""int C.Length.get""
IL_000b: ldc.i4.1
IL_000c: bne.un.s IL_003c
IL_000e: ldloc.2
IL_000f: ldc.i4.0
IL_0010: callvirt ""int C.this[int].get""
IL_0015: stloc.0
IL_0016: ldarg.0
IL_0017: stloc.2
IL_0018: ldloc.2
IL_0019: brfalse.s IL_003c
IL_001b: ldloc.2
IL_001c: callvirt ""int C.Length.get""
IL_0021: stloc.3
IL_0022: ldloc.2
IL_0023: ldc.i4.0
IL_0024: ldloc.3
IL_0025: callvirt ""int C.Slice(int, int)""
IL_002a: stloc.1
IL_002b: ldloc.0
IL_002c: ldloc.1
IL_002d: newobj ""System.ValueTuple<int, int>..ctor(int, int)""
IL_0032: box ""System.ValueTuple<int, int>""
IL_0037: call ""void System.Console.Write(object)""
IL_003c: ret
}
");
}
[Fact]
public void ListPattern_StaticIndexers()
{
var source = @"
_ = new C() is [var x, .. var y];
class C
{
public int Length => 0;
public static int this[System.Index i] => 0;
public static int this[System.Range r] => 0;
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyDiagnostics(
// (7,23): error CS0106: The modifier 'static' is not valid for this item
// public static int this[System.Index i] => 0;
Diagnostic(ErrorCode.ERR_BadMemberFlag, "this").WithArguments("static").WithLocation(7, 23),
// (8,23): error CS0106: The modifier 'static' is not valid for this item
// public static int this[System.Range r] => 0;
Diagnostic(ErrorCode.ERR_BadMemberFlag, "this").WithArguments("static").WithLocation(8, 23)
);
}
[Fact]
public void ListPattern_SetOnlyIndexers()
{
var source = @"
_ = new C() is [var x, .. var y]; // 1, 2, 3
_ = new C()[^1]; // 4
_ = new C()[..]; // 5
class C
{
public int Length { set { } }
public int this[System.Index i] { set { } }
public int this[System.Range r] { set { } }
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics(
// (2,16): error CS0154: The property or indexer 'C.this[Index]' cannot be used in this context because it lacks the get accessor
// _ = new C() is [var x, .. var y]; // 1, 2, 3
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "[var x, .. var y]").WithArguments("C.this[System.Index]").WithLocation(2, 16),
// (2,24): error CS0154: The property or indexer 'C.this[Range]' cannot be used in this context because it lacks the get accessor
// _ = new C() is [var x, .. var y]; // 1, 2, 3
Diagnostic(ErrorCode.ERR_PropertyLacksGet, ".. var y").WithArguments("C.this[System.Range]").WithLocation(2, 24),
// (3,5): error CS0154: The property or indexer 'C.this[Index]' cannot be used in this context because it lacks the get accessor
// _ = new C()[^1]; // 4
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "new C()[^1]").WithArguments("C.this[System.Index]").WithLocation(3, 5),
// (4,5): error CS0154: The property or indexer 'C.this[Range]' cannot be used in this context because it lacks the get accessor
// _ = new C()[..]; // 5
Diagnostic(ErrorCode.ERR_PropertyLacksGet, "new C()[..]").WithArguments("C.this[System.Range]").WithLocation(4, 5)
);
}
[Fact]
public void SlicePattern_OnConsList()
{
var source = @"
#nullable enable
using System;
record ConsList(object Head, ConsList? Tail)
{
public int Length => throw null!;
public object this[Index i] => throw null!;
public ConsList? this[Range r] => throw null!;
public static void Print(ConsList? list)
{
switch (list)
{
case null:
return;
case [var head, .. var tail]:
System.Console.Write(head.ToString() + "" "");
Print(tail);
return;
}
}
}
";
// Note: this pattern doesn't work well because list-patterns needs a functional Length
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, IsExternalInitTypeDefinition });
compilation.VerifyDiagnostics();
var verifier = CompileAndVerify(compilation, verify: Verification.Fails);
verifier.VerifyIL("ConsList.Print", @"
{
// Code size 84 (0x54)
.maxstack 4
.locals init (object V_0, //head
ConsList V_1) //tail
IL_0000: ldarg.0
IL_0001: brfalse.s IL_0036
IL_0003: ldarg.0
IL_0004: callvirt ""int ConsList.Length.get""
IL_0009: ldc.i4.1
IL_000a: blt.s IL_0053
IL_000c: ldarg.0
IL_000d: ldc.i4.0
IL_000e: ldc.i4.0
IL_000f: newobj ""System.Index..ctor(int, bool)""
IL_0014: callvirt ""object ConsList.this[System.Index].get""
IL_0019: stloc.0
IL_001a: ldarg.0
IL_001b: ldc.i4.1
IL_001c: ldc.i4.0
IL_001d: newobj ""System.Index..ctor(int, bool)""
IL_0022: ldc.i4.0
IL_0023: ldc.i4.1
IL_0024: newobj ""System.Index..ctor(int, bool)""
IL_0029: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_002e: callvirt ""ConsList ConsList.this[System.Range].get""
IL_0033: stloc.1
IL_0034: br.s IL_0037
IL_0036: ret
IL_0037: ldloc.0
IL_0038: callvirt ""string object.ToString()""
IL_003d: ldstr "" ""
IL_0042: call ""string string.Concat(string, string)""
IL_0047: call ""void System.Console.Write(string)""
IL_004c: ldloc.1
IL_004d: call ""void ConsList.Print(ConsList)""
IL_0052: ret
IL_0053: ret
}
");
}
[Fact]
public void PositionalPattern_OnConsList()
{
var source = @"
#nullable enable
var list = new ConsList(1, new ConsList(2, new ConsList(3, null)));
ConsList.Print(list);
record ConsList(object Head, ConsList? Tail)
{
public static void Print(ConsList? list)
{
switch (list)
{
case null:
return;
case (var head, var tail):
System.Console.Write(head.ToString() + "" "");
Print(tail);
return;
}
}
}
";
var compilation = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, IsExternalInitTypeDefinition });
compilation.VerifyDiagnostics();
var verifier = CompileAndVerify(compilation, expectedOutput: "1 2 3", verify: Verification.Fails);
verifier.VerifyIL("ConsList.Print", @"
{
// Code size 44 (0x2c)
.maxstack 3
.locals init (object V_0, //head
ConsList V_1) //tail
IL_0000: ldarg.0
IL_0001: brfalse.s IL_000f
IL_0003: ldarg.0
IL_0004: ldloca.s V_0
IL_0006: ldloca.s V_1
IL_0008: callvirt ""void ConsList.Deconstruct(out object, out ConsList)""
IL_000d: br.s IL_0010
IL_000f: ret
IL_0010: ldloc.0
IL_0011: callvirt ""string object.ToString()""
IL_0016: ldstr "" ""
IL_001b: call ""string string.Concat(string, string)""
IL_0020: call ""void System.Console.Write(string)""
IL_0025: ldloc.1
IL_0026: call ""void ConsList.Print(ConsList)""
IL_002b: ret
}
");
}
[Fact]
public void Simple_IndexIndexer()
{
var source = @"
if (new C() is [var x])
{
System.Console.Write((x, new C()[^1]));
}
class C
{
public int Length => 1;
public int this[System.Index i] => 42;
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(42, 42)");
}
[Fact]
public void Simple_IntIndexer_MissingIndex()
{
var source = @"
if (new C() is [var x])
{
System.Console.Write(x);
}
class C
{
public int Count => 1;
public int this[int i] => 42;
}
";
var comp = CreateCompilation(source);
comp.VerifyEmitDiagnostics(
// (2,16): error CS0518: Predefined type 'System.Index' is not defined or imported
// if (new C() is [var x])
Diagnostic(ErrorCode.ERR_PredefinedTypeNotFound, "[var x]").WithArguments("System.Index").WithLocation(2, 16),
// (2,16): error CS0656: Missing compiler required member 'System.Index.GetOffset'
// if (new C() is [var x])
Diagnostic(ErrorCode.ERR_MissingPredefinedMember, "[var x]").WithArguments("System.Index", "GetOffset").WithLocation(2, 16)
);
}
[Fact]
public void Simple_IntIndexer()
{
var source = @"
if (new C() is [var x])
{
System.Console.Write((x, new C()[^1]));
}
class C
{
public int Count => 1;
public int this[int i] => 42;
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(42, 42)");
}
[Fact]
public void Simple_String()
{
var source = @"
if (""42"" is [var x, var y])
{
System.Console.Write((x, y));
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(4, 2)");
}
[Fact]
public void Simple_Array()
{
var source = @"
if (new[] { 4, 2 } is [var x, _])
{
var y = new[] { 4, 2 }[^1];
System.Console.Write((x, y));
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(4, 2)");
}
[Theory]
[InlineData("{ 4, 0, 0 }", "[var x, _, _]", "[0]")]
[InlineData("{ 0, 4, 0 }", "[_, var x, _]", "[1]")]
[InlineData("{ 0, 0, 4 }", "[_, _, var x]", "[2]")]
[InlineData("{ 4, 0, 0 }", "[.., var x, _, _]", "[^3]")]
[InlineData("{ 0, 4, 0 }", "[.., _, var x, _]", "[^2]")]
[InlineData("{ 0, 0, 4 }", "[.., _, _, var x]", "[^1]")]
public void Simple_Array_VerifyIndexMaths(string data, string pattern, string elementAccess)
{
var source = $@"
if (new[] {data} is {pattern})
{{
var y = new[] {data}{elementAccess};
System.Console.Write((x, y));
}}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(4, 4)");
}
[Fact]
public void Simple_IndexIndexer_Slice()
{
var source = @"
if (new C() is [.. var x])
{
System.Console.Write((x, new C()[..]));
}
class C
{
public int Length => 0;
public int this[System.Index i] => throw null;
public int this[System.Range r] => 42;
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(42, 42)");
}
[Fact]
public void Simple_IntIndexer_Slice()
{
var source = @"
if (new C() is [.. var x])
{
System.Console.Write((x, new C()[..]));
}
class C
{
public int Length => 1;
public int this[System.Index i] => throw null;
public int Slice(int i, int j) => 42;
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(42, 42)");
}
[Fact]
public void Simple_String_Slice()
{
var source = @"
if (""0420"" is [_, .. var x, _])
{
System.Console.Write(x);
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "42");
}
[Fact, WorkItem(57728, "https://github.com/dotnet/roslyn/issues/57728")]
public void Simple_Array_Slice()
{
var source = @"
class C
{
public static void Main()
{
if (new[] { 0, 4, 2, 0 } is [_, .. var x, _])
{
var y = new[] { 0, 4, 2, 0 }[1..^1];
System.Console.Write((x[0], x[1], y[0], y[1]));
}
}
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray }, options: TestOptions.ReleaseExe);
comp.VerifyEmitDiagnostics();
var verifier = CompileAndVerify(comp, expectedOutput: "(4, 2, 4, 2)");
// we use Array.Length to get the length, but should be using ldlen
// Tracked by https://github.com/dotnet/roslyn/issues/57728
verifier.VerifyIL("C.Main", @"
{
// Code size 116 (0x74)
.maxstack 5
.locals init (int[] V_0, //x
int[] V_1,
int[] V_2) //y
IL_0000: ldc.i4.4
IL_0001: newarr ""int""
IL_0006: dup
IL_0007: ldc.i4.1
IL_0008: ldc.i4.4
IL_0009: stelem.i4
IL_000a: dup
IL_000b: ldc.i4.2
IL_000c: ldc.i4.2
IL_000d: stelem.i4
IL_000e: stloc.1
IL_000f: ldloc.1
IL_0010: brfalse.s IL_0073
IL_0012: ldloc.1
IL_0013: ldlen
IL_0014: conv.i4
IL_0015: ldc.i4.2
IL_0016: blt.s IL_0073
IL_0018: ldloc.1
IL_0019: ldc.i4.1
IL_001a: ldc.i4.0
IL_001b: newobj ""System.Index..ctor(int, bool)""
IL_0020: ldc.i4.1
IL_0021: ldc.i4.1
IL_0022: newobj ""System.Index..ctor(int, bool)""
IL_0027: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_002c: call ""int[] System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray<int>(int[], System.Range)""
IL_0031: stloc.0
IL_0032: ldc.i4.4
IL_0033: newarr ""int""
IL_0038: dup
IL_0039: ldc.i4.1
IL_003a: ldc.i4.4
IL_003b: stelem.i4
IL_003c: dup
IL_003d: ldc.i4.2
IL_003e: ldc.i4.2
IL_003f: stelem.i4
IL_0040: ldc.i4.1
IL_0041: call ""System.Index System.Index.op_Implicit(int)""
IL_0046: ldc.i4.1
IL_0047: ldc.i4.1
IL_0048: newobj ""System.Index..ctor(int, bool)""
IL_004d: newobj ""System.Range..ctor(System.Index, System.Index)""
IL_0052: call ""int[] System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray<int>(int[], System.Range)""
IL_0057: stloc.2
IL_0058: ldloc.0
IL_0059: ldc.i4.0
IL_005a: ldelem.i4
IL_005b: ldloc.0
IL_005c: ldc.i4.1
IL_005d: ldelem.i4
IL_005e: ldloc.2
IL_005f: ldc.i4.0
IL_0060: ldelem.i4
IL_0061: ldloc.2
IL_0062: ldc.i4.1
IL_0063: ldelem.i4
IL_0064: newobj ""System.ValueTuple<int, int, int, int>..ctor(int, int, int, int)""
IL_0069: box ""System.ValueTuple<int, int, int, int>""
IL_006e: call ""void System.Console.Write(object)""
IL_0073: ret
}
");
}
[Theory]
[InlineData("{ 4, 2, 0, 0, 0 }", "[.. var x, _, _, _]", "[0..^3]")]
[InlineData("{ 0, 4, 2, 0, 0 }", "[_, .. var x, _, _]", "[1..^2]")]
[InlineData("{ 0, 0, 4, 2, 0 }", "[_, _, .. var x, _]", "[2..^1]")]
[InlineData("{ 0, 0, 0, 4, 2 }", "[_, _, _, .. var x]", "[3..^0]")]
public void Simple_Array_Slice_VerifyRangeMaths(string data, string pattern, string elementAccess)
{
var source = $@"
if (new[] {data} is {pattern})
{{
var y = new[] {data}{elementAccess};
System.Console.Write((x[0], x[1], x.Length, y[0], y[1], y.Length));
}}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray });
comp.VerifyEmitDiagnostics();
CompileAndVerify(comp, expectedOutput: "(4, 2, 2, 4, 2, 2)");
}
[Fact]
public void ArrayLengthAccess()
{
var source = @"
class C
{
public int M(int[] a)
{
switch (a)
{
case [.., var x]: return x;
}
return 3;
}
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.GetSubArray }, options: TestOptions.ReleaseDll);
var verifier = CompileAndVerify(comp).VerifyDiagnostics();
verifier.VerifyIL("C.M", @"
{
// Code size 19 (0x13)
.maxstack 3
.locals init (int V_0)
IL_0000: ldarg.1
IL_0001: brfalse.s IL_0011
IL_0003: ldarg.1
IL_0004: ldlen
IL_0005: conv.i4
IL_0006: stloc.0
IL_0007: ldloc.0
IL_0008: ldc.i4.1
IL_0009: blt.s IL_0011
IL_000b: ldarg.1
IL_000c: ldloc.0
IL_000d: ldc.i4.1
IL_000e: sub
IL_000f: ldelem.i4
IL_0010: ret
IL_0011: ldc.i4.3
IL_0012: ret
}
");
}
[Fact]
public void ListPattern_NotCountableInterface()
{
var source = @"
_ = new C() is INotCountable and [var x, .. var y];
interface INotCountable { }
class C : INotCountable
{
public int Length { get => 0; }
public int this[System.Index i] { get => 0; }
public int this[System.Range r] { get => 0; }
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
comp.VerifyEmitDiagnostics(
// (2,34): error CS0021: Cannot apply indexing with [] to an expression of type 'INotCountable'
// _ = new C() is INotCountable and [var x, .. var y];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "[var x, .. var y]").WithArguments("INotCountable").WithLocation(2, 34),
// (2,42): error CS0021: Cannot apply indexing with [] to an expression of type 'INotCountable'
// _ = new C() is INotCountable and [var x, .. var y];
Diagnostic(ErrorCode.ERR_BadIndexLHS, ".. var y").WithArguments("INotCountable").WithLocation(2, 42)
);
}
[Fact]
public void ListPattern_ExplicitInterfaceImplementation()
{
var source = @"
if (new C() is Interface and [var x, .. var y])
{
System.Console.Write((x, y));
}
interface Interface
{
int Length { get; }
int this[System.Index i] { get; }
int this[System.Range r] { get; }
}
class C : Interface
{
int Interface.Length { get => 2; }
int Interface.this[System.Index i] { get => 42; }
int Interface.this[System.Range r] { get => 43; }
}
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range });
var verifier = CompileAndVerify(comp, expectedOutput: "(42, 43)");
verifier.VerifyDiagnostics();
}
[Fact]
public void ListPattern_Tuples()
{
var source = @"
_ = (1, 2) is [var x, .. var y];
System.Runtime.CompilerServices.ITuple ituple = default;
_ = ituple is [var x2];
_ = ituple is [..var y2];
_ = ituple switch
{
[1, 2] => 0,
(1, 2) => 0,
_ => 0,
};
";
var comp = CreateCompilation(new[] { source, TestSources.Index, TestSources.Range, TestSources.ITuple });
comp.VerifyEmitDiagnostics(
// (2,15): error CS0021: Cannot apply indexing with [] to an expression of type '(int, int)'
// _ = (1, 2) is [var x, .. var y];
Diagnostic(ErrorCode.ERR_BadIndexLHS, "[var x, .. var y]").WithArguments("(int, int)").WithLocation(2, 15),
// (2,23): error CS0021: Cannot apply indexing with [] to an expression of type '(int, int)'
// _ = (1, 2) is [var x, .. var y];
Diagnostic(ErrorCode.ERR_BadIndexLHS, ".. var y").WithArguments("(int, int)").WithLocation(2, 23),
// (6,16): error CS1503: Argument 1: cannot convert from 'System.Range' to 'int'
// _ = ituple is [..var y2];
Diagnostic(ErrorCode.ERR_BadArgType, "..var y2").WithArguments("1", "System.Range", "int").WithLocation(6, 16)
);
}
[Fact]
public void ListPattern_NullTestOnSlice()
{
var source = @"
using System;
Span<int> s = default;
switch (s)
{
case [..[1],2,3]:
case [1,2,3]: // error
break;
}
int[] a = default;
switch (a)
{
case [..[1],2,3]:
case [1,2,3]: // error
break;
}
";
var comp = CreateCompilationWithIndexAndRangeAndSpan(new[] { source, TestSources.GetSubArray });
comp.VerifyEmitDiagnostics(
// (7,10): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [1,2,3]: // error
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[1,2,3]").WithLocation(7, 10),
// (15,10): error CS8120: The switch case is unreachable. It has already been handled by a previous case or it is impossible to match.
// case [1,2,3]: // error
Diagnostic(ErrorCode.ERR_SwitchCaseSubsumed, "[1,2,3]").WithLocation(15, 10)
);
}
}
| 36.180759 | 246 | 0.571124 | [
"MIT"
] | RaphDal/roslyn | src/Compilers/CSharp/Test/Semantic/Semantics/PatternMatchingTests_ListPatterns.cs | 301,243 | C# |
// *** WARNING: this file was generated by the Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.AzureNative.MachineLearningServices.V20210101
{
public static class ListMachineLearningComputeNodes
{
/// <summary>
/// Compute node information related to a AmlCompute.
/// </summary>
public static Task<ListMachineLearningComputeNodesResult> InvokeAsync(ListMachineLearningComputeNodesArgs args, InvokeOptions? options = null)
=> Pulumi.Deployment.Instance.InvokeAsync<ListMachineLearningComputeNodesResult>("azure-native:machinelearningservices/v20210101:listMachineLearningComputeNodes", args ?? new ListMachineLearningComputeNodesArgs(), options.WithVersion());
}
public sealed class ListMachineLearningComputeNodesArgs : Pulumi.InvokeArgs
{
/// <summary>
/// Name of the Azure Machine Learning compute.
/// </summary>
[Input("computeName", required: true)]
public string ComputeName { get; set; } = null!;
/// <summary>
/// Name of the resource group in which workspace is located.
/// </summary>
[Input("resourceGroupName", required: true)]
public string ResourceGroupName { get; set; } = null!;
/// <summary>
/// Name of Azure Machine Learning workspace.
/// </summary>
[Input("workspaceName", required: true)]
public string WorkspaceName { get; set; } = null!;
public ListMachineLearningComputeNodesArgs()
{
}
}
[OutputType]
public sealed class ListMachineLearningComputeNodesResult
{
/// <summary>
/// The type of compute
/// Expected value is 'AmlCompute'.
/// </summary>
public readonly string ComputeType;
/// <summary>
/// The continuation token.
/// </summary>
public readonly string NextLink;
/// <summary>
/// The collection of returned AmlCompute nodes details.
/// </summary>
public readonly ImmutableArray<Outputs.AmlComputeNodeInformationResponse> Nodes;
[OutputConstructor]
private ListMachineLearningComputeNodesResult(
string computeType,
string nextLink,
ImmutableArray<Outputs.AmlComputeNodeInformationResponse> nodes)
{
ComputeType = computeType;
NextLink = nextLink;
Nodes = nodes;
}
}
}
| 33.886076 | 249 | 0.646619 | [
"Apache-2.0"
] | polivbr/pulumi-azure-native | sdk/dotnet/MachineLearningServices/V20210101/ListMachineLearningComputeNodes.cs | 2,677 | C# |
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the route53domains-2014-05-15.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Text;
using System.Xml.Serialization;
using Amazon.Route53Domains.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
using ThirdParty.Json.LitJson;
namespace Amazon.Route53Domains.Model.Internal.MarshallTransformations
{
/// <summary>
/// ListDomains Request Marshaller
/// </summary>
public class ListDomainsRequestMarshaller : IMarshaller<IRequest, ListDomainsRequest> , IMarshaller<IRequest,AmazonWebServiceRequest>
{
/// <summary>
/// Marshaller the request object to the HTTP request.
/// </summary>
/// <param name="input"></param>
/// <returns></returns>
public IRequest Marshall(AmazonWebServiceRequest input)
{
return this.Marshall((ListDomainsRequest)input);
}
/// <summary>
/// Marshaller the request object to the HTTP request.
/// </summary>
/// <param name="publicRequest"></param>
/// <returns></returns>
public IRequest Marshall(ListDomainsRequest publicRequest)
{
IRequest request = new DefaultRequest(publicRequest, "Amazon.Route53Domains");
string target = "Route53Domains_v20140515.ListDomains";
request.Headers["X-Amz-Target"] = target;
request.Headers["Content-Type"] = "application/x-amz-json-1.1";
request.Headers[Amazon.Util.HeaderKeys.XAmzApiVersion] = "2014-05-15";
request.HttpMethod = "POST";
request.ResourcePath = "/";
using (StringWriter stringWriter = new StringWriter(CultureInfo.InvariantCulture))
{
JsonWriter writer = new JsonWriter(stringWriter);
writer.WriteObjectStart();
var context = new JsonMarshallerContext(request, writer);
if(publicRequest.IsSetFilterConditions())
{
context.Writer.WritePropertyName("FilterConditions");
context.Writer.WriteArrayStart();
foreach(var publicRequestFilterConditionsListValue in publicRequest.FilterConditions)
{
context.Writer.WriteObjectStart();
var marshaller = FilterConditionMarshaller.Instance;
marshaller.Marshall(publicRequestFilterConditionsListValue, context);
context.Writer.WriteObjectEnd();
}
context.Writer.WriteArrayEnd();
}
if(publicRequest.IsSetMarker())
{
context.Writer.WritePropertyName("Marker");
context.Writer.Write(publicRequest.Marker);
}
if(publicRequest.IsSetMaxItems())
{
context.Writer.WritePropertyName("MaxItems");
context.Writer.Write(publicRequest.MaxItems);
}
if(publicRequest.IsSetSortCondition())
{
context.Writer.WritePropertyName("SortCondition");
context.Writer.WriteObjectStart();
var marshaller = SortConditionMarshaller.Instance;
marshaller.Marshall(publicRequest.SortCondition, context);
context.Writer.WriteObjectEnd();
}
writer.WriteObjectEnd();
string snippet = stringWriter.ToString();
request.Content = System.Text.Encoding.UTF8.GetBytes(snippet);
}
return request;
}
private static ListDomainsRequestMarshaller _instance = new ListDomainsRequestMarshaller();
internal static ListDomainsRequestMarshaller GetInstance()
{
return _instance;
}
/// <summary>
/// Gets the singleton.
/// </summary>
public static ListDomainsRequestMarshaller Instance
{
get
{
return _instance;
}
}
}
} | 36.335766 | 137 | 0.60004 | [
"Apache-2.0"
] | aws/aws-sdk-net | sdk/src/Services/Route53Domains/Generated/Model/Internal/MarshallTransformations/ListDomainsRequestMarshaller.cs | 4,978 | C# |
using System;
namespace Tenant.Mvc.Core.Telemetry
{
public class PurchaseEvent
{
#region - Properties -
public Int64 CustomerId { get; set; }
public Int64 ProductId { get; set; }
public Guid OrderId { get; set; }
public int Price { get; set; }
public DateTime PurchaseTime { get; set; }
#endregion
}
} | 17.952381 | 50 | 0.580902 | [
"MIT"
] | Bhaskers-Blu-Org2/WingTipTickets | WebPortal/Tenant.Mvc/Core/Telemetry/PurchaseEvent.cs | 379 | C# |
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information
namespace Dnn.PersonaBar.Roles.Services.DTO
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;
using DotNetNuke.Security.Roles;
[DataContract]
public class RoleDto
{
[DataMember(Name = "id")]
public int Id { get; set; }
[DataMember(Name = "groupId")]
public int GroupId { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
[DataMember(Name = "description")]
public string Description { get; set; }
[DataMember(Name = "serviceFee")]
public float ServiceFee { get; set; }
[DataMember(Name = "billingPeriod")]
public int BillingPeriod { get; set; }
[DataMember(Name = "billingFrequency")]
public string BillingFrequency { get; set; }
[DataMember(Name = "trialFee")]
public float TrialFee { get; set; }
[DataMember(Name = "trialPeriod")]
public int TrialPeriod { get; set; }
[DataMember(Name = "trialFrequency")]
public string TrialFrequency { get; set; }
[DataMember(Name = "isPublic")]
public bool IsPublic { get; set; }
[DataMember(Name = "autoAssign")]
public bool AutoAssign { get; set; }
[DataMember(Name = "rsvpCode")]
public string RsvpCode { get; set; }
[DataMember(Name = "icon")]
public string Icon { get; set; }
[DataMember(Name = "status")]
public RoleStatus Status { get; set; }
[DataMember(Name = "securityMode")]
public SecurityMode SecurityMode { get; set; }
[DataMember(Name = "isSystem")]
public bool IsSystem { get; set; }
[DataMember(Name = "usersCount")]
public long UsersCount { get; set; }
[DataMember(Name = "allowOwner")]
public bool AllowOwner { get; set; }
public static RoleDto FromRoleInfo(RoleInfo role)
{
if (role == null) return null;
return new RoleDto()
{
Id = role.RoleID,
GroupId = role.RoleGroupID,
Name = role.RoleName,
Description = role.Description,
ServiceFee = role.ServiceFee,
BillingPeriod = role.BillingPeriod,
BillingFrequency = role.BillingFrequency,
TrialFee = role.TrialFee,
TrialPeriod = role.TrialPeriod,
TrialFrequency = role.TrialFrequency,
IsPublic = role.IsPublic,
AutoAssign = role.AutoAssignment,
RsvpCode = role.RSVPCode,
Icon = role.IconFile,
Status = role.Status,
SecurityMode = role.SecurityMode,
IsSystem = role.IsSystemRole,
UsersCount = role.UserCount,
AllowOwner = (role.SecurityMode == SecurityMode.SocialGroup) || (role.SecurityMode == SecurityMode.Both),
};
}
public RoleInfo ToRoleInfo()
{
return new RoleInfo()
{
RoleID = this.Id,
RoleGroupID = this.GroupId,
RoleName = this.Name,
Description = this.Description,
ServiceFee = this.ServiceFee,
BillingPeriod = this.BillingPeriod,
BillingFrequency = this.BillingFrequency,
TrialFee = this.TrialFee,
TrialPeriod = this.TrialPeriod,
TrialFrequency = this.TrialFrequency,
IsPublic = this.IsPublic,
AutoAssignment = this.AutoAssign,
RSVPCode = this.RsvpCode,
IconFile = this.Icon,
Status = this.Status,
SecurityMode = this.SecurityMode,
IsSystemRole = this.IsSystem,
};
}
}
}
| 32.795276 | 121 | 0.553661 | [
"MIT"
] | Andy9999/Dnn.Platform | Dnn.AdminExperience/Dnn.PersonaBar.Extensions/Services/DTO/RoleDto.cs | 4,167 | C# |
namespace OnlyV.Helpers
{
using System.Collections.ObjectModel;
using OnlyV.ViewModel;
internal class MultipleVerseSelection
{
public MultipleVerseSelection(int anchorVerse)
{
AnchorVerse = anchorVerse;
}
public int AnchorVerse { get; }
public int LowVerse { get; private set; }
public int HighVerse { get; private set; }
public void ChangeSelection(int verseSelected, ObservableCollection<VerseButtonModel> verseButtons)
{
AddOrRemoveSelection(LowVerse, HighVerse, verseButtons, shouldAdd: false);
LowVerse = verseSelected < AnchorVerse
? verseSelected
: AnchorVerse;
HighVerse = verseSelected > AnchorVerse
? verseSelected
: AnchorVerse;
AddOrRemoveSelection(LowVerse, HighVerse, verseButtons, shouldAdd: true);
}
private void AddOrRemoveSelection(
int startVerse,
int endVerse,
ObservableCollection<VerseButtonModel> verseButtons,
bool shouldAdd)
{
if (startVerse == 0 || endVerse == 0)
{
return;
}
for (var vs = startVerse; vs <= endVerse; ++vs)
{
verseButtons[vs - 1].Selected = shouldAdd;
}
}
}
}
| 27.076923 | 107 | 0.560369 | [
"MIT"
] | CristianoNunes1000/OnlyV | OnlyV/Helpers/MultipleVerseSelection.cs | 1,410 | C# |
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UniRx;
public class ScoreView : MonoBehaviour
{
[SerializeField] private Text score = null;
[Zenject.Inject] private ScoreModel model = null;
void Start()
{
model.OnScoreChange
.Throttle(TimeSpan.FromMilliseconds(100))
.Subscribe(OnScoreUpdate);
}
private void OnScoreUpdate(int score)
{
this.score.text = score.ToString();
}
}
| 21.04 | 53 | 0.673004 | [
"MIT"
] | sumogri/pack_a | UnityProject/Pack_A/Assets/Pack_a/Scripts/ScoreView.cs | 528 | C# |
using System;
using System.Collections.Generic;
using System.Text;
using EntityFrameworkCore.DbContextScope;
using ApplicationLogic.Repositories.DB;
using ApplicationLogic.Business.Commands.PriceLevel.InsertCommand.Models;
using Framework.Core.Crypto;
using Framework.Core.Messages;
using FluentValidation;
namespace ApplicationLogic.Business.Commands.PriceLevel.InsertCommand
{
public class PriceLevelInsertValidator : FluentValidation.AbstractValidator<PriceLevelInsertCommandInputDTO>
{
public PriceLevelInsertValidator()
{
// Email Required
this.RuleFor(x => x.Name)
.NotEmpty();
}
}
}
| 29.043478 | 112 | 0.745509 | [
"Apache-2.0"
] | lneninger/quickbookdesktop-integrator | src/public API/Solution/ApplicationLogic/Business/Commands/PriceLevel/InsertCommand/Validator/PriceLevelInsertValidator.cs | 670 | C# |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AssemblyStripper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AssemblyStripper")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5be14f51-025e-4995-827a-c33184f51bac")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 37.837838 | 84 | 0.749286 | [
"MIT"
] | TheManta/AssemblyStripper | AssemblyStripper/Properties/AssemblyInfo.cs | 1,403 | C# |
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.Aws.NetworkFirewall.Outputs
{
[OutputType]
public sealed class RuleGroupRuleGroup
{
/// <summary>
/// A configuration block that defines additional settings available to use in the rules defined in the rule group. Can only be specified for **stateful** rule groups. See Rule Variables below for details.
/// </summary>
public readonly Outputs.RuleGroupRuleGroupRuleVariables? RuleVariables;
/// <summary>
/// A configuration block that defines the stateful or stateless rules for the rule group. See Rules Source below for details.
/// </summary>
public readonly Outputs.RuleGroupRuleGroupRulesSource RulesSource;
[OutputConstructor]
private RuleGroupRuleGroup(
Outputs.RuleGroupRuleGroupRuleVariables? ruleVariables,
Outputs.RuleGroupRuleGroupRulesSource rulesSource)
{
RuleVariables = ruleVariables;
RulesSource = rulesSource;
}
}
}
| 36.944444 | 213 | 0.697744 | [
"ECL-2.0",
"Apache-2.0"
] | aamir-locus/pulumi-aws | sdk/dotnet/NetworkFirewall/Outputs/RuleGroupRuleGroup.cs | 1,330 | C# |
//
// Copyright (c) 2020 LabMICRO FACET UNT
//
// This file is licensed under the MIT License.
// Full license text is available in 'licenses/MIT.txt'.
//
using System;
using System.Linq;
using Antmicro.Renode.Core;
using Antmicro.Renode.Logging;
using Antmicro.Migrant;
using System.Collections.Generic;
using System.Text;
namespace Antmicro.Renode.Peripherals.Miscellaneous
{
// This class implements an multiplexed seven segment display with a variable number of digits
// First eighths input gpio lines are used to handle from "a" to "f" segments and dot point
// Remaining input gpio lines are used to enable each of digits starting from left
// To activate a segment, the digit and segment gpio inputs must be set to true
// Anode and catode common displays can be emulated with invertSegments and invertDigits parameters
public class SevenSegmentsDisplay : IGPIOReceiver
{
public SevenSegmentsDisplay(uint digitsCount = 1, bool invertSegments = false, bool invertDigits = false)
{
this.invertSegments = invertSegments;
this.invertDigits = invertDigits;
digit = new Digit();
enabledDigits = new bool[digitsCount];
sync = new object();
Reset();
}
public void Reset()
{
digit.Clear();
for(var index = 0; index < enabledDigits.Length; index++)
{
enabledDigits[index] = invertDigits;
}
Update();
}
public void OnGPIO(int number, bool value)
{
if(number >= 0 && number < SegmentsCount)
{
digit.SetSegment((Segments)(1 << number), invertSegments ? !value : value);
}
else if(number >= SegmentsCount && number - SegmentsCount < enabledDigits.Length)
{
enabledDigits[number - SegmentsCount] = invertDigits ? !value : value;
}
else
{
this.Log(LogLevel.Error, "This device can handle GPIOs in range 0 - {0}, but {1} was set", SegmentsCount + enabledDigits.Length, number);
return;
}
Update();
}
[field: Transient]
public event Action<IPeripheral, string> StateChanged;
public string Image { get; private set; }
public string State { get; private set; }
private void Update()
{
lock(sync)
{
var newState = AsSegmentsString();
if(newState == State)
{
return;
}
State = newState;
Image = AsPrettyString();
StateChanged?.Invoke(this, State);
this.Log(LogLevel.Noisy, "Seven Segments state changed to {0} {1}", State, Image);
}
}
private string AsPrettyString()
{
var result = new StringBuilder();
result.Append("(");
foreach(var isEnabled in enabledDigits)
{
result.Append(isEnabled
? digit.AsString()
: "_");
}
result.Append(")");
return result.ToString();
}
private string AsSegmentsString()
{
var result = new StringBuilder();
foreach(var isEnabled in enabledDigits)
{
result.Append("[");
if(isEnabled)
{
result.Append(digit.Value.ToString());
}
result.Append("]");
}
return result.ToString();
}
private readonly Digit digit;
private readonly bool[] enabledDigits;
private readonly bool invertSegments;
private readonly bool invertDigits;
private readonly object sync;
private const int SegmentsCount = 8;
[Flags]
private enum Segments
{
A = 1 << 0,
B = 1 << 1,
C = 1 << 2,
D = 1 << 3,
E = 1 << 4,
F = 1 << 5,
G = 1 << 6,
DOT = 1 << 7
}
private class Digit
{
public Segments Value { get; private set; }
public void SetSegment(Segments segment, bool asOn)
{
if(asOn)
{
Value |= segment;
}
else
{
Value &= ~segment;
}
}
public void Clear()
{
Value = 0;
}
public string AsString()
{
var hasDot = (Value & Segments.DOT) == Segments.DOT;
if(!SegmentsToStringMapping.TryGetValue(Value & ~Segments.DOT, out var result))
{
result = "?";
}
if(hasDot)
{
result += ".";
}
return result;
}
private static readonly Dictionary<Segments, string> SegmentsToStringMapping = new Dictionary<Segments, string>()
{
{ Segments.A | Segments.B | Segments.C | Segments.D | Segments.E | Segments.F , "0" },
{ Segments.B | Segments.C , "1" },
{ Segments.A | Segments.B | Segments.D | Segments.E | Segments.G, "2" },
{ Segments.A | Segments.B | Segments.C | Segments.D | Segments.G, "3" },
{ Segments.B | Segments.C | Segments.F | Segments.G, "4" },
{ Segments.A | Segments.C | Segments.D | Segments.F | Segments.G, "5" },
{ Segments.A | Segments.C | Segments.D | Segments.E | Segments.F | Segments.G, "6" },
{ Segments.A | Segments.B | Segments.C , "7" },
{ Segments.A | Segments.B | Segments.C | Segments.D | Segments.E | Segments.F | Segments.G, "8" },
{ Segments.A | Segments.B | Segments.C | Segments.D | Segments.F | Segments.G, "9" },
{ Segments.A | Segments.B | Segments.C | Segments.E | Segments.F | Segments.G, "A" },
{ Segments.C | Segments.D | Segments.E | Segments.F | Segments.G, "B" },
{ Segments.A | Segments.D | Segments.E | Segments.F , "C" },
{ Segments.B | Segments.C | Segments.D | Segments.E | Segments.G, "D" },
{ Segments.A | Segments.D | Segments.E | Segments.F | Segments.G, "E" },
{ Segments.A | Segments.E | Segments.F | Segments.G, "F" },
};
}
}
}
| 34.591346 | 153 | 0.46435 | [
"MIT"
] | UPBIoT/renode-iot | src/Infrastructure/src/Emulator/Peripherals/Peripherals/Miscellaneous/SevenSegmentsDisplay.cs | 7,197 | C# |
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DirectoryButton : VRUIButton
{
public string directoryName;
public FileBrowser fileBrowser;
private Text _text;
protected override void Start()
{
_text = transform.GetComponent<Text>();
_text.text = directoryName;
_text.color = baseColor;
}
public override void OnHovered()
{
_text.color = hoveredColor;
}
public override void OnUnhovered()
{
_text.color = baseColor;
}
public override void Select(GameObject sender)
{
fileBrowser.EnterDirectory(directoryName);
}
}
| 19.857143 | 50 | 0.664748 | [
"MIT"
] | ErwanLeGoffic/Tectrid | TectridVR/Assets/Resources/FileBrowser/Scripts/DirectoryButton.cs | 697 | C# |
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/
/*
* Do not modify this file. This file is generated from the pinpoint-2016-12-01.normal.json service model.
*/
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Net;
using System.Text;
using System.Xml.Serialization;
using Amazon.Pinpoint.Model;
using Amazon.Runtime;
using Amazon.Runtime.Internal;
using Amazon.Runtime.Internal.Transform;
using Amazon.Runtime.Internal.Util;
using ThirdParty.Json.LitJson;
namespace Amazon.Pinpoint.Model.Internal.MarshallTransformations
{
/// <summary>
/// Response Unmarshaller for MethodNotAllowedException Object
/// </summary>
public class MethodNotAllowedExceptionUnmarshaller : IErrorResponseUnmarshaller<MethodNotAllowedException, JsonUnmarshallerContext>
{
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <returns></returns>
public MethodNotAllowedException Unmarshall(JsonUnmarshallerContext context)
{
return this.Unmarshall(context, new ErrorResponse());
}
/// <summary>
/// Unmarshaller the response from the service to the response class.
/// </summary>
/// <param name="context"></param>
/// <param name="errorResponse"></param>
/// <returns></returns>
public MethodNotAllowedException Unmarshall(JsonUnmarshallerContext context, ErrorResponse errorResponse)
{
context.Read();
MethodNotAllowedException unmarshalledObject = new MethodNotAllowedException(errorResponse.Message, errorResponse.InnerException,
errorResponse.Type, errorResponse.Code, errorResponse.RequestId, errorResponse.StatusCode);
int targetDepth = context.CurrentDepth;
while (context.ReadAtDepth(targetDepth))
{
if (context.TestExpression("RequestID", targetDepth))
{
var unmarshaller = StringUnmarshaller.Instance;
unmarshalledObject.RequestID = unmarshaller.Unmarshall(context);
continue;
}
}
return unmarshalledObject;
}
private static MethodNotAllowedExceptionUnmarshaller _instance = new MethodNotAllowedExceptionUnmarshaller();
/// <summary>
/// Gets the singleton.
/// </summary>
public static MethodNotAllowedExceptionUnmarshaller Instance
{
get
{
return _instance;
}
}
}
} | 36.791209 | 142 | 0.639785 | [
"Apache-2.0"
] | philasmar/aws-sdk-net | sdk/src/Services/Pinpoint/Generated/Model/Internal/MarshallTransformations/MethodNotAllowedExceptionUnmarshaller.cs | 3,348 | C# |
namespace X10D.Performant.ReExposed;
[SuppressMessage("ReSharper", "UnusedMember.Global")]
[SuppressMessage("ReSharper", "UnusedType.Global")]
public static partial class CharExtensions
{
/// <inheritdoc cref="long.Parse(ReadOnlySpan{char},NumberStyles,IFormatProvider)"/>
public static long ToInt64(this ReadOnlySpan<char> chars,
NumberStyles style = NumberStyles.Integer,
IFormatProvider? formatProvider = null) =>
long.Parse(chars, style, formatProvider ?? NumberFormatInfo.CurrentInfo);
/// <inheritdoc cref="long.Parse(ReadOnlySpan{char},NumberStyles,IFormatProvider)"/>
public static long ToInt64(this Span<char> chars, NumberStyles style = NumberStyles.Integer, IFormatProvider? formatProvider = null) =>
long.Parse(chars, style, formatProvider ?? NumberFormatInfo.CurrentInfo);
/// <inheritdoc cref="long.TryParse(ReadOnlySpan{char},NumberStyles,IFormatProvider,out long)"/>
public static bool TryToInt64(this ReadOnlySpan<char> chars,
out long result,
NumberStyles style = NumberStyles.Integer,
IFormatProvider? formatProvider = null) =>
long.TryParse(chars, style, formatProvider ?? NumberFormatInfo.CurrentInfo, out result);
/// <inheritdoc cref="long.TryParse(ReadOnlySpan{char},NumberStyles,IFormatProvider,out long)"/>
public static bool TryToInt64(this Span<char> chars,
out long result,
NumberStyles style = NumberStyles.Integer,
IFormatProvider? formatProvider = null) =>
long.TryParse(chars, style, formatProvider ?? NumberFormatInfo.CurrentInfo, out result);
} | 60.466667 | 139 | 0.652701 | [
"MIT"
] | rubiksmaster02/X10D | X10D.Performant/src/ReExposed/CharExtensions/System.Long.cs | 1,816 | C# |
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEditor.UIElements;
#if PLATFORM_LUMIN
using UnityEditor.Lumin;
#endif // PLATFORM_LUMIN
using UnityEngine;
using UnityEngine.UIElements;
using UnityEngine.Rendering;
namespace UnityEditor.XR.MagicLeap
{
#if PLATFORM_LUMIN
public class MLDashboard : EditorWindow
{
private IMGUIContainer _remoteChecksUi;
private VisualElement _mainVisualContainer;
private string[] _availablePackages = new string[] {};
private void OnDisable()
{
}
private void OnEnable()
{
_remoteChecksUi = new IMGUIContainer(OnRemoteChecksUI);
_mainVisualContainer = new VisualElement()
{
name = "MainVisualContainer"
};
_mainVisualContainer.Add(_remoteChecksUi);
var root = this.rootVisualElement;
root.Add(_mainVisualContainer);
_availablePackages = MagicLeapPackageLocator.GetUnityPackages().ToArray();
}
private void OnRemoteChecksUI()
{
GUILayout.Label("MagicLeap Remote Requirements", EditorStyles.boldLabel);
using (new GUILayout.HorizontalScope())
{
GUILayout.Label("Rendering API:");
GUILayout.Label(SystemInfo.graphicsDeviceType.ToString(), GUI.skin.textField);
using (new EditorGUI.DisabledScope(!NeedToSwitchToGLCore))
{
if (GUILayout.Button("Restart w/ OpenGL"))
{
if (EditorUtility.DisplayDialog("Editor Restart Required",
string.Format(
"To use Magic Leap zero iteration mode in the editor, the editor must restart using OpenGL."),
"Restart", "Do Not Restart"))
{
Restart("-force-glcore");
}
}
}
}
using (new GUILayout.HorizontalScope())
{
var present = HasVirtualDevice;
using (new EditorGUI.DisabledScope(!present))
{
if (GUILayout.Button("Launch ML Remote"))
{
if (!IsRemoteAlreadyRunning)
LaunchRemote();
}
}
}
using (new GUILayout.HorizontalScope())
{
if (GUILayout.Button("Import MagicLeap unitypackage"))
{
var rect = GUILayoutUtility.GetLastRect();
var versions = new GenericMenu();
foreach (var pkg in _availablePackages)
{
versions.AddItem(new GUIContent(pkg), false, InstallPackage, pkg);
}
// show options as a drop down.
versions.DropDown(rect);
}
}
}
//[MenuItem("Window/XR/MagicLeap Dashboard", false, 1)]
private static void Display()
{
// Get existing open window or if none, make a new one:
EditorWindow.GetWindow<MLDashboard>(false, "ML Dashboard").Show();
}
private void InstallPackage(object p)
{
var path = p as string;
UnityEngine.Debug.LogFormat("Importing: {0}", path);
AssetDatabase.ImportPackage(path, true);
}
private static void LaunchProcess(string filename, string args = "")
{
var startInfo = new ProcessStartInfo
{
FileName = filename,
Arguments = args,
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true
};
Process.Start(startInfo);
}
[MenuItem("Magic Leap/ML Remote/Launch MLRemote")]
private static void LaunchRemote()
{
if (SystemInfo.operatingSystemFamily == OperatingSystemFamily.MacOSX)
{
// MacOSX - Environment Setup
//LaunchProcess("bash", Path.Combine(SDKPath, "envsetup.sh"));
//LaunchProcess("bash", Path.Combine(VirtualDevicePath, "mlvdsetup.sh"));
// MacOSX - MLRemote
LaunchProcess("bash", Path.Combine(VirtualDevicePath, "MLRemote.sh"));
}
else
{
// Windows - Environment Setup
//LaunchProcess(Path.Combine(SDKPath, "envsetup.bat"));
//LaunchProcess(Path.Combine(VirtualDevicePath, "mlvdsetup.bat"));
// Windows - MLRemote
LaunchProcess(Path.Combine(VirtualDevicePath, "MLRemote.bat"));
}
}
[MenuItem("Magic Leap/Lauch MLRemote", true)]
private static bool CanLaunchRemote()
{
return HasVirtualDevice;
}
private static string SdkPath
{
get { return SDK.Find(true).Path; }
}
private static string VirtualDevicePath
{
get { return Path.Combine(SdkPath, "VirtualDevice"); }
}
private static bool HasVirtualDevice
{
get
{
try
{
var sdk = SDK.Find(false);
return (sdk != null) ? sdk.HasMLRemote : false;
}
catch (Exception)
{
return false;
}
}
}
private static void Restart(params string[] args)
{
EditorApplication.OpenProject(ProjectPath, args);
}
private static string ProjectPath
{
get { return Path.GetDirectoryName(Application.dataPath); }
}
private static bool NeedToSwitchToGLCore
{
get { return SystemInfo.graphicsDeviceType != GraphicsDeviceType.OpenGLCore; }
}
private static bool IsRemoteAlreadyRunning
{
get
{
var activeProcesses = Process.GetProcessesByName("MLRemote");
return activeProcesses.Length > 0;
}
}
}
#endif // PLATFORM_LUMIN
internal static class MagicLeapPackageLocator
{
public static IEnumerable<string> GetUnityPackages()
{
var tools = Path.Combine(MagicLeapRoot, "tools");
return new DirectoryInfo(tools).GetFiles("*.unitypackage", SearchOption.AllDirectories).Select(fi => fi.FullName);
}
private static string HomeFolder
{
get
{
var home = Environment.GetEnvironmentVariable("USERPROFILE");
return (string.IsNullOrEmpty(home))
? Environment.GetEnvironmentVariable("HOME")
: home;
}
}
public static string MagicLeapRoot { get { return Path.Combine(HomeFolder, "MagicLeap"); } }
}
} | 32.540541 | 126 | 0.524363 | [
"MIT"
] | kikijinqili/XRCircuits-new | Library/PackageCache/com.unity.xr.magicleap@2.0.0-preview.18/Editor/MLDashboard.cs | 7,224 | C# |
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace WordTutor.Desktop
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
| 18.388889 | 42 | 0.706949 | [
"MIT"
] | theunrepentantgeek/wordtutor | src/WordTutor.Desktop/App.xaml.cs | 333 | C# |
// *** WARNING: this file was generated by the Pulumi SDK Generator. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Threading.Tasks;
using Pulumi.Serialization;
namespace Pulumi.AzureNextGen.DBforMySQL.V20200701PrivatePreview.Inputs
{
/// <summary>
/// Identity for the resource.
/// </summary>
public sealed class IdentityArgs : Pulumi.ResourceArgs
{
/// <summary>
/// The identity type.
/// </summary>
[Input("type")]
public Input<string>? Type { get; set; }
public IdentityArgs()
{
}
}
}
| 24.793103 | 81 | 0.635605 | [
"Apache-2.0"
] | test-wiz-sec/pulumi-azure-nextgen | sdk/dotnet/DBforMySQL/V20200701PrivatePreview/Inputs/IdentityArgs.cs | 719 | C# |
using System;
using System.Net;
using Autofac.Extensions.DependencyInjection;
using MarketingBox.Bridge.Capartners.Service.Settings;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Server.Kestrel.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using MyJetWallet.Sdk.Service;
using MySettingsReader;
namespace MarketingBox.Bridge.Capartners.Service
{
public class Program
{
public const string SettingsFileName = ".marketingboxcapartnersbridge";
public static SettingsModel Settings { get; private set; }
public static ILoggerFactory LogFactory { get; private set; }
public static Func<T> ReloadedSettings<T>(Func<SettingsModel, T> getter)
{
return () =>
{
var settings = SettingsReader.GetSettings<SettingsModel>(SettingsFileName);
var value = getter.Invoke(settings);
return value;
};
}
public static void Main(string[] args)
{
Console.Title = "MarketingBox.Bridge.Capartners.Service";
Settings = SettingsReader.GetSettings<SettingsModel>(SettingsFileName);
using var loggerFactory = LogConfigurator.Configure("MarketingBox.Bridge.Capartners.Service",
Settings.SeqServiceUrl);
var logger = loggerFactory.CreateLogger<Program>();
LogFactory = loggerFactory;
try
{
logger.LogInformation("Application is being started");
CreateHostBuilder(loggerFactory, args).Build().Run();
logger.LogInformation("Application has been stopped");
}
catch (Exception ex)
{
logger.LogCritical(ex, "Application has been terminated unexpectedly");
}
}
public static IHostBuilder CreateHostBuilder(ILoggerFactory loggerFactory, string[] args) =>
Host.CreateDefaultBuilder(args)
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureWebHostDefaults(webBuilder =>
{
var httpPort = Environment.GetEnvironmentVariable("HTTP_PORT") ?? "8080";
var grpcPort = Environment.GetEnvironmentVariable("GRPC_PORT") ?? "80";
Console.WriteLine($"HTTP PORT: {httpPort}");
Console.WriteLine($"GRPC PORT: {grpcPort}");
webBuilder.ConfigureKestrel(options =>
{
options.Listen(IPAddress.Any, int.Parse(httpPort), o => o.Protocols = HttpProtocols.Http1);
options.Listen(IPAddress.Any, int.Parse(grpcPort), o => o.Protocols = HttpProtocols.Http2);
});
webBuilder.UseStartup<Startup>();
})
.ConfigureServices(services =>
{
services.AddSingleton(loggerFactory);
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>));
});
}
}
| 36.872093 | 115 | 0.603595 | [
"MIT"
] | MyJetMarketingBox/MarketingBox.Bridge.Capartners.Service | src/MarketingBox.Bridge.Capartners.Service/Program.cs | 3,173 | C# |
// Copyright (c) Josef Pihrt and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Diagnostics;
using Roslynator.CSharp;
using Roslynator.CSharp.Syntax;
using Roslynator.CSharp.SyntaxWalkers;
namespace Roslynator.CodeAnalysis.CSharp
{
[DiagnosticAnalyzer(LanguageNames.CSharp)]
public sealed class UsePatternMatchingAnalyzer : BaseDiagnosticAnalyzer
{
private static ImmutableHashSet<string> _syntaxKindNames;
private static ImmutableHashSet<string> _syntaxTypeNames;
private static ImmutableDictionary<ushort, string> _syntaxKindValuesToNames;
private static ImmutableArray<DiagnosticDescriptor> _supportedDiagnostics;
public override ImmutableArray<DiagnosticDescriptor> SupportedDiagnostics
{
get
{
if (_supportedDiagnostics.IsDefault)
Immutable.InterlockedInitialize(ref _supportedDiagnostics, DiagnosticRules.UsePatternMatching);
return _supportedDiagnostics;
}
}
public override void Initialize(AnalysisContext context)
{
base.Initialize(context);
context.RegisterCompilationStartAction(startContext =>
{
if (_syntaxKindNames == null)
{
Compilation compilation = startContext.Compilation;
INamedTypeSymbol csharpSyntaxNodeSymbol = compilation.GetTypeByMetadataName("Microsoft.CodeAnalysis.CSharp.CSharpSyntaxNode");
if (csharpSyntaxNodeSymbol == null)
return;
Dictionary<string, string> kindsToNames = compilation
.GetTypeByMetadataName("Microsoft.CodeAnalysis.CSharp.Syntax.AccessorDeclarationSyntax")
.ContainingNamespace
.GetTypeMembers()
.Where(f => f.TypeKind == TypeKind.Class
&& !f.IsAbstract
&& f.InheritsFrom(csharpSyntaxNodeSymbol)
&& f.Name.EndsWith("Syntax", StringComparison.Ordinal))
.ToDictionary(f => f.Name.Remove(f.Name.Length - 6), f => f.Name);
ImmutableHashSet<string>.Builder syntaxKindNames = ImmutableHashSet.CreateBuilder<string>();
ImmutableHashSet<string>.Builder syntaxTypeNames = ImmutableHashSet.CreateBuilder<string>();
ImmutableDictionary<ushort, string>.Builder syntaxKindValuesToNames = ImmutableDictionary.CreateBuilder<ushort, string>();
foreach (SyntaxKind syntaxKind in Enum.GetValues(typeof(SyntaxKind))
.Cast<SyntaxKind>()
.Select(f => f))
{
string name = syntaxKind.ToString();
if (kindsToNames.TryGetValue(name, out string symbolName))
{
syntaxKindNames.Add(name);
syntaxTypeNames.Add(symbolName);
}
syntaxKindValuesToNames.Add((ushort)syntaxKind, name);
}
Interlocked.CompareExchange(ref _syntaxKindNames, syntaxKindNames.ToImmutable(), null);
Interlocked.CompareExchange(ref _syntaxTypeNames, syntaxTypeNames.ToImmutable(), null);
Interlocked.CompareExchange(ref _syntaxKindValuesToNames, syntaxKindValuesToNames.ToImmutable(), null);
}
startContext.RegisterSyntaxNodeAction(f => AnalyzeSwitchStatement(f), SyntaxKind.SwitchStatement);
startContext.RegisterSyntaxNodeAction(f => AnalyzeIfStatement(f), SyntaxKind.IfStatement);
});
}
private static void AnalyzeSwitchStatement(SyntaxNodeAnalysisContext context)
{
var switchStatement = (SwitchStatementSyntax)context.Node;
SyntaxList<SwitchSectionSyntax> sections = switchStatement.Sections;
if (!sections.Any())
return;
ExpressionSyntax switchExpression = switchStatement.Expression;
SingleLocalDeclarationStatementInfo localInfo = default;
string name = GetName();
if (name == null)
return;
ITypeSymbol kindSymbol = context.SemanticModel.GetTypeSymbol(switchExpression, context.CancellationToken);
if (kindSymbol?.HasMetadataName(RoslynMetadataNames.Microsoft_CodeAnalysis_CSharp_SyntaxKind) != true)
return;
foreach (SwitchSectionSyntax section in sections)
{
SwitchLabelSyntax label = section.Labels.SingleOrDefault(shouldThrow: false);
if (label == null)
return;
SyntaxKind labelKind = label.Kind();
if (labelKind == SyntaxKind.DefaultSwitchLabel)
continue;
if (labelKind != SyntaxKind.CaseSwitchLabel)
{
Debug.Assert(labelKind == SyntaxKind.CasePatternSwitchLabel, labelKind.ToString());
return;
}
var caseLabel = (CaseSwitchLabelSyntax)label;
ExpressionSyntax value = caseLabel.Value;
if (!value.IsKind(SyntaxKind.SimpleMemberAccessExpression))
return;
var memberAccess = (MemberAccessExpressionSyntax)value;
if (memberAccess.Name is not IdentifierNameSyntax identifierName)
return;
string kindName = identifierName.Identifier.ValueText;
if (!_syntaxKindNames.Contains(kindName))
return;
SyntaxList<StatementSyntax> statements = section.Statements;
StatementSyntax statement = statements.FirstOrDefault();
if (statement == null)
return;
if (statement is BlockSyntax block)
{
statement = block.Statements.FirstOrDefault();
}
if (!statement.IsKind(SyntaxKind.LocalDeclarationStatement))
return;
SingleLocalDeclarationStatementInfo localStatement = SyntaxInfo.SingleLocalDeclarationStatementInfo((LocalDeclarationStatementSyntax)statement);
if (!localStatement.Success)
return;
if (localStatement.Value is not CastExpressionSyntax castExpression)
return;
if (castExpression.Expression is not IdentifierNameSyntax localName)
return;
if (name != localName.Identifier.ValueText)
return;
if (!IsFixableSyntaxSymbol(castExpression.Type, kindName, context.SemanticModel, context.CancellationToken))
return;
}
if (localInfo.Success
&& IsLocalVariableReferenced(context, localInfo, switchStatement))
{
return;
}
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.UsePatternMatching, switchStatement.SwitchKeyword);
string GetName()
{
switch (switchExpression.Kind())
{
case SyntaxKind.IdentifierName:
{
StatementSyntax previousStatement = switchStatement.PreviousStatement();
if (!previousStatement.IsKind(SyntaxKind.LocalDeclarationStatement))
return null;
localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo((LocalDeclarationStatementSyntax)previousStatement);
if (!localInfo.Success)
return null;
if (localInfo.IdentifierText != ((IdentifierNameSyntax)switchExpression).Identifier.ValueText)
return null;
if (!localInfo.Value.IsKind(SyntaxKind.InvocationExpression))
return null;
return GetName2((InvocationExpressionSyntax)localInfo.Value);
}
case SyntaxKind.InvocationExpression:
{
return GetName2((InvocationExpressionSyntax)switchExpression);
}
default:
{
return null;
}
}
}
static string GetName2(InvocationExpressionSyntax invocationExpression)
{
SimpleMemberInvocationExpressionInfo invocationInfo = SyntaxInfo.SimpleMemberInvocationExpressionInfo(invocationExpression);
if (!invocationInfo.Success)
return null;
if (invocationInfo.Arguments.Any())
return null;
if (invocationInfo.NameText != "Kind")
return null;
if (invocationInfo.Expression is not IdentifierNameSyntax identifierName)
return null;
return identifierName.Identifier.ValueText;
}
}
private static void AnalyzeIfStatement(SyntaxNodeAnalysisContext context)
{
var ifStatement = (IfStatementSyntax)context.Node;
SemanticModel semanticModel = context.SemanticModel;
CancellationToken cancellationToken = context.CancellationToken;
IsKindExpressionInfo isKindExpression = IsKindExpressionInfo.Create(ifStatement.Condition, semanticModel, cancellationToken: cancellationToken);
if (!isKindExpression.Success)
return;
Optional<object> optionalConstantValue = semanticModel.GetConstantValue(isKindExpression.KindExpression, cancellationToken);
if (!optionalConstantValue.HasValue)
return;
if (optionalConstantValue.Value is not ushort value)
return;
if (!_syntaxKindValuesToNames.TryGetValue(value, out string name))
return;
if (!_syntaxKindNames.Contains(name))
return;
switch (isKindExpression.Style)
{
case IsKindExpressionStyle.IsKind:
case IsKindExpressionStyle.IsKindConditional:
case IsKindExpressionStyle.Kind:
case IsKindExpressionStyle.KindConditional:
{
if (ifStatement.Statement is not BlockSyntax block)
return;
Analyze(block.Statements.FirstOrDefault());
break;
}
case IsKindExpressionStyle.NotIsKind:
case IsKindExpressionStyle.NotIsKindConditional:
case IsKindExpressionStyle.NotKind:
case IsKindExpressionStyle.NotKindConditional:
{
if (ifStatement.Else != null)
return;
StatementSyntax statement = ifStatement.Statement.SingleNonBlockStatementOrDefault();
if (statement == null)
return;
if (!CSharpFacts.IsJumpStatement(statement.Kind()))
return;
Analyze(ifStatement.NextStatement());
break;
}
}
void Analyze(StatementSyntax statement)
{
SingleLocalDeclarationStatementInfo localInfo = SyntaxInfo.SingleLocalDeclarationStatementInfo(statement);
if (!localInfo.Success)
return;
if (localInfo.Value is not CastExpressionSyntax castExpression)
return;
if (!IsFixableSyntaxSymbol(castExpression.Type, name, semanticModel, cancellationToken))
return;
if (!CSharpFactory.AreEquivalent(isKindExpression.Expression, castExpression.Expression))
return;
DiagnosticHelpers.ReportDiagnostic(context, DiagnosticRules.UsePatternMatching, ifStatement.IfKeyword);
}
}
private static bool IsFixableSyntaxSymbol(
TypeSyntax type,
string kindName,
SemanticModel semanticModel,
CancellationToken cancellationToken)
{
ITypeSymbol syntaxSymbol = semanticModel.GetTypeSymbol(type, cancellationToken);
if (syntaxSymbol.IsErrorType())
return false;
string syntaxName = syntaxSymbol.Name;
if (!_syntaxTypeNames.Contains(syntaxName))
return false;
if (kindName.Length != syntaxName.Length - 6)
return false;
if (string.Compare(kindName, 0, syntaxName, 0, kindName.Length, StringComparison.Ordinal) != 0)
return false;
if (!syntaxSymbol.InheritsFrom(RoslynMetadataNames.Microsoft_CodeAnalysis_CSharp_CSharpSyntaxNode))
return false;
return true;
}
private static bool IsLocalVariableReferenced(
SyntaxNodeAnalysisContext context,
SingleLocalDeclarationStatementInfo localInfo,
SwitchStatementSyntax switchStatement)
{
ISymbol localSymbol = context.SemanticModel.GetDeclaredSymbol(localInfo.Declarator, context.CancellationToken);
if (localSymbol.IsKind(SymbolKind.Local))
{
bool isReferenced;
ContainsLocalOrParameterReferenceWalker walker = null;
try
{
walker = ContainsLocalOrParameterReferenceWalker.GetInstance(localSymbol, context.SemanticModel, context.CancellationToken);
walker.VisitList(switchStatement.Sections);
if (!walker.Result)
{
StatementListInfo statementsInfo = SyntaxInfo.StatementListInfo(switchStatement);
if (statementsInfo.Success)
{
int index = statementsInfo.IndexOf(switchStatement);
if (index < statementsInfo.Count - 1)
walker.VisitList(statementsInfo.Statements, index + 1);
}
}
isReferenced = walker.Result;
}
finally
{
if (walker != null)
ContainsLocalOrParameterReferenceWalker.Free(walker);
}
return isReferenced;
}
return false;
}
}
}
| 38.673317 | 160 | 0.572156 | [
"Apache-2.0"
] | ProphetLamb-Organistion/Roslynator | src/CodeAnalysis.Analyzers/CSharp/UsePatternMatchingAnalyzer.cs | 15,510 | C# |
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
using System.Collections.Generic;
using Aliyun.Acs.Core;
namespace Aliyun.Acs.Rds.Model.V20140815
{
public class DescribeBackupsResponse : AcsResponse
{
private string requestId;
private string totalRecordCount;
private string pageNumber;
private string pageRecordCount;
private long? totalBackupSize;
private List<DescribeBackups_Backup> items;
public string RequestId
{
get
{
return requestId;
}
set
{
requestId = value;
}
}
public string TotalRecordCount
{
get
{
return totalRecordCount;
}
set
{
totalRecordCount = value;
}
}
public string PageNumber
{
get
{
return pageNumber;
}
set
{
pageNumber = value;
}
}
public string PageRecordCount
{
get
{
return pageRecordCount;
}
set
{
pageRecordCount = value;
}
}
public long? TotalBackupSize
{
get
{
return totalBackupSize;
}
set
{
totalBackupSize = value;
}
}
public List<DescribeBackups_Backup> Items
{
get
{
return items;
}
set
{
items = value;
}
}
public class DescribeBackups_Backup
{
private string backupId;
private string dBInstanceId;
private string backupStatus;
private string backupStartTime;
private string backupEndTime;
private string backupType;
private string backupMode;
private string backupMethod;
private string backupDownloadURL;
private string backupIntranetDownloadURL;
private string backupLocation;
private string backupExtractionStatus;
private string backupScale;
private string backupDBNames;
private long? totalBackupSize;
private long? backupSize;
private string hostInstanceID;
private string storeStatus;
private string metaStatus;
private string slaveStatus;
public string BackupId
{
get
{
return backupId;
}
set
{
backupId = value;
}
}
public string DBInstanceId
{
get
{
return dBInstanceId;
}
set
{
dBInstanceId = value;
}
}
public string BackupStatus
{
get
{
return backupStatus;
}
set
{
backupStatus = value;
}
}
public string BackupStartTime
{
get
{
return backupStartTime;
}
set
{
backupStartTime = value;
}
}
public string BackupEndTime
{
get
{
return backupEndTime;
}
set
{
backupEndTime = value;
}
}
public string BackupType
{
get
{
return backupType;
}
set
{
backupType = value;
}
}
public string BackupMode
{
get
{
return backupMode;
}
set
{
backupMode = value;
}
}
public string BackupMethod
{
get
{
return backupMethod;
}
set
{
backupMethod = value;
}
}
public string BackupDownloadURL
{
get
{
return backupDownloadURL;
}
set
{
backupDownloadURL = value;
}
}
public string BackupIntranetDownloadURL
{
get
{
return backupIntranetDownloadURL;
}
set
{
backupIntranetDownloadURL = value;
}
}
public string BackupLocation
{
get
{
return backupLocation;
}
set
{
backupLocation = value;
}
}
public string BackupExtractionStatus
{
get
{
return backupExtractionStatus;
}
set
{
backupExtractionStatus = value;
}
}
public string BackupScale
{
get
{
return backupScale;
}
set
{
backupScale = value;
}
}
public string BackupDBNames
{
get
{
return backupDBNames;
}
set
{
backupDBNames = value;
}
}
public long? TotalBackupSize
{
get
{
return totalBackupSize;
}
set
{
totalBackupSize = value;
}
}
public long? BackupSize
{
get
{
return backupSize;
}
set
{
backupSize = value;
}
}
public string HostInstanceID
{
get
{
return hostInstanceID;
}
set
{
hostInstanceID = value;
}
}
public string StoreStatus
{
get
{
return storeStatus;
}
set
{
storeStatus = value;
}
}
public string MetaStatus
{
get
{
return metaStatus;
}
set
{
metaStatus = value;
}
}
public string SlaveStatus
{
get
{
return slaveStatus;
}
set
{
slaveStatus = value;
}
}
}
}
}
| 14.712846 | 64 | 0.552474 | [
"Apache-2.0"
] | sdk-team/aliyun-openapi-net-sdk | aliyun-net-sdk-rds/Rds/Model/V20140815/DescribeBackupsResponse.cs | 5,841 | C# |
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System.Collections.Generic;
using System.Linq;
namespace Microsoft.eShopOnContainers.Services.Basket.API.Auth.Server
{
public class AuthorizationHeaderParameterOperationFilter3 : IOperationFilter
{
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
var filterPipeline = context.ApiDescription.ActionDescriptor.FilterDescriptors;
var isAuthorized = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is AuthorizeFilter);
var allowAnonymous = filterPipeline.Select(filterInfo => filterInfo.Filter).Any(filter => filter is IAllowAnonymousFilter);
if (isAuthorized && !allowAnonymous)
{
if (operation.Parameters == null)
operation.Parameters = new List<OpenApiParameter>();
operation.Parameters.Add(new OpenApiParameter
{
Name = "Authorization",
In = ParameterLocation.Header,
Description = "access token",
Required = true
});
}
}
}
}
| 37.857143 | 135 | 0.648302 | [
"MIT"
] | anjoy8/eShopOnContainersAs | src/Services/Basket/Basket.API/Auth/Server/AuthorizationHeaderParameterOperationFilter.cs | 1,327 | C# |
// ----------------------------------------------------------------------------------
//
// Copyright Microsoft Corporation
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------------
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Microsoft.WindowsAzure.Commands.Test.Utilities.Common;
using Xunit;
using Xunit.Abstractions;
namespace Microsoft.Azure.Commands.IotHub.Test.ScenarioTests
{
public class IotHubRoutingTests : RMTestBase
{
public XunitTracingInterceptor _logger;
public IotHubRoutingTests(ITestOutputHelper output)
{
_logger = new XunitTracingInterceptor(output);
XunitTracingInterceptor.AddToContext(_logger);
}
#if NETSTANDARD
[Fact(Skip = "Needs re-recorded")]
#else
[Fact]
#endif
[Trait(Category.AcceptanceType, Category.CheckIn)]
[Trait("Re-record", "ClientRuntime changes")]
public void TestAzureIotHubRoutingLifeCycle()
{
IotHubController.NewInstance.RunPsTest(_logger, "Test-AzureRmIotHubRoutingLifecycle");
}
}
}
| 38.217391 | 99 | 0.638794 | [
"MIT"
] | Andrean/azure-powershell | src/ResourceManager/IotHub/Commands.IotHub.Test/ScenarioTests/IotHubRoutingTests.cs | 1,715 | C# |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VirtoCommerce.Platform.Core.PushNotifications;
namespace VirtoCommerce.TildaModule.Web.Model
{
/// <summary>
/// Notification for sync.
/// </summary>
public class SyncNotification : PushNotification
{
public SyncNotification(string creator)
: base(creator)
{
NotifyType = "TildaSync";
}
}
} | 22.65 | 52 | 0.657837 | [
"MIT"
] | VirtoCommerce/vc-module-tilda | VirtoCommerce.TildaModule.Web/Model/SyncNotification.cs | 455 | C# |
using System;
using NetOffice;
namespace NetOffice.VisioApi.Enums
{
/// <summary>
/// SupportByVersion Visio 14, 15
/// </summary>
///<remarks> MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/ff768606(v=office.14).aspx </remarks>
[SupportByVersionAttribute("Visio", 14,15)]
[EntityTypeAttribute(EntityType.IsEnum)]
public enum VisBuiltInStencilTypes
{
/// <summary>
/// SupportByVersion Visio 14, 15
/// </summary>
/// <remarks>0</remarks>
[SupportByVersionAttribute("Visio", 14,15)]
visBuiltInStencilBackgrounds = 0,
/// <summary>
/// SupportByVersion Visio 14, 15
/// </summary>
/// <remarks>1</remarks>
[SupportByVersionAttribute("Visio", 14,15)]
visBuiltInStencilBorders = 1,
/// <summary>
/// SupportByVersion Visio 14, 15
/// </summary>
/// <remarks>2</remarks>
[SupportByVersionAttribute("Visio", 14,15)]
visBuiltInStencilContainers = 2,
/// <summary>
/// SupportByVersion Visio 14, 15
/// </summary>
/// <remarks>3</remarks>
[SupportByVersionAttribute("Visio", 14,15)]
visBuiltInStencilCallouts = 3,
/// <summary>
/// SupportByVersion Visio 14, 15
/// </summary>
/// <remarks>4</remarks>
[SupportByVersionAttribute("Visio", 14,15)]
visBuiltInStencilLegends = 4
}
} | 28.145833 | 126 | 0.638046 | [
"MIT"
] | NetOffice/NetOffice | Source/Visio/Enums/VisBuiltInStencilTypes.cs | 1,351 | C# |
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for details.
using System;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using OpenLiveWriter.CoreServices;
using OpenLiveWriter.CoreServices.Settings;
using OpenLiveWriter.Interop.Windows;
namespace OpenLiveWriter.ApplicationFramework.Preferences
{
/// <summary>
/// Preferences base class.
/// </summary>
public abstract class Preferences
{
#region Static & Constant Declarations
#endregion Static & Constant Declarations
#region Private Member Variables
/// <summary>
/// The settings persister helper.
/// </summary>
private SettingsPersisterHelper settingsPersisterHelper;
/// <summary>
/// A value that indicates that the Preferences object has been modified since being
/// loaded.
/// </summary>
private bool modified;
/// <summary>
/// Handle to underlying registry key used by these prefs (we need this in order
/// to register for change notifications)
/// </summary>
private UIntPtr hPrefsKey = UIntPtr.Zero;
/// <summary>
/// Win32 event that is signalled whenever our prefs key is changed
/// </summary>
private ManualResetEvent settingsChangedEvent = null;
/// <summary>
/// State variable that indicates we have disabled change monitoring
/// (normally because a very unexpected error has occurred during change
/// monitoring initialization)
/// </summary>
private bool changeMonitoringDisabled = false;
#endregion Private Member Variables
#region Public Events
/// <summary>
/// Occurs when one or more preferences in the Preferences class have been modified.
/// </summary>
public event EventHandler PreferencesModified;
/// <summary>
/// Occurs when one or more preferences in the Preferences class have changed.
/// </summary>
public event EventHandler PreferencesChanged;
#endregion
#region Class Initialization & Termination
/// <summary>
/// Initialize preferences
/// </summary>
/// <param name="subKey">sub key name</param>
public Preferences(string subKey) : this(subKey, false)
{
}
/// <summary>
/// Initializes a new instance of the Preferences class (optionally enable change monitoring)
/// </summary>
/// <param name="subKey">sub-key name</param>
/// <param name="monitorChanges">specifies whether the creator intendes to monitor
/// this prefs object for changes by calling the CheckForChanges method</param>
public Preferences(string subKey, bool monitorChanges)
{
// Instantiate the settings persister helper object.
settingsPersisterHelper = ApplicationEnvironment.PreferencesSettingsRoot.GetSubSettings(subKey);
// Load preferences
LoadPreferences();
// Monitor changes, if requested.
if (monitorChanges)
ConfigureChangeMonitoring(subKey);
}
#endregion Class Initialization & Termination
#region Public Methods
/// <summary>
/// Check for changes to the preferences
/// </summary>
/// <returns>true if there were changes; otherwise, false.</returns>
public bool CheckForChanges()
{
return ReloadPreferencesIfNecessary();
}
/// <summary>
/// Returns a value that indicates that the Preferences object has been modified since
/// being loaded.
/// </summary>
public bool IsModified()
{
return modified;
}
/// <summary>
/// Saves preferences.
/// </summary>
public void Save()
{
if (modified)
{
SavePreferences();
modified = false;
}
}
#endregion Public Methods
#region Protected Methods
/// <summary>
/// Loads preferences. This method is overridden in derived classes to load the
/// preferences of the class.
/// </summary>
protected abstract void LoadPreferences();
/// <summary>
/// Saves preferences. This method is overridden in derived classes to save the
/// preferences of the class.
/// </summary>
protected abstract void SavePreferences();
/// <summary>
/// Sets a value that indicates that the Preferences object has been modified since being
/// loaded.
/// </summary>
protected void Modified()
{
modified = true;
OnPreferencesModified(EventArgs.Empty);
}
#endregion Protected Methods
#region Protected Properties
/// <summary>
/// Gets the SettingsPersisterHelper for this Preferences object.
/// </summary>
protected SettingsPersisterHelper SettingsPersisterHelper
{
get
{
return settingsPersisterHelper;
}
}
#endregion Protected Properties
#region Protected Events
/// <summary>
/// Raises the PreferencesModified event.
/// </summary>
/// <param name="e">An EventArgs that contains the event data.</param>
protected virtual void OnPreferencesModified(EventArgs e)
{
if (PreferencesModified != null)
PreferencesModified(this, e);
}
/// <summary>
/// Raises the Changed event.
/// </summary>
/// <param name="e">An EventArgs that contains the event data.</param>
protected virtual void OnPreferencesChanged(EventArgs e)
{
if (PreferencesChanged != null)
PreferencesChanged(this, e);
}
#endregion Protected Events
#region Private Methods
/// <summary>
/// Configure change monitoring for this prefs object
/// </summary>
/// <param name="subKey"></param>
private void ConfigureChangeMonitoring(string subKey)
{
// assert preconditions
Debug.Assert(hPrefsKey == UIntPtr.Zero);
Debug.Assert(settingsChangedEvent == null);
try
{
// open handle to registry key
int result = Advapi32.RegOpenKeyEx(
HKEY.CURRENT_USER,
String.Format(CultureInfo.InvariantCulture, @"{0}\{1}\{2}", ApplicationEnvironment.SettingsRootKeyName, ApplicationConstants.PREFERENCES_SUB_KEY, subKey),
0, KEY.READ, out hPrefsKey);
if (result != ERROR.SUCCESS)
{
Trace.Fail("Failed to open registry key");
changeMonitoringDisabled = true;
return;
}
// create settings changed event
settingsChangedEvent = new ManualResetEvent(false);
// start monitoring changes
MonitorChanges();
}
catch (Exception e)
{
// Just being super-paranoid here because this code is likely be called during
// application initialization -- if ANY type of error occurs then we disable
// change monitoring for the life of this object
Trace.WriteLine("Unexpected error occurred during change monitor configuration: " + e.Message + "\r\n" + e.StackTrace);
changeMonitoringDisabled = true;
}
}
/// <summary>
/// Monitor changes in the registry key for this prefs object
/// </summary>
private void MonitorChanges()
{
// reset the settings changed event so it will not be signaled until
// a change is made to the specified key
settingsChangedEvent.Reset();
// request that the event be signaled when the registry key changes
int result = Advapi32.RegNotifyChangeKeyValue(hPrefsKey, false, REG_NOTIFY_CHANGE.LAST_SET, settingsChangedEvent.SafeWaitHandle, true);
if (result != ERROR.SUCCESS)
{
Trace.WriteLine("Unexpeced failure to monitor reg key (Error code: " + result.ToString(CultureInfo.InvariantCulture));
changeMonitoringDisabled = true;
}
}
/// <summary>
/// Load changes to preferences if they have changed since our last check
/// </summary>
/// <returns>true if preferences were reloaded; otherwise, false.</returns>
private bool ReloadPreferencesIfNecessary()
{
// If change monitoring is disabled, then just return.
if (changeMonitoringDisabled)
return false;
// Verify this instance is configured to monitor changes.
if (settingsChangedEvent == null)
{
Debug.Fail("Must initialize preferences object with monitorChanges flag set to true in order to call CheckForChanges");
return false;
}
// check to see whether any changes have occurred
try
{
// if the settings changed event is signaled then reload preferences
if (settingsChangedEvent.WaitOne(0, false))
{
// Reload.
LoadPreferences();
// Monitor subsequent changes.
MonitorChanges();
// Raise the PreferencesChanged event.
OnPreferencesChanged(EventArgs.Empty);
// Changes were loaded.
return true;
}
}
catch (Exception e)
{
// Just being super-paranoid here because this code is called from a timer
// in the UI thread -- if ANY type of error occurs during change monitoring
// then we disable change monitoring for the life of this object
Trace.WriteLine("Unexpected error occurred during check for changes: " + e.Message + "\r\n" + e.StackTrace);
changeMonitoringDisabled = true;
return false;
}
// Not loaded!
return false;
}
#endregion
}
}
| 34.252396 | 174 | 0.574387 | [
"MIT"
] | DNSNets/OpenLiveWriter | src/managed/OpenLiveWriter.ApplicationFramework/Preferences/Preferences.cs | 10,721 | C# |
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using s3cr3txMVC.Data;
using System;
namespace s3cr3txMVC.Data.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "3.0.0")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex")
.HasFilter("[NormalizedName] IS NOT NULL");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("RoleId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.HasColumnType("nvarchar(450)");
b.Property<int>("AccessFailedCount")
.HasColumnType("int");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed")
.HasColumnType("bit");
b.Property<bool>("LockoutEnabled")
.HasColumnType("bit");
b.Property<DateTimeOffset?>("LockoutEnd")
.HasColumnType("datetimeoffset");
b.Property<string>("NormalizedEmail")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.Property<string>("PasswordHash")
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.HasColumnType("nvarchar(max)");
b.Property<bool>("PhoneNumberConfirmed")
.HasColumnType("bit");
b.Property<string>("SecurityStamp")
.HasColumnType("nvarchar(max)");
b.Property<bool>("TwoFactorEnabled")
.HasColumnType("bit");
b.Property<string>("UserName")
.HasColumnType("nvarchar(256)")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex")
.HasFilter("[NormalizedUserName] IS NOT NULL");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ClaimType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ClaimValue")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("ProviderKey")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("ProviderDisplayName")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserId")
.IsRequired()
.HasColumnType("nvarchar(450)");
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("RoleId")
.HasColumnType("nvarchar(450)");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId")
.HasColumnType("nvarchar(450)");
b.Property<string>("LoginProvider")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Name")
.HasColumnType("nvarchar(128)")
.HasMaxLength(128);
b.Property<string>("Value")
.HasColumnType("nvarchar(max)");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityUser", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
#pragma warning restore 612, 618
}
}
}
| 37.652174 | 125 | 0.468149 | [
"MIT"
] | patrickkelly20/s3cr3tx | s3cr3txMVC/Data/Migrations/ApplicationDbContextModelSnapshot.cs | 10,392 | C# |
using Oldmansoft.Html.Util;
namespace Oldmansoft.Html.WebMan.FormValidate
{
class Regexp : Validator
{
public string Pattern { get; set; }
protected override void Set(JsonObject json)
{
json.Set("regexp", new JsonRaw(string.Format("/{0}/i", Pattern)));
}
}
}
| 21.2 | 78 | 0.600629 | [
"Apache-2.0"
] | Oldmansoft/WebMan | src/Oldmansoft.Html.WebMan/FormValidate/Regexp.cs | 320 | C# |
using Xunit;
namespace Transmute
{
public class ComplexTypeReducerTests: ReducerTests
{
[Theory]
[ClassData(typeof(TestActions))]
public void CanComposeStateReducersAndDelegateToThem(object action)
{
ComplexTypeReducer<TestState> reducer = new ComplexTypeReducer<TestState>()
.SetPropertyReducer(x => x.Name, new Reducer<string>().Scan(typeof(StateNameReducer)));
TestState actual = reducer.Reduce(TestState.Before, action);
string expected = action switch
{
TestAction1 a1 => StateNameReducer.OnTestAction1(TestState.Before.Name, a1),
TestAction2 a2 => StateNameReducer.OnTestAction2(TestState.Before.Name, a2),
_ => TestState.Before.Name
};
Assert.Equal(expected, actual.Name);
}
protected override Reducer<TestState> Testable =>
new ComplexTypeReducer<TestState>();
}
} | 34.586207 | 103 | 0.617149 | [
"MIT"
] | pwarner/Transmute.Net | tests/Transmute.Tests/ComplexTypeReducerTests.cs | 1,005 | C# |
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Serilog;
using Serilog.Events;
namespace ExperimentationLite.Api.Middleware
{
// CWCID: https://blog.getseq.net/smart-logging-middleware-for-asp-net-core/
public class RequestLogger
{
const string MessageTemplate = "HTTP {RequestMethod} {RequestPath} responded {StatusCode} in {Elapsed:0.0000} ms";
static readonly ILogger Log = Serilog.Log.ForContext<RequestLogger>();
readonly RequestDelegate _next;
public RequestLogger(RequestDelegate next)
{
_next = next ?? throw new ArgumentNullException(nameof(next));
}
public async Task Invoke(HttpContext httpContext)
{
if (httpContext == null)
{
throw new ArgumentNullException(nameof(httpContext));
}
var sw = Stopwatch.StartNew();
try
{
await _next(httpContext);
sw.Stop();
var statusCode = httpContext.Response?.StatusCode;
var level = statusCode > 499 ? LogEventLevel.Error : LogEventLevel.Information;
var log = level == LogEventLevel.Error ? LogForErrorContext(httpContext) : Log;
log.Write(level, MessageTemplate, httpContext.Request.Method, httpContext.Request.Path, statusCode,
sw.Elapsed.TotalMilliseconds);
}
catch (Exception ex)
when (LogException(httpContext, sw, ex))
{
}
}
static bool LogException(HttpContext httpContext, Stopwatch sw, Exception ex)
{
sw.Stop();
LogForErrorContext(httpContext)
.Error(ex, MessageTemplate, httpContext.Request.Method, httpContext.Request.Path, 500, sw.Elapsed.TotalMilliseconds);
return false;
}
static ILogger LogForErrorContext(HttpContext httpContext)
{
var request = httpContext.Request;
var result = Log
.ForContext("RequestHeaders", request.Headers.ToDictionary(h => h.Key, h => h.Value.ToString()), true)
.ForContext("RequestHost", request.Host)
.ForContext("RequestProtocol", request.Protocol);
if (request.HasFormContentType)
{
result = result.ForContext("RequestForm", request.Form.ToDictionary(v => v.Key, v => v.Value.ToString()));
}
return result;
}
}
} | 33.641026 | 133 | 0.59375 | [
"MIT"
] | iby-dev/ExperimentationLite-API | src/ExperimentationLite.Api/Middleware/RequestLogger.cs | 2,626 | C# |
using BennyKok.RuntimeDebug.Actions;
using UnityEngine;
namespace BennyKok.RuntimeDebug.Components
{
[AddComponentMenu("Runtime Debug Action/Actions/Debug Action Input")]
public class DebugActionInputHandler : BaseDebugActionHandler<DebugActionInput>
{
}
#if UNITY_EDITOR
[UnityEditor.CanEditMultipleObjects]
[UnityEditor.CustomEditor(typeof(DebugActionInputHandler))]
public class DebugActionInputHandlerEditor : DebugActionHandlerEditor { }
#endif
} | 28.352941 | 83 | 0.79668 | [
"MIT"
] | BennyKok/unity-runtime-debug-action | Runtime/Components/Actions/DebugActionInputHandler.cs | 482 | C# |
using System;
using CoreGraphics;
using UIKit;
namespace UIKit
{
public static class CGRectExtensions
{
public static CGRect ApplyInset(this CGRect rect, UIEdgeInsets inset)
{
rect.X += inset.Left;
rect.Y += inset.Top;
rect.Height -= inset.Top + inset.Bottom;
rect.Width -= inset.Left + inset.Right;
return rect;
}
}
}
| 18.210526 | 71 | 0.687861 | [
"Apache-2.0"
] | Clancey/iOSHelpers | iOSHelpers/Extensions/CGRectExtensions.cs | 348 | C# |
using System;
using System.Xml.Serialization;
using System.ComponentModel.DataAnnotations;
using BroadWorksConnector.Ocip.Validation;
using System.Collections.Generic;
namespace BroadWorksConnector.Ocip.Models
{
/// <summary>
/// Get a list of Communication Barring Incoming Criteria assigned to a service provider.
/// The response is either a ServiceProviderCommunicationBarringIncomingCriteriaGetAssignedListResponse
/// or an ErrorResponse.
/// <see cref="ServiceProviderCommunicationBarringIncomingCriteriaGetAssignedListResponse"/>
/// <see cref="ErrorResponse"/>
/// </summary>
[Serializable]
[XmlRoot(Namespace = "")]
[Groups(@"[{""__type"":""Sequence:#BroadWorksConnector.Ocip.Validation"",""id"":""f1088f4c5ceb30d524d2ba0f8097c393:1714""}]")]
public class ServiceProviderCommunicationBarringIncomingCriteriaGetAssignedListRequest : BroadWorksConnector.Ocip.Models.C.OCIRequest
{
private string _serviceProviderId;
[XmlElement(ElementName = "serviceProviderId", IsNullable = false, Namespace = "")]
[Group(@"f1088f4c5ceb30d524d2ba0f8097c393:1714")]
[MinLength(1)]
[MaxLength(30)]
public string ServiceProviderId
{
get => _serviceProviderId;
set
{
ServiceProviderIdSpecified = true;
_serviceProviderId = value;
}
}
[XmlIgnore]
protected bool ServiceProviderIdSpecified { get; set; }
}
}
| 34.386364 | 137 | 0.686715 | [
"MIT"
] | JTOne123/broadworks-connector-net | BroadworksConnector/Ocip/Models/ServiceProviderCommunicationBarringIncomingCriteriaGetAssignedListRequest.cs | 1,513 | C# |
/*
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System.Collections.Generic;
using QuantConnect.Algorithm.Framework;
using QuantConnect.Algorithm.Framework.Alphas;
using QuantConnect.Algorithm.Framework.Execution;
using QuantConnect.Algorithm.Framework.Portfolio;
using QuantConnect.Algorithm.Framework.Risk;
using QuantConnect.Algorithm.Framework.Selection;
namespace QuantConnect.Algorithm.CSharp
{
/// <summary>
/// Framework algorithm that uses the <see cref="PairsTradingAlphaModel"/> to detect
/// divergences between correllated assets. Detection of asset correlation is not
/// performed and is expected to be handled outside of the alpha model.
/// </summary>
public class PairsTradingAlphaModelFrameworkAlgorithm : QCAlgorithmFramework, IRegressionAlgorithmDefinition
{
public override void Initialize()
{
SetStartDate(2013, 10, 07);
SetEndDate(2013, 10, 11);
var bac = AddEquity("BAC");
var aig = AddEquity("AIG");
SetUniverseSelection(new ManualUniverseSelectionModel(Securities.Keys));
SetAlpha(new PairsTradingAlphaModel(bac.Symbol, aig.Symbol));
SetPortfolioConstruction(new EqualWeightingPortfolioConstructionModel());
SetExecution(new ImmediateExecutionModel());
SetRiskManagement(new NullRiskManagementModel());
}
/// <summary>
/// This is used by the regression test system to indicate which languages this algorithm is written in.
/// </summary>
public Language[] Languages { get; } = { Language.CSharp, Language.Python };
/// <summary>
/// This is used by the regression test system to indicate what the expected statistics are from running the algorithm
/// </summary>
public Dictionary<string, string> ExpectedStatistics => new Dictionary<string, string>
{
{"Total Trades", "4"},
{"Average Win", "2.15%"},
{"Average Loss", "-1.35%"},
{"Compounding Annual Return", "75.075%"},
{"Drawdown", "0.600%"},
{"Expectancy", "0.293"},
{"Net Profit", "0.719%"},
{"Sharpe Ratio", "6.982"},
{"Loss Rate", "50%"},
{"Win Rate", "50%"},
{"Profit-Loss Ratio", "1.59"},
{"Alpha", "0"},
{"Beta", "32.812"},
{"Annual Standard Deviation", "0.052"},
{"Annual Variance", "0.003"},
{"Information Ratio", "6.782"},
{"Tracking Error", "0.052"},
{"Treynor Ratio", "0.011"},
{"Total Fees", "$74.09"},
{"Total Insights Generated", "4"},
{"Total Insights Closed", "4"},
{"Total Insights Analysis Completed", "4"},
{"Long Insight Count", "2"},
{"Short Insight Count", "2"},
{"Long/Short Ratio", "100%"},
{"Estimated Monthly Alpha Value", "$-1148.429"},
{"Total Accumulated Estimated Alpha Value", "$-185.0247"},
{"Mean Population Estimated Insight Value", "$-46.25617"},
{"Mean Population Direction", "50%"},
{"Mean Population Magnitude", "0%"},
{"Rolling Averaged Population Direction", "3.8827%"},
{"Rolling Averaged Population Magnitude", "0%"}
};
}
}
| 43.473118 | 126 | 0.618847 | [
"Apache-2.0"
] | matriksiqteam/Lean | Algorithm.CSharp/PairsTradingAlphaModelFrameworkAlgorithm.cs | 4,043 | C# |
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using static ColorPicker.Win32Apis;
namespace ColorPicker.Keyboard
{
internal class GlobalKeyboardHook : IDisposable
{
private IntPtr _windowsHookHandle;
private IntPtr _user32LibraryHandle;
private HookProc _hookProc;
public GlobalKeyboardHook()
{
_windowsHookHandle = IntPtr.Zero;
_user32LibraryHandle = IntPtr.Zero;
_hookProc = LowLevelKeyboardProc; // we must keep alive _hookProc, because GC is not aware about SetWindowsHookEx behaviour.
_user32LibraryHandle = LoadLibrary("User32");
if (_user32LibraryHandle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode, $"Failed to load library 'User32.dll'. Error {errorCode}: {new Win32Exception(Marshal.GetLastWin32Error()).Message}.");
}
_windowsHookHandle = SetWindowsHookEx(WH_KEYBOARD_LL, _hookProc, _user32LibraryHandle, 0);
if (_windowsHookHandle == IntPtr.Zero)
{
int errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode, $"Failed to adjust keyboard hooks for '{Process.GetCurrentProcess().ProcessName}'. Error {errorCode}: {new Win32Exception(Marshal.GetLastWin32Error()).Message}.");
}
}
internal event EventHandler<GlobalKeyboardHookEventArgs> KeyboardPressed;
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// because we can unhook only in the same thread, not in garbage collector thread
if (_windowsHookHandle != IntPtr.Zero)
{
if (!UnhookWindowsHookEx(_windowsHookHandle))
{
int errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode, $"Failed to remove keyboard hooks for '{Process.GetCurrentProcess().ProcessName}'. Error {errorCode}: {new Win32Exception(Marshal.GetLastWin32Error()).Message}.");
}
_windowsHookHandle = IntPtr.Zero;
// ReSharper disable once DelegateSubtraction
_hookProc -= LowLevelKeyboardProc;
}
}
if (_user32LibraryHandle != IntPtr.Zero)
{
if (!FreeLibrary(_user32LibraryHandle)) // reduces reference to library by 1.
{
int errorCode = Marshal.GetLastWin32Error();
throw new Win32Exception(errorCode, $"Failed to unload library 'User32.dll'. Error {errorCode}: {new Win32Exception(Marshal.GetLastWin32Error()).Message}.");
}
_user32LibraryHandle = IntPtr.Zero;
}
}
~GlobalKeyboardHook()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
public enum KeyboardState
{
KeyDown = 0x0100,
KeyUp = 0x0101,
SysKeyDown = 0x0104,
SysKeyUp = 0x0105
}
private IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam)
{
bool fEatKeyStroke = false;
var wparamTyped = wParam.ToInt32();
if (Enum.IsDefined(typeof(KeyboardState), wparamTyped))
{
object o = Marshal.PtrToStructure(lParam, typeof(LowLevelKeyboardInputEvent));
LowLevelKeyboardInputEvent p = (LowLevelKeyboardInputEvent)o;
var eventArguments = new GlobalKeyboardHookEventArgs(p, (KeyboardState)wparamTyped);
EventHandler<GlobalKeyboardHookEventArgs> handler = KeyboardPressed;
handler?.Invoke(this, eventArguments);
fEatKeyStroke = eventArguments.Handled;
}
return fEatKeyStroke ? (IntPtr)1 : CallNextHookEx(IntPtr.Zero, nCode, wParam, lParam);
}
}
}
| 38.66055 | 223 | 0.597057 | [
"MIT"
] | AdrianMayron/ColorPicker | ColorPicker/Keyboard/GlobalKeyboardHook.cs | 4,216 | C# |
using System;
using NetRuntimeSystem = System;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
using System.ComponentModel;
using System.Reflection;
using System.Collections.Generic;
using System.Collections;
using NetOffice;
namespace NetOffice.OfficeApi
{
///<summary>
/// DispatchInterface ThemeColorScheme
/// SupportByVersion Office, 12,14,15
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff863682.aspx
///</summary>
[SupportByVersionAttribute("Office", 12,14,15)]
[EntityTypeAttribute(EntityType.IsDispatchInterface)]
public class ThemeColorScheme : _IMsoDispObj ,IEnumerable<object>
{
#pragma warning disable
#region Type Information
private static Type _type;
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public static Type LateBindingApiWrapperType
{
get
{
if (null == _type)
_type = typeof(ThemeColorScheme);
return _type;
}
}
#endregion
#region Construction
///<param name="factory">current used factory core</param>
///<param name="parentObject">object there has created the proxy</param>
///<param name="comProxy">inner wrapped COM proxy</param>
public ThemeColorScheme(Core factory, COMObject parentObject, object comProxy) : base(factory, parentObject, comProxy)
{
}
///<param name="parentObject">object there has created the proxy</param>
///<param name="comProxy">inner wrapped COM proxy</param>
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public ThemeColorScheme(COMObject parentObject, object comProxy) : base(parentObject, comProxy)
{
}
///<param name="factory">current used factory core</param>
///<param name="parentObject">object there has created the proxy</param>
///<param name="comProxy">inner wrapped COM proxy</param>
///<param name="comProxyType">Type of inner wrapped COM proxy"</param>
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public ThemeColorScheme(Core factory, COMObject parentObject, object comProxy, NetRuntimeSystem.Type comProxyType) : base(factory, parentObject, comProxy, comProxyType)
{
}
///<param name="parentObject">object there has created the proxy</param>
///<param name="comProxy">inner wrapped COM proxy</param>
///<param name="comProxyType">Type of inner wrapped COM proxy"</param>
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public ThemeColorScheme(COMObject parentObject, object comProxy, NetRuntimeSystem.Type comProxyType) : base(parentObject, comProxy, comProxyType)
{
}
///<param name="replacedObject">object to replaced. replacedObject are not usable after this action</param>
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public ThemeColorScheme(COMObject replacedObject) : base(replacedObject)
{
}
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public ThemeColorScheme() : base()
{
}
/// <param name="progId">registered ProgID</param>
[EditorBrowsable(EditorBrowsableState.Never), Browsable(false)]
public ThemeColorScheme(string progId) : base(progId)
{
}
#endregion
#region Properties
/// <summary>
/// SupportByVersion Office 12, 14, 15
/// Get
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff864930.aspx
/// Unknown COM Proxy
/// </summary>
[SupportByVersionAttribute("Office", 12,14,15)]
public object Parent
{
get
{
object[] paramsArray = null;
object returnItem = Invoker.PropertyGet(this, "Parent", paramsArray);
COMObject newObject = Factory.CreateObjectFromComProxy(this,returnItem);
return newObject;
}
}
/// <summary>
/// SupportByVersion Office 12, 14, 15
/// Get
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff861492.aspx
/// </summary>
[SupportByVersionAttribute("Office", 12,14,15)]
public Int32 Count
{
get
{
object[] paramsArray = null;
object returnItem = Invoker.PropertyGet(this, "Count", paramsArray);
return NetRuntimeSystem.Convert.ToInt32(returnItem);
}
}
#endregion
#region Methods
/// <summary>
/// SupportByVersion Office 12, 14, 15
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff860912.aspx
/// </summary>
/// <param name="index">NetOffice.OfficeApi.Enums.MsoThemeColorSchemeIndex Index</param>
[SupportByVersionAttribute("Office", 12,14,15)]
public NetOffice.OfficeApi.ThemeColor Colors(NetOffice.OfficeApi.Enums.MsoThemeColorSchemeIndex index)
{
object[] paramsArray = Invoker.ValidateParamsArray(index);
object returnItem = Invoker.MethodReturn(this, "Colors", paramsArray);
NetOffice.OfficeApi.ThemeColor newObject = Factory.CreateKnownObjectFromComProxy(this, returnItem,NetOffice.OfficeApi.ThemeColor.LateBindingApiWrapperType) as NetOffice.OfficeApi.ThemeColor;
return newObject;
}
/// <summary>
/// SupportByVersion Office 12, 14, 15
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff862095.aspx
/// </summary>
/// <param name="fileName">string FileName</param>
[SupportByVersionAttribute("Office", 12,14,15)]
public void Load(string fileName)
{
object[] paramsArray = Invoker.ValidateParamsArray(fileName);
Invoker.Method(this, "Load", paramsArray);
}
/// <summary>
/// SupportByVersion Office 12, 14, 15
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff861898.aspx
/// </summary>
/// <param name="fileName">string FileName</param>
[SupportByVersionAttribute("Office", 12,14,15)]
public void Save(string fileName)
{
object[] paramsArray = Invoker.ValidateParamsArray(fileName);
Invoker.Method(this, "Save", paramsArray);
}
/// <summary>
/// SupportByVersion Office 12, 14, 15
/// MSDN Online Documentation: http://msdn.microsoft.com/en-us/en-us/library/office/ff862172.aspx
/// </summary>
/// <param name="name">string Name</param>
[SupportByVersionAttribute("Office", 12,14,15)]
public Int32 GetCustomColor(string name)
{
object[] paramsArray = Invoker.ValidateParamsArray(name);
object returnItem = Invoker.MethodReturn(this, "GetCustomColor", paramsArray);
return NetRuntimeSystem.Convert.ToInt32(returnItem);
}
#endregion
#region IEnumerable<object> Member
/// <summary>
/// SupportByVersionAttribute Office, 12,14,15
/// </summary>
[SupportByVersionAttribute("Office", 12,14,15)]
public IEnumerator<object> GetEnumerator()
{
NetRuntimeSystem.Collections.IEnumerable innerEnumerator = (this as NetRuntimeSystem.Collections.IEnumerable);
foreach (object item in innerEnumerator)
yield return item;
}
#endregion
#region IEnumerable Members
/// <summary>
/// SupportByVersionAttribute Office, 12,14,15
/// </summary>
[SupportByVersionAttribute("Office", 12,14,15)]
IEnumerator NetRuntimeSystem.Collections.IEnumerable.GetEnumerator()
{
return NetOffice.Utils.GetProxyEnumeratorAsProperty(this);
}
#endregion
#pragma warning restore
}
} | 35.291667 | 194 | 0.685688 | [
"MIT"
] | NetOffice/NetOffice | Source/Office/DispatchInterfaces/ThemeColorScheme.cs | 7,623 | C# |
using System;
using System.Diagnostics.CodeAnalysis;
using System.Web;
using URSA.Web.Http.Configuration;
namespace URSA.Web.Configuration
{
/// <summary>Provides a <see cref="HttpContext" /> based configuration.</summary>
[ExcludeFromCodeCoverage]
public class HttpContextBoundServerConfiguration : IHttpServerConfiguration
{
private Uri _baseUri = null;
/// <inheritdoc />
public Uri BaseUri
{
get
{
if ((_baseUri == null) && (HttpContext.Current != null))
{
_baseUri = new Uri(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority));
}
return _baseUri;
}
}
}
} | 27.071429 | 106 | 0.583113 | [
"BSD-3-Clause"
] | CharlesOkwuagwu/URSA | URSA.Web/Configuration/HttpContextBoundServerConfiguration.cs | 760 | C# |
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using BuildXL.Cache.ContentStore.Service;
using BuildXL.Cache.ContentStore.Interfaces.FileSystem;
using BuildXL.Cache.ContentStore.Hashing;
using BuildXL.Cache.ContentStore.Interfaces.Stores;
using BuildXL.Cache.ContentStore.InterfacesTest.FileSystem;
using BuildXL.Cache.ContentStore.InterfacesTest.Time;
using ContentStoreTest.Test;
using FluentAssertions;
using Xunit;
namespace ContentStoreTest.Service
{
public class HibernatedSessionsTests : TestBase
{
private const string CacheName = "cacheName";
private const string SessionName = "sessionName";
private const int ContentHashCount = 1000;
private static readonly List<ContentHash> ContentHashes =
Enumerable.Range(0, ContentHashCount).Select(x => ContentHash.Random()).ToList();
public HibernatedSessionsTests()
: base(() => new MemoryFileSystem(new TestSystemClock()), TestGlobal.Logger)
{
}
[Fact]
[Trait("Category", "WindowsOSOnly")]
public Task RoundtripProtected()
{
return Roundtrip(true);
}
[Theory]
[InlineData(false)]
public async Task Roundtrip(bool useProtected)
{
var fileName = $"{Guid.NewGuid()}.json";
using (var directory = new DisposableDirectory(FileSystem))
{
const Capabilities capabilities = Capabilities.Heartbeat;
var pins = ContentHashes.Select(x => x.Serialize()).ToList();
var expirationTicks = DateTime.UtcNow.Ticks;
var sessionInfo = new HibernatedContentSessionInfo(1, SessionName, ImplicitPin.None, CacheName, pins, expirationTicks, capabilities);
var sessions1 = new HibernatedSessions<HibernatedContentSessionInfo>(new List<HibernatedContentSessionInfo> {sessionInfo});
if (useProtected)
{
await sessions1.WriteProtectedAsync(FileSystem, directory.Path, fileName);
}
else
{
sessions1.Write(FileSystem, directory.Path, fileName);
}
FileSystem.HibernatedSessionsExists(directory.Path, fileName).Should().BeTrue();
var fileSize = FileSystem.GetFileSize(directory.Path / fileName);
fileSize.Should().BeGreaterThan(0);
var sessions2 = useProtected
? await FileSystem.ReadProtectedHibernatedSessionsAsync<HibernatedContentSessionInfo>(directory.Path, fileName)
: await FileSystem.ReadHibernatedSessionsAsync<HibernatedContentSessionInfo>(directory.Path, fileName);
sessions2.Sessions.Count.Should().Be(1);
sessions2.Sessions[0].Pins.Count.Should().Be(ContentHashCount);
sessions2.Sessions[0].ExpirationUtcTicks.Should().Be(expirationTicks);
sessions2.Sessions[0].Capabilities.Should().Be(capabilities);
await FileSystem.DeleteHibernatedSessions(directory.Path, fileName);
}
}
[Fact]
public async Task RoundtripSessionsWithSameName()
{
const int count = 3;
var fileName = $"{Guid.NewGuid()}.json";
using (var directory = new DisposableDirectory(FileSystem))
{
var sessionInfoList = new List<HibernatedContentSessionInfo>();
foreach (var i in Enumerable.Range(0, count))
{
List<string> pins = ContentHashes.Select(x => x.Serialize()).ToList();
sessionInfoList.Add(new HibernatedContentSessionInfo(i, SessionName, ImplicitPin.None, CacheName, pins, DateTime.UtcNow.Ticks, Capabilities.None));
}
var sessions1 = new HibernatedSessions<HibernatedContentSessionInfo>(sessionInfoList);
sessions1.Write(FileSystem, directory.Path, fileName);
FileSystem.HibernatedSessionsExists(directory.Path, fileName).Should().BeTrue();
var sessions2 = await FileSystem.ReadHibernatedSessionsAsync<HibernatedContentSessionInfo>(directory.Path, fileName);
sessions2.Sessions.Count.Should().Be(count);
sessions2.Sessions.All(s => s.Pins.Count == ContentHashCount).Should().BeTrue();
sessions2.Sessions.All(s => s.Session == SessionName).Should().BeTrue();
sessions2.Sessions.All(s => s.Cache == CacheName).Should().BeTrue();
await FileSystem.DeleteHibernatedSessions(directory.Path, fileName);
}
}
}
}
| 46.45283 | 168 | 0.626726 | [
"MIT"
] | BearerPipelineTest/BuildXL | Public/Src/Cache/ContentStore/Test/Service/HibernatedSessionsTests.cs | 4,924 | C# |
namespace Khala.Processes.Sql
{
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using AutoFixture;
using FluentAssertions;
using Khala.FakeDomain;
using Khala.Messaging;
using Khala.TransientFaultHandling;
using Microsoft.EntityFrameworkCore;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;
[TestClass]
public class SqlCommandPublisher_specs
{
private readonly DbContextOptions<ProcessManagerDbContext> _dbContextOptions;
public SqlCommandPublisher_specs()
{
_dbContextOptions = new DbContextOptionsBuilder<ProcessManagerDbContext>()
.UseInMemoryDatabase(nameof(ProcessManagerDbContext_specs))
.Options;
}
[TestMethod]
public void sut_implements_ICommandPublisher()
{
typeof(SqlCommandPublisher).Should().Implement<ICommandPublisher>();
}
[TestMethod]
public async Task FlushCommands_deletes_all_commands_associated_with_specified_process_manager()
{
// Arrange
var serializer = new JsonMessageSerializer();
var processManager = new FakeProcessManager();
var noiseProcessManager = new FakeProcessManager();
const int noiseCommandCount = 3;
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
var commands = new List<PendingCommand>(
from command in Enumerable.Repeat(new FakeCommand(), 3)
let envelope = new Envelope(command)
select PendingCommand.FromEnvelope(processManager, envelope, serializer));
commands.AddRange(
from command in Enumerable.Repeat(new FakeCommand(), noiseCommandCount)
let envelope = new Envelope(command)
select PendingCommand.FromEnvelope(noiseProcessManager, envelope, serializer));
var random = new Random();
db.PendingCommands.AddRange(
from command in commands
orderby random.Next()
select command);
await db.SaveChangesAsync();
}
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
Mock.Of<IScheduledMessageBus>());
// Act
await sut.FlushCommands(processManager.Id, CancellationToken.None);
// Assert
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
(await db.PendingCommands.AnyAsync(c => c.ProcessManagerId == processManager.Id)).Should().BeFalse();
(await db.PendingCommands.CountAsync(c => c.ProcessManagerId == noiseProcessManager.Id)).Should().Be(noiseCommandCount);
}
}
[TestMethod]
public async Task FlushCommands_sends_all_commands_associated_with_specified_process_manager_sequentially()
{
// Arrange
var serializer = new JsonMessageSerializer();
var processManager = new FakeProcessManager();
var noiseProcessManager = new FakeProcessManager();
var random = new Random();
var fixture = new Fixture();
var envelopes = new List<Envelope>(
from command in new[]
{
new FakeCommand { Int32Value = random.Next(), StringValue = fixture.Create<string>() },
new FakeCommand { Int32Value = random.Next(), StringValue = fixture.Create<string>() },
new FakeCommand { Int32Value = random.Next(), StringValue = fixture.Create<string>() },
}
select new Envelope(
Guid.NewGuid(),
command,
operationId: Guid.NewGuid().ToString(),
correlationId: Guid.NewGuid(),
contributor: Guid.NewGuid().ToString()));
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
db.PendingCommands.AddRange(from envelope in envelopes
select PendingCommand.FromEnvelope(processManager, envelope, serializer));
db.PendingCommands.AddRange(from envelope in new[]
{
new Envelope(new object()),
new Envelope(new object()),
new Envelope(new object()),
}
select PendingCommand.FromEnvelope(noiseProcessManager, envelope, serializer));
await db.SaveChangesAsync();
}
var messageBus = new MessageBus();
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
messageBus,
Mock.Of<IScheduledMessageBus>());
// Act
await sut.FlushCommands(processManager.Id, CancellationToken.None);
// Assert
messageBus.Sent.Should().BeEquivalentTo(envelopes, opts => opts.WithStrictOrdering().RespectingRuntimeTypes());
}
[TestMethod]
public async Task given_message_bus_fails_FlushCommands_deletes_no_command()
{
// Arrange
var serializer = new JsonMessageSerializer();
var processManager = new FakeProcessManager();
var random = new Random();
var commands = new List<PendingCommand>(
from command in new[]
{
new FakeCommand { Int32Value = random.Next(), StringValue = Guid.NewGuid().ToString() },
new FakeCommand { Int32Value = random.Next(), StringValue = Guid.NewGuid().ToString() },
new FakeCommand { Int32Value = random.Next(), StringValue = Guid.NewGuid().ToString() },
}
let envelope = new Envelope(command)
select PendingCommand.FromEnvelope(processManager, envelope, serializer));
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
db.PendingCommands.AddRange(commands);
await db.SaveChangesAsync();
}
IMessageBus messageBus = Mock.Of<IMessageBus>();
var exception = new InvalidOperationException();
Mock.Get(messageBus)
.Setup(x => x.Send(It.IsAny<IEnumerable<Envelope>>(), It.IsAny<CancellationToken>()))
.ThrowsAsync(exception);
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
messageBus,
Mock.Of<IScheduledMessageBus>());
// Act
Func<Task> action = () => sut.FlushCommands(processManager.Id, CancellationToken.None);
// Assert
action.Should().Throw<InvalidOperationException>().Which.Should().BeSameAs(exception);
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
IQueryable<PendingCommand> query = from c in db.PendingCommands
where c.ProcessManagerId == processManager.Id
select c;
List<PendingCommand> actual = await query.ToListAsync();
actual.Should().BeEquivalentTo(commands, opts => opts.RespectingRuntimeTypes());
}
}
[TestMethod]
public async Task given_no_command_FlushCommands_does_not_try_to_send()
{
// Arrange
IMessageBus messageBus = Mock.Of<IMessageBus>();
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
new JsonMessageSerializer(),
messageBus,
Mock.Of<IScheduledMessageBus>());
var processManagerId = Guid.NewGuid();
// Act
await sut.FlushCommands(processManagerId, CancellationToken.None);
// Assert
Mock.Get(messageBus).Verify(
x =>
x.Send(
It.IsAny<IEnumerable<Envelope>>(),
It.IsAny<CancellationToken>()),
Times.Never());
}
[TestMethod]
public async Task FlushCommands_absorbs_exception_caused_by_that_some_pending_command_already_deleted_since_loaded()
{
// Arrange
var messageBus = new CompletableMessageBus();
var serializer = new JsonMessageSerializer();
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
messageBus,
Mock.Of<IScheduledMessageBus>());
var processManager = new FakeProcessManager();
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
db.PendingCommands.AddRange(
new[]
{
new FakeCommand(),
new FakeCommand(),
new FakeCommand(),
}
.Select(c => new Envelope(c))
.Select(e => PendingCommand.FromEnvelope(processManager, e, serializer)));
await db.SaveChangesAsync();
}
// Act
Func<Task> action = async () =>
{
Task flushTask = sut.FlushCommands(processManager.Id, CancellationToken.None);
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
List<PendingCommand> pendingCommands = await db
.PendingCommands
.Where(c => c.ProcessManagerId == processManager.Id)
.OrderByDescending(c => c.Id)
.Take(1)
.ToListAsync();
db.PendingCommands.RemoveRange(pendingCommands);
await db.SaveChangesAsync();
}
messageBus.Complete();
await flushTask;
};
// Assert
action.Should().NotThrow();
}
[TestMethod]
public async Task FlushCommands_deletes_all_scheduled_commands_associated_with_specified_process_manager()
{
// Arrange
var serializer = new JsonMessageSerializer();
var processManager = new FakeProcessManager();
var noiseProcessManager = new FakeProcessManager();
const int noiseCommandCount = 3;
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
var commands = new List<PendingScheduledCommand>(
from command in Enumerable.Repeat(new FakeCommand(), 3)
let scheduledEnvelope = new ScheduledEnvelope(new Envelope(command), DateTime.UtcNow)
select PendingScheduledCommand.FromScheduledEnvelope(processManager, scheduledEnvelope, serializer));
commands.AddRange(
from command in Enumerable.Repeat(new FakeCommand(), noiseCommandCount)
let scheduledEnvelope = new ScheduledEnvelope(new Envelope(command), DateTime.UtcNow)
select PendingScheduledCommand.FromScheduledEnvelope(noiseProcessManager, scheduledEnvelope, serializer));
var random = new Random();
db.PendingScheduledCommands.AddRange(
from command in commands
orderby random.Next()
select command);
await db.SaveChangesAsync();
}
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
Mock.Of<IScheduledMessageBus>());
// Act
await sut.FlushCommands(processManager.Id, CancellationToken.None);
// Assert
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
(await db.PendingScheduledCommands.AnyAsync(c => c.ProcessManagerId == processManager.Id)).Should().BeFalse();
(await db.PendingScheduledCommands.CountAsync(c => c.ProcessManagerId == noiseProcessManager.Id)).Should().Be(noiseCommandCount);
}
}
[TestMethod]
public async Task FlushCommands_sends_all_scheduled_commands_associated_with_specified_process_manager_sequentially()
{
// Arrange
var serializer = new JsonMessageSerializer();
var processManager = new FakeProcessManager();
var noiseProcessManager = new FakeProcessManager();
var random = new Random();
var fixture = new Fixture();
var scheduledEnvelopes = new List<ScheduledEnvelope>(
from command in new[]
{
new FakeCommand { Int32Value = random.Next(), StringValue = fixture.Create<string>() },
new FakeCommand { Int32Value = random.Next(), StringValue = fixture.Create<string>() },
new FakeCommand { Int32Value = random.Next(), StringValue = fixture.Create<string>() },
}
let envelope = new Envelope(
Guid.NewGuid(),
command,
operationId: Guid.NewGuid().ToString(),
correlationId: Guid.NewGuid(),
contributor: Guid.NewGuid().ToString())
select new ScheduledEnvelope(envelope, DateTime.UtcNow.AddTicks(random.Next())));
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
db.PendingScheduledCommands.AddRange(
from scheduledEnvelope in scheduledEnvelopes
select PendingScheduledCommand.FromScheduledEnvelope(processManager, scheduledEnvelope, serializer));
db.PendingScheduledCommands.AddRange(
from scheduledEnvelope in new[]
{
new ScheduledEnvelope(new Envelope(new object()), DateTime.UtcNow),
new ScheduledEnvelope(new Envelope(new object()), DateTime.UtcNow),
new ScheduledEnvelope(new Envelope(new object()), DateTime.UtcNow),
}
select PendingScheduledCommand.FromScheduledEnvelope(noiseProcessManager, scheduledEnvelope, serializer));
await db.SaveChangesAsync();
}
var scheduledMessageBus = new ScheduledMessageBus();
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
scheduledMessageBus);
// Act
await sut.FlushCommands(processManager.Id, CancellationToken.None);
// Assert
scheduledMessageBus.Sent.Should().BeEquivalentTo(scheduledEnvelopes, opts => opts.WithStrictOrdering().RespectingRuntimeTypes());
}
[TestMethod]
public async Task given_scheduled_message_bus_fails_FlushCommands_deletes_no_scheduled_command()
{
// Arrange
var serializer = new JsonMessageSerializer();
var processManager = new FakeProcessManager();
var random = new Random();
var scheduledCommands = new List<PendingScheduledCommand>(
from command in new[]
{
new FakeCommand { Int32Value = random.Next(), StringValue = Guid.NewGuid().ToString() },
new FakeCommand { Int32Value = random.Next(), StringValue = Guid.NewGuid().ToString() },
new FakeCommand { Int32Value = random.Next(), StringValue = Guid.NewGuid().ToString() },
}
let envelope = new Envelope(command)
let scheduledEnvelope = new ScheduledEnvelope(envelope, DateTime.UtcNow.AddTicks(random.Next()))
select PendingScheduledCommand.FromScheduledEnvelope(processManager, scheduledEnvelope, serializer));
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
db.PendingScheduledCommands.AddRange(scheduledCommands);
await db.SaveChangesAsync();
}
Guid poisonedMessageId = (from c in scheduledCommands
orderby c.GetHashCode()
select c.MessageId).First();
IScheduledMessageBus scheduledMessageBus = Mock.Of<IScheduledMessageBus>();
var exception = new InvalidOperationException();
Mock.Get(scheduledMessageBus)
.Setup(x => x.Send(It.Is<ScheduledEnvelope>(p => p.Envelope.MessageId == poisonedMessageId), CancellationToken.None))
.ThrowsAsync(exception);
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
scheduledMessageBus);
// Act
Func<Task> action = () => sut.FlushCommands(processManager.Id, CancellationToken.None);
// Assert
action.Should().Throw<InvalidOperationException>().Which.Should().BeSameAs(exception);
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
IQueryable<PendingScheduledCommand> query = from c in db.PendingScheduledCommands
where c.ProcessManagerId == processManager.Id
select c;
List<PendingScheduledCommand> actual = await query.ToListAsync();
actual.Should().BeEquivalentTo(scheduledCommands, opts => opts.RespectingRuntimeTypes());
}
}
[TestMethod]
public async Task FlushCommands_absorbs_exception_caused_by_that_some_pending_scheduled_command_already_deleted_since_loaded()
{
// Arrange
var scheduledMessageBus = new CompletableScheduledMessageBus();
var serializer = new JsonMessageSerializer();
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
scheduledMessageBus);
var processManager = new FakeProcessManager();
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
db.PendingScheduledCommands.AddRange(
from command in new[]
{
new FakeCommand(),
new FakeCommand(),
new FakeCommand(),
}
let envelope = new Envelope(command)
let scheduledEnvelope = new ScheduledEnvelope(envelope, DateTime.UtcNow)
select PendingScheduledCommand.FromScheduledEnvelope(processManager, scheduledEnvelope, serializer));
await db.SaveChangesAsync();
}
// Act
Func<Task> action = async () =>
{
Task flushTask = sut.FlushCommands(processManager.Id, CancellationToken.None);
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
List<PendingScheduledCommand> pendingScheduledCommands = await db
.PendingScheduledCommands
.Where(c => c.ProcessManagerId == processManager.Id)
.OrderByDescending(c => c.Id)
.Take(1)
.ToListAsync();
db.PendingScheduledCommands.RemoveRange(pendingScheduledCommands);
await db.SaveChangesAsync();
}
scheduledMessageBus.Complete();
await flushTask;
};
// Assert
action.Should().NotThrow();
}
[TestMethod]
public async Task EnqueueAll_publishes_all_pending_commands_asynchronously()
{
// Arrange
var serializer = new JsonMessageSerializer();
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
for (int i = 0; i < 3; i++)
{
var processManager = new FakeProcessManager();
db.PendingCommands.AddRange(from command in Enumerable.Repeat(new FakeCommand(), 3)
let envelope = new Envelope(command)
select PendingCommand.FromEnvelope(processManager, envelope, serializer));
}
await db.SaveChangesAsync();
}
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
Mock.Of<IScheduledMessageBus>());
// Act
sut.EnqueueAll(CancellationToken.None);
// Assert
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
int maximumRetryCount = 5;
var retryPolicy = new RetryPolicy<bool>(
maximumRetryCount,
new DelegatingTransientFaultDetectionStrategy<bool>(any => any == true),
new ConstantRetryIntervalStrategy(TimeSpan.FromSeconds(1.0)));
(await retryPolicy.Run(db.PendingCommands.AnyAsync, CancellationToken.None)).Should().BeFalse();
}
}
[TestMethod]
public async Task EnqueueAll_publishes_all_pending_scheduled_commands_asynchronously()
{
// Arrange
var serializer = new JsonMessageSerializer();
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
for (int i = 0; i < 3; i++)
{
var processManager = new FakeProcessManager();
db.PendingScheduledCommands.AddRange(from command in Enumerable.Repeat(new FakeCommand(), 3)
let envelope = new Envelope(command)
let scheduledEnvelope = new ScheduledEnvelope(envelope, DateTime.UtcNow)
select PendingScheduledCommand.FromScheduledEnvelope(processManager, scheduledEnvelope, serializer));
}
await db.SaveChangesAsync();
}
var sut = new SqlCommandPublisher(
() => new ProcessManagerDbContext(_dbContextOptions),
serializer,
Mock.Of<IMessageBus>(),
Mock.Of<IScheduledMessageBus>());
// Act
sut.EnqueueAll(CancellationToken.None);
// Assert
using (var db = new ProcessManagerDbContext(_dbContextOptions))
{
int maximumRetryCount = 5;
var retryPolicy = new RetryPolicy<bool>(
maximumRetryCount,
new DelegatingTransientFaultDetectionStrategy<bool>(any => any == true),
new ConstantRetryIntervalStrategy(TimeSpan.FromSeconds(1.0)));
(await retryPolicy.Run(db.PendingScheduledCommands.AnyAsync, CancellationToken.None)).Should().BeFalse();
}
}
private class MessageBus : IMessageBus
{
private readonly ConcurrentQueue<Envelope> _sent = new ConcurrentQueue<Envelope>();
public IReadOnlyCollection<Envelope> Sent => _sent;
public Task Send(Envelope envelope, CancellationToken cancellationToken)
{
_sent.Enqueue(envelope);
return Task.CompletedTask;
}
public Task Send(IEnumerable<Envelope> envelopes, CancellationToken cancellationToken)
{
foreach (Envelope envelope in envelopes)
{
_sent.Enqueue(envelope);
}
return Task.CompletedTask;
}
}
private class CompletableMessageBus : IMessageBus
{
private readonly TaskCompletionSource<bool> _completionSource = new TaskCompletionSource<bool>();
public void Complete() => _completionSource.SetResult(true);
public Task Send(Envelope envelope, CancellationToken cancellationToken) => _completionSource.Task;
public Task Send(IEnumerable<Envelope> envelopes, CancellationToken cancellationToken) => _completionSource.Task;
}
private class ScheduledMessageBus : IScheduledMessageBus
{
private readonly ConcurrentQueue<ScheduledEnvelope> _sent = new ConcurrentQueue<ScheduledEnvelope>();
public IReadOnlyCollection<ScheduledEnvelope> Sent => _sent;
public Task Send(ScheduledEnvelope envelope, CancellationToken cancellationToken)
{
_sent.Enqueue(envelope);
return Task.CompletedTask;
}
}
private class CompletableScheduledMessageBus : IScheduledMessageBus
{
private readonly TaskCompletionSource<bool> _completionSource = new TaskCompletionSource<bool>();
public void Complete() => _completionSource.SetResult(true);
public Task Send(ScheduledEnvelope envelope, CancellationToken cancellationToken) => _completionSource.Task;
}
}
}
| 42.870192 | 158 | 0.562334 | [
"MIT"
] | Reacture/Khala.Processes | source/Khala.Processes.Tests.Core/Processes/Sql/SqlCommandPublisher_specs.cs | 26,753 | C# |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.