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.Text.RegularExpressions; using System.Diagnostics; using System; using System.Drawing.Drawing2D; using System.Windows.Forms; using System.Collections; using System.Drawing; using Microsoft.VisualBasic; using System.Data.SqlClient; using System.Data; using System.Collections.Generic; using WeifenLuo.WinFormsUI; using Microsoft.Win32; using WeifenLuo; namespace SoftLogik.Win { namespace UI { [global::Microsoft.VisualBasic.CompilerServices.DesignerGenerated()]public partial class MasterForm : SetupForm { //Form overrides dispose to clean up the component list. [System.Diagnostics.DebuggerNonUserCode()]protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } //Required by the Windows Form Designer private System.ComponentModel.Container components = null; //NOTE: The following procedure is required by the Windows Form Designer //It can be modified using the Windows Form Designer. //Do not modify it using the code editor. [System.Diagnostics.DebuggerStepThrough()]private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MasterForm)); this.gbxOutline = new System.Windows.Forms.GroupBox(); this.TypeIDField = new System.Windows.Forms.TextBox(); this.NoteLabel = new System.Windows.Forms.Label(); this.NoteTextField = new System.Windows.Forms.TextBox(); this.NameTextField = new System.Windows.Forms.TextBox(); this.NameLabel = new System.Windows.Forms.Label(); this.tbcMain.SuspendLayout(); this.tabGeneral.SuspendLayout(); ((System.ComponentModel.ISupportInitialize) this.ErrorNotify).BeginInit(); this.gbxOutline.SuspendLayout(); this.SuspendLayout(); // //tvwName // this.tvwName.LineColor = System.Drawing.Color.Black; this.tvwName.TabIndex = 3; // //tbcMain // this.tbcMain.TabIndex = 5; // //tabGeneral // this.tabGeneral.Controls.Add(this.gbxOutline); this.tabGeneral.TabIndex = 6; // //IconSource // this.IconSource.ImageStream = (System.Windows.Forms.ImageListStreamer) (resources.GetObject("IconSource.ImageStream")); this.IconSource.Images.SetKeyName(0, "DOC.png"); // //gbxOutline // this.gbxOutline.Controls.Add(this.TypeIDField); this.gbxOutline.Controls.Add(this.NoteLabel); this.gbxOutline.Controls.Add(this.NoteTextField); this.gbxOutline.Controls.Add(this.NameTextField); this.gbxOutline.Controls.Add(this.NameLabel); this.gbxOutline.Dock = System.Windows.Forms.DockStyle.Fill; this.gbxOutline.Location = new System.Drawing.Point(3, 3); this.gbxOutline.Name = "gbxOutline"; this.gbxOutline.Size = new System.Drawing.Size(503, 389); this.gbxOutline.TabIndex = 0; this.gbxOutline.TabStop = false; // //TypeIDField // this.TypeIDField.Location = new System.Drawing.Point(90, 298); this.TypeIDField.Name = "TypeIDField"; this.TypeIDField.Size = new System.Drawing.Size(100, 20); this.TypeIDField.TabIndex = 2; this.TypeIDField.Tag = "TypeID"; this.TypeIDField.Visible = false; // //NoteLabel // this.NoteLabel.AutoSize = true; this.NoteLabel.Location = new System.Drawing.Point(33, 95); this.NoteLabel.Name = "NoteLabel"; this.NoteLabel.Size = new System.Drawing.Size(33, 13); this.NoteLabel.TabIndex = 0; this.NoteLabel.Text = "N&ote:"; // //NoteTextField // this.NoteTextField.Location = new System.Drawing.Point(90, 92); this.NoteTextField.Multiline = true; this.NoteTextField.Name = "NoteTextField"; this.NoteTextField.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.NoteTextField.Size = new System.Drawing.Size(300, 200); this.NoteTextField.TabIndex = 1; this.NoteTextField.Tag = "Note"; // //NameTextField // this.NameTextField.Location = new System.Drawing.Point(90, 66); this.NameTextField.Name = "NameTextField"; this.NameTextField.Size = new System.Drawing.Size(300, 20); this.NameTextField.TabIndex = 1; this.NameTextField.Tag = "Name"; // //NameLabel // this.NameLabel.AutoSize = true; this.NameLabel.Location = new System.Drawing.Point(33, 69); this.NameLabel.Name = "NameLabel"; this.NameLabel.Size = new System.Drawing.Size(38, 13); this.NameLabel.TabIndex = 0; this.NameLabel.Text = "&Name:"; // //MasterForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6.0, 13.0); this.ClientSize = new System.Drawing.Size(778, 443); this.Icon = (System.Drawing.Icon) (resources.GetObject("$this.Icon")); this.Name = "MasterForm"; this.tbcMain.ResumeLayout(false); this.tabGeneral.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize) this.ErrorNotify).EndInit(); this.gbxOutline.ResumeLayout(false); this.gbxOutline.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } internal System.Windows.Forms.GroupBox gbxOutline; protected internal System.Windows.Forms.Label NoteLabel; protected internal System.Windows.Forms.TextBox NoteTextField; protected internal System.Windows.Forms.TextBox NameTextField; protected internal System.Windows.Forms.Label NameLabel; protected internal System.Windows.Forms.TextBox TypeIDField; } } }
34.716981
134
0.710507
[ "MIT" ]
okyereadugyamfi/softlogik
SPCode/CS/UI/Form/MasterForm.Designer.cs
5,520
C#
using MARC.HI.EHRS.SVC.Auditing.Data; using OpenIZ.Core.Interfaces; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Linq.Expressions; using MARC.HI.EHRS.SVC.Core; using MARC.HI.EHRS.SVC.Core.Services; using OpenIZ.Core.Security; using MARC.HI.EHRS.SVC.Core.Data; namespace OpenIZ.Core.Services.Impl { /// <summary> /// Represents an audit repository which stores and queries audit data. /// </summary> public class LocalAuditRepository : IAuditRepositoryService, IAuditEventSource { /// <summary> /// Fired when data has been created /// </summary> public event EventHandler<AuditDataEventArgs> DataCreated; /// <summary> /// Fired when data has been disclosed /// </summary> public event EventHandler<AuditDataDisclosureEventArgs> DataDisclosed; /// <summary> /// Fired when data has been obsoleted /// </summary> public event EventHandler<AuditDataEventArgs> DataObsoleted; /// <summary> /// Fired when data has been updated /// </summary> public event EventHandler<AuditDataEventArgs> DataUpdated; /// <summary> /// Find the specified data /// </summary> /// <param name="query"></param> /// <returns></returns> public IEnumerable<AuditData> Find(Expression<Func<AuditData, bool>> query) { var tr = 0; return this.Find(query, 0, null, out tr); } /// <summary> /// Find with query controls /// </summary> public IEnumerable<AuditData> Find(Expression<Func<AuditData, bool>> query, int offset, int? count, out int totalResults) { var service = ApplicationContext.Current.GetService<IDataPersistenceService<AuditData>>(); if (service == null) throw new InvalidOperationException("Cannot find the data persistence service for audits"); var results = service.Query(query, offset, count, AuthenticationContext.Current.Principal, out totalResults); this?.DataDisclosed(this, new AuditDataDisclosureEventArgs(query.ToString(), results)); return results; } /// <summary> /// Gets the specified object /// </summary> public AuditData Get(Guid key) { return this.Get(key, Guid.Empty); } /// <summary> /// Gets the specified correlation key /// </summary> public AuditData Get(object correlationKey) { return this.Get((Guid)correlationKey, Guid.Empty); } /// <summary> /// Get the specified audit by key /// </summary> public AuditData Get(Guid key, Guid versionKey) { var service = ApplicationContext.Current.GetService<IDataPersistenceService<AuditData>>(); if (service == null) throw new InvalidOperationException("Cannot find the data persistence service for audits"); var result = service.Get(new MARC.HI.EHRS.SVC.Core.Data.Identifier<Guid>(key, versionKey), AuthenticationContext.Current.Principal, false); this?.DataDisclosed(this, new AuditDataDisclosureEventArgs(key.ToString(), new List<Object>() { result })); return result; } /// <summary> /// Insert the specified data /// </summary> public AuditData Insert(AuditData audit) { var service = ApplicationContext.Current.GetService<IDataPersistenceService<AuditData>>(); if (service == null) throw new InvalidOperationException("Cannot find the data persistence service for audits"); var result = service.Insert(audit, AuthenticationContext.Current.Principal, TransactionMode.Commit); this?.DataCreated(this, new AuditDataEventArgs(audit)); return result; } /// <summary> /// Obsolete the specified data /// </summary> public AuditData Obsolete(Guid key) { var service = ApplicationContext.Current.GetService<IDataPersistenceService<AuditData>>(); if (service == null) throw new InvalidOperationException("Cannot find the data persistence service for audits"); var result = service.Obsolete(new AuditData() { CorrelationToken = key }, AuthenticationContext.Current.Principal, TransactionMode.Commit); this?.DataObsoleted(this, new AuditDataEventArgs(key)); return result; } /// <summary> /// Save (create or update) the specified object /// </summary> public AuditData Save(AuditData data) { var service = ApplicationContext.Current.GetService<IDataPersistenceService<AuditData>>(); if (service == null) throw new InvalidOperationException("Cannot find the data persistence service for audits"); var existing = service.Get(new Identifier<Guid>(data.CorrelationToken, Guid.Empty), AuthenticationContext.Current.Principal, false); if (existing == null) { data = service.Update(data, AuthenticationContext.Current.Principal, TransactionMode.Commit); this?.DataUpdated(this, new AuditDataEventArgs(data)); } else { data = service.Insert(data, AuthenticationContext.Current.Principal, TransactionMode.Commit); this?.DataCreated(this, new AuditDataEventArgs(data)); } return data; } } }
40.624113
151
0.620461
[ "Apache-2.0" ]
santedb/openiz
OpenIZ.Core/Services/Impl/LocalAuditRepository.cs
5,730
C#
using System.Collections.Generic; namespace NextcloudClient.Types { /// <summary> /// ownCloud App information. /// </summary> public class AppInfo { /// <summary> /// Gets or sets the identifier. /// </summary> /// <value>The identifier.</value> public string Id { get; set; } /// <summary> /// Gets or sets the name. /// </summary> /// <value>The name.</value> public string Name { get; set; } /// <summary> /// Gets or sets the description. /// </summary> /// <value>The description.</value> public string Description { get; set; } /// <summary> /// Gets or sets the licence. /// </summary> /// <value>The licence.</value> public string Licence { get; set; } /// <summary> /// Gets or sets the author. /// </summary> /// <value>The author.</value> public string Author { get; set; } /// <summary> /// Gets or sets the require minimum. /// </summary> /// <value>The require minimum.</value> public string RequireMin { get; set; } /// <summary> /// Gets or sets a value indicating whether this <see cref="AppInfo"/> is shipped. /// </summary> /// <value><c>true</c> if shipped; otherwise, <c>false</c>.</value> public bool Shipped { get; set; } /// <summary> /// Gets or sets a value indicating whether this <see cref="AppInfo"/> is standalone. /// </summary> /// <value><c>true</c> if standalone; otherwise, <c>false</c>.</value> public bool Standalone { get; set; } /// <summary> /// Gets or sets a value indicating whether this <see cref="AppInfo"/> default enable. /// </summary> /// <value><c>true</c> if default enable; otherwise, <c>false</c>.</value> public bool DefaultEnable { get; set; } /// <summary> /// Gets or sets the types. /// </summary> /// <value>The types.</value> public List<string> Types { get; set; } /// <summary> /// Gets or sets the remote. /// </summary> /// <value>The remote.</value> public Dictionary<string, string> Remote { get; set; } /// <summary> /// Gets or sets the documentation. /// </summary> /// <value>The documentation.</value> public Dictionary<string, string> Documentation { get; set; } /// <summary> /// Gets or sets the info. /// </summary> /// <value>The info.</value> public Dictionary<string, string> Info { get; set; } /// <summary> /// Gets or sets the public. /// </summary> /// <value>The public.</value> public Dictionary<string, string> Public { get; set; } } }
29.771084
88
0.608256
[ "MPL-2.0", "MPL-2.0-no-copyleft-exception" ]
Fangrn/nextcloud-windows-universal
NextcloudClient/Types/AppInfo.cs
2,473
C#
using LR.WebUI.Infrastructure; using SX.WebCore.MvcControllers; namespace LR.WebUI.Areas.Admin.Controllers { public sealed class UsersController : SxUsersController { } }
19.3
59
0.725389
[ "MIT" ]
simlex-titul2005/leavingrussia.ru
LR.WebUI/Areas/Admin/Controllers/UsersController.cs
195
C#
// Decompiled with JetBrains decompiler // Type: RetroAesthetics.SceneField // Assembly: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null // MVID: 5F8D6662-C74B-4D30-A4EA-D74F7A9A95B9 // Assembly location: C:\YandereSimulator\YandereSimulator_Data\Managed\Assembly-CSharp.dll using System; using UnityEngine; namespace RetroAesthetics { [Serializable] public class SceneField { [SerializeField] private UnityEngine.Object m_SceneAsset; [SerializeField] private string m_SceneName = ""; public string SceneName => this.m_SceneName; public static implicit operator string(SceneField sceneField) => sceneField.SceneName; } }
27.24
91
0.76652
[ "Unlicense" ]
JaydenB14/YandereSimulatorDecompiled
Assembly-CSharp/RetroAesthetics/SceneField.cs
683
C#
namespace RollbarDotNet.Builder { using Payloads; using Exception = System.Exception; public interface IExceptionBuilder { void Execute(Payload payload, Exception exception); } }
20.8
59
0.701923
[ "MIT" ]
ECrownofFire/RollbarDotNet
RollbarDotNet/Builder/IExceptionBuilder.cs
210
C#
// Copyright (c) Josef Pihrt. All rights reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; namespace Roslynator.CSharp.Refactorings.Test { internal class WrapInTryCatchRefactoring { public void Method() { MethodThatCanThrowException(); MethodThatCanThrowException2(); switch (0) { case 0: MethodThatCanThrowException(); MethodThatCanThrowException2(); break; } } private void MethodThatCanThrowException() { } private void MethodThatCanThrowException2() { } private void MethodThatCanThrowException3() { } private void MethodThatCanThrowException4() { } } }
17.240741
160
0.55102
[ "Apache-2.0" ]
TechnoridersForks/Roslynator
source/Test/RefactoringsTest/WrapInTryCatchRefactoring.cs
933
C#
using System; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using DISPPARAMS = System.Runtime.InteropServices.ComTypes.DISPPARAMS; using EXCEPINFO = System.Runtime.InteropServices.ComTypes.EXCEPINFO; using FUNCDESC = System.Runtime.InteropServices.ComTypes.FUNCDESC; using IDLDESC = System.Runtime.InteropServices.ComTypes.IDLDESC; using INVOKEKIND = System.Runtime.InteropServices.ComTypes.INVOKEKIND; using TYPEDESC = System.Runtime.InteropServices.ComTypes.TYPEDESC; using TYPEKIND = System.Runtime.InteropServices.ComTypes.TYPEKIND; using VARDESC = System.Runtime.InteropServices.ComTypes.VARDESC; namespace Vanara.PInvoke { public static partial class OleAut32 { /// <summary>Returns error information.</summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-icreateerrorinfo [PInvokeData("oaidl.h", MSDNShortId = "2e7c5ad5-9018-413e-8826-ef752ebf302c")] [ComImport, Guid("22F03340-547D-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateErrorInfo { /// <summary>Sets the globally unique identifier (GUID) of the interface that defined the error.</summary> /// <param name="rguid"> /// The GUID of the interface that defined the error, or GUID_NULL if the error was defined by the operating system. /// </param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// This method sets the GUID of the interface that defined the error. If the error was defined by the system, set /// <c>ICreateErrorInfo::SetGUID</c> to GUID_NULL. /// </para> /// <para> /// This GUID does not necessarily represent the source of the error; however, the source is the class or application that /// raised the error. Using the GUID, applications can handle errors in an interface, independent of the class that implements /// the interface. /// </para> /// <para>Use of this function is demonstrated in the file Main.cpp of the COM Fundamentals Hello sample.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreateerrorinfo-setguid HRESULT SetGUID(REFGUID rguid); [PreserveSig] HRESULT SetGUID(in Guid rguid); /// <summary>Sets the language-dependent programmatic identifier (ProgID) for the class or application that raised the error.</summary> /// <param name="szSource">A ProgID in the form progname.objectname.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// This method should be used to identify the class or application that is the source of the error. The language for the /// returned ProgID depends on the locale identifier (LCID) that was passed to the method at the time of invocation. /// </para> /// <para>Use of this function is demonstrated in the file Main.cpp of the COM Fundamentals Hello sample.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreateerrorinfo-setsource HRESULT SetSource(LPOLESTR szSource); [PreserveSig] HRESULT SetSource([MarshalAs(UnmanagedType.LPWStr)] string szSource); /// <summary>Sets the textual description of the error.</summary> /// <param name="szDescription">A brief description of the error.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// The text should be supplied in the language specified by the locale ID (LCID) that was passed to the method raising the /// error. For more information, see LCID Attribute in Type Libraries and the Object Description Language. /// </para> /// <para>Use of this function is demonstrated in the file Main.cpp of the COM Fundamentals Hello sample.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreateerrorinfo-setdescription HRESULT SetDescription(// // LPOLESTR szDescription); [PreserveSig] HRESULT SetDescription([MarshalAs(UnmanagedType.LPWStr)] string szDescription); /// <summary>Sets the path of the Help file that describes the error.</summary> /// <param name="szHelpFile">The fully qualified path of the Help file that describes the error.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// This method sets the fully qualified path of the Help file that describes the current error. Use /// ICreateErrorInfo::SetHelpContext to set the Help context ID for the error in the Help file. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreateerrorinfo-sethelpfile HRESULT SetHelpFile(LPOLESTR szHelpFile); [PreserveSig] HRESULT SetHelpFile([MarshalAs(UnmanagedType.LPWStr)] string szHelpFile); /// <summary>Sets the Help context identifier (ID) for the error.</summary> /// <param name="dwHelpContext">The Help context ID for the error.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks>This method sets the Help context ID for the error. To establish the Help file to which it applies, use ICreateErrorInfo::SetHelpFile.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreateerrorinfo-sethelpcontext HRESULT SetHelpContext(// // DWORD dwHelpContext); [PreserveSig] HRESULT SetHelpContext(uint dwHelpContext); } /// <summary>Provides the tools for creating and administering the type information defined through the type description.</summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-icreatetypeinfo [PInvokeData("oaidl.h", MSDNShortId = "c8bbb677-2666-4900-8fb9-788742eef656")] [ComImport, Guid("00020405-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateTypeInfo { /// <summary>Sets the globally unique identifier (GUID) associated with the type description.</summary> /// <param name="guid">The globally unique ID to be associated with the type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// For an interface, this is an interface ID (IID); for a coclass, it is a class ID (CLSID). For information on GUIDs, see Type /// Libraries and the Object Description Language. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setguid HRESULT SetGuid(REFGUID guid); [PreserveSig] HRESULT SetGuid(in Guid guid); /// <summary>Sets type flags of the type description being created.</summary> /// <param name="uTypeFlags">The settings for the type flags. For details, see TYPEFLAGS.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-settypeflags HRESULT SetTypeFlags(UINT uTypeFlags); [PreserveSig] HRESULT SetTypeFlags(uint uTypeFlags); /// <summary>Sets the documentation string displayed by type browsers.</summary> /// <param name="pStrDoc">A brief description of the type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setdocstring HRESULT SetDocString(LPOLESTR pStrDoc); [PreserveSig] HRESULT SetDocString([MarshalAs(UnmanagedType.LPWStr)] string pStrDoc); /// <summary>Sets the Help context ID of the type information.</summary> /// <param name="dwHelpContext">A handle to the Help context.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-sethelpcontext HRESULT SetHelpContext(// // DWORD dwHelpContext); [PreserveSig] HRESULT SetHelpContext(uint dwHelpContext); /// <summary>Sets the major and minor version number of the type information.</summary> /// <param name="wMajorVerNum">The major version number.</param> /// <param name="wMinorVerNum">The minor version number.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setversion HRESULT SetVersion(WORD // wMajorVerNum, WORD wMinorVerNum); [PreserveSig] HRESULT SetVersion(ushort wMajorVerNum, ushort wMinorVerNum); /// <summary>Adds a type description to those referenced by the type description being created.</summary> /// <param name="pTInfo">The type description to be referenced.</param> /// <param name="phRefType">The handle that this type description associates with the referenced type information.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The second parameter returns a pointer to the handle of the added type information. If <c>AddRefTypeInfo</c> has been called /// previously for the same type information, the index that was returned by the previous call is returned in phRefType. If the /// referenced type description is in the type library being created, its type information can be obtained by calling /// IUnknown::QueryInterface(IID_ITypeInfo, ...) on the ICreateTypeInfo interface of that type description. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addreftypeinfo HRESULT AddRefTypeInfo(// // ITypeInfo *pTInfo, HREFTYPE *phRefType); [PreserveSig] HRESULT AddRefTypeInfo([In] ITypeInfo pTInfo, out uint phRefType); /// <summary>Adds a function description to the type description.</summary> /// <param name="index">The index of the new FUNCDESC in the type information.</param> /// <param name="pFuncDesc"> /// A FUNCDESC structure that describes the function. The <c>bstrIDLInfo</c> field in the FUNCDESC should be null. /// </param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// The index specifies the order of the functions within the type information. The first function has an index of zero. If an /// index is specified that exceeds one less than the number of functions in the type information, an error is returned. Calling /// this function does not pass ownership of the FUNCDESC structure to ICreateTypeInfo. Therefore, the caller must still /// de-allocate the FUNCDESC structure. /// </para> /// <para> /// The passed-in virtual function table (VTBL) field (oVft) of the FUNCDESC is ignored if the TYPEKIND is TKIND_MODULE or if /// oVft is -1 or 0. This attribute is set when ICreateTypeInfo::LayOut is called. The oVft value is used if the TYPEKIND is /// TKIND_DISPATCH and a dual interface or if the TYPEKIND is TKIND_INTERFACE. If the oVft is used, it must be a multiple of the /// sizeof(VOID *) on the machine, otherwise the function fails and E_INVALIDARG is returned as the HRESULT. /// </para> /// <para> /// The function <c>AddFuncDesc</c> uses the passed-in member identifier (memid) fields within each FUNCDESC for classes with /// TYPEKIND = TKIND_DISPATCH or TKIND_INTERFACE. If the member IDs are set to MEMBERID_NIL, <c>AddFuncDesc</c> assigns member /// IDs to the functions. Otherwise, the member ID fields within each FUNCDESC are ignored. /// </para> /// <para> /// Any HREFTYPE fields in the FUNCDESC structure must have been produced by the same instance of ITypeInfo for which /// <c>AddFuncDesc</c> is called. /// </para> /// <para>The get and put accessor functions for the same property must have the same dispatch identifier (DISPID).</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addfuncdesc HRESULT AddFuncDesc(UINT index, // FUNCDESC *pFuncDesc); [PreserveSig] HRESULT AddFuncDesc(uint index, in FUNCDESC pFuncDesc); /// <summary>Specifies an inherited interface, or an interface implemented by a component object class (coclass).</summary> /// <param name="index"> /// The index of the implementation class to be added. Specifies the order of the type relative to the other type. /// </param> /// <param name="hRefType">A handle to the referenced type description obtained from the AddRefType description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// To specify an inherited interface, use index = 0. For a dispinterface with Syntax 2, call /// <c>ICreateTypeInfo::AddImplType</c> twice, once with index = 0 for the inherited IDispatch and once with index = 1 for the /// interface that is being wrapped. For a dual interface, call <c>ICreateTypeInfo::AddImplType</c> with index = -1 for the /// TKIND_INTERFACE type information component of the dual interface. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addimpltype HRESULT AddImplType(UINT index, // HREFTYPE hRefType); [PreserveSig] HRESULT AddImplType(uint index, uint hRefType); /// <summary>Sets the attributes for an implemented or inherited interface of a type.</summary> /// <param name="index">The index of the interface for which to set type flags.</param> /// <param name="implTypeFlags">IMPLTYPE flags to be set.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setimpltypeflags HRESULT // SetImplTypeFlags(// UINT index, INT implTypeFlags); [PreserveSig] HRESULT SetImplTypeFlags(uint index, System.Runtime.InteropServices.ComTypes.IMPLTYPEFLAGS implTypeFlags); /// <summary>Specifies the data alignment for an item of TYPEKIND=TKIND_RECORD.</summary> /// <param name="cbAlignment"> /// Alignment method for the type. A value of 0 indicates alignment on the 64K boundary; 1 indicates no special alignment. For /// other values, n indicates alignment on byte n. /// </param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The alignment is the minimum of the natural alignment (for example, byte data on byte boundaries, word data on word /// boundaries, and so on), and the alignment denoted by cbAlignment. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setalignment HRESULT SetAlignment(WORD cbAlignment); [PreserveSig] HRESULT SetAlignment(ushort cbAlignment); /// <summary>Reserved for future use.</summary> /// <param name="pStrSchema">The schema.</param> [PreserveSig] HRESULT SetSchema([MarshalAs(UnmanagedType.LPWStr)] string pStrSchema); /// <summary>Adds a variable or data member description to the type description.</summary> /// <param name="index">The index of the variable or data member to be added to the type description.</param> /// <param name="pVarDesc">A pointer to the variable or data member description to be added.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// The index specifies the order of the variables. The first variable has an index of zero. <c>ICreateTypeInfo::AddVarDesc</c> /// returns an error if the specified index is greater than the number of variables currently in the type information. Calling /// this function does not pass ownership of the VARDESC structure to ICreateTypeInfo. The instance field (oInst) of the VARDESC /// structure is ignored. This attribute is set only when ICreateTypeInfo::LayOut is called. Also, the member ID fields within /// the VARDESCs are ignored unless the TYPEKIND of the class is TKIND_DISPATCH. /// </para> /// <para> /// Any HREFTYPE fields in the VARDESC structure must have been produced by the same instance of ITypeInfo for which /// <c>AddVarDesc</c> is called. /// </para> /// <para><c>AddVarDesc</c> ignores the contents of the idldesc field of the ELEMDESC.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addvardesc HRESULT AddVarDesc(UINT index, // VARDESC *pVarDesc); [PreserveSig] HRESULT AddVarDesc(uint index, in VARDESC pVarDesc); /// <summary>Sets the name of a function and the names of its parameters to the specified names.</summary> /// <param name="index">The index of the function whose function name and parameter names are to be set.</param> /// <param name="rgszNames"> /// An array of pointers to names. The first element is the function name. Subsequent elements are names of parameters. /// </param> /// <param name="cNames">The number of elements in the rgszNames array.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> /// <remarks> /// This method must be used once for each property. The last parameter for put and putref accessor functions is unnamed. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setfuncandparamnames HRESULT // SetFuncAndParamNames(UINT index, LPOLESTR *rgszNames, UINT cNames); [PreserveSig] HRESULT SetFuncAndParamNames(uint index, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2, ArraySubType = UnmanagedType.LPWStr)] string[] rgszNames, uint cNames); /// <summary>Sets the name of a variable.</summary> /// <param name="index">The index of the variable.</param> /// <param name="szName">The name.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setvarname HRESULT SetVarName(UINT index, // LPOLESTR szName); [PreserveSig] HRESULT SetVarName(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szName); /// <summary>Sets the type description for which this type description is an alias, if TYPEKIND=TKIND_ALIAS.</summary> /// <param name="pTDescAlias">The type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks>To set the type for an alias, call <c>SetTypeDescAlias</c> for a type description whose TYPEKIND is TKIND_ALIAS.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-settypedescalias HRESULT // SetTypeDescAlias(// TYPEDESC *pTDescAlias); [PreserveSig] HRESULT SetTypeDescAlias(in TYPEDESC pTDescAlias); /// <summary>Associates a DLL entry point with the function that has the specified index.</summary> /// <param name="index">The index of the function.</param> /// <param name="szDllName">The name of the DLL that contains the entry point.</param> /// <param name="szProcName">The name of the entry point or an ordinal (if the high word is zero).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// If the high word of szProcName is zero, then the low word must contain the ordinal of the entry point; otherwise, szProcName /// points to the zero-terminated name of the entry point. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-definefuncasdllentry HRESULT // DefineFuncAsDllEntry(UINT index, LPOLESTR szDllName, LPOLESTR szProcName); [PreserveSig] HRESULT DefineFuncAsDllEntry(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szDllName, [MarshalAs(UnmanagedType.LPWStr)] string szProcName); /// <summary>Sets the documentation string for the function with the specified index.</summary> /// <param name="index">The index of the function.</param> /// <param name="szDocString">The documentation string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The documentation string is a brief description of the function intended for use by tools such as type browsers. /// <c>SetFuncDocString</c> only needs to be used once for each property, because all property accessor functions are identified /// by one name. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setfuncdocstring HRESULT // SetFuncDocString(// UINT index, LPOLESTR szDocString); [PreserveSig] HRESULT SetFuncDocString(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szDocString); /// <summary>Sets the documentation string for the variable with the specified index.</summary> /// <param name="index">The index of the variable.</param> /// <param name="szDocString">The documentation string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setvardocstring HRESULT SetVarDocString(// // UINT index, LPOLESTR szDocString); [PreserveSig] HRESULT SetVarDocString(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szDocString); /// <summary>Sets the Help context ID for the function with the specified index.</summary> /// <param name="index">The index of the function.</param> /// <param name="dwHelpContext">The Help context ID for the Help topic.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <c>SetFuncHelpContext</c> only needs to be set once for each property, because all property accessor functions are /// identified by one name. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setfunchelpcontext HRESULT // SetFuncHelpContext(UINT index, DWORD dwHelpContext); [PreserveSig] HRESULT SetFuncHelpContext(uint index, uint dwHelpContext); /// <summary>Sets the Help context ID for the variable with the specified index.</summary> /// <param name="index">The index of the variable.</param> /// <param name="dwHelpContext">The handle to the Help context ID for the Help topic on the variable.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setvarhelpcontext HRESULT // SetVarHelpContext(UINT index, DWORD dwHelpContext); [PreserveSig] HRESULT SetVarHelpContext(uint index, uint dwHelpContext); /// <summary>Sets the marshaling opcode string associated with the type description or the function.</summary> /// <param name="index"> /// The index of the member for which to set the opcode string. If index is –1, sets the opcode string for the type description. /// </param> /// <param name="bstrMops">The marshaling opcode string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setmops HRESULT SetMops(UINT index, BSTR bstrMops); [PreserveSig] HRESULT SetMops(uint index, [MarshalAs(UnmanagedType.BStr)] string bstrMops); /// <summary>Reserved for future use.</summary> /// <param name="pIdlDesc">The IDLDESC.</param> [PreserveSig] HRESULT SetTypeIdldesc(in IDLDESC pIdlDesc); /// <summary> /// Assigns VTBL offsets for virtual functions and instance offsets for per-instance data members, and creates the two type /// descriptions for dual interfaces. /// </summary> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_UNDEFINEDTYPE</term> /// <term>Bound to unrecognized type.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// <item> /// <term>TYPE_E_AMBIGUOUSNAME</term> /// <term>More than one item exists with this name.</term> /// </item> /// <item> /// <term>TYPE_E_SIZETOOBIG</term> /// <term>The type information is too long.</term> /// </item> /// <item> /// <term>TYPE_E_TYPEMISMATCH</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// <c>LayOut</c> also assigns member ID numbers to the functions and variables, unless the TYPEKIND of the class is /// TKIND_DISPATCH. Call <c>LayOut</c> after all members of the type information are defined, and before the type library is saved. /// </para> /// <para> /// Use ICreateTypeLib::SaveAllChanges to save the type information after calling <c>LayOut</c>. Other members of the /// ICreateTypeInfo interface should not be called after calling <c>LayOut</c>. /// </para> /// <para> /// <c>Note</c> Different implementations of ICreateTypeLib::SaveAllChanges or other interfaces that create type information are /// free to assign any member ID numbers, provided that all members (including inherited members), have unique IDs. For /// examples, see ICreateTypeInfo2. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-layout HRESULT LayOut(); [PreserveSig] HRESULT LayOut(); } /// <summary> /// <para> /// Provides the tools for creating and administering the type information defined through the type description. Derives from /// ICreateTypeInfo, and adds methods for deleting items that have been added through ICreateTypeInfo. /// </para> /// <para> /// The ICreateTypeInfo::LayOut method provides a way for the creator of the type information to check for any errors. A call to /// QueryInterface can be made to the ICreateTypeInfo instance at any time for its ITypeInfo interface. Calling any of the methods /// in the ITypeInfointerface that require layout information lays out the type information automatically. /// </para> /// </summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-icreatetypeinfo2 [PInvokeData("oaidl.h", MSDNShortId = "34dc6f52-6864-4edb-b22d-80eef05d4c8c")] [ComImport, Guid("0002040E-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateTypeInfo2 : ICreateTypeInfo { /// <summary>Sets the globally unique identifier (GUID) associated with the type description.</summary> /// <param name="guid">The globally unique ID to be associated with the type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// For an interface, this is an interface ID (IID); for a coclass, it is a class ID (CLSID). For information on GUIDs, see Type /// Libraries and the Object Description Language. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setguid HRESULT SetGuid(REFGUID guid); [PreserveSig] new HRESULT SetGuid(in Guid guid); /// <summary>Sets type flags of the type description being created.</summary> /// <param name="uTypeFlags">The settings for the type flags. For details, see TYPEFLAGS.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-settypeflags HRESULT SetTypeFlags(UINT uTypeFlags); [PreserveSig] new HRESULT SetTypeFlags(uint uTypeFlags); /// <summary>Sets the documentation string displayed by type browsers.</summary> /// <param name="pStrDoc">A brief description of the type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setdocstring HRESULT SetDocString(LPOLESTR pStrDoc); [PreserveSig] new HRESULT SetDocString([MarshalAs(UnmanagedType.LPWStr)] string pStrDoc); /// <summary>Sets the Help context ID of the type information.</summary> /// <param name="dwHelpContext">A handle to the Help context.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-sethelpcontext HRESULT SetHelpContext(// // DWORD dwHelpContext); [PreserveSig] new HRESULT SetHelpContext(uint dwHelpContext); /// <summary>Sets the major and minor version number of the type information.</summary> /// <param name="wMajorVerNum">The major version number.</param> /// <param name="wMinorVerNum">The minor version number.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setversion HRESULT SetVersion(WORD // wMajorVerNum, WORD wMinorVerNum); [PreserveSig] new HRESULT SetVersion(ushort wMajorVerNum, ushort wMinorVerNum); /// <summary>Adds a type description to those referenced by the type description being created.</summary> /// <param name="pTInfo">The type description to be referenced.</param> /// <param name="phRefType">The handle that this type description associates with the referenced type information.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The second parameter returns a pointer to the handle of the added type information. If <c>AddRefTypeInfo</c> has been called /// previously for the same type information, the index that was returned by the previous call is returned in phRefType. If the /// referenced type description is in the type library being created, its type information can be obtained by calling /// IUnknown::QueryInterface(IID_ITypeInfo, ...) on the ICreateTypeInfo interface of that type description. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addreftypeinfo HRESULT AddRefTypeInfo(// // ITypeInfo *pTInfo, HREFTYPE *phRefType); [PreserveSig] new HRESULT AddRefTypeInfo([In] ITypeInfo pTInfo, out uint phRefType); /// <summary>Adds a function description to the type description.</summary> /// <param name="index">The index of the new FUNCDESC in the type information.</param> /// <param name="pFuncDesc"> /// A FUNCDESC structure that describes the function. The <c>bstrIDLInfo</c> field in the FUNCDESC should be null. /// </param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// The index specifies the order of the functions within the type information. The first function has an index of zero. If an /// index is specified that exceeds one less than the number of functions in the type information, an error is returned. Calling /// this function does not pass ownership of the FUNCDESC structure to ICreateTypeInfo. Therefore, the caller must still /// de-allocate the FUNCDESC structure. /// </para> /// <para> /// The passed-in virtual function table (VTBL) field (oVft) of the FUNCDESC is ignored if the TYPEKIND is TKIND_MODULE or if /// oVft is -1 or 0. This attribute is set when ICreateTypeInfo::LayOut is called. The oVft value is used if the TYPEKIND is /// TKIND_DISPATCH and a dual interface or if the TYPEKIND is TKIND_INTERFACE. If the oVft is used, it must be a multiple of the /// sizeof(VOID *) on the machine, otherwise the function fails and E_INVALIDARG is returned as the HRESULT. /// </para> /// <para> /// The function <c>AddFuncDesc</c> uses the passed-in member identifier (memid) fields within each FUNCDESC for classes with /// TYPEKIND = TKIND_DISPATCH or TKIND_INTERFACE. If the member IDs are set to MEMBERID_NIL, <c>AddFuncDesc</c> assigns member /// IDs to the functions. Otherwise, the member ID fields within each FUNCDESC are ignored. /// </para> /// <para> /// Any HREFTYPE fields in the FUNCDESC structure must have been produced by the same instance of ITypeInfo for which /// <c>AddFuncDesc</c> is called. /// </para> /// <para>The get and put accessor functions for the same property must have the same dispatch identifier (DISPID).</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addfuncdesc HRESULT AddFuncDesc(UINT index, // FUNCDESC *pFuncDesc); [PreserveSig] new HRESULT AddFuncDesc(uint index, in FUNCDESC pFuncDesc); /// <summary>Specifies an inherited interface, or an interface implemented by a component object class (coclass).</summary> /// <param name="index"> /// The index of the implementation class to be added. Specifies the order of the type relative to the other type. /// </param> /// <param name="hRefType">A handle to the referenced type description obtained from the AddRefType description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// To specify an inherited interface, use index = 0. For a dispinterface with Syntax 2, call /// <c>ICreateTypeInfo::AddImplType</c> twice, once with index = 0 for the inherited IDispatch and once with index = 1 for the /// interface that is being wrapped. For a dual interface, call <c>ICreateTypeInfo::AddImplType</c> with index = -1 for the /// TKIND_INTERFACE type information component of the dual interface. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addimpltype HRESULT AddImplType(UINT index, // HREFTYPE hRefType); [PreserveSig] new HRESULT AddImplType(uint index, uint hRefType); /// <summary>Sets the attributes for an implemented or inherited interface of a type.</summary> /// <param name="index">The index of the interface for which to set type flags.</param> /// <param name="implTypeFlags">IMPLTYPE flags to be set.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setimpltypeflags HRESULT // SetImplTypeFlags(// UINT index, INT implTypeFlags); [PreserveSig] new HRESULT SetImplTypeFlags(uint index, System.Runtime.InteropServices.ComTypes.IMPLTYPEFLAGS implTypeFlags); /// <summary>Specifies the data alignment for an item of TYPEKIND=TKIND_RECORD.</summary> /// <param name="cbAlignment"> /// Alignment method for the type. A value of 0 indicates alignment on the 64K boundary; 1 indicates no special alignment. For /// other values, n indicates alignment on byte n. /// </param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The alignment is the minimum of the natural alignment (for example, byte data on byte boundaries, word data on word /// boundaries, and so on), and the alignment denoted by cbAlignment. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setalignment HRESULT SetAlignment(WORD cbAlignment); [PreserveSig] new HRESULT SetAlignment(ushort cbAlignment); /// <summary>Reserved for future use.</summary> /// <param name="pStrSchema">The schema.</param> [PreserveSig] new HRESULT SetSchema([MarshalAs(UnmanagedType.LPWStr)] string pStrSchema); /// <summary>Adds a variable or data member description to the type description.</summary> /// <param name="index">The index of the variable or data member to be added to the type description.</param> /// <param name="pVarDesc">A pointer to the variable or data member description to be added.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// The index specifies the order of the variables. The first variable has an index of zero. <c>ICreateTypeInfo::AddVarDesc</c> /// returns an error if the specified index is greater than the number of variables currently in the type information. Calling /// this function does not pass ownership of the VARDESC structure to ICreateTypeInfo. The instance field (oInst) of the VARDESC /// structure is ignored. This attribute is set only when ICreateTypeInfo::LayOut is called. Also, the member ID fields within /// the VARDESCs are ignored unless the TYPEKIND of the class is TKIND_DISPATCH. /// </para> /// <para> /// Any HREFTYPE fields in the VARDESC structure must have been produced by the same instance of ITypeInfo for which /// <c>AddVarDesc</c> is called. /// </para> /// <para><c>AddVarDesc</c> ignores the contents of the idldesc field of the ELEMDESC.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-addvardesc HRESULT AddVarDesc(UINT index, // VARDESC *pVarDesc); [PreserveSig] new HRESULT AddVarDesc(uint index, in VARDESC pVarDesc); /// <summary>Sets the name of a function and the names of its parameters to the specified names.</summary> /// <param name="index">The index of the function whose function name and parameter names are to be set.</param> /// <param name="rgszNames"> /// An array of pointers to names. The first element is the function name. Subsequent elements are names of parameters. /// </param> /// <param name="cNames">The number of elements in the rgszNames array.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> /// <remarks> /// This method must be used once for each property. The last parameter for put and putref accessor functions is unnamed. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setfuncandparamnames HRESULT // SetFuncAndParamNames(UINT index, LPOLESTR *rgszNames, UINT cNames); [PreserveSig] new HRESULT SetFuncAndParamNames(uint index, [MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2, ArraySubType = UnmanagedType.LPWStr)] string[] rgszNames, uint cNames); /// <summary>Sets the name of a variable.</summary> /// <param name="index">The index of the variable.</param> /// <param name="szName">The name.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setvarname HRESULT SetVarName(UINT index, // LPOLESTR szName); [PreserveSig] new HRESULT SetVarName(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szName); /// <summary>Sets the type description for which this type description is an alias, if TYPEKIND=TKIND_ALIAS.</summary> /// <param name="pTDescAlias">The type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks>To set the type for an alias, call <c>SetTypeDescAlias</c> for a type description whose TYPEKIND is TKIND_ALIAS.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-settypedescalias HRESULT // SetTypeDescAlias(// TYPEDESC *pTDescAlias); [PreserveSig] new HRESULT SetTypeDescAlias(in TYPEDESC pTDescAlias); /// <summary>Associates a DLL entry point with the function that has the specified index.</summary> /// <param name="index">The index of the function.</param> /// <param name="szDllName">The name of the DLL that contains the entry point.</param> /// <param name="szProcName">The name of the entry point or an ordinal (if the high word is zero).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// If the high word of szProcName is zero, then the low word must contain the ordinal of the entry point; otherwise, szProcName /// points to the zero-terminated name of the entry point. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-definefuncasdllentry HRESULT // DefineFuncAsDllEntry(UINT index, LPOLESTR szDllName, LPOLESTR szProcName); [PreserveSig] new HRESULT DefineFuncAsDllEntry(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szDllName, [MarshalAs(UnmanagedType.LPWStr)] string szProcName); /// <summary>Sets the documentation string for the function with the specified index.</summary> /// <param name="index">The index of the function.</param> /// <param name="szDocString">The documentation string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The documentation string is a brief description of the function intended for use by tools such as type browsers. /// <c>SetFuncDocString</c> only needs to be used once for each property, because all property accessor functions are identified /// by one name. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setfuncdocstring HRESULT // SetFuncDocString(// UINT index, LPOLESTR szDocString); [PreserveSig] new HRESULT SetFuncDocString(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szDocString); /// <summary>Sets the documentation string for the variable with the specified index.</summary> /// <param name="index">The index of the variable.</param> /// <param name="szDocString">The documentation string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setvardocstring HRESULT SetVarDocString(// // UINT index, LPOLESTR szDocString); [PreserveSig] new HRESULT SetVarDocString(uint index, [MarshalAs(UnmanagedType.LPWStr)] string szDocString); /// <summary>Sets the Help context ID for the function with the specified index.</summary> /// <param name="index">The index of the function.</param> /// <param name="dwHelpContext">The Help context ID for the Help topic.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <c>SetFuncHelpContext</c> only needs to be set once for each property, because all property accessor functions are /// identified by one name. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setfunchelpcontext HRESULT // SetFuncHelpContext(UINT index, DWORD dwHelpContext); [PreserveSig] new HRESULT SetFuncHelpContext(uint index, uint dwHelpContext); /// <summary>Sets the Help context ID for the variable with the specified index.</summary> /// <param name="index">The index of the variable.</param> /// <param name="dwHelpContext">The handle to the Help context ID for the Help topic on the variable.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setvarhelpcontext HRESULT // SetVarHelpContext(UINT index, DWORD dwHelpContext); [PreserveSig] new HRESULT SetVarHelpContext(uint index, uint dwHelpContext); /// <summary>Sets the marshaling opcode string associated with the type description or the function.</summary> /// <param name="index"> /// The index of the member for which to set the opcode string. If index is –1, sets the opcode string for the type description. /// </param> /// <param name="bstrMops">The marshaling opcode string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-setmops HRESULT SetMops(UINT index, BSTR bstrMops); [PreserveSig] new HRESULT SetMops(uint index, [MarshalAs(UnmanagedType.BStr)] string bstrMops); /// <summary>Reserved for future use.</summary> /// <param name="pIdlDesc">The IDLDESC.</param> [PreserveSig] new HRESULT SetTypeIdldesc(in IDLDESC pIdlDesc); /// <summary> /// Assigns VTBL offsets for virtual functions and instance offsets for per-instance data members, and creates the two type /// descriptions for dual interfaces. /// </summary> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>E_ACCESSDENIED</term> /// <term>Cannot write to the destination.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_UNDEFINEDTYPE</term> /// <term>Bound to unrecognized type.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// <item> /// <term>TYPE_E_ELEMENTNOTFOUND</term> /// <term>The element cannot be found.</term> /// </item> /// <item> /// <term>TYPE_E_AMBIGUOUSNAME</term> /// <term>More than one item exists with this name.</term> /// </item> /// <item> /// <term>TYPE_E_SIZETOOBIG</term> /// <term>The type information is too long.</term> /// </item> /// <item> /// <term>TYPE_E_TYPEMISMATCH</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para> /// <c>LayOut</c> also assigns member ID numbers to the functions and variables, unless the TYPEKIND of the class is /// TKIND_DISPATCH. Call <c>LayOut</c> after all members of the type information are defined, and before the type library is saved. /// </para> /// <para> /// Use ICreateTypeLib::SaveAllChanges to save the type information after calling <c>LayOut</c>. Other members of the /// ICreateTypeInfo interface should not be called after calling <c>LayOut</c>. /// </para> /// <para> /// <c>Note</c> Different implementations of ICreateTypeLib::SaveAllChanges or other interfaces that create type information are /// free to assign any member ID numbers, provided that all members (including inherited members), have unique IDs. For /// examples, see ICreateTypeInfo2. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo-layout HRESULT LayOut(); [PreserveSig] new HRESULT LayOut(); /// <summary>Deletes a function description specified by the index number.</summary> /// <param name="index"> /// The index of the function whose description is to be deleted. The index should be in the range of 0 to 1 less than the /// number of functions in this type. /// </param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-deletefuncdesc HRESULT DeleteFuncDesc(// // UINT index); [PreserveSig] HRESULT DeleteFuncDesc(uint index); /// <summary>Deletes the specified function description (FUNCDESC).</summary> /// <param name="memid">The member identifier of the FUNCDESC to delete.</param> /// <param name="invKind">The type of the invocation.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-deletefuncdescbymemid HRESULT // DeleteFuncDescByMemId(MEMBERID memid, INVOKEKIND invKind); [PreserveSig] HRESULT DeleteFuncDescByMemId(int memid, INVOKEKIND invKind); /// <summary>Deletes the specified VARDESC structure.</summary> /// <param name="index">The index number of the VARDESC structure.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_IOERROR</term> /// <term>The function cannot read from the file.</term> /// </item> /// <item> /// <term>TYPE_E_INVDATAREAD</term> /// <term>The function cannot read from the file.</term> /// </item> /// <item> /// <term>TYPE_E_UNSUPFORMAT</term> /// <term>The type library has an old format.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The type library cannot be opened.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-deletevardesc HRESULT DeleteVarDesc(UINT index); [PreserveSig] HRESULT DeleteVarDesc(uint index); /// <summary>Deletes the specified VARDESC structure.</summary> /// <param name="memid">The member identifier of the VARDESC to be deleted.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_IOERROR</term> /// <term>The function cannot read from the file.</term> /// </item> /// <item> /// <term>TYPE_E_INVDATAREAD</term> /// <term>The function cannot read from the file.</term> /// </item> /// <item> /// <term>TYPE_E_UNSUPFORMAT</term> /// <term>The type library has an old format.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The type library cannot be opened.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-deletevardescbymemid HRESULT // DeleteVarDescByMemId(MEMBERID memid); [PreserveSig] HRESULT DeleteVarDescByMemId(int memid); /// <summary>Deletes the IMPLTYPE flags for the indexed interface.</summary> /// <param name="index">The index of the interface for which to delete the type flags.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-deleteimpltype HRESULT DeleteImplType(// // UINT index); [PreserveSig] HRESULT DeleteImplType(uint index); /// <summary>Sets a value for custom data.</summary> /// <param name="guid">The unique identifier that can be used to identify the data.</param> /// <param name="pVarVal">The data to store (any variant except an object).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setcustdata HRESULT SetCustData(REFGUID // guid, VARIANT *pVarVal); [PreserveSig] HRESULT SetCustData(in Guid guid, [In, MarshalAs(UnmanagedType.Struct)] object pVarVal); /// <summary>Sets a value for custom data for the specified function.</summary> /// <param name="index">The index of the function for which to set the custom data.</param> /// <param name="guid">The unique identifier used to identify the data.</param> /// <param name="pVarVal">The data to store (any variant except an object).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setfunccustdata HRESULT SetFuncCustData(// // UINT index, REFGUID guid, VARIANT *pVarVal); [PreserveSig] HRESULT SetFuncCustData(uint index, in Guid guid, [In, MarshalAs(UnmanagedType.Struct)] object pVarVal); /// <summary>Sets a value for the custom data for the specified parameter.</summary> /// <param name="indexFunc">The index of the function for which to set the custom data.</param> /// <param name="indexParam">The index of the parameter of the function for which to set the custom data.</param> /// <param name="guid">The globally unique identifier (GUID) used to identify the data.</param> /// <param name="pVarVal">The data to store (any variant except an object).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setparamcustdata HRESULT // SetParamCustData(// UINT indexFunc, UINT indexParam, REFGUID guid, VARIANT *pVarVal); [PreserveSig] HRESULT SetParamCustData(uint indexFunc, uint indexParam, in Guid guid, [In, MarshalAs(UnmanagedType.Struct)] object pVarVal); /// <summary>Sets a value for custom data for the specified variable.</summary> /// <param name="index">The index of the variable for which to set the custom data.</param> /// <param name="guid">The globally unique ID (GUID) used to identify the data.</param> /// <param name="pVarVal">The data to store (any variant except an object).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setvarcustdata HRESULT SetVarCustData(// // UINT index, REFGUID guid, VARIANT *pVarVal); [PreserveSig] HRESULT SetVarCustData(uint index, in Guid guid, [In, MarshalAs(UnmanagedType.Struct)] object pVarVal); /// <summary>Sets a value for custom data for the specified implementation type.</summary> /// <param name="index">The index of the variable for which to set the custom data.</param> /// <param name="guid">The unique identifier used to identify the data.</param> /// <param name="pVarVal">The data to store (any variant except an object).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setimpltypecustdata HRESULT // SetImplTypeCustData(UINT index, REFGUID guid, VARIANT *pVarVal); [PreserveSig] HRESULT SetImplTypeCustData(uint index, in Guid guid, [In, MarshalAs(UnmanagedType.Struct)] object pVarVal); /// <summary>Sets the context number for the specified Help string.</summary> /// <param name="dwHelpStringContext">The Help string context number.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-sethelpstringcontext HRESULT // SetHelpStringContext(ULONG dwHelpStringContext); [PreserveSig] HRESULT SetHelpStringContext(uint dwHelpStringContext); /// <summary>Sets a Help context value for a specified function.</summary> /// <param name="index">The index of the function for which to set the help string context.</param> /// <param name="dwHelpStringContext">The Help string context for a localized string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setfunchelpstringcontext HRESULT // SetFuncHelpStringContext(UINT index, ULONG dwHelpStringContext); [PreserveSig] HRESULT SetFuncHelpStringContext(uint index, uint dwHelpStringContext); /// <summary>Sets a Help context value for a specified variable.</summary> /// <param name="index">The index of the variable.</param> /// <param name="dwHelpStringContext">The Help string context for a localized string.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setvarhelpstringcontext HRESULT // SetVarHelpStringContext(UINT index, ULONG dwHelpStringContext); [PreserveSig] HRESULT SetVarHelpStringContext(uint index, uint dwHelpStringContext); /// <summary>Reserved for future use.</summary> [PreserveSig] HRESULT Invalidate(); /// <summary>Sets the name of the typeinfo.</summary> /// <param name="szName">The name to be assigned.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypeinfo2-setname HRESULT SetName(LPOLESTR szName); [PreserveSig] HRESULT SetName([In, MarshalAs(UnmanagedType.LPWStr)] string szName); } /// <summary> /// Provides the methods for creating and managing the component or file that contains type information. Type libraries are created /// from type descriptions using the MIDL compiler. These type libraries are accessed through the ITypeLib interface. /// </summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-icreatetypelib [PInvokeData("oaidl.h", MSDNShortId = "d245cd25-ce31-42da-a42d-dc412d5b98e7")] [ComImport, Guid("00020406-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateTypeLib { /// <summary>Creates a new type description instance within the type library.</summary> /// <param name="szName">The name of the new type.</param> /// <param name="tkind">TYPEKIND of the type description to be created.</param> /// <param name="ppCTInfo">The type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// <item> /// <term>TYPE_E_NAMECONFLICT</term> /// <term>The provided name is not unique.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// Use ICreateTypeLib to create a new type description instance within the library. An error is returned if the specified name /// already appears in the library. Valid tkind values are described in TYPEKIND. To get the type information of the type /// description that is being created, call on the returned <c>ICreateTypeLib</c>. This type information can be used by other /// type descriptions that reference it by using ICreateTypeInfo::AddRefTypeInfo. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-createtypeinfo HRESULT // CreateTypeInfo(LPOLESTR szName, TYPEKIND tkind, ICreateTypeInfo **ppCTInfo); [PreserveSig] HRESULT CreateTypeInfo([In, MarshalAs(UnmanagedType.LPWStr)] string szName, TYPEKIND tkind, out ICreateTypeInfo ppCTInfo); /// <summary>Sets the name of the type library.</summary> /// <param name="szName">The name to be assigned to the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setname HRESULT SetName(LPOLESTR szName); [PreserveSig] HRESULT SetName([In, MarshalAs(UnmanagedType.LPWStr)] string szName); /// <summary>Sets the major and minor version numbers of the type library.</summary> /// <param name="wMajorVerNum">The major version number for the library.</param> /// <param name="wMinorVerNum">The minor version number for the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setversion HRESULT SetVersion(WORD // wMajorVerNum, WORD wMinorVerNum); [PreserveSig] HRESULT SetVersion(ushort wMajorVerNum, ushort wMinorVerNum); /// <summary> /// Sets the universal unique identifier (UUID) associated with the type library (Also known as the globally unique identifier (GUID)). /// </summary> /// <param name="guid">The globally unique identifier to be assigned to the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setguid HRESULT SetGuid(REFGUID guid); [PreserveSig] HRESULT SetGuid(in Guid guid); /// <summary>Sets the documentation string associated with the library.</summary> /// <param name="szDoc">A brief description of the type library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The documentation string is a brief description of the library intended for use by type information browsing tools. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setdocstring HRESULT SetDocString(LPOLESTR szDoc); [PreserveSig] HRESULT SetDocString([MarshalAs(UnmanagedType.LPWStr)] string szDoc); /// <summary>Sets the name of the Help file.</summary> /// <param name="szHelpFileName">The name of the Help file for the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para>Each type library can reference a single Help file.</para> /// <para> /// The GetDocumentation method of the created ITypeLib returns a fully qualified path for the Help file, which is formed by /// appending the name passed into szHelpFileName to the registered Help directory for the type library. The Help directory is /// registered under: /// </para> /// <para>\TYPELIB&amp;lt;guid of library&gt;&amp;lt;Major.Minor version &gt;\HELPDIR</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-sethelpfilename HRESULT // SetHelpFileName(LPOLESTR szHelpFileName); [PreserveSig] HRESULT SetHelpFileName([MarshalAs(UnmanagedType.LPWStr)] string szHelpFileName); /// <summary>Sets the Help context ID for retrieving general Help information for the type library.</summary> /// <param name="dwHelpContext">The Help context ID.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// Calling <c>SetHelpContext</c> with a Help context of zero is equivalent to not calling it at all, because zero indicates a /// null Help context. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-sethelpcontext HRESULT SetHelpContext(DWORD dwHelpContext); [PreserveSig] HRESULT SetHelpContext(uint dwHelpContext); /// <summary>Sets the binary Microsoft national language ID associated with the library.</summary> /// <param name="lcid">The locale ID for the type library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// For more information on national language IDs, see Supporting Multiple National Languages and the National Language Support /// (NLS) API. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setlcid HRESULT SetLcid(LCID lcid); [PreserveSig] HRESULT SetLcid(LCID lcid); /// <summary>Sets library flags.</summary> /// <param name="uLibFlags">The flags to set.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks>Valid uLibFlags values are listed in LIBFLAGS.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setlibflags HRESULT SetLibFlags(UINT uLibFlags); [PreserveSig] HRESULT SetLibFlags(uint uLibFlags); /// <summary>Saves the ICreateTypeLib instance following the layout of type information.</summary> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_IOERROR</term> /// <term>The function cannot write to the file.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks>You should not call any other ICreateTypeLib methods after calling <c>SaveAllChanges</c>.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-saveallchanges HRESULT SaveAllChanges(); [PreserveSig] HRESULT SaveAllChanges(); } /// <summary> /// Provides the methods for creating and managing the component or file that contains type information. Derives from /// ICreateTypeLib. The ICreateTypeInfo instance returned from <c>ICreateTypeLib</c> can be accessed through a <c>QueryInterface</c> /// call to ICreateTypeInfo2. /// </summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-icreatetypelib2 [PInvokeData("oaidl.h", MSDNShortId = "97378353-8c2d-493a-8ee9-42d33ab47d18")] [ComImport, Guid("0002040F-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ICreateTypeLib2 : ICreateTypeLib { /// <summary>Creates a new type description instance within the type library.</summary> /// <param name="szName">The name of the new type.</param> /// <param name="tkind">TYPEKIND of the type description to be created.</param> /// <param name="ppCTInfo">The type description.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// <item> /// <term>TYPE_E_NAMECONFLICT</term> /// <term>The provided name is not unique.</term> /// </item> /// <item> /// <term>TYPE_E_WRONGTYPEKIND</term> /// <term>Type mismatch.</term> /// </item> /// </list> /// </returns> /// <remarks> /// Use ICreateTypeLib to create a new type description instance within the library. An error is returned if the specified name /// already appears in the library. Valid tkind values are described in TYPEKIND. To get the type information of the type /// description that is being created, call on the returned <c>ICreateTypeLib</c>. This type information can be used by other /// type descriptions that reference it by using ICreateTypeInfo::AddRefTypeInfo. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-createtypeinfo HRESULT // CreateTypeInfo(LPOLESTR szName, TYPEKIND tkind, ICreateTypeInfo **ppCTInfo); [PreserveSig] new HRESULT CreateTypeInfo([In, MarshalAs(UnmanagedType.LPWStr)] string szName, TYPEKIND tkind, out ICreateTypeInfo ppCTInfo); /// <summary>Sets the name of the type library.</summary> /// <param name="szName">The name to be assigned to the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setname HRESULT SetName(LPOLESTR szName); [PreserveSig] new HRESULT SetName([In, MarshalAs(UnmanagedType.LPWStr)] string szName); /// <summary>Sets the major and minor version numbers of the type library.</summary> /// <param name="wMajorVerNum">The major version number for the library.</param> /// <param name="wMinorVerNum">The minor version number for the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setversion HRESULT SetVersion(WORD // wMajorVerNum, WORD wMinorVerNum); [PreserveSig] new HRESULT SetVersion(ushort wMajorVerNum, ushort wMinorVerNum); /// <summary> /// Sets the universal unique identifier (UUID) associated with the type library (Also known as the globally unique identifier (GUID)). /// </summary> /// <param name="guid">The globally unique identifier to be assigned to the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setguid HRESULT SetGuid(REFGUID guid); [PreserveSig] new HRESULT SetGuid(in Guid guid); /// <summary>Sets the documentation string associated with the library.</summary> /// <param name="szDoc">A brief description of the type library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// The documentation string is a brief description of the library intended for use by type information browsing tools. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setdocstring HRESULT SetDocString(LPOLESTR szDoc); [PreserveSig] new HRESULT SetDocString([MarshalAs(UnmanagedType.LPWStr)] string szDoc); /// <summary>Sets the name of the Help file.</summary> /// <param name="szHelpFileName">The name of the Help file for the library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para>Each type library can reference a single Help file.</para> /// <para> /// The GetDocumentation method of the created ITypeLib returns a fully qualified path for the Help file, which is formed by /// appending the name passed into szHelpFileName to the registered Help directory for the type library. The Help directory is /// registered under: /// </para> /// <para>\TYPELIB&amp;lt;guid of library&gt;&amp;lt;Major.Minor version &gt;\HELPDIR</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-sethelpfilename HRESULT // SetHelpFileName(LPOLESTR szHelpFileName); [PreserveSig] new HRESULT SetHelpFileName([MarshalAs(UnmanagedType.LPWStr)] string szHelpFileName); /// <summary>Sets the Help context ID for retrieving general Help information for the type library.</summary> /// <param name="dwHelpContext">The Help context ID.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// Calling <c>SetHelpContext</c> with a Help context of zero is equivalent to not calling it at all, because zero indicates a /// null Help context. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-sethelpcontext HRESULT SetHelpContext(DWORD dwHelpContext); [PreserveSig] new HRESULT SetHelpContext(uint dwHelpContext); /// <summary>Sets the binary Microsoft national language ID associated with the library.</summary> /// <param name="lcid">The locale ID for the type library.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks> /// For more information on national language IDs, see Supporting Multiple National Languages and the National Language Support /// (NLS) API. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setlcid HRESULT SetLcid(LCID lcid); [PreserveSig] new HRESULT SetLcid(LCID lcid); /// <summary>Sets library flags.</summary> /// <param name="uLibFlags">The flags to set.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks>Valid uLibFlags values are listed in LIBFLAGS.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-setlibflags HRESULT SetLibFlags(UINT uLibFlags); [PreserveSig] new HRESULT SetLibFlags(uint uLibFlags); /// <summary>Saves the ICreateTypeLib instance following the layout of type information.</summary> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>STG_E_INSUFFICIENTMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// <item> /// <term>TYPE_E_IOERROR</term> /// <term>The function cannot write to the file.</term> /// </item> /// <item> /// <term>TYPE_E_INVALIDSTATE</term> /// <term>The state of the type library is not valid for this operation.</term> /// </item> /// </list> /// </returns> /// <remarks>You should not call any other ICreateTypeLib methods after calling <c>SaveAllChanges</c>.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib-saveallchanges HRESULT SaveAllChanges(); [PreserveSig] new HRESULT SaveAllChanges(); /// <summary>Deletes a specified type information from the type library.</summary> /// <param name="szName">The name of the type information to remove.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib2-deletetypeinfo HRESULT DeleteTypeInfo( // LPOLESTR szName ); [PreserveSig] HRESULT DeleteTypeInfo([MarshalAs(UnmanagedType.LPWStr)] string szName); /// <summary>Sets a value to custom data.</summary> /// <param name="guid">The unique identifier for the data.</param> /// <param name="pVarVal">The data to store (any variant except an object).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib2-setcustdata HRESULT SetCustData( REFGUID // guid, VARIANT *pVarVal ); [PreserveSig] HRESULT SetCustData(in Guid guid, [In, MarshalAs(UnmanagedType.Struct)] object pVarVal); /// <summary>Sets the Help string context number.</summary> /// <param name="dwHelpStringContext">The Help string context number.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib2-sethelpstringcontext HRESULT // SetHelpStringContext( ULONG dwHelpStringContext ); [PreserveSig] HRESULT SetHelpStringContext(uint dwHelpStringContext); /// <summary>Sets the DLL name to be used for Help string lookup (for localization purposes).</summary> /// <param name="szFileName">The DLL file name.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-icreatetypelib2-sethelpstringdll HRESULT SetHelpStringDll( // LPOLESTR szFileName ); [PreserveSig] HRESULT SetHelpStringDll([MarshalAs(UnmanagedType.LPWStr)] string szFileName); } /// <summary> /// Exposes objects, methods and properties to programming tools and other applications that support Automation. COM components /// implement the <c>IDispatch</c> interface to enable access by Automation clients, such as Visual Basic. /// </summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-idispatch [PInvokeData("oaidl.h", MSDNShortId = "ebbff4bc-36b2-4861-9efa-ffa45e013eb5")] [System.Security.SuppressUnmanagedCodeSecurity, ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("00020400-0000-0000-C000-000000000046")] public interface IDispatch { /// <summary>Retrieves the number of type information interfaces that an object provides (either 0 or 1).</summary> /// <param name="pctinfo"> /// The number of type information interfaces provided by the object. If the object provides type information, this number is 1; /// otherwise the number is 0. /// </param> /// <remarks> /// The method may return zero, which indicates that the object does not provide any type information. In this case, the object /// may still be programmable through <c>IDispatch</c> or a VTBL, but does not provide run-time type information for browsers, /// compilers, or other programming tools that access type information. This can be useful for hiding an object from browsers. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-idispatch-gettypeinfocount HRESULT GetTypeInfoCount(UINT // *pctinfo); [System.Security.SecurityCritical] void GetTypeInfoCount(out uint pctinfo); /// <summary>Retrieves the type information for an object, which can then be used to get the type information for an interface.</summary> /// <param name="iTInfo">The type information to return. Pass 0 to retrieve type information for the IDispatch implementation.</param> /// <param name="lcid"> /// The locale identifier for the type information. An object may be able to return different type information for different /// languages. This is important for classes that support localized member names. For classes that do not support localized /// member names, this parameter can be ignored. /// </param> /// <param name="ppTInfo">The requested type information object.</param> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-idispatch-gettypeinfo HRESULT GetTypeInfo(UINT iTInfo, LCID // lcid, ITypeInfo **ppTInfo); [System.Security.SecurityCritical] void GetTypeInfo(uint iTInfo, LCID lcid, out ITypeInfo ppTInfo); /// <summary> /// Maps a single member and an optional set of argument names to a corresponding set of integer DISPIDs, which can be used on /// subsequent calls to Invoke. The dispatch function DispGetIDsOfNames provides a standard implementation of <c>GetIDsOfNames</c>. /// </summary> /// <param name="riid">Reserved for future use. Must be IID_NULL.</param> /// <param name="rgszNames">The array of names to be mapped.</param> /// <param name="cNames">The count of the names to be mapped.</param> /// <param name="lcid">The locale context in which to interpret the names.</param> /// <param name="rgDispId"> /// Caller-allocated array, each element of which contains an identifier (ID) corresponding to one of the names passed in the /// rgszNames array. The first element represents the member name. The subsequent elements represent each of the member's parameters. /// </param> /// <remarks> /// <para> /// An IDispatch implementation can associate any positive integer ID value with a given name. Zero is reserved for the default, /// or <c>Value</c> property; –1 is reserved to indicate an unknown name; and other negative values are defined for other /// purposes. For example, if <c>GetIDsOfNames</c> is called, and the implementation does not recognize one or more of the /// names, it returns DISP_E_UNKNOWNNAME, and the rgDispId array contains DISPID_UNKNOWN for the entries that correspond to the /// unknown names. /// </para> /// <para> /// The member and parameter DISPIDs must remain constant for the lifetime of the object. This allows a client to obtain the /// DISPIDs once, and cache them for later use. /// </para> /// <para> /// When <c>GetIDsOfNames</c> is called with more than one name, the first name (rgszNames[0]) corresponds to the member name, /// and subsequent names correspond to the names of the member's parameters. /// </para> /// <para> /// The same name may map to different DISPIDs, depending on context. For example, a name may have a DISPID when it is used as a /// member name with a particular interface, a different ID as a member of a different interface, and different mapping for each /// time it appears as a parameter. /// </para> /// <para> /// <c>GetIDsOfNames</c> is used when an IDispatch client binds to names at run time. To bind at compile time instead, an /// <c>IDispatch</c> client can map names to DISPIDs by using the type information interfaces described in Type Description /// Interfaces. This allows a client to bind to members at compile time and avoid calling <c>GetIDsOfNames</c> at run time. For /// a description of binding at compile time, see Type Description Interfaces. /// </para> /// <para> /// The implementation of <c>GetIDsOfNames</c> is case insensitive. Users that need case-sensitive name mapping should use type /// information interfaces to map names to DISPIDs, rather than call <c>GetIDsOfNames</c>. /// </para> /// <para> /// <c>Caution</c> You cannot use this method to access values that have been added dynamically, such as values added through /// JavaScript. Instead, use the GetDispID of the IDispatchEx interface. For more information, see the IDispatchEx interface. /// </para> /// <para>Examples</para> /// <para> /// The following code from the Lines sample file Lines.cpp implements the <c>GetIDsOfNames</c> member function for the CLine /// class. The ActiveX or OLE object uses the standard implementation, DispGetIDsOfNames. This implementation relies on /// <c>DispGetIdsOfNames</c> to validate input arguments. To help minimize security risks, include code that performs more /// robust validation of the input arguments. /// </para> /// <para> /// The following code might appear in an ActiveX client that calls <c>GetIDsOfNames</c> to get the DISPID of the /// <c>CLine</c><c>Color</c> property. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-idispatch-getidsofnames HRESULT GetIDsOfNames(REFIID riid, // LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId); [System.Security.SecurityCritical] void GetIDsOfNames([Optional] in Guid riid, [In, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.LPWStr, SizeParamIndex = 2)] string[] rgszNames, uint cNames, LCID lcid, [Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.I4, SizeParamIndex = 2)] int[] rgDispId); /// <summary> /// Provides access to properties and methods exposed by an object. The dispatch function DispInvoke provides a standard /// implementation of <c>Invoke</c>. /// </summary> /// <param name="dispIdMember"> /// Identifies the member. Use GetIDsOfNames or the object's documentation to obtain the dispatch identifier. /// </param> /// <param name="riid">Reserved for future use. Must be IID_NULL.</param> /// <param name="lcid"> /// <para> /// The locale context in which to interpret arguments. The <paramref name="lcid"/> is used by the GetIDsOfNames function, and /// is also passed to <c>Invoke</c> to allow the object to interpret its arguments specific to a locale. /// </para> /// <para> /// Applications that do not support multiple national languages can ignore this parameter. For more information, refer to /// Supporting Multiple National Languages and Exposing ActiveX Objects. /// </para> /// </param> /// <param name="wFlags"> /// <para>Flags describing the context of the <c>Invoke</c> call.</para> /// <list type="table"> /// <listheader> /// <term>Value</term> /// <term>Meaning</term> /// </listheader> /// <item> /// <term>DISPATCH_METHOD</term> /// <term> /// The member is invoked as a method. If a property has the same name, both this and the DISPATCH_PROPERTYGET flag can be set. /// </term> /// </item> /// <item> /// <term>DISPATCH_PROPERTYGET</term> /// <term>The member is retrieved as a property or data member.</term> /// </item> /// <item> /// <term>DISPATCH_PROPERTYPUT</term> /// <term>The member is changed as a property or data member.</term> /// </item> /// <item> /// <term>DISPATCH_PROPERTYPUTREF</term> /// <term> /// The member is changed by a reference assignment, rather than a value assignment. This flag is valid only when the property /// accepts a reference to an object. /// </term> /// </item> /// </list> /// </param> /// <param name="pDispParams"> /// Pointer to a DISPPARAMS structure containing an array of arguments, an array of argument DISPIDs for named arguments, and /// counts for the number of elements in the arrays. /// </param> /// <param name="pVarResult"> /// Pointer to the location where the result is to be stored, or NULL if the caller expects no result. This argument is ignored /// if DISPATCH_PROPERTYPUT or DISPATCH_PROPERTYPUTREF is specified. /// </param> /// <param name="pExcepInfo"> /// Pointer to a structure that contains exception information. This structure should be filled in if DISP_E_EXCEPTION is /// returned. Can be NULL. /// </param> /// <param name="puArgErr"> /// The index within rgvarg of the first argument that has an error. Arguments are stored in pDispParams-&gt;rgvarg in reverse /// order, so the first argument is the one with the highest index in the array. This parameter is returned only when the /// resulting return value is DISP_E_TYPEMISMATCH or DISP_E_PARAMNOTFOUND. This argument can be set to null. For details, see /// Returning Errors. /// </param> /// <remarks> /// <para> /// Generally, you should not implement <c>Invoke</c> directly. Instead, use the dispatch interface to create functions /// CreateStdDispatch and DispInvoke. For details, refer to <c>CreateStdDispatch</c>, <c>DispInvoke</c>, Creating the IDispatch /// Interface and Exposing ActiveX Objects. /// </para> /// <para> /// If some application-specific processing needs to be performed before calling a member, the code should perform the necessary /// actions, and then call ITypeInfo::Invoke to invoke the member. <c>ITypeInfo::Invoke</c> acts exactly like <c>Invoke</c>. The /// standard implementations of <c>Invoke</c> created by <c>CreateStdDispatch</c> and <c>DispInvoke</c> defer to <c>ITypeInfo::Invoke</c>. /// </para> /// <para> /// In an ActiveX client, <c>Invoke</c> should be used to get and set the values of properties, or to call a method of an /// ActiveX object. The dispIdMember argument identifies the member to invoke. The DISPIDs that identify members are defined by /// the implementor of the object and can be determined by using the object's documentation, the IDispatch::GetIDsOfNames /// function, or the ITypeInfo interface. /// </para> /// <para> /// When you use <c>IDispatch::Invoke()</c> with DISPATCH_PROPERTYPUT or DISPATCH_PROPERTYPUTREF, you have to specially /// initialize the <c>cNamedArgs</c> and <c>rgdispidNamedArgs</c> elements of your DISPPARAMS structure with the following: /// </para> /// <para> /// The information that follows addresses developers of ActiveX clients and others who use code to expose ActiveX objects. It /// describes the behavior that users of exposed objects should expect. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-idispatch-invoke HRESULT Invoke(DISPID dispIdMember, REFIID // riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr); [System.Security.SecurityCritical] void Invoke(int dispIdMember, [Optional] in Guid riid, LCID lcid, INVOKEKIND wFlags, ref DISPPARAMS pDispParams, [Optional] IntPtr pVarResult, [Optional] IntPtr pExcepInfo, [Optional] IntPtr puArgErr); } /// <summary>Provides detailed contextual error information.</summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-ierrorinfo [PInvokeData("oaidl.h", MSDNShortId = "4dda6909-2d9a-4727-ae0c-b5f90dcfa447")] [ComImport, Guid("1CF2B120-547D-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IErrorInfo { /// <summary>Returns the globally unique identifier (GUID) of the interface that defined the error.</summary> /// <param name="pGUID">A pointer to a GUID, or GUID_NULL, if the error was defined by the operating system.</param> /// <returns>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns> /// <remarks> /// <para> /// <c>IErrorInfo::GetGUID</c> returns the GUID of the interface that defined the error. If the error was defined by the system, /// <c>IErrorInfo::GetGUID</c> returns GUID_NULL. /// </para> /// <para> /// This GUID does not necessarily represent the source of the error. The source is the class or application that raised the /// error. Using the GUID, an application can handle errors in an interface, independent of the class that implements the interface. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-ierrorinfo-getguid HRESULT GetGUID(GUID *pGUID); [PreserveSig] HRESULT GetGUID(out Guid pGUID); /// <summary>Returns the language-dependent programmatic ID (ProgID) for the class or application that raised the error.</summary> /// <param name="pBstrSource">A ProgID, in the form progname.objectname.</param> /// <returns>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns> /// <remarks> /// Use <c>IErrorInfo::GetSource</c> to determine the class or application that is the source of the error. The language for the /// returned ProgID depends on the locale ID (LCID) that was passed into the method at the time of invocation. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-ierrorinfo-getsource HRESULT GetSource(BSTR *pBstrSource); [PreserveSig] HRESULT GetSource([MarshalAs(UnmanagedType.BStr)] out string pBstrSource); /// <summary>Returns a textual description of the error.</summary> /// <param name="pBstrDescription">A brief description of the error.</param> /// <returns>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns> /// <remarks> /// The text is returned in the language specified by the locale identifier (LCID) that was passed to IDispatch::Invoke for the /// method that encountered the error. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-ierrorinfo-getdescription HRESULT GetDescription(BSTR // *pBstrDescription); [PreserveSig] HRESULT GetDescription([MarshalAs(UnmanagedType.BStr)] out string pBstrDescription); /// <summary>Returns the path of the Help file that describes the error.</summary> /// <param name="pBstrHelpFile">The fully qualified path of the Help file.</param> /// <returns>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns> /// <remarks> /// This method returns the fully qualified path of the Help file that describes the current error. IErrorInfo::GetHelpContext /// should be used to find the Help context ID for the error in the Help file. /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-ierrorinfo-gethelpfile HRESULT GetHelpFile(BSTR // *pBstrHelpFile); [PreserveSig] HRESULT GetHelpFile([MarshalAs(UnmanagedType.BStr)] out string pBstrHelpFile); /// <summary>Returns the Help context identifier (ID) for the error.</summary> /// <param name="pdwHelpContext">The Help context ID for the error.</param> /// <returns>If this method succeeds, it returns <c>S_OK</c>. Otherwise, it returns an <c>HRESULT</c> error code.</returns> /// <remarks>This method returns the Help context ID for the error. To find the Help file to which it applies, use IErrorInfo::GetHelpFile.</remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-ierrorinfo-gethelpcontext HRESULT GetHelpContext(DWORD // *pdwHelpContext); [PreserveSig] HRESULT GetHelpContext(out uint pdwHelpContext); } /// <summary>Communicates detailed error information between a client and an object.</summary> [ComImport, Guid("3127CA40-446E-11CE-8135-00AA004BB851"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [PInvokeData("OAIdl.h")] public interface IErrorLog { /// <summary>Logs an error (using an EXCEPINFO structure) in the error log for a named property.</summary> /// <param name="pszPropName"> /// A pointer to a string containing the name of the property involved with the error. This cannot be NULL. /// </param> /// <param name="pExcepInfo"> /// A pointer to the caller-initialized EXCEPINFO structure that describes the error to log. This cannot be NULL. /// </param> void AddError([In, MarshalAs(UnmanagedType.LPWStr)] string pszPropName, in EXCEPINFO pExcepInfo); } /// <summary>Provides an object with a property bag in which the object can save its properties persistently.</summary> /// <remarks> /// To read a property in IPersistPropertyBag::Load, the object calls IPropertyBag::Read. When the object saves properties in /// IPersistPropertyBag::Save, it calls IPropertyBag::Write. Each property is described with a name, whose value is stored in a /// VARIANT. This information allows a client to save the property values as text, for example; which is the primary reason why a /// client might choose to support IPersistPropertyBag. /// </remarks> [ComImport, Guid("55272A00-42CB-11CE-8135-00AA004BB851"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [PInvokeData("OAIdl.h")] public interface IPropertyBag { /// <summary>Tells the property bag to read the named property into a caller-initialized VARIANT.</summary> /// <param name="pszPropName">The address of the name of the property to read. This cannot be NULL.</param> /// <param name="pVar"> /// The address of the caller-initialized VARIANT that receives the property value on output. The function must set the type /// field and the value field in the VARIANT before it returns. If the caller initialized the pVar-&gt;vt field on entry, the /// property bag attempts to change its corresponding value to this type. If the caller sets pVar-&gt;vt to VT_EMPTY, the /// property bag can use whatever type is convenient. /// </param> /// <param name="pErrorLog"> /// The address of the caller's error log in which the property bag stores any errors that occur during reads. This can be NULL; /// in which case, the caller does not receive errors. /// </param> /// <remarks> /// The Read method tells the property bag to read the property named in pszPropName to the caller-initialized VARIANT in pVar. /// Errors are logged in the error log that is pointed to by pErrorLog. When pVar-&gt;vt specifies another object pointer /// (VT_UNKNOWN), the property bag is responsible for creating and initializing the object described by pszPropName. /// </remarks> void Read([In, MarshalAs(UnmanagedType.LPWStr)] string pszPropName, [In, Out] ref object pVar, [In] IErrorLog pErrorLog); /// <summary>Tells the property bag to save the named property in a caller-initialized VARIANT.</summary> /// <param name="pszPropName">The address of a string containing the name of the property to write. This cannot be NULL.</param> /// <param name="pVar"> /// The address of the caller-initialized VARIANT that holds the property value to save. The caller owns this VARIANT, and is /// responsible for all of its allocations. That is, the property bag does not attempt to free data in the VARIANT. /// </param> /// <remarks> /// The Write method tells the property bag to save the property named with pszPropName by using the type and value in the /// caller-initialized VARIANT in pVar. In some cases, the caller might be telling the property bag to save another object, for /// example, when pVar-&gt;vt is VT_UNKNOWN. In such cases, the property bag queries this object pointer for a persistence /// interface, such as IPersistStream or IPersistPropertyBag, and has that object save its data as well. Usually this results in /// the property bag having some byte array for this object, which can be saved as encoded text, such as hexadecimal string, /// MIME, and so on. When the property bag is later used to reinitialize a control, the client that owns the property bag must /// re-create the object when the caller asks for it, initializing that object with the previously saved bits. /// <para> /// This allows efficient persistence operations for Binary Large Object (BLOB) properties, such as a picture, where the owner /// of the property bag tells the picture object (which is managed as a property in the control that is saved) to save to a /// specific location. This avoids potential extra copy operations that might be involved with other property-based persistence mechanisms. /// </para> /// </remarks> void Write([In, MarshalAs(UnmanagedType.LPWStr)] string pszPropName, in object pVar); } /// <summary>Provides an object with a property bag in which the object can save its properties persistently.</summary> /// <remarks> /// <para> /// When a client wants to control how the individually named properties of an object are saved, it uses an object's /// <c>IPersistPropertyBag2</c> interface as a persistence mechanism. The client supplies a property bag to the object in the form /// of an <c>IPropertyBag2</c> interface. /// </para> /// <para> /// <c>IPropertyBag2</c> is an enhancement of the <c>IPropertyBag</c> interface. <c>IPropertyBag2</c> allows the object to obtain /// type information for each property by using the <c>CountProperties</c> method and the <c>GetPropertyInfo</c> method. A property /// bag that implements <c>IPropertyBag2</c> must also support <c>IPropertyBag</c>, so that objects that only support /// <c>IPropertyBag</c> can access their properties. Also, an object that supports <c>IPropertyBag2</c> must also support /// <c>IPropertyBag</c> so that the object can communicate with property bags that only support <c>IPropertyBag</c>. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768192(v=vs.85) [PInvokeData("Ocidl.h")] [ComImport, Guid("22F55882-280B-11d0-A8A9-00A0C90C2004"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IPropertyBag2 { /// <summary>Causes one or more properties to be read from the property bag.</summary> /// <param name="cProperties"> /// <para>[in]Type: <c>unsigned long</c></para> /// <para> /// The number of properties to read. This argument specifies the number of elements in the arrays at pPropBag, pvarValue, and phrError. /// </para> /// </param> /// <param name="pPropBag"> /// <para>[in]Type: <c>[</c> PROPBAG2 <c>]</c></para> /// <para> /// The address of an array of <c>PROPBAG2</c> structures that specify the properties that are requested. The <c>vt</c> member /// and the <c>pstrName</c> member of these structures must be filled in before this method can be called. The <c>dwHint</c> /// member of these structures is optional. There must be at least cProperties elements in this array. This argument cannot be NULL. /// </para> /// </param> /// <param name="pErrLog"> /// <para>[in]Type: <c>IErrorLog</c></para> /// <para> /// The address of an <c>IErrorlog</c> interface in which the property bag stores any errors that occur during the reads. This /// argument can be NULL; in which case, the caller receives no logging errors. /// </para> /// </param> /// <param name="pvarValue"> /// <para>[out]Type: <c>VARIANT</c></para> /// <para> /// The address of an array of <c>VARIANT</c> structures that receive the property values. The caller does not have to /// initialize these structures before calling <c>IPropertyBag2::Read</c>. The <c>IPropertyBag2::Read</c> method fills the type /// field and the value field in these structures before it returns. There must be at least cProperties elements in this array. /// The calling application is responsible for freeing any allocations that are contained in these structures. This argument /// cannot be NULL. /// </para> /// </param> /// <param name="phrError"> /// <para>[out]Type: <c>HRESULT</c></para> /// <para> /// The address of an array of <c>HRESULT</c> values that receives the result of each property read. There must be at least /// cProperties elements in this array. This argument cannot be NULL. /// </para> /// </param> // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768194%28v%3dvs.85%29 // HRESULT retVal = object.Read(cProperties, pPropBag, pErrLog, pvarValue, phrError); void Read(uint cProperties, [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] PROPBAG2[] pPropBag, [Optional] IErrorLog pErrLog, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] object[] pvarValue, [In, Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 0)] HRESULT[] phrError); /// <summary>Causes one or more properties to be saved into the property bag.</summary> /// <param name="cProperties"> /// <para>[in]Type: <c>unsigned long</c></para> /// <para>The number of properties to save. This argument specifies the number of elements in the arrays at pPropBag and pvarValue.</para> /// </param> /// <param name="pPropBag"> /// <para>[in]Type: <c>[</c> PROPBAG2 <c>](aa768188(v=vs.85).md)</c></para> /// <para> /// The address of an array of <c>PROPBAG2</c> structures that specify the properties saved. The <c>pstrName</c> member of these /// structures must be filled in before this method is called. The <c>dwHint</c> member of these structures is optional. There /// must be at least cProperties elements in this array. This argument cannot be NULL. /// </para> /// </param> /// <param name="pvarValue"> /// <para>[in]Type: <c>VARIANT</c></para> /// <para> /// The address of an array of <c>VARIANT</c> structures that contain the property values to save. There must be at least /// cProperties elements in this array. This argument cannot be NULL. /// </para> /// </param> // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768195(v=vs.85) // HRESULT retVal = object.Write(cProperties, pPropBag, pvarValue); void Write(uint cProperties, PROPBAG2[] pPropBag, VARIANT[] pvarValue); /// <summary>Gets the number of properties in the property bag.</summary> /// <returns> /// <para>[out]Type: <c>unsigned long</c></para> /// <para>The address of a <c>unsigned long</c> that receives the number of properties in the property bag.</para> /// </returns> // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768190(v=vs.85) // HRESULT retVal = object.CountProperties(pcProperties); uint CountProperties(); /// <summary>Gets information for properties in a property bag without actually getting those properties.</summary> /// <param name="iProperty"> /// <para>[in]Type: <c>unsigned long</c></para> /// <para> /// The zero-based index of the first property for which information is requested. This argument must be less than the number of /// properties retrieved by <c>IPropertyBag2::CountProperties</c>. /// </para> /// </param> /// <param name="cProperties"> /// <para>[in]Type: <c>unsigned long</c></para> /// <para>The number of properties to get information for. This argument specifies the number of array elements in pPropBag.</para> /// </param> /// <param name="pPropBag"> /// <para>[out]Type: <c>[</c> PROPBAG2 <c>](aa768188(v=vs.85).md)</c></para> /// <para> /// The address of an array of <c>PROPBAG2</c> structures that receive the information for the properties. There must be at /// least cProperties elements in this array. This argument cannot be NULL. /// </para> /// </param> /// <param name="pcProperties"> /// <para>[out]Type: <c>unsigned long</c></para> /// <para> /// The address of a <c>unsigned long</c> that receives the number of properties for which information was retrieved. This /// argument cannot be NULL. /// </para> /// </param> /// <remarks> /// <para>When you implement this method, use CoTaskMemAlloc to allocate memory for the <c>pstrName</c> member of pPropBag.</para> /// <para>When you call this method, use CoTaskMemFree to free the <c>pstrName</c> member of pPropBag.</para> /// </remarks> // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768191(v=vs.85) // HRESULT retVal = object.GetPropertyInfo(iProperty, cProperties, pPropBag, pcProperties); void GetPropertyInfo( uint iProperty, uint cProperties, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PROPBAG2[] pPropBag, out uint pcProperties); /// <summary> /// Causes the property bag to instruct a property object that was previously created and initialized to read its persistent properties. /// </summary> /// <param name="pstrName"> /// <para>[in]Type: <c>LPCOLESTR</c></para> /// <para>The address of the name of the property object.</para> /// </param> /// <param name="dwHint"> /// <para>[in]Type: <c>DWORD</c></para> /// <para> /// An integer value that was retrieved by using <c>IPropertyBag2::GetPropertyInfo</c>. This argument is optional and must be /// zero, if the value is not known or used. /// </para> /// </param> /// <param name="pUnkObject"> /// <para>[in]Type: <c>IUnknown</c></para> /// <para>The address of the object's IUnknown interface. This argument cannot be NULL.</para> /// </param> /// <param name="pErrLog"> /// <para>[in]Type: <c>IErrorLog</c></para> /// <para> /// The address of an <c>IErrorlog</c> interface in which the property bag stores any errors that occur during the load. This /// argument can be NULL; in which case, the caller does not receive logging errors. /// </para> /// </param> /// <remarks> /// <para> /// The <c>IPropertyBag2::LoadObject</c> method enables the calling application to participate in the creation and /// initialization of a property object. When the <c>IPropertyBag</c> interface is used, a property object can be loaded by /// using the <c>IPropertyBag::Read</c> method with <c>VT_UNKNOWN</c>. The <c>IPropertyBag</c> interface does not allow the /// property object to be initialized by the calling application before the property object reads its own persistent data. /// <c>IPropertyBag2::LoadObject</c> allows the property object to be created and initialized by the calling application, /// instead of using the property bag to create and initialize the property object. /// </para> /// <para> /// To use <c>IPropertyBag2::LoadObject</c>, get the property object's name and CLSID by using /// <c>IPropertyBag2::GetPropertyInfo</c>. The property object is created and initialized. <c>IPropertyBag2::LoadObject</c> is /// used instead of <c>IPropertyBag2::Read</c> to cause the property object to read its persistent data. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/previous-versions/windows/internet-explorer/ie-developer/platform-apis/aa768193(v=vs.85) // HRESULT retVal = object.LoadObject(pstrName, dwHint, pUnkObject, pErrLog); void LoadObject([MarshalAs(UnmanagedType.LPWStr)] string pstrName, uint dwHint, [In, MarshalAs(UnmanagedType.IUnknown)] object pUnkObject, [Optional] IErrorLog pErrLog); } /// <summary> /// Describes the structure of a particular UDT. You can use IRecordInfo any time you need to access the description of UDTs /// contained in type libraries. IRecordInfo can be reused as needed; there can be many instances of the UDT for a single /// IRecordInfo pointer. /// </summary> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nn-oaidl-irecordinfo [PInvokeData("OAIdl.h")] [ComImport, Guid("0000002F-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface IRecordInfo { /// <summary> /// <para>Initializes a new instance of a record.</para> /// </summary> /// <param name="pvNew"> /// <para>An instance of a record.</para> /// </param> /// <remarks> /// <para>The caller must allocate the memory of the record by its appropriate size using the GetSize method.</para> /// <para><c>RecordInit</c> sets all contents of the record to 0 and the record should hold no resources.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-recordinit void RecordInit(IntPtr pvNew); /// <summary> /// <para>Releases object references and other values of a record without deallocating the record.</para> /// </summary> /// <param name="pvExisting"> /// <para>The record to be cleared.</para> /// </param> /// <remarks> /// <c>RecordClear</c> releases memory blocks held by VT_PTR or VT_SAFEARRAY instance fields. The caller needs to free the /// instance fields memory, <c>RecordClear</c> will do nothing if there are no resources held. /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-recordclear void RecordClear(IntPtr pvExisting); /// <summary> /// <para>Copies an existing record into the passed in buffer.</para> /// </summary> /// <param name="pvExisting"> /// <para>The current record instance.</para> /// </param> /// <param name="pvNew"> /// <para>The destination where the record will be copied.</para> /// </param> /// <remarks> /// <c>RecordCopy</c> will release the resources in the destination first. The caller is responsible for allocating sufficient /// memory in the destination by calling GetSize or RecordCreate. If <c>RecordCopy</c> fails to copy any of the fields then all /// fields will be cleared, as though RecordClear had been called. /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-recordcopy void RecordCopy(IntPtr pvExisting, IntPtr pvNew); /// <summary> /// <para>Gets the GUID of the record type.</para> /// </summary> /// <returns> /// <para>The class GUID of the TypeInfo that describes the UDT.</para> /// </returns> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-getguid Guid GetGuid(); /// <summary> /// <para> /// Gets the name of the record type. This is useful if you want to print out the type of the record, because each UDT has it's /// own IRecordInfo. /// </para> /// </summary> /// <returns> /// <para>The name.</para> /// </returns> /// <remarks> /// <para>The caller must free the BSTR by calling SysFreeString.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-getname [return: MarshalAs(UnmanagedType.BStr)] string GetName(); /// <summary> /// <para> /// Gets the number of bytes of memory necessary to hold the record instance. This allows you to allocate memory for a record /// instance rather than calling RecordCreate. /// </para> /// </summary> /// <returns> /// <para>The size of a record instance, in bytes.</para> /// </returns> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-getsize uint GetSize(); /// <summary>Retrieves the type information that describes a UDT or safearray of UDTs.</summary> /// <param name="ppTypeInfo">The type information.</param> /// <remarks><c>AddRef</c> is called on the pointer ppTypeInfo.</remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-gettypeinfo void GetTypeInfo([MarshalAs(UnmanagedType.CustomMarshaler, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.TypeToTypeInfoMarshaler")] out Type ppTypeInfo); /// <summary> /// <para>Returns a pointer to the VARIANT containing the value of a given field name.</para> /// </summary> /// <param name="pvData"> /// <para>The instance of a record.</para> /// </param> /// <param name="szFieldName"> /// <para>The field name.</para> /// </param> /// <returns> /// The VARIANT that you want to hold the value of the field name, szFieldName. On return, places a copy of the field's value in /// the variant. /// </returns> /// <remarks> /// <para> /// The VARIANT that you pass in contains a copy of the field's value upon return. If you modify the VARIANT then the underlying /// record field does not change. /// </para> /// <para>The caller allocates memory of the VARIANT.</para> /// <para>The method VariantClear is called for pvarField before copying.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-getfield [return: MarshalAs(UnmanagedType.Struct)] object GetField(IntPtr pvData, [MarshalAs(UnmanagedType.LPWStr)] string szFieldName); /// <summary> /// <para>Returns a pointer to the value of a given field name without copying the value and allocating resources.</para> /// </summary> /// <param name="pvData"> /// <para>The instance of a record.</para> /// </param> /// <param name="szFieldName"> /// <para>The name of the field.</para> /// </param> /// <param name="pvarField"> /// <para>The VARIANT that will contain the UDT upon return.</para> /// </param> /// <returns> /// <para>Receives the value of the field upon return.</para> /// </returns> /// <remarks> /// <para> /// Upon return, the VARIANT you pass contains a direct pointer to the record's field, ppvDataCArray. If you modify the VARIANT, /// then the underlying record field will change. /// </para> /// <para> /// The caller allocates memory of the VARIANT, but does not own the memory so cannot free pvarField. This method calls /// VariantClear for pvarField before filling in the requested field. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-getfieldnocopy IntPtr GetFieldNoCopy(IntPtr pvData, [MarshalAs(UnmanagedType.LPWStr)] string szFieldName, [MarshalAs(UnmanagedType.Struct)] out object pvarField); /// <summary> /// <para>Puts a variant into a field.</para> /// </summary> /// <param name="wFlags"> /// <para>The only legal values for the wFlags parameter is INVOKE_PROPERTYPUT or INVOKE_PROPERTYPUTREF.</para> /// <para> /// If INVOKE_PROPERTYPUTREF is passed in then <c>PutField</c> just assigns the value of the variant that is passed in to the /// field using normal coercion rules. /// </para> /// <para> /// If INVOKE_PROPERTYPUT is passed in then specific rules apply. If the field is declared as a class that derives from /// IDispatch and the field's value is NULL then an error will be returned. If the field's value is not NULL then the variant /// will be passed to the default property supported by the object referenced by the field. If the field is not declared as a /// class derived from <c>IDispatch</c> then an error will be returned. If the field is declared as a variant of type /// VT_Dispatch then the default value of the object is assigned to the field. Otherwise, the variant's value is assigned to the field. /// </para> /// </param> /// <param name="pvData"> /// <para>The pointer to an instance of the record.</para> /// </param> /// <param name="szFieldName"> /// <para>The name of the field of the record.</para> /// </param> /// <param name="pvarField"> /// <para>The pointer to the variant.</para> /// </param> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-putfield void PutField(uint wFlags, IntPtr pvData, [MarshalAs(UnmanagedType.LPWStr)] string szFieldName, [In, MarshalAs(UnmanagedType.Struct)] ref object pvarField); /// <summary> /// <para> /// Passes ownership of the data to the assigned field by placing the actual data into the field. <c>PutFieldNoCopy</c> is /// useful for saving resources because it allows you to place your data directly into a record field. <c>PutFieldNoCopy</c> /// differs from PutField because it does not copy the data referenced by the variant. /// </para> /// </summary> /// <param name="wFlags"> /// <para>The only legal values for the wFlags parameter is INVOKE_PROPERTYPUT or INVOKE_PROPERTYPUTREF.</para> /// </param> /// <param name="pvData"> /// <para>An instance of the record described by IRecordInfo.</para> /// </param> /// <param name="szFieldName"> /// <para>The name of the field of the record.</para> /// </param> /// <param name="pvarField"> /// <para>The variant to be put into the field.</para> /// </param> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-putfieldnocopy void PutFieldNoCopy(uint wFlags, IntPtr pvData, [MarshalAs(UnmanagedType.LPWStr)] string szFieldName, [In, MarshalAs(UnmanagedType.Struct)] ref object pvarField); /// <summary> /// <para>Gets the names of the fields of the record.</para> /// </summary> /// <param name="pcNames"> /// <para>The number of names to return.</para> /// </param> /// <param name="rgBstrNames"> /// <para>The name of the array of type BSTR.</para> /// <para>If the rgBstrNames parameter is NULL, then pcNames is returned with the number of field names.</para> /// <para> /// It the rgBstrNames parameter is not NULL, then the string names contained in rgBstrNames are returned. If the number of /// names in pcNames and rgBstrNames are not equal then the lesser number of the two is the number of returned field names. The /// caller needs to free the BSTRs inside the array returned in rgBstrNames. /// </para> /// </param> /// <remarks> /// <para> /// The caller should allocate memory for the array of BSTRs. If the array is larger than needed, set the unused portion to 0. /// </para> /// <para>On return, the caller will need to free each contained BSTR using SysFreeString.</para> /// <para>In case of out of memory, pcNames points to error code.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-getfieldnames void GetFieldNames(ref uint pcNames, [In, Out, MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.BStr, SizeParamIndex = 0)] string[] rgBstrNames); /// <summary> /// <para>Determines whether the record that is passed in matches that of the current record information.</para> /// </summary> /// <param name="pRecordInfo"> /// <para>The information of the record.</para> /// </param> /// <returns> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>TRUE</term> /// <term>The record that is passed in matches the current record information.</term> /// </item> /// <item> /// <term>FALSE</term> /// <term>The record that is passed in does not match the current record information.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-ismatchingtype [PreserveSig] [return: MarshalAs(UnmanagedType.Bool)] bool IsMatchingType([In] IRecordInfo pRecordInfo); /// <summary> /// <para>Allocates memory for a new record, initializes the instance and returns a pointer to the record.</para> /// </summary> /// <returns> /// <para>This method returns a pointer to the created record.</para> /// </returns> /// <remarks> /// <para>The memory is set to zeros before it is returned.</para> /// <para>The records created must be freed by calling RecordDestroy.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-recordcreate [PreserveSig] IntPtr RecordCreate(); /// <summary> /// <para>Creates a copy of an instance of a record to the specified location.</para> /// </summary> /// <param name="pvSource"> /// <para>An instance of the record to be copied.</para> /// </param> /// <param name="ppvDest"> /// <para>The new record with data copied from pvSource.</para> /// </param> /// <remarks> /// <para>The records created must be freed by calling RecordDestroy.</para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-recordcreatecopy void RecordCreateCopy(IntPtr pvSource, out IntPtr ppvDest); /// <summary> /// <para>Releases the resources and deallocates the memory of the record.</para> /// </summary> /// <param name="pvRecord"> /// <para>An instance of the record to be destroyed.</para> /// </param> /// <remarks> /// <para>RecordClear is called to release the resources held by the instance of a record without deallocating memory.</para> /// <para> /// <c>Note</c> This method can only be called on records allocated through RecordCreate and RecordCreateCopy. If you allocate /// the record yourself, you cannot call this method. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/desktop/api/oaidl/nf-oaidl-irecordinfo-recorddestroy void RecordDestroy(IntPtr pvRecord); } /// <summary> /// Ensures that error information can be propagated up the call chain correctly. Automation objects that use the error handling /// interfaces must implement <c>ISupportErrorInfo</c>. /// </summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-isupporterrorinfo [PInvokeData("oaidl.h", MSDNShortId = "42d33066-36b4-4a5b-aa5d-46682e560f32")] [ComImport, Guid("DF0B3D60-548F-101B-8E65-08002B2BD119"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ISupportErrorInfo { /// <summary>Indicates whether an interface supports the IErrorInfo interface.</summary> /// <param name="riid">An interface identifier (IID).</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>The interface supports IErrorInfo.</term> /// </item> /// <item> /// <term>S_FALSE</term> /// <term>The interface does not support IErrorInfo.</term> /// </item> /// </list> /// </returns> /// <remarks> /// <para>Objects that support the IErrorInfo interface must also implement this interface.</para> /// <para> /// Programs that receive an error return value should call <c>QueryInterface</c> to get a pointer to the /// ISupportErrorInfointerface, and then call <c>InterfaceSupportsErrorInfo</c> with the riid of the interface that returned the /// return value. If <c>InterfaceSupportsErrorInfo</c> returns S_FALSE, then the error object does not represent an error /// returned from the caller, but from somewhere else. In this case, the error object can be considered incorrect and should be discarded. /// </para> /// <para>If ISupportErrorInfo returns S_OK, use the GetErrorInfo function to get a pointer to the error object.</para> /// <para> /// For an example that demonstrates implementing <c>InterfaceSupportsErrorInfo</c>, see the ErrorInfo.cpp file in the COM /// Fundamentals Lines sample. /// </para> /// </remarks> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-isupporterrorinfo-interfacesupportserrorinfo HRESULT // InterfaceSupportsErrorInfo(REFIID riid); [PreserveSig] HRESULT InterfaceSupportsErrorInfo(in Guid riid); } /// <summary> /// Enables clients to subscribe to type change notifications on objects that implement the ITypeInfo, ITypeInfo2, ICreateTypeInfo, /// and ICreateTypeInfo2 interfaces. When ITypeChangeEvents is implemented on an object, it acts as an incoming interface that /// enables the object to receive calls from external clients and engage in bidirectional communication with those clients. For more /// information, see Events in COM and Connectable Objects. /// </summary> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nn-oaidl-itypechangeevents [PInvokeData("oaidl.h", MSDNShortId = "5e286a4b-b36b-40d6-9a39-d572086e5a2d")] [ComImport, Guid("00020410-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] public interface ITypeChangeEvents { /// <summary>Raised when a request has been made to change a type. The change can be disallowed.</summary> /// <param name="changeKind"> /// <para>The type of change.</para> /// <para>CHANGEKIND_ADDMEMBER</para> /// <para>CHANGEKIND_DELETEMEMBER</para> /// <para>CHANGEKIND_SETNAMES</para> /// <para>CHANGEKIND_SETDOCUMENTATION</para> /// <para>CHANGEKIND_GENERAL</para> /// <para>CHANGEKIND_INVALIDATE</para> /// <para>CHANGEKIND_CHANGEFAILED</para> /// </param> /// <param name="pTInfoBefore"> /// An object that implements the ITypeInfo, ITypeInfo2, ICreateTypeInfo, or ICreateTypeInfo2 interface and that contains the /// type information before the change was made. The client subscribes to this object to receive notifications about any changes. /// </param> /// <param name="pStrName">The name of the change. This value may be null.</param> /// <param name="pfCancel">False to disallow the change; otherwise, true.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-itypechangeevents-requesttypechange HRESULT // RequestTypeChange( CHANGEKIND changeKind, ITypeInfo *pTInfoBefore, LPOLESTR pStrName, INT *pfCancel ); [PreserveSig] HRESULT RequestTypeChange([In] CHANGEKIND changeKind, [In] ITypeInfo pTInfoBefore, [MarshalAs(UnmanagedType.LPWStr)] string pStrName, out int pfCancel); /// <summary>Raised after a type has been changed.</summary> /// <param name="changeKind"> /// <para>The type of change.</para> /// <para>CHANGEKIND_ADDMEMBER</para> /// <para>CHANGEKIND_DELETEMEMBER</para> /// <para>CHANGEKIND_SETNAMES</para> /// <para>CHANGEKIND_SETDOCUMENTATION</para> /// <para>CHANGEKIND_GENERAL</para> /// <para>CHANGEKIND_INVALIDATE</para> /// <para>CHANGEKIND_CHANGEFAILED</para> /// </param> /// <param name="pTInfoAfter"> /// An object that implements the ITypeInfo, ITypeInfo2, ICreateTypeInfo, or ICreateTypeInfo2 interface and that contains the /// type information before the change was made. The client subscribes to this object to receive notifications about any changes. /// </param> /// <param name="pStrName">The name of the change. This value may be null.</param> /// <returns> /// <para>This method can return one of these values.</para> /// <list type="table"> /// <listheader> /// <term>Return code</term> /// <term>Description</term> /// </listheader> /// <item> /// <term>S_OK</term> /// <term>Success.</term> /// </item> /// <item> /// <term>E_INVALIDARG</term> /// <term>One or more of the arguments is not valid.</term> /// </item> /// <item> /// <term>E_OUTOFMEMORY</term> /// <term>Insufficient memory to complete the operation.</term> /// </item> /// </list> /// </returns> // https://docs.microsoft.com/en-us/windows/win32/api/oaidl/nf-oaidl-itypechangeevents-aftertypechange HRESULT AfterTypeChange( // CHANGEKIND changeKind, ITypeInfo *pTInfoAfter, LPOLESTR pStrName ); [PreserveSig] HRESULT AfterTypeChange([In] CHANGEKIND changeKind, [In] ITypeInfo pTInfoAfter, [MarshalAs(UnmanagedType.LPWStr)] string pStrName); } } }
42.854483
204
0.654876
[ "MIT" ]
DigitalPlatform/Vanara
PInvoke/Ole/OleAut32/OAIdl.Interfaces.cs
186,425
C#
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; namespace Sereno.STS.UI.Pages { public class IndexModel : PageModel { public IActionResult OnGet() { return this.Page(); } } }
19.307692
42
0.625498
[ "MIT" ]
sergiomcalzada/sereno
src/Sereno.STS.UI/Pages/Index.cshtml.cs
253
C#
using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Windows; // Le informazioni generali relative a un assembly sono controllate dal seguente // set di attributi. Modificare i valori di questi attributi per modificare le informazioni // associate a un assembly. [assembly: AssemblyTitle("Dmeta")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Dmeta")] [assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili // ai componenti COM. Se è necessario accedere a un tipo in questo assembly da // COM, impostare su true l'attributo ComVisible per tale tipo. [assembly: ComVisible(false)] //Per iniziare a creare applicazioni localizzabili, impostare //<UICulture>CultureYouAreCodingWith</UICulture> nel file .csproj //all'interno di un <PropertyGroup>. Ad esempio, se si utilizza l'inglese (Stati Uniti) //nei file di origine, impostare <UICulture> su en-US. Rimuovere quindi il commento dall'attributo //NeutralResourceLanguage riportato di seguito. Aggiornare "en-US" nella //riga sottostante in modo che corrisponda all'impostazione UICulture nel file di progetto. //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] [assembly: ThemeInfo( ResourceDictionaryLocation.None, //dove si trovano i dizionari delle risorse specifiche del tema //(da usare se nella pagina non viene trovata una risorsa, // oppure nei dizionari delle risorse dell'applicazione) ResourceDictionaryLocation.SourceAssembly //dove si trova il dizionario delle risorse generiche //(da usare se nella pagina non viene trovata una risorsa, // nell'applicazione o nei dizionari delle risorse specifiche del tema) )] // Le informazioni sulla versione di un assembly sono costituite dai seguenti quattro valori: // // Versione principale // Versione secondaria // Numero di build // Revisione // // È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build // usando l'asterisco '*' come illustrato di seguito: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")]
46.928571
127
0.726788
[ "MIT" ]
eti88/dmeta
Dmeta/Properties/AssemblyInfo.cs
2,633
C#
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. #if !UNIX using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Management.Automation; using System.Management.Automation.Internal; using System.Net; using System.Reflection; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using Microsoft.Win32; using Microsoft.PowerShell.Commands.Internal; using Microsoft.Management.Infrastructure; using Microsoft.Management.Infrastructure.Options; using System.Linq; using Dbg = System.Management.Automation; using Microsoft.PowerShell.CoreClr.Stubs; // FxCop suppressions for resource strings: [module: SuppressMessage("Microsoft.Naming", "CA1703:ResourceStringsShouldBeSpelledCorrectly", Scope = "resource", Target = "ComputerResources.resources", MessageId = "unjoined")] [module: SuppressMessage("Microsoft.Naming", "CA1701:ResourceStringCompoundWordsShouldBeCasedCorrectly", Scope = "resource", Target = "ComputerResources.resources", MessageId = "UpTime")] namespace Microsoft.PowerShell.Commands { #region Restart-Computer /// <summary> /// This exception is thrown when the timeout expires before a computer finishes restarting /// </summary> [Serializable] public sealed class RestartComputerTimeoutException : RuntimeException { /// <summary> /// Name of the computer that is restarting /// </summary> public string ComputerName { get; private set; } /// <summary> /// The timeout value specified by the user. It indicates the seconds to wait before timeout. /// </summary> public int Timeout { get; private set; } /// <summary> /// Construct a RestartComputerTimeoutException. /// </summary> /// <param name="computerName"></param> /// <param name="timeout"></param> /// <param name="message"></param> /// <param name="errorId"></param> internal RestartComputerTimeoutException(string computerName, int timeout, string message, string errorId) : base(message) { SetErrorId(errorId); SetErrorCategory(ErrorCategory.OperationTimeout); ComputerName = computerName; Timeout = timeout; } /// <summary> /// Construct a RestartComputerTimeoutException /// </summary> public RestartComputerTimeoutException() : base() { } /// <summary> /// Constructs a RestartComputerTimeoutException /// </summary> /// <param name="message"> /// The message used in the exception. /// </param> public RestartComputerTimeoutException(string message) : base(message) { } /// <summary> /// Constructs a RestartComputerTimeoutException /// </summary> /// <param name="message"> /// The message used in the exception. /// </param> /// <param name="innerException"> /// An exception that led to this exception. /// </param> public RestartComputerTimeoutException(string message, Exception innerException) : base(message, innerException) { } #region Serialization /// <summary> /// Serialization constructor for class RestartComputerTimeoutException /// </summary> /// <param name="info"> /// serialization information /// </param> /// <param name="context"> /// streaming context /// </param> private RestartComputerTimeoutException(SerializationInfo info, StreamingContext context) : base(info, context) { if (info == null) { throw new PSArgumentNullException("info"); } ComputerName = info.GetString("ComputerName"); Timeout = info.GetInt32("Timeout"); } /// <summary> /// Serializes the RestartComputerTimeoutException. /// </summary> /// <param name="info"> /// serialization information /// </param> /// <param name="context"> /// streaming context /// </param> [SecurityPermission(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { throw new PSArgumentNullException("info"); } base.GetObjectData(info, context); info.AddValue("ComputerName", ComputerName); info.AddValue("Timeout", Timeout); } #endregion Serialization } /// <summary> /// Defines the services that Restart-Computer can wait on /// </summary> [SuppressMessage("Microsoft.Design", "CA1027:MarkEnumsWithFlags")] public enum WaitForServiceTypes { /// <summary> /// Wait for the WMI service to be ready /// </summary> Wmi = 0x0, /// <summary> /// Wait for the WinRM service to be ready /// </summary> WinRM = 0x1, /// <summary> /// Wait for the PowerShell to be ready /// </summary> PowerShell = 0x2, } /// <summary> /// Restarts the computer /// </summary> [Cmdlet(VerbsLifecycle.Restart, "Computer", SupportsShouldProcess = true, DefaultParameterSetName = DefaultParameterSet, HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135253", RemotingCapability = RemotingCapability.OwnedByCommand)] public class RestartComputerCommand : PSCmdlet, IDisposable { #region "Parameters and PrivateData" private const string DefaultParameterSet = "DefaultSet"; private const int forcedReboot = 6; // see https://msdn.microsoft.com/library/aa394058(v=vs.85).aspx /// <summary> /// The authentication options for CIM_WSMan connection /// </summary> [Parameter(ParameterSetName = DefaultParameterSet)] [ValidateSet( "Default", "Basic", "Negotiate", // can be used with and without credential (without -> PSRP mapped to NegotiateWithImplicitCredential) "CredSSP", "Digest", "Kerberos")] // can be used with explicit or implicit credential [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] public string WsmanAuthentication { get; set; } /// <summary> /// Specifies the computer (s)Name on which this command is executed. /// When this parameter is omitted, this cmdlet restarts the local computer. /// Type the NETBIOS name, IP address, or fully-qualified domain name of one /// or more computers in a comma-separated list. To specify the local computer, type the computername or "localhost". /// </summary> [Parameter(Position = 0, ValueFromPipeline = true, ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] [Alias("CN", "__SERVER", "Server", "IPAddress")] public String[] ComputerName { get; set; } = new string[] { "." }; private List<string> _validatedComputerNames = new List<string>(); private readonly List<string> _waitOnComputers = new List<string>(); private readonly HashSet<string> _uniqueComputerNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase); /// <summary> /// The following is the definition of the input parameter "Credential". /// Specifies a user account that has permission to perform this action. Type a /// user-name, such as "User01" or "Domain01\User01", or enter a PSCredential /// object, such as one from the Get-Credential cmdlet /// </summary> [Parameter(Position = 1)] [ValidateNotNullOrEmpty] [Credential] public PSCredential Credential { get; set; } /// <summary> /// Using Force in conjunction with Reboot on a /// remote computer immediately reboots the remote computer. /// </summary> [Parameter] [Alias("f")] public SwitchParameter Force { get; set; } /// <summary> /// Specify the Wait parameter. Prompt will be blocked is the Timeout is not 0 /// </summary> [Parameter(ParameterSetName = DefaultParameterSet)] public SwitchParameter Wait { get; set; } /// <summary> /// Specify the Timeout parameter. /// Negative value indicates wait infinitely. /// Positive value indicates the seconds to wait before timeout. /// </summary> [Parameter(ParameterSetName = DefaultParameterSet)] [Alias("TimeoutSec")] [ValidateRange(-1, int.MaxValue)] public int Timeout { get { return _timeout; } set { _timeout = value; _timeoutSpecified = true; } } private int _timeout = -1; private bool _timeoutSpecified = false; /// <summary> /// Specify the For parameter. /// Wait for the specific service before unblocking the prompt. /// </summary> [Parameter(ParameterSetName = DefaultParameterSet)] public WaitForServiceTypes For { get { return _waitFor; } set { _waitFor = value; _waitForSpecified = true; } } private WaitForServiceTypes _waitFor = WaitForServiceTypes.PowerShell; private bool _waitForSpecified = false; /// <summary> /// Specify the Delay parameter. /// The specific time interval (in second) to wait between network pings or service queries. /// </summary> [Parameter(ParameterSetName = DefaultParameterSet)] [ValidateRange(1, Int16.MaxValue)] public Int16 Delay { get { return (Int16)_delay; } set { _delay = value; _delaySpecified = true; } } private int _delay = 5; private bool _delaySpecified = false; /// <summary> /// Script to test if the PowerShell is ready /// </summary> private const string TestPowershellScript = @" $array = @($input) $result = @{} foreach ($computerName in $array[1]) { $ret = $null $arguments = @{ ComputerName = $computerName ScriptBlock = { $true } SessionOption = NewPSSessionOption -NoMachineProfile ErrorAction = 'SilentlyContinue' } if ( $null -ne $array[0] ) { $arguments['Credential'] = $array[0] } $result[$computerName] = (Invoke-Command @arguments) -as [bool] } $result "; /// <summary> /// The indicator to use when show progress /// </summary> private string[] _indicator = { "|", "/", "-", "\\" }; /// <summary> /// The activity id /// </summary> private int _activityId; /// <summary> /// After call 'Shutdown' on the target computer, wait a few /// seconds for the restart to begin. /// </summary> private const int SecondsToWaitForRestartToBegin = 25; /// <summary> /// Actual time out in seconds /// </summary> private int _timeoutInMilliseconds; /// <summary> /// Indicate to exit /// </summary> private bool _exit, _timeUp; private readonly CancellationTokenSource _cancel = new CancellationTokenSource(); /// <summary> /// A waithandler to wait on. Current thread will wait on it during the delay interval. /// </summary> private readonly ManualResetEventSlim _waitHandler = new ManualResetEventSlim(false); private readonly Dictionary<string, ComputerInfo> _computerInfos = new Dictionary<string, ComputerInfo>(StringComparer.OrdinalIgnoreCase); // CLR 4.0 Port note - use https://msdn.microsoft.com/library/system.net.networkinformation.ipglobalproperties.hostname(v=vs.110).aspx private readonly string _shortLocalMachineName = Dns.GetHostName(); // And for this, use PsUtils.GetHostname() private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync(string.Empty).Result.HostName; private int _percent; private string _status; private string _activity; private Timer _timer; private System.Management.Automation.PowerShell _powershell; private const string StageVerification = "VerifyStage"; private const string WmiConnectionTest = "WMI"; private const string WinrmConnectionTest = "WinRM"; private const string PowerShellConnectionTest = "PowerShell"; #endregion "parameters and PrivateData" #region "IDisposable Members" /// <summary> /// Dispose Method /// </summary> public void Dispose() { this.Dispose(true); // Use SuppressFinalize in case a subclass // of this type implements a finalizer. GC.SuppressFinalize(this); } /// <summary> /// Dispose Method. /// </summary> /// <param name="disposing"></param> public void Dispose(bool disposing) { if (disposing) { if (_timer != null) { _timer.Dispose(); } _waitHandler.Dispose(); _cancel.Dispose(); if (_powershell != null) { _powershell.Dispose(); } } } #endregion "IDisposable Members" #region "Private Methods" /// <summary> /// Validate parameters for 'DefaultSet' /// 1. When the Wait is specified, the computername cannot contain the local machine /// 2. If the local machine is present, make sure it is at the end of the list (so the remote ones get restarted before the local machine reboot). /// </summary> private void ValidateComputerNames() { bool containLocalhost = false; _validatedComputerNames.Clear(); foreach (string name in ComputerName) { ErrorRecord error = null; string targetComputerName = ComputerWMIHelper.ValidateComputerName(name, _shortLocalMachineName, _fullLocalMachineName, ref error); if (targetComputerName == null) { if (error != null) { WriteError(error); } continue; } if (targetComputerName.Equals(ComputerWMIHelper.localhostStr, StringComparison.OrdinalIgnoreCase)) { containLocalhost = true; } else if (!_uniqueComputerNames.Contains(targetComputerName)) { _validatedComputerNames.Add(targetComputerName); _uniqueComputerNames.Add(targetComputerName); } } // Force wait with a test hook even if we're on the local computer if (!InternalTestHooks.TestWaitStopComputer && Wait && containLocalhost) { // The local machine will be ignored, and an error will be emitted. InvalidOperationException ex = new InvalidOperationException(ComputerResources.CannotWaitLocalComputer); WriteError(new ErrorRecord(ex, "CannotWaitLocalComputer", ErrorCategory.InvalidOperation, null)); containLocalhost = false; } // Add the localhost to the end of the list, so we will restart remote machines // before we restart the local one. if (containLocalhost) { _validatedComputerNames.Add(ComputerWMIHelper.localhostStr); } } /// <summary> /// Write out progress /// </summary> /// <param name="activity"></param> /// <param name="status"></param> /// <param name="percent"></param> /// <param name="progressRecordType"></param> private void WriteProgress(string activity, string status, int percent, ProgressRecordType progressRecordType) { ProgressRecord progress = new ProgressRecord(_activityId, activity, status); progress.PercentComplete = percent; progress.RecordType = progressRecordType; WriteProgress(progress); } /// <summary> /// Calculate the progress percentage /// </summary> /// <param name="currentStage"></param> /// <returns></returns> private int CalculateProgressPercentage(string currentStage) { switch (currentStage) { case StageVerification: return _waitFor.Equals(WaitForServiceTypes.Wmi) || _waitFor.Equals(WaitForServiceTypes.WinRM) ? 33 : 20; case WmiConnectionTest: return _waitFor.Equals(WaitForServiceTypes.Wmi) ? 66 : 40; case WinrmConnectionTest: return _waitFor.Equals(WaitForServiceTypes.WinRM) ? 66 : 60; case PowerShellConnectionTest: return 80; default: break; } Dbg.Diagnostics.Assert(false, "CalculateProgressPercentage should never hit the default case"); return 0; } /// <summary> /// Event handler for the timer /// </summary> /// <param name="s"></param> private void OnTimedEvent(object s) { _exit = _timeUp = true; _cancel.Cancel(); _waitHandler.Set(); if (_powershell != null) { _powershell.Stop(); _powershell.Dispose(); } } private class ComputerInfo { internal string LastBootUpTime; internal bool RebootComplete; } private List<string> TestRestartStageUsingWsman(IEnumerable<string> computerNames, List<string> nextTestList, CancellationToken token) { var restartStageTestList = new List<string>(); var operationOptions = new CimOperationOptions { Timeout = TimeSpan.FromMilliseconds(2000), CancellationToken = token }; foreach (var computer in computerNames) { try { if (token.IsCancellationRequested) { break; } using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(computer, Credential, WsmanAuthentication, token, this)) { bool itemRetrieved = false; IEnumerable<CimInstance> mCollection = cimSession.QueryInstances( ComputerWMIHelper.CimOperatingSystemNamespace, ComputerWMIHelper.CimQueryDialect, "Select * from " + ComputerWMIHelper.WMI_Class_OperatingSystem, operationOptions); foreach (CimInstance os in mCollection) { itemRetrieved = true; string newLastBootUpTime = os.CimInstanceProperties["LastBootUpTime"].Value.ToString(); string oldLastBootUpTime = _computerInfos[computer].LastBootUpTime; if (string.Compare(newLastBootUpTime, oldLastBootUpTime, StringComparison.OrdinalIgnoreCase) != 0) { _computerInfos[computer].RebootComplete = true; nextTestList.Add(computer); } else { restartStageTestList.Add(computer); } } if (!itemRetrieved) { restartStageTestList.Add(computer); } } } catch (CimException) { restartStageTestList.Add(computer); } catch (Exception) { restartStageTestList.Add(computer); } } return restartStageTestList; } private List<string> SetUpComputerInfoUsingWsman(IEnumerable<string> computerNames, CancellationToken token) { var validComputerNameList = new List<string>(); var operationOptions = new CimOperationOptions { Timeout = TimeSpan.FromMilliseconds(2000), CancellationToken = token }; foreach (var computer in computerNames) { try { using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(computer, Credential, WsmanAuthentication, token, this)) { bool itemRetrieved = false; IEnumerable<CimInstance> mCollection = cimSession.QueryInstances( ComputerWMIHelper.CimOperatingSystemNamespace, ComputerWMIHelper.CimQueryDialect, "Select * from " + ComputerWMIHelper.WMI_Class_OperatingSystem, operationOptions); foreach (CimInstance os in mCollection) { itemRetrieved = true; if (!_computerInfos.ContainsKey(computer)) { var info = new ComputerInfo { LastBootUpTime = os.CimInstanceProperties["LastBootUpTime"].Value.ToString(), RebootComplete = false }; _computerInfos.Add(computer, info); validComputerNameList.Add(computer); } } if (!itemRetrieved) { string errMsg = StringUtil.Format(ComputerResources.RestartComputerSkipped, computer, ComputerResources.CannotGetOperatingSystemObject); var error = new ErrorRecord(new InvalidOperationException(errMsg), "RestartComputerSkipped", ErrorCategory.OperationStopped, computer); this.WriteError(error); } } } catch (CimException ex) { string errMsg = StringUtil.Format(ComputerResources.RestartComputerSkipped, computer, ex.Message); var error = new ErrorRecord(new InvalidOperationException(errMsg), "RestartComputerSkipped", ErrorCategory.OperationStopped, computer); this.WriteError(error); } catch (Exception ex) { string errMsg = StringUtil.Format(ComputerResources.RestartComputerSkipped, computer, ex.Message); var error = new ErrorRecord(new InvalidOperationException(errMsg), "RestartComputerSkipped", ErrorCategory.OperationStopped, computer); this.WriteError(error); } } return validComputerNameList; } private void WriteOutTimeoutError(IEnumerable<string> computerNames) { const string errorId = "RestartComputerTimeout"; foreach (string computer in computerNames) { string errorMsg = StringUtil.Format(ComputerResources.RestartcomputerFailed, computer, ComputerResources.TimeoutError); var exception = new RestartComputerTimeoutException(computer, Timeout, errorMsg, errorId); var error = new ErrorRecord(exception, errorId, ErrorCategory.OperationTimeout, computer); if (!InternalTestHooks.TestWaitStopComputer) { WriteError(error); } } } #endregion "Private Methods" #region "Internal Methods" internal static List<string> TestWmiConnectionUsingWsman(List<string> computerNames, List<string> nextTestList, CancellationToken token, PSCredential credential, string wsmanAuthentication, PSCmdlet cmdlet) { // Check if the WMI service "Winmgmt" is started const string wmiServiceQuery = "Select * from " + ComputerWMIHelper.WMI_Class_Service + " Where name = 'Winmgmt'"; var wmiTestList = new List<string>(); var operationOptions = new CimOperationOptions { Timeout = TimeSpan.FromMilliseconds(2000), CancellationToken = token }; foreach (var computer in computerNames) { try { if (token.IsCancellationRequested) { break; } using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(computer, credential, wsmanAuthentication, token, cmdlet)) { bool itemRetrieved = false; IEnumerable<CimInstance> mCollection = cimSession.QueryInstances( ComputerWMIHelper.CimOperatingSystemNamespace, ComputerWMIHelper.CimQueryDialect, wmiServiceQuery, operationOptions); foreach (CimInstance service in mCollection) { itemRetrieved = true; if (LanguagePrimitives.IsTrue(service.CimInstanceProperties["Started"].Value)) { nextTestList.Add(computer); } else { wmiTestList.Add(computer); } } if (!itemRetrieved) { wmiTestList.Add(computer); } } } catch (CimException) { wmiTestList.Add(computer); } catch (Exception) { wmiTestList.Add(computer); } } return wmiTestList; } /// <summary> /// Test the PowerShell state for the restarting computer /// </summary> /// <param name="computerNames"></param> /// <param name="nextTestList"></param> /// <param name="powershell"></param> /// <param name="credential"></param> /// <returns></returns> internal static List<string> TestPowerShell(List<string> computerNames, List<string> nextTestList, System.Management.Automation.PowerShell powershell, PSCredential credential) { List<string> psList = new List<string>(); try { Collection<PSObject> psObjectCollection = powershell.Invoke(new object[] { credential, computerNames.ToArray() }); if (psObjectCollection == null) { Dbg.Diagnostics.Assert(false, "This should never happen. Invoke should never return null."); } // If ^C or timeout happens when we are in powershell.Invoke(), the psObjectCollection might be empty if (psObjectCollection.Count == 0) { return computerNames; } object result = PSObject.Base(psObjectCollection[0]); Hashtable data = result as Hashtable; Dbg.Diagnostics.Assert(data != null, "data should never be null"); Dbg.Diagnostics.Assert(data.Count == computerNames.Count, "data should contain results for all computers in computerNames"); foreach (string computer in computerNames) { if (LanguagePrimitives.IsTrue(data[computer])) { nextTestList.Add(computer); } else { psList.Add(computer); } } } catch (PipelineStoppedException) { // powershell.Stop() is invoked because timeout expires, or Ctrl+C is pressed } catch (ObjectDisposedException) { // powershell.dispose() is invoked because timeout expires, or Ctrl+C is pressed } return psList; } #endregion "Internal Methods" #region "Overrides" /// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { // Timeout, For, Delay, Progress cannot be present if Wait is not present if ((_timeoutSpecified || _waitForSpecified || _delaySpecified) && !Wait) { InvalidOperationException ex = new InvalidOperationException(ComputerResources.RestartComputerInvalidParameter); ThrowTerminatingError(new ErrorRecord(ex, "RestartComputerInvalidParameter", ErrorCategory.InvalidOperation, null)); } if (Wait) { _activityId = (new Random()).Next(); if (_timeout == -1 || _timeout >= int.MaxValue / 1000) { _timeoutInMilliseconds = int.MaxValue; } else { _timeoutInMilliseconds = _timeout * 1000; } // We don't support combined service types for now switch (_waitFor) { case WaitForServiceTypes.Wmi: case WaitForServiceTypes.WinRM: break; case WaitForServiceTypes.PowerShell: _powershell = System.Management.Automation.PowerShell.Create(); _powershell.AddScript(TestPowershellScript); break; default: InvalidOperationException ex = new InvalidOperationException(ComputerResources.NoSupportForCombinedServiceType); ErrorRecord error = new ErrorRecord(ex, "NoSupportForCombinedServiceType", ErrorCategory.InvalidOperation, (int)_waitFor); ThrowTerminatingError(error); break; } } } /// <summary> /// ProcessRecord method. /// </summary> [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] protected override void ProcessRecord() { // Validate parameters ValidateComputerNames(); object[] flags = new object[] { 2, 0 }; if (Force) flags[0] = forcedReboot; if (ParameterSetName.Equals(DefaultParameterSet, StringComparison.OrdinalIgnoreCase)) { if (Wait && _timeout != 0) { _validatedComputerNames = SetUpComputerInfoUsingWsman(_validatedComputerNames, _cancel.Token); } foreach (string computer in _validatedComputerNames) { bool isLocal = false; string compname; if (computer.Equals("localhost", StringComparison.OrdinalIgnoreCase)) { compname = _shortLocalMachineName; isLocal = true; } else { compname = computer; } // Generate target and action strings string action = StringUtil.Format( ComputerResources.RestartComputerAction, isLocal ? ComputerResources.LocalShutdownPrivilege : ComputerResources.RemoteShutdownPrivilege); string target = isLocal ? StringUtil.Format(ComputerResources.DoubleComputerName, "localhost", compname) : compname; if (!ShouldProcess(target, action)) { continue; } bool isSuccess = ComputerWMIHelper.InvokeWin32ShutdownUsingWsman(this, isLocal, compname, flags, Credential, WsmanAuthentication, ComputerResources.RestartcomputerFailed, "RestartcomputerFailed", _cancel.Token); if (isSuccess && Wait && _timeout != 0) { _waitOnComputers.Add(computer); } }//end foreach if (_waitOnComputers.Count > 0) { var restartStageTestList = new List<string>(_waitOnComputers); var wmiTestList = new List<string>(); var winrmTestList = new List<string>(); var psTestList = new List<string>(); var allDoneList = new List<string>(); bool isForWmi = _waitFor.Equals(WaitForServiceTypes.Wmi); bool isForWinRm = _waitFor.Equals(WaitForServiceTypes.WinRM); bool isForPowershell = _waitFor.Equals(WaitForServiceTypes.PowerShell); int indicatorIndex = 0; int machineCompleteRestart = 0; int actualDelay = SecondsToWaitForRestartToBegin; bool first = true; bool waitComplete = false; _percent = 0; _status = ComputerResources.WaitForRestartToBegin; _activity = _waitOnComputers.Count == 1 ? StringUtil.Format(ComputerResources.RestartSingleComputerActivity, _waitOnComputers[0]) : ComputerResources.RestartMultipleComputersActivity; _timer = new Timer(OnTimedEvent, null, _timeoutInMilliseconds, System.Threading.Timeout.Infinite); while (true) { int loopCount = actualDelay * 4; // (delay * 1000)/250ms while (loopCount > 0) { WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing); loopCount--; _waitHandler.Wait(250); if (_exit) { break; } } if (first) { actualDelay = _delay; first = false; if (_waitOnComputers.Count > 1) { _status = StringUtil.Format(ComputerResources.WaitForMultipleComputers, machineCompleteRestart, _waitOnComputers.Count); WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing); } } do { // Test restart stage. // We check if the target machine has already rebooted by querying the LastBootUpTime from the Win32_OperatingSystem object. // So after this step, we are sure that both the Network and the WMI or WinRM service have already come up. if (_exit) { break; } if (restartStageTestList.Count > 0) { if (_waitOnComputers.Count == 1) { _status = ComputerResources.VerifyRebootStage; _percent = CalculateProgressPercentage(StageVerification); WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing); } List<string> nextTestList = (isForWmi || isForPowershell) ? wmiTestList : winrmTestList; restartStageTestList = TestRestartStageUsingWsman(restartStageTestList, nextTestList, _cancel.Token); } // Test WMI service if (_exit) { break; } if (wmiTestList.Count > 0) { // This statement block executes for both CLRs. // In the "full" CLR, it serves as the else case. { if (_waitOnComputers.Count == 1) { _status = ComputerResources.WaitForWMI; _percent = CalculateProgressPercentage(WmiConnectionTest); WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing); } wmiTestList = TestWmiConnectionUsingWsman(wmiTestList, winrmTestList, _cancel.Token, Credential, WsmanAuthentication, this); } } if (isForWmi) { break; } // Test WinRM service if (_exit) { break; } if (winrmTestList.Count > 0) { // This statement block executes for both CLRs. // In the "full" CLR, it serves as the else case. { // CIM-WSMan in use. In this case, restart stage checking is done by using WMIv2, // so the WinRM service on the target machine is already up at this point. psTestList.AddRange(winrmTestList); winrmTestList.Clear(); if (_waitOnComputers.Count == 1) { // This is to simulate the test for WinRM service _status = ComputerResources.WaitForWinRM; _percent = CalculateProgressPercentage(WinrmConnectionTest); loopCount = actualDelay * 4; // (delay * 1000)/250ms while (loopCount > 0) { WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing); loopCount--; _waitHandler.Wait(250); if (_exit) { break; } } } } } if (isForWinRm) { break; } // Test PowerShell if (_exit) { break; } if (psTestList.Count > 0) { if (_waitOnComputers.Count == 1) { _status = ComputerResources.WaitForPowerShell; _percent = CalculateProgressPercentage(PowerShellConnectionTest); WriteProgress(_indicator[(indicatorIndex++) % 4] + _activity, _status, _percent, ProgressRecordType.Processing); } psTestList = TestPowerShell(psTestList, allDoneList, _powershell, this.Credential); } } while (false); // if time is up or Ctrl+c is typed, break out if (_exit) { break; } // Check if the restart completes switch (_waitFor) { case WaitForServiceTypes.Wmi: waitComplete = (winrmTestList.Count == _waitOnComputers.Count); machineCompleteRestart = winrmTestList.Count; break; case WaitForServiceTypes.WinRM: waitComplete = (psTestList.Count == _waitOnComputers.Count); machineCompleteRestart = psTestList.Count; break; case WaitForServiceTypes.PowerShell: waitComplete = (allDoneList.Count == _waitOnComputers.Count); machineCompleteRestart = allDoneList.Count; break; } // Wait is done or time is up if (waitComplete || _exit) { if (waitComplete) { _status = ComputerResources.RestartComplete; WriteProgress(_indicator[indicatorIndex % 4] + _activity, _status, 100, ProgressRecordType.Completed); _timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); } break; } if (_waitOnComputers.Count > 1) { _status = StringUtil.Format(ComputerResources.WaitForMultipleComputers, machineCompleteRestart, _waitOnComputers.Count); _percent = machineCompleteRestart * 100 / _waitOnComputers.Count; } }// end while(true) if (_timeUp) { // The timeout expires. Write out timeout error messages for the computers that haven't finished restarting do { if (restartStageTestList.Count > 0) { WriteOutTimeoutError(restartStageTestList); } if (wmiTestList.Count > 0) { WriteOutTimeoutError(wmiTestList); } // Wait for WMI. All computers that finished restarting are put in "winrmTestList" if (isForWmi) { break; } // Wait for WinRM. All computers that finished restarting are put in "psTestList" if (winrmTestList.Count > 0) { WriteOutTimeoutError(winrmTestList); } if (isForWinRm) { break; } if (psTestList.Count > 0) { WriteOutTimeoutError(psTestList); } // Wait for PowerShell. All computers that finished restarting are put in "allDoneList" } while (false); } }// end if(waitOnComputer.Count > 0) }//end DefaultParameter }//End Processrecord /// <summary> /// to implement ^C /// </summary> protected override void StopProcessing() { _exit = true; _cancel.Cancel(); _waitHandler.Set(); if (_timer != null) { _timer.Change(System.Threading.Timeout.Infinite, System.Threading.Timeout.Infinite); } if (_powershell != null) { _powershell.Stop(); _powershell.Dispose(); } } #endregion "Overrides" } #endregion Restart-Computer #region Stop-Computer /// <summary> /// cmdlet to stop computer /// </summary> [Cmdlet(VerbsLifecycle.Stop, "Computer", SupportsShouldProcess = true, HelpUri = "https://go.microsoft.com/fwlink/?LinkID=135263", RemotingCapability = RemotingCapability.SupportedByCommand)] public sealed class StopComputerCommand : PSCmdlet, IDisposable { #region Private Members private readonly CancellationTokenSource _cancel = new CancellationTokenSource(); private const int forcedShutdown = 5; // See https://msdn.microsoft.com/library/aa394058(v=vs.85).aspx #endregion #region "Parameters" /// <summary> /// The authentication options for CIM_WSMan connection /// </summary> [Parameter] [ValidateSet( "Default", "Basic", "Negotiate", // can be used with and without credential (without -> PSRP mapped to NegotiateWithImplicitCredential) "CredSSP", "Digest", "Kerberos")] // can be used with explicit or implicit credential [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] public string WsmanAuthentication { get; set; } = "Default"; /// <summary> /// The following is the definition of the input parameter "ComputerName". /// Value of the address requested. The form of the value can be either the /// computer name ("wxyz1234"), IPv4 address ("192.168.177.124"), or IPv6 /// address ("2010:836B:4179::836B:4179"). /// </summary> [Parameter(Position = 0, ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")] [Alias("CN", "__SERVER", "Server", "IPAddress")] public String[] ComputerName { get; set; } = new string[] { "." }; /// <summary> /// The following is the definition of the input parameter "Credential". /// Specifies a user account that has permission to perform this action. Type a /// user-name, such as "User01" or "Domain01\User01", or enter a PSCredential /// object, such as one from the Get-Credential cmdlet /// </summary> [Parameter(Position = 1)] [ValidateNotNullOrEmpty] [Credential] public PSCredential Credential { get; set; } /// <summary> /// Force the operation to take place if possible /// </summary> [Parameter] public SwitchParameter Force { get; set; } = false; #endregion "parameters" #region "IDisposable Members" /// <summary> /// Dispose Method /// </summary> public void Dispose() { try { _cancel.Dispose(); } catch (ObjectDisposedException) { } } #endregion "IDisposable Members" #region "Overrides" /// <summary> /// ProcessRecord /// </summary> [SuppressMessage("Microsoft.Maintainability", "CA1506:AvoidExcessiveClassCoupling")] protected override void ProcessRecord() { object[] flags = new object[] { 1, 0 }; if (Force.IsPresent) flags[0] = forcedShutdown; ProcessWSManProtocol(flags); }//End Processrecord /// <summary> /// to implement ^C /// </summary> protected override void StopProcessing() { try { _cancel.Cancel(); } catch (ObjectDisposedException) { } catch (AggregateException) { } } #endregion "Overrides" #region Private Methods private void ProcessWSManProtocol(object[] flags) { foreach (string computer in ComputerName) { string compname = string.Empty; string strLocal = string.Empty; bool isLocalHost = false; if (_cancel.Token.IsCancellationRequested) { break; } if ((computer.Equals("localhost", StringComparison.OrdinalIgnoreCase)) || (computer.Equals(".", StringComparison.OrdinalIgnoreCase))) { compname = Dns.GetHostName(); strLocal = "localhost"; isLocalHost = true; } else { compname = computer; } if (!ShouldProcess(StringUtil.Format(ComputerResources.DoubleComputerName, strLocal, compname))) { continue; } else { ComputerWMIHelper.InvokeWin32ShutdownUsingWsman( this, isLocalHost, compname, flags, Credential, WsmanAuthentication, ComputerResources.StopcomputerFailed, "StopComputerException", _cancel.Token); } } } #endregion } #endregion #region Rename-Computer /// <summary> /// Renames a domain computer and its corresponding domain account or a /// workgroup computer. Use this command to rename domain workstations and local /// machines only. It cannot be used to rename Domain Controllers. /// </summary> [Cmdlet(VerbsCommon.Rename, "Computer", SupportsShouldProcess = true, HelpUri = "https://go.microsoft.com/fwlink/?LinkID=219990", RemotingCapability = RemotingCapability.SupportedByCommand)] public class RenameComputerCommand : PSCmdlet { #region Private Members private bool _containsLocalHost = false; private string _newNameForLocalHost = null; private readonly string _shortLocalMachineName = Dns.GetHostName(); private readonly string _fullLocalMachineName = Dns.GetHostEntryAsync(string.Empty).Result.HostName; #endregion #region Parameters /// <summary> /// Target computers to rename /// </summary> [Parameter(ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] public string ComputerName { get; set; } = "localhost"; /// <summary> /// Emit the output. /// </summary> //[Alias("Restart")] [Parameter] public SwitchParameter PassThru { get; set; } /// <summary> /// The domain credential of the domain the target computer joined /// </summary> [Parameter] [ValidateNotNullOrEmpty] [Credential] public PSCredential DomainCredential { get; set; } /// <summary> /// The administrator credential of the target computer /// </summary> [Parameter] [ValidateNotNullOrEmpty] [Credential] public PSCredential LocalCredential { get; set; } /// <summary> /// New names for the target computers /// </summary> [Parameter(Mandatory = true, Position = 0, ValueFromPipelineByPropertyName = true)] [ValidateNotNullOrEmpty] public string NewName { get; set; } /// <summary> /// Suppress the ShouldContinue /// </summary> [Parameter] public SwitchParameter Force { get { return _force; } set { _force = value; } } private bool _force; /// <summary> /// To restart the target computer after rename it /// </summary> [Parameter] public SwitchParameter Restart { get { return _restart; } set { _restart = value; } } private bool _restart; /// <summary> /// The authentication options for CIM_WSMan connection /// </summary> [Parameter] [ValidateSet( "Default", "Basic", "Negotiate", // can be used with and without credential (without -> PSRP mapped to NegotiateWithImplicitCredential) "CredSSP", "Digest", "Kerberos")] // can be used with implicit or explicit credential [SuppressMessage("Microsoft.Naming", "CA1704:IdentifiersShouldBeSpelledCorrectly")] public string WsmanAuthentication { get; set; } = "Default"; #endregion #region "Private Methods" /// <summary> /// Check to see if the target computer is the local machine /// </summary> private string ValidateComputerName() { // Validate target name. ErrorRecord targetError = null; string targetComputer = ComputerWMIHelper.ValidateComputerName(ComputerName, _shortLocalMachineName, _fullLocalMachineName, ref targetError); if (targetComputer == null) { if (targetError != null) { WriteError(targetError); } return null; } // Validate *new* name. Validate the format of the new name. Check if the old name is the same as the // new name later. if (!ComputerWMIHelper.IsComputerNameValid(NewName)) { bool isLocalhost = targetComputer.Equals(ComputerWMIHelper.localhostStr, StringComparison.OrdinalIgnoreCase); string errMsg = StringUtil.Format(ComputerResources.InvalidNewName, isLocalhost ? _shortLocalMachineName : targetComputer, NewName); ErrorRecord error = new ErrorRecord( new InvalidOperationException(errMsg), "InvalidNewName", ErrorCategory.InvalidArgument, NewName); WriteError(error); return null; } return targetComputer; } private void DoRenameComputerAction(string computer, string newName, bool isLocalhost) { string computerName = isLocalhost ? _shortLocalMachineName : computer; if (!ShouldProcess(computerName)) { return; } // Check the length of the new name if (newName != null && newName.Length > ComputerWMIHelper.NetBIOSNameMaxLength) { string truncatedName = newName.Substring(0, ComputerWMIHelper.NetBIOSNameMaxLength); string query = StringUtil.Format(ComputerResources.TruncateNetBIOSName, truncatedName); string caption = ComputerResources.TruncateNetBIOSNameCaption; if (!Force && !ShouldContinue(query, caption)) { return; } } DoRenameComputerWsman(computer, computerName, newName, isLocalhost); } private void DoRenameComputerWsman(string computer, string computerName, string newName, bool isLocalhost) { bool successful = false; int retVal; PSCredential credToUse = isLocalhost ? null : (LocalCredential ?? DomainCredential); try { using (CancellationTokenSource cancelTokenSource = new CancellationTokenSource()) using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(computer, credToUse, WsmanAuthentication, cancelTokenSource.Token, this)) { var operationOptions = new CimOperationOptions { Timeout = TimeSpan.FromMilliseconds(10000), CancellationToken = cancelTokenSource.Token, //This prefix works against all versions of the WinRM server stack, both win8 and win7 ResourceUriPrefix = new Uri(ComputerWMIHelper.CimUriPrefix) }; IEnumerable<CimInstance> mCollection = cimSession.QueryInstances( ComputerWMIHelper.CimOperatingSystemNamespace, ComputerWMIHelper.CimQueryDialect, "Select * from " + ComputerWMIHelper.WMI_Class_ComputerSystem, operationOptions); foreach (CimInstance cimInstance in mCollection) { var oldName = cimInstance.CimInstanceProperties["DNSHostName"].Value.ToString(); if (oldName.Equals(newName, StringComparison.OrdinalIgnoreCase)) { string errMsg = StringUtil.Format(ComputerResources.NewNameIsOldName, computerName, newName); ErrorRecord error = new ErrorRecord( new InvalidOperationException(errMsg), "NewNameIsOldName", ErrorCategory.InvalidArgument, newName); WriteError(error); continue; } // If the target computer is in a domain, always use the DomainCred. If the DomainCred is not given, // use null for UserName and Password, so the context of the caller will be used. // If the target computer is not in a domain, just use null for the UserName and Password string dUserName = null; string dPassword = null; if (((bool)cimInstance.CimInstanceProperties["PartOfDomain"].Value) && (DomainCredential != null)) { dUserName = DomainCredential.UserName; dPassword = Utils.GetStringFromSecureString(DomainCredential.Password); } var methodParameters = new CimMethodParametersCollection(); methodParameters.Add(CimMethodParameter.Create( "Name", newName, Microsoft.Management.Infrastructure.CimType.String, CimFlags.None)); methodParameters.Add(CimMethodParameter.Create( "UserName", dUserName, Microsoft.Management.Infrastructure.CimType.String, (dUserName == null) ? CimFlags.NullValue : CimFlags.None)); methodParameters.Add( CimMethodParameter.Create( "Password", dPassword, Microsoft.Management.Infrastructure.CimType.String, (dPassword == null) ? CimFlags.NullValue : CimFlags.None)); if (!InternalTestHooks.TestRenameComputer) { CimMethodResult result = cimSession.InvokeMethod( ComputerWMIHelper.CimOperatingSystemNamespace, cimInstance, "Rename", methodParameters, operationOptions); retVal = Convert.ToInt32(result.ReturnValue.Value, CultureInfo.CurrentCulture); } else { retVal = InternalTestHooks.TestRenameComputerResults; } if (retVal != 0) { var ex = new Win32Exception(retVal); string errMsg = StringUtil.Format(ComputerResources.FailToRename, computerName, newName, ex.Message); ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "FailToRenameComputer", ErrorCategory.OperationStopped, computerName); WriteError(error); } else { successful = true; } if (PassThru) { WriteObject(ComputerWMIHelper.GetRenameComputerStatusObject(retVal, newName, computerName)); } if (successful) { if (_restart) { // If successful and the Restart parameter is specified, restart the computer object[] flags = new object[] { 6, 0 }; ComputerWMIHelper.InvokeWin32ShutdownUsingWsman( this, isLocalhost, computerName, flags, credToUse, WsmanAuthentication, ComputerResources.RestartcomputerFailed, "RestartcomputerFailed", cancelTokenSource.Token); } else { WriteWarning(StringUtil.Format(ComputerResources.RestartNeeded, null, computerName)); } } } // end foreach } // end using } catch (CimException ex) { string errMsg = StringUtil.Format(ComputerResources.FailToConnectToComputer, computerName, ex.Message); ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "RenameComputerException", ErrorCategory.OperationStopped, computerName); WriteError(error); } catch (Exception ex) { string errMsg = StringUtil.Format(ComputerResources.FailToConnectToComputer, computerName, ex.Message); ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), "RenameComputerException", ErrorCategory.OperationStopped, computerName); WriteError(error); } } #endregion "Private Methods" #region "Override Methods" /// <summary> /// ProcessRecord method. /// </summary> protected override void ProcessRecord() { string targetComputer = ValidateComputerName(); if (targetComputer == null) return; bool isLocalhost = targetComputer.Equals("localhost", StringComparison.OrdinalIgnoreCase); if (isLocalhost) { if (!_containsLocalHost) _containsLocalHost = true; _newNameForLocalHost = NewName; return; } DoRenameComputerAction(targetComputer, NewName, false); } /// <summary> /// EndProcessing method /// </summary> protected override void EndProcessing() { if (!_containsLocalHost) return; DoRenameComputerAction("localhost", _newNameForLocalHost, true); } #endregion "Override Methods" } #endregion Rename-Computer #region "Public API" /// <summary> /// The object returned by SAM Computer cmdlets representing the status of the target machine. /// </summary> public sealed class ComputerChangeInfo { private const string MatchFormat = "{0}:{1}"; /// <summary> /// The HasSucceeded which shows the operation was success or not /// </summary> public bool HasSucceeded { get; set; } /// <summary> /// The ComputerName on which the operation is done. /// </summary> public string ComputerName { get; set; } /// <summary> /// Returns the string representation of this object. /// </summary> /// <returns></returns> public override string ToString() { return FormatLine(this.HasSucceeded.ToString(), this.ComputerName); } /// <summary> /// Formats a line for use in ToString. /// </summary> /// <param name="HasSucceeded"></param> /// <param name="computername"></param> /// <returns></returns> private string FormatLine(string HasSucceeded, string computername) { return StringUtil.Format(MatchFormat, HasSucceeded, computername); } } /// <summary> /// The object returned by Rename-Computer cmdlet representing the status of the target machine. /// </summary> public sealed class RenameComputerChangeInfo { private const string MatchFormat = "{0}:{1}:{2}"; /// <summary> /// The status which shows the operation was success or failure. /// </summary> public bool HasSucceeded { get; set; } /// <summary> /// The NewComputerName which represents the target machine. /// </summary> public string NewComputerName { get; set; } /// <summary> /// The OldComputerName which represented the target machine. /// </summary> public string OldComputerName { get; set; } /// <summary> /// Returns the string representation of this object. /// </summary> /// <returns></returns> public override string ToString() { return FormatLine(this.HasSucceeded.ToString(), this.NewComputerName, this.OldComputerName); } /// <summary> /// Formats a line for use in ToString. /// </summary> /// <param name="HasSucceeded"></param> /// <param name="newcomputername"></param> /// <param name="oldcomputername"></param> /// <returns></returns> private string FormatLine(string HasSucceeded, string newcomputername, string oldcomputername) { return StringUtil.Format(MatchFormat, HasSucceeded, newcomputername, oldcomputername); } } #endregion "Public API" #region Helper /// <summary> /// Helper Class used by Stop-Computer,Restart-Computer and Test-Connection /// Also Contain constants used by System Restore related Cmdlets. /// </summary> internal static class ComputerWMIHelper { /// <summary> /// The maximum length of a valid NetBIOS name /// </summary> internal const int NetBIOSNameMaxLength = 15; /// <summary> /// System Restore Class used by Cmdlets /// </summary> internal const string WMI_Class_SystemRestore = "SystemRestore"; /// <summary> /// OperatingSystem WMI class used by Cmdlets /// </summary> internal const string WMI_Class_OperatingSystem = "Win32_OperatingSystem"; /// <summary> /// Service WMI class used by Cmdlets /// </summary> internal const string WMI_Class_Service = "Win32_Service"; /// <summary> /// Win32_ComputerSystem WMI class used by Cmdlets /// </summary> internal const string WMI_Class_ComputerSystem = "Win32_ComputerSystem"; /// <summary> /// Ping Class used by Cmdlet. /// </summary> internal const string WMI_Class_PingStatus = "Win32_PingStatus"; /// <summary> /// CIMV2 path /// </summary> internal const string WMI_Path_CIM = "\\root\\cimv2"; /// <summary> /// Default path /// </summary> internal const string WMI_Path_Default = "\\root\\default"; /// <summary> /// The error says The interface is unknown. /// </summary> internal const int ErrorCode_Interface = 1717; /// <summary> /// This error says An instance of the service is already running. /// </summary> internal const int ErrorCode_Service = 1056; /// <summary> /// The name of the privilege to shutdown a local system /// </summary> internal const string SE_SHUTDOWN_NAME = "SeShutdownPrivilege"; /// <summary> /// The name of the privilege to shutdown a remote system /// </summary> internal const string SE_REMOTE_SHUTDOWN_NAME = "SeRemoteShutdownPrivilege"; /// <summary> /// CimUriPrefix /// </summary> internal const string CimUriPrefix = "http://schemas.microsoft.com/wbem/wsman/1/wmi/root/cimv2"; /// <summary> /// CimOperatingSystemNamespace /// </summary> internal const string CimOperatingSystemNamespace = "root/cimv2"; /// <summary> /// CimOperatingSystemShutdownMethod /// </summary> internal const string CimOperatingSystemShutdownMethod = "Win32shutdown"; /// <summary> /// CimQueryDialect /// </summary> internal const string CimQueryDialect = "WQL"; /// <summary> /// Local host name /// </summary> internal const string localhostStr = "localhost"; /// <summary> /// Get the local admin user name from a local NetworkCredential /// </summary> /// <param name="computerName"></param> /// <param name="psLocalCredential"></param> /// <returns></returns> internal static string GetLocalAdminUserName(string computerName, PSCredential psLocalCredential) { string localUserName = null; // The format of local admin username should be "ComputerName\AdminName" if (psLocalCredential.UserName.Contains("\\")) { localUserName = psLocalCredential.UserName; } else { int dotIndex = computerName.IndexOf(".", StringComparison.OrdinalIgnoreCase); if (dotIndex == -1) { localUserName = computerName + "\\" + psLocalCredential.UserName; } else { localUserName = computerName.Substring(0, dotIndex) + "\\" + psLocalCredential.UserName; } } return localUserName; } /// <summary> /// Generate a random password /// </summary> /// <param name="passwordLength"></param> /// <returns></returns> internal static string GetRandomPassword(int passwordLength) { const int charMin = 32, charMax = 122; const int allowedCharsCount = charMax - charMin + 1; byte[] randomBytes = new byte[passwordLength]; char[] chars = new char[passwordLength]; RandomNumberGenerator rng = RandomNumberGenerator.Create(); rng.GetBytes(randomBytes); for (int i = 0; i < passwordLength; i++) { chars[i] = (char)(randomBytes[i] % allowedCharsCount + charMin); } return new string(chars); } /// <summary> /// Gets the Scope /// </summary> /// <param name="computer"></param> /// <param name="namespaceParameter"></param> /// <returns></returns> internal static string GetScopeString(string computer, string namespaceParameter) { StringBuilder returnValue = new StringBuilder("\\\\"); if (computer.Equals("::1", StringComparison.OrdinalIgnoreCase) || computer.Equals("[::1]", StringComparison.OrdinalIgnoreCase)) { returnValue.Append("localhost"); } else { returnValue.Append(computer); } returnValue.Append(namespaceParameter); return returnValue.ToString(); } /// <summary> /// Returns true if it is a valid drive on the system. /// </summary> /// <param name="drive"></param> /// <returns></returns> internal static bool IsValidDrive(string drive) { DriveInfo[] drives = DriveInfo.GetDrives(); foreach (DriveInfo logicalDrive in drives) { if (logicalDrive.DriveType.Equals(DriveType.Fixed)) { if (drive.ToString().Equals(logicalDrive.Name.ToString(), System.StringComparison.OrdinalIgnoreCase)) return true; } } return false; } /// <summary> /// Checks whether string[] contains System Drive. /// </summary> /// <param name="drives"></param> /// <param name="sysdrive"></param> /// <returns></returns> internal static bool ContainsSystemDrive(string[] drives, string sysdrive) { string driveApp; foreach (string drive in drives) { if (!drive.EndsWith("\\", StringComparison.OrdinalIgnoreCase)) { driveApp = String.Concat(drive, "\\"); } else driveApp = drive; if (driveApp.Equals(sysdrive, StringComparison.OrdinalIgnoreCase)) return true; } return false; } /// <summary> /// Returns the given computernames in a string /// </summary> /// <param name="computerNames"></param> internal static string GetMachineNames(string[] computerNames) { string separator = ","; RegistryKey regKey = Registry.CurrentUser.OpenSubKey(@"Control Panel\International"); if (regKey != null) { object sListValue = regKey.GetValue("sList"); if (sListValue != null) { separator = sListValue.ToString(); } } string compname = string.Empty; StringBuilder strComputers = new StringBuilder(); int i = 0; foreach (string computer in computerNames) { if (i > 0) { strComputers.Append(separator); } else { i++; } if ((computer.Equals("localhost", StringComparison.OrdinalIgnoreCase)) || (computer.Equals(".", StringComparison.OrdinalIgnoreCase))) { compname = Dns.GetHostName(); } else { compname = computer; } strComputers.Append(compname); } return strComputers.ToString(); } internal static ComputerChangeInfo GetComputerStatusObject(int errorcode, string computername) { ComputerChangeInfo computerchangeinfo = new ComputerChangeInfo(); computerchangeinfo.ComputerName = computername; if (errorcode != 0) { computerchangeinfo.HasSucceeded = false; } else { computerchangeinfo.HasSucceeded = true; } return computerchangeinfo; } internal static RenameComputerChangeInfo GetRenameComputerStatusObject(int errorcode, string newcomputername, string oldcomputername) { RenameComputerChangeInfo renamecomputerchangeinfo = new RenameComputerChangeInfo(); renamecomputerchangeinfo.OldComputerName = oldcomputername; renamecomputerchangeinfo.NewComputerName = newcomputername; if (errorcode != 0) { renamecomputerchangeinfo.HasSucceeded = false; } else { renamecomputerchangeinfo.HasSucceeded = true; } return renamecomputerchangeinfo; } internal static void WriteNonTerminatingError(int errorcode, PSCmdlet cmdlet, string computername) { Win32Exception ex = new Win32Exception(errorcode); string additionalmessage = String.Empty; if (ex.NativeErrorCode.Equals(0x00000035)) { additionalmessage = StringUtil.Format(ComputerResources.NetworkPathNotFound, computername); } string message = StringUtil.Format(ComputerResources.OperationFailed, ex.Message, computername, additionalmessage); ErrorRecord er = new ErrorRecord(new InvalidOperationException(message), "InvalidOperationException", ErrorCategory.InvalidOperation, computername); cmdlet.WriteError(er); } /// <summary> /// Check whether the new computer name is valid /// </summary> /// <param name="computerName"></param> /// <returns></returns> internal static bool IsComputerNameValid(string computerName) { bool allDigits = true; if (computerName.Length >= 64) return false; foreach (char t in computerName) { if (t >= 'A' && t <= 'Z' || t >= 'a' && t <= 'z') { allDigits = false; continue; } else if (t >= '0' && t <= '9') { continue; } else if (t == '-') { allDigits = false; continue; } else { return false; } } return !allDigits; } /// <summary> /// System Restore APIs are not supported on the ARM platform. Skip the system restore operation is necessary. /// </summary> /// <param name="cmdlet"></param> /// <returns></returns> internal static bool SkipSystemRestoreOperationForARMPlatform(PSCmdlet cmdlet) { bool retValue = false; if (PsUtils.IsRunningOnProcessorArchitectureARM()) { var ex = new InvalidOperationException(ComputerResources.SystemRestoreNotSupported); var er = new ErrorRecord(ex, "SystemRestoreNotSupported", ErrorCategory.InvalidOperation, null); cmdlet.WriteError(er); retValue = true; } return retValue; } /// <summary> /// Invokes the Win32Shutdown command on provided target computer using WSMan /// over a CIMSession. The flags parameter determines the type of shutdown operation /// such as shutdown, reboot, force etc. /// </summary> /// <param name="cmdlet">Cmdlet host for reporting errors</param> /// <param name="isLocalhost">True if local host computer</param> /// <param name="computerName">Target computer</param> /// <param name="flags">Win32Shutdown flags</param> /// <param name="credential">Optional credential</param> /// <param name="authentication">Optional authentication</param> /// <param name="formatErrorMessage">Error message format string that takes two parameters</param> /// <param name="ErrorFQEID">Fully qualified error Id</param> /// <param name="cancelToken">Cancel token</param> /// <returns>True on success</returns> internal static bool InvokeWin32ShutdownUsingWsman( PSCmdlet cmdlet, bool isLocalhost, string computerName, object[] flags, PSCredential credential, string authentication, string formatErrorMessage, string ErrorFQEID, CancellationToken cancelToken) { Dbg.Diagnostics.Assert(flags.Length == 2, "Caller need to verify the flags passed in"); bool isSuccess = false; string targetMachine = isLocalhost ? "localhost" : computerName; string authInUse = isLocalhost ? null : authentication; PSCredential credInUse = isLocalhost ? null : credential; var currentPrivilegeState = new PlatformInvokes.TOKEN_PRIVILEGE(); var operationOptions = new CimOperationOptions { Timeout = TimeSpan.FromMilliseconds(10000), CancellationToken = cancelToken, //This prefix works against all versions of the WinRM server stack, both win8 and win7 ResourceUriPrefix = new Uri(ComputerWMIHelper.CimUriPrefix) }; try { if (!(isLocalhost && PlatformInvokes.EnableTokenPrivilege(ComputerWMIHelper.SE_SHUTDOWN_NAME, ref currentPrivilegeState)) && !(!isLocalhost && PlatformInvokes.EnableTokenPrivilege(ComputerWMIHelper.SE_REMOTE_SHUTDOWN_NAME, ref currentPrivilegeState))) { string message = StringUtil.Format(ComputerResources.PrivilegeNotEnabled, computerName, isLocalhost ? ComputerWMIHelper.SE_SHUTDOWN_NAME : ComputerWMIHelper.SE_REMOTE_SHUTDOWN_NAME); ErrorRecord errorRecord = new ErrorRecord(new InvalidOperationException(message), "PrivilegeNotEnabled", ErrorCategory.InvalidOperation, null); cmdlet.WriteError(errorRecord); return false; } using (CimSession cimSession = RemoteDiscoveryHelper.CreateCimSession(targetMachine, credInUse, authInUse, cancelToken, cmdlet)) { var methodParameters = new CimMethodParametersCollection(); int retVal; methodParameters.Add(CimMethodParameter.Create( "Flags", flags[0], Microsoft.Management.Infrastructure.CimType.SInt32, CimFlags.None)); methodParameters.Add(CimMethodParameter.Create( "Reserved", flags[1], Microsoft.Management.Infrastructure.CimType.SInt32, CimFlags.None)); if (!InternalTestHooks.TestStopComputer) { CimMethodResult result = cimSession.InvokeMethod( ComputerWMIHelper.CimOperatingSystemNamespace, ComputerWMIHelper.WMI_Class_OperatingSystem, ComputerWMIHelper.CimOperatingSystemShutdownMethod, methodParameters, operationOptions); retVal = Convert.ToInt32(result.ReturnValue.Value, CultureInfo.CurrentCulture); } else { retVal = InternalTestHooks.TestStopComputerResults; } if (retVal != 0) { var ex = new Win32Exception(retVal); string errMsg = StringUtil.Format(formatErrorMessage, computerName, ex.Message); ErrorRecord error = new ErrorRecord( new InvalidOperationException(errMsg), ErrorFQEID, ErrorCategory.OperationStopped, computerName); cmdlet.WriteError(error); } else { isSuccess = true; } } } catch (CimException ex) { string errMsg = StringUtil.Format(formatErrorMessage, computerName, ex.Message); ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), ErrorFQEID, ErrorCategory.OperationStopped, computerName); cmdlet.WriteError(error); } catch (Exception ex) { string errMsg = StringUtil.Format(formatErrorMessage, computerName, ex.Message); ErrorRecord error = new ErrorRecord(new InvalidOperationException(errMsg), ErrorFQEID, ErrorCategory.OperationStopped, computerName); cmdlet.WriteError(error); } finally { // Restore the previous privilege state if something unexpected happened PlatformInvokes.RestoreTokenPrivilege( isLocalhost ? ComputerWMIHelper.SE_SHUTDOWN_NAME : ComputerWMIHelper.SE_REMOTE_SHUTDOWN_NAME, ref currentPrivilegeState); } return isSuccess; } /// <summary> /// Returns valid computer name or null on failure. /// </summary> /// <param name="nameToCheck">Computer name to validate</param> /// <param name="shortLocalMachineName"></param> /// <param name="fullLocalMachineName"></param> /// <param name="error"></param> /// <returns>Valid computer name</returns> internal static string ValidateComputerName( string nameToCheck, string shortLocalMachineName, string fullLocalMachineName, ref ErrorRecord error) { string validatedComputerName = null; if (nameToCheck.Equals(".", StringComparison.OrdinalIgnoreCase) || nameToCheck.Equals(localhostStr, StringComparison.OrdinalIgnoreCase) || nameToCheck.Equals(shortLocalMachineName, StringComparison.OrdinalIgnoreCase) || nameToCheck.Equals(fullLocalMachineName, StringComparison.OrdinalIgnoreCase)) { validatedComputerName = localhostStr; } else { bool isIPAddress = false; try { IPAddress unused; isIPAddress = IPAddress.TryParse(nameToCheck, out unused); } catch (Exception) { } try { string fqcn = Dns.GetHostEntryAsync(nameToCheck).Result.HostName; if (fqcn.Equals(shortLocalMachineName, StringComparison.OrdinalIgnoreCase) || fqcn.Equals(fullLocalMachineName, StringComparison.OrdinalIgnoreCase)) { // The IPv4 or IPv6 of the local machine is specified validatedComputerName = localhostStr; } else { validatedComputerName = nameToCheck; } } catch (Exception e) { // If GetHostEntry() throw exception, then the target should not be the local machine if (!isIPAddress) { // Return error if the computer name is not an IP address. Dns.GetHostEntry() may not work on IP addresses. string errMsg = StringUtil.Format(ComputerResources.CannotResolveComputerName, nameToCheck, e.Message); error = new ErrorRecord( new InvalidOperationException(errMsg), "AddressResolutionException", ErrorCategory.InvalidArgument, nameToCheck); return null; } validatedComputerName = nameToCheck; } } return validatedComputerName; } } #endregion Helper }//End namespace #endif
40.979784
218
0.524342
[ "MIT" ]
Francisco-Gamino/PowerShell
src/Microsoft.PowerShell.Commands.Management/commands/management/Computer.cs
91,221
C#
/* **************************************************************************** * * Copyright (c) Microsoft Corporation. All rights reserved. * * This software is subject to the Microsoft Public License (Ms-PL). * A copy of the license can be found in the license.htm file included * in this distribution. * * You must not remove this notice, or any other, from this software. * * ***************************************************************************/ namespace System.Web.Mvc { using System; using System.Globalization; using System.Text; using System.Web.Mvc.Resources; public class ViewResult : ViewResultBase { private string _masterName; public string MasterName { get { return _masterName ?? String.Empty; } set { _masterName = value; } } protected override ViewEngineResult FindView(ControllerContext context) { ViewEngineResult result = ViewEngineCollection.FindView(context, ViewName, MasterName); if (result.View != null) { return result; } // we need to generate an exception containing all the locations we searched StringBuilder locationsText = new StringBuilder(); foreach (string location in result.SearchedLocations) { locationsText.AppendLine(); locationsText.Append(location); } throw new InvalidOperationException(String.Format(CultureInfo.CurrentUICulture, MvcResources.Common_ViewNotFound, ViewName, locationsText)); } } }
35.8125
100
0.548575
[ "Apache-2.0" ]
121468615/mono
mcs/class/System.Web.Mvc/System.Web.Mvc/ViewResult.cs
1,721
C#
// Author: Daniele Giardini - http://www.demigiant.com // Created: 2018/07/16 18:41 // License Copyright (c) Daniele Giardini // This work is subject to the terms at http://dotween.demigiant.com/license.php using System; using System.Reflection; using UnityEditor; using UnityEditor.Callbacks; using UnityEngine; using DateTime = System.DateTime; namespace DG.DOTweenUpgradeManager { /// <summary> /// This class and its whole library are deleted the first time DOTween's setup is run after an upgrade (or after a new install). /// NOTE: DidReloadScripts doesn't work on first install so it's useless, InitializeOnLoad is the only way /// </summary> [InitializeOnLoad] static class Autorun { static Autorun() { EditorApplication.update += OnUpdate; } public static void OnUpdate() { if (!UpgradeWindowIsOpen()) { ApplyModulesSettings(); UpgradeWindow.Open(); } } static bool UpgradeWindowIsOpen() { return Resources.FindObjectsOfTypeAll<UpgradeWindow>().Length > 0; } static void ApplyModulesSettings() { Type doeditorT = Type.GetType("DG.DOTweenEditor.UI.DOTweenUtilityWindowModules, DOTweenEditor"); if (doeditorT != null) { MethodInfo miOpen = doeditorT.GetMethod("ApplyModulesSettings", BindingFlags.Static | BindingFlags.Public); if (miOpen != null) { miOpen.Invoke(null, null); } } } } }
31.588235
133
0.614525
[ "Unlicense" ]
HelloWindows/AccountBook
client/framework/dotween-develop/_DOTween.Assembly/DOTweenUpgradeManager/Autorun.cs
1,613
C#
// Copyright © .NET Foundation and Contributors. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. namespace PInvoke { using System; /// <content> /// Contains the <see cref="NCryptSecretAgreementFlags"/> nested type. /// </content> public partial class NCrypt { /// <summary> /// The flags that may be passed to the <see cref="NCryptSecretAgreement(SafeKeyHandle, SafeKeyHandle, out SafeSecretHandle, NCryptSecretAgreementFlags)"/> method. /// </summary> [Flags] public enum NCryptSecretAgreementFlags { /// <summary> /// No flags. /// </summary> None = 0x0, /// <summary> /// Requests that the key service provider (KSP) not display any user interface. If the provider must display the UI to operate, the call fails and the KSP should set the NTE_SILENT_CONTEXT error code as the last error. /// </summary> NCRYPT_SILENT_FLAG = 0x00000040, } } }
35.645161
231
0.620814
[ "MIT" ]
AArnott/pinvoke
src/NCrypt/NCrypt+NCryptSecretAgreementFlags.cs
1,108
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.Linq; using System.Threading.Tasks; using Microsoft.EntityFrameworkCore.TestModels.GearsOfWarModel; using Xunit; using Xunit.Abstractions; namespace Microsoft.EntityFrameworkCore.Query { public class GearsOfWarQuerySqlServerTest : GearsOfWarQueryRelationalTestBase<GearsOfWarQuerySqlServerFixture> { #pragma warning disable IDE0060 // Remove unused parameter public GearsOfWarQuerySqlServerTest(GearsOfWarQuerySqlServerFixture fixture, ITestOutputHelper testOutputHelper) #pragma warning restore IDE0060 // Remove unused parameter : base(fixture) { Fixture.TestSqlLoggerFactory.Clear(); //Fixture.TestSqlLoggerFactory.SetTestOutputHelper(testOutputHelper); } protected override bool CanExecuteQueryString => true; public override async Task Negate_on_binary_expression(bool async) { await base.Negate_on_binary_expression(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE [s].[Id] = -([s].[Id] + [s].[Id])"); } public override async Task Negate_on_column(bool async) { await base.Negate_on_column(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE [s].[Id] = -[s].[Id]"); } public override async Task Negate_on_like_expression(bool async) { await base.Negate_on_like_expression(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE [s].[Name] IS NOT NULL AND NOT ([s].[Name] LIKE N'us%')"); } public override async Task Entity_equality_empty(bool async) { await base.Entity_equality_empty(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE 0 = 1"); } public override async Task Include_multiple_one_to_one_and_one_to_many(bool async) { await base.Include_multiple_one_to_one_and_one_to_many(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Include_multiple_one_to_one_optional_and_one_to_one_required(bool async) { await base.Include_multiple_one_to_one_optional_and_one_to_one_required(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id]"); } public override async Task Include_multiple_circular(bool async) { await base.Include_multiple_circular(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN [Gears] AS [g0] ON [c].[Name] = [g0].[AssignedCityName] ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_multiple_circular_with_filter(bool async) { await base.Include_multiple_circular_with_filter(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN [Gears] AS [g0] ON [c].[Name] = [g0].[AssignedCityName] WHERE [g].[Nickname] = N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_using_alternate_key(bool async) { await base.Include_using_alternate_key(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[Nickname] = N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Include_navigation_on_derived_type(bool async) { await base.Include_navigation_on_derived_type(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task String_based_Include_navigation_on_derived_type(bool async) { await base.String_based_Include_navigation_on_derived_type(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Select_Where_Navigation_Included(bool async) { await base.Select_Where_Navigation_Included(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE [g].[Nickname] = N'Marcus'"); } public override async Task Include_with_join_reference1(bool async) { await base.Include_with_join_reference1(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON ([g].[SquadId] = [t].[GearSquadId]) AND ([g].[Nickname] = [t].[GearNickName]) INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name]"); } public override async Task Include_with_join_reference2(bool async) { await base.Include_with_join_reference2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation] FROM [Tags] AS [t] INNER JOIN [Gears] AS [g] ON ([t].[GearSquadId] = [g].[SquadId]) AND ([t].[GearNickName] = [g].[Nickname]) INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name]"); } public override async Task Include_with_join_collection1(bool async) { await base.Include_with_join_collection1(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON ([g].[SquadId] = [t].[GearSquadId]) AND ([g].[Nickname] = [t].[GearNickName]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [w].[Id]"); } public override async Task Include_with_join_collection2(bool async) { await base.Include_with_join_collection2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Tags] AS [t] INNER JOIN [Gears] AS [g] ON ([t].[GearSquadId] = [g].[SquadId]) AND ([t].[GearNickName] = [g].[Nickname]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Include_where_list_contains_navigation(bool async) { await base.Include_where_list_contains_navigation(async); AssertSql( @"SELECT [t].[Id] FROM [Tags] AS [t]", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE [t].[Id] IS NOT NULL AND [t].[Id] IN ('34c8d86e-a4ac-4be5-827f-584dda348a07', 'df36f493-463f-4123-83f9-6b135deeb7ba', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', '70534e05-782c-4052-8720-c2c54481ce5f', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69', 'b39a6fba-9026-4d69-828e-fd7068673e57')"); } public override async Task Include_where_list_contains_navigation2(bool async) { await base.Include_where_list_contains_navigation2(async); AssertSql( @"SELECT [t].[Id] FROM [Tags] AS [t]", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE [c].[Location] IS NOT NULL AND [t].[Id] IN ('34c8d86e-a4ac-4be5-827f-584dda348a07', 'df36f493-463f-4123-83f9-6b135deeb7ba', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', '70534e05-782c-4052-8720-c2c54481ce5f', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69', 'b39a6fba-9026-4d69-828e-fd7068673e57')"); } public override async Task Navigation_accessed_twice_outside_and_inside_subquery(bool async) { await base.Navigation_accessed_twice_outside_and_inside_subquery(async); AssertSql( @"SELECT [t].[Id] FROM [Tags] AS [t]", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE [t].[Id] IS NOT NULL AND [t].[Id] IN ('34c8d86e-a4ac-4be5-827f-584dda348a07', 'df36f493-463f-4123-83f9-6b135deeb7ba', 'a8ad98f9-e023-4e2a-9a70-c2728455bd34', '70534e05-782c-4052-8720-c2c54481ce5f', 'a7be028a-0cf2-448f-ab55-ce8bc5d8cf69', 'b39a6fba-9026-4d69-828e-fd7068673e57')"); } public override async Task Include_with_join_multi_level(bool async) { await base.Include_with_join_multi_level(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation], [t].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON ([g].[SquadId] = [t].[GearSquadId]) AND ([g].[Nickname] = [t].[GearNickName]) INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN [Gears] AS [g0] ON [c].[Name] = [g0].[AssignedCityName] ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [c].[Name], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_with_join_and_inheritance1(bool async) { await base.Include_with_join_and_inheritance1(async); AssertSql( @"SELECT [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [c].[Name], [c].[Location], [c].[Nation] FROM [Tags] AS [t] INNER JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t0] ON ([t].[GearSquadId] = [t0].[SquadId]) AND ([t].[GearNickName] = [t0].[Nickname]) INNER JOIN [Cities] AS [c] ON [t0].[CityOfBirthName] = [c].[Name]"); } public override async Task Include_with_join_and_inheritance_with_orderby_before_and_after_include(bool async) { await base.Include_with_join_and_inheritance_with_orderby_before_and_after_include(async); AssertSql( @"SELECT [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [t].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Tags] AS [t] INNER JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t0] ON ([t].[GearSquadId] = [t0].[SquadId]) AND ([t].[GearNickName] = [t0].[Nickname]) LEFT JOIN [Gears] AS [g0] ON ([t0].[Nickname] = [g0].[LeaderNickname]) AND ([t0].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [t0].[HasSoulPatch], [t0].[Nickname] DESC, [t].[Id], [t0].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_with_join_and_inheritance2(bool async) { await base.Include_with_join_and_inheritance2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON ([g].[SquadId] = [t].[GearSquadId]) AND ([g].[Nickname] = [t].[GearNickName]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [w].[Id]"); } public override async Task Include_with_join_and_inheritance3(bool async) { await base.Include_with_join_and_inheritance3(async); AssertSql( @"SELECT [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [t].[Id], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Tags] AS [t] INNER JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t0] ON ([t].[GearSquadId] = [t0].[SquadId]) AND ([t].[GearNickName] = [t0].[Nickname]) LEFT JOIN [Gears] AS [g0] ON ([t0].[Nickname] = [g0].[LeaderNickname]) AND ([t0].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [t].[Id], [t0].[Nickname], [t0].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_with_nested_navigation_in_order_by(bool async) { await base.Include_with_nested_navigation_in_order_by(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] WHERE ([g].[Nickname] <> N'Paduk') OR [g].[Nickname] IS NULL ORDER BY [c].[Name], [w].[Id]"); } public override async Task Where_enum(bool async) { await base.Where_enum(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Rank] = 4"); } public override async Task Where_nullable_enum_with_constant(bool async) { await base.Where_nullable_enum_with_constant(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = 1"); } public override async Task Where_nullable_enum_with_null_constant(bool async) { await base.Where_nullable_enum_with_null_constant(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL"); } public override async Task Where_nullable_enum_with_non_nullable_parameter(bool async) { await base.Where_nullable_enum_with_non_nullable_parameter(async); AssertSql( @"@__ammunitionType_0='1' SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = @__ammunitionType_0"); } public override async Task Where_nullable_enum_with_nullable_parameter(bool async) { await base.Where_nullable_enum_with_nullable_parameter(async); AssertSql( @"@__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = @__ammunitionType_0", // @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL"); } public override async Task Where_bitwise_and_enum(bool async) { await base.Where_bitwise_and_enum(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 2) > 0", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 2) = 2"); } public override async Task Where_bitwise_and_integral(bool async) { await base.Where_bitwise_and_integral(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 1) = 1", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (CAST([g].[Rank] AS bigint) & CAST(1 AS bigint)) = CAST(1 AS bigint)", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (CAST([g].[Rank] AS smallint) & CAST(1 AS smallint)) = CAST(1 AS smallint)"); } public override async Task Where_bitwise_and_nullable_enum_with_constant(bool async) { await base.Where_bitwise_and_nullable_enum_with_constant(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] & 1) > 0"); } public override async Task Where_bitwise_and_nullable_enum_with_null_constant(bool async) { await base.Where_bitwise_and_nullable_enum_with_null_constant(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] & NULL) > 0"); } public override async Task Where_bitwise_and_nullable_enum_with_non_nullable_parameter(bool async) { await base.Where_bitwise_and_nullable_enum_with_non_nullable_parameter(async); AssertSql( @"@__ammunitionType_0='1' SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] & @__ammunitionType_0) > 0"); } public override async Task Where_bitwise_and_nullable_enum_with_nullable_parameter(bool async) { await base.Where_bitwise_and_nullable_enum_with_nullable_parameter(async); AssertSql( @"@__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] & @__ammunitionType_0) > 0", // @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] & NULL) > 0"); } public override async Task Where_bitwise_or_enum(bool async) { await base.Where_bitwise_or_enum(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] | 2) > 0"); } public override async Task Bitwise_projects_values_in_select(bool async) { await base.Bitwise_projects_values_in_select(async); AssertSql( @"SELECT TOP(1) CASE WHEN ([g].[Rank] & 2) = 2 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [BitwiseTrue], CASE WHEN ([g].[Rank] & 2) = 4 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [BitwiseFalse], [g].[Rank] & 2 AS [BitwiseValue] FROM [Gears] AS [g] WHERE ([g].[Rank] & 2) = 2"); } public override async Task Where_enum_has_flag(bool async) { await base.Where_enum_has_flag(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 2) = 2", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 18) = 18", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 1) = 1", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & 1) = 1", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (2 & [g].[Rank]) = [g].[Rank]"); } public override async Task Where_enum_has_flag_subquery(bool async) { await base.Where_enum_has_flag_subquery(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0)) = COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0)", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (2 & COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0)) = COALESCE(( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]), 0)"); } public override async Task Where_enum_has_flag_subquery_with_pushdown(bool async) { await base.Where_enum_has_flag_subquery_with_pushdown(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (([g].[Rank] & ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId])) = ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId])) OR ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ((2 & ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId])) = ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId])) OR ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL"); } public override async Task Where_enum_has_flag_subquery_client_eval(bool async) { await base.Where_enum_has_flag_subquery_client_eval(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (([g].[Rank] & ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId])) = ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId])) OR ( SELECT TOP(1) [g0].[Rank] FROM [Gears] AS [g0] ORDER BY [g0].[Nickname], [g0].[SquadId]) IS NULL"); } public override async Task Where_enum_has_flag_with_non_nullable_parameter(bool async) { await base.Where_enum_has_flag_with_non_nullable_parameter(async); AssertSql( @"@__parameter_0='2' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & @__parameter_0) = @__parameter_0"); } public override async Task Where_has_flag_with_nullable_parameter(bool async) { await base.Where_has_flag_with_nullable_parameter(async); AssertSql( @"@__parameter_0='2' (Nullable = true) SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & @__parameter_0) = @__parameter_0"); } public override async Task Select_enum_has_flag(bool async) { await base.Select_enum_has_flag(async); AssertSql( @"SELECT TOP(1) CASE WHEN ([g].[Rank] & 2) = 2 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [hasFlagTrue], CASE WHEN ([g].[Rank] & 4) = 4 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [hasFlagFalse] FROM [Gears] AS [g] WHERE ([g].[Rank] & 2) = 2"); } public override async Task Where_count_subquery_without_collision(bool async) { await base.Where_count_subquery_without_collision(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]) = 2"); } public override async Task Where_any_subquery_without_collision(bool async) { await base.Where_any_subquery_without_collision(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE EXISTS ( SELECT 1 FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName])"); } public override async Task Select_inverted_boolean(bool async) { await base.Select_inverted_boolean(async); AssertSql( @"SELECT [w].[Id], CASE WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Manual] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = CAST(1 AS bit)"); } public override async Task Select_comparison_with_null(bool async) { await base.Select_comparison_with_null(async); AssertSql( @"@__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], CASE WHEN ([w].[AmmunitionType] = @__ammunitionType_0) AND [w].[AmmunitionType] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] = @__ammunitionType_0", // @"SELECT [w].[Id], CASE WHEN [w].[AmmunitionType] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Cartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL"); } public override async Task Select_null_parameter(bool async) { await base.Select_null_parameter(async); AssertSql( @"@__ammunitionType_0='1' (Nullable = true) SELECT [w].[Id], @__ammunitionType_0 AS [AmmoType] FROM [Weapons] AS [w]", // @"SELECT [w].[Id], NULL AS [AmmoType] FROM [Weapons] AS [w]", // @"@__ammunitionType_0='2' (Nullable = true) SELECT [w].[Id], @__ammunitionType_0 AS [AmmoType] FROM [Weapons] AS [w]", // @"SELECT [w].[Id], NULL AS [AmmoType] FROM [Weapons] AS [w]"); } public override async Task Select_ternary_operation_with_boolean(bool async) { await base.Select_ternary_operation_with_boolean(async); AssertSql( @"SELECT [w].[Id], CASE WHEN [w].[IsAutomatic] = CAST(1 AS bit) THEN 1 ELSE 0 END AS [Num] FROM [Weapons] AS [w]"); } public override async Task Select_ternary_operation_with_inverted_boolean(bool async) { await base.Select_ternary_operation_with_inverted_boolean(async); AssertSql( @"SELECT [w].[Id], CASE WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN 1 ELSE 0 END AS [Num] FROM [Weapons] AS [w]"); } public override async Task Select_ternary_operation_with_has_value_not_null(bool async) { await base.Select_ternary_operation_with_has_value_not_null(async); AssertSql( @"SELECT [w].[Id], CASE WHEN [w].[AmmunitionType] IS NOT NULL AND ([w].[AmmunitionType] = 1) THEN N'Yes' ELSE N'No' END AS [IsCartridge] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NOT NULL AND ([w].[AmmunitionType] = 1)"); } public override async Task Select_ternary_operation_multiple_conditions(bool async) { await base.Select_ternary_operation_multiple_conditions(async); AssertSql( @"SELECT [w].[Id], CASE WHEN ([w].[AmmunitionType] = 2) AND ([w].[SynergyWithId] = 1) THEN N'Yes' ELSE N'No' END AS [IsCartridge] FROM [Weapons] AS [w]"); } public override async Task Select_ternary_operation_multiple_conditions_2(bool async) { await base.Select_ternary_operation_multiple_conditions_2(async); AssertSql( @"SELECT [w].[Id], CASE WHEN ([w].[IsAutomatic] = CAST(0 AS bit)) AND ([w].[SynergyWithId] = 1) THEN N'Yes' ELSE N'No' END AS [IsCartridge] FROM [Weapons] AS [w]"); } public override async Task Select_multiple_conditions(bool async) { await base.Select_multiple_conditions(async); AssertSql( @"SELECT [w].[Id], CASE WHEN ([w].[IsAutomatic] = CAST(0 AS bit)) AND (([w].[SynergyWithId] = 1) AND [w].[SynergyWithId] IS NOT NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsCartridge] FROM [Weapons] AS [w]"); } public override async Task Select_nested_ternary_operations(bool async) { await base.Select_nested_ternary_operations(async); AssertSql( @"SELECT [w].[Id], CASE WHEN [w].[IsAutomatic] = CAST(0 AS bit) THEN CASE WHEN [w].[AmmunitionType] = 1 THEN N'ManualCartridge' ELSE N'Manual' END ELSE N'Auto' END AS [IsManualCartridge] FROM [Weapons] AS [w]"); } public override async Task Null_propagation_optimization1(bool async) { await base.Null_propagation_optimization1(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[LeaderNickname] = N'Marcus') AND [g].[LeaderNickname] IS NOT NULL"); } public override async Task Null_propagation_optimization2(bool async) { await base.Null_propagation_optimization2(async); // issue #16050 AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE CASE WHEN [g].[LeaderNickname] IS NULL THEN NULL ELSE CASE WHEN [g].[LeaderNickname] IS NOT NULL AND ([g].[LeaderNickname] LIKE N'%us') THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END END = CAST(1 AS bit)"); } public override async Task Null_propagation_optimization3(bool async) { await base.Null_propagation_optimization3(async); // issue #16050 AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE WHEN [g].[LeaderNickname] LIKE N'%us' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL END = CAST(1 AS bit)"); } public override async Task Null_propagation_optimization4(bool async) { await base.Null_propagation_optimization4(async); // issue #16050 AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (CASE WHEN [g].[LeaderNickname] IS NULL THEN NULL ELSE CAST(LEN([g].[LeaderNickname]) AS int) END = 5) AND CASE WHEN [g].[LeaderNickname] IS NULL THEN NULL ELSE CAST(LEN([g].[LeaderNickname]) AS int) END IS NOT NULL"); } public override async Task Null_propagation_optimization5(bool async) { await base.Null_propagation_optimization5(async); // issue #16050 AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) ELSE NULL END = 5) AND CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) ELSE NULL END IS NOT NULL"); } public override async Task Null_propagation_optimization6(bool async) { await base.Null_propagation_optimization6(async); // issue #16050 AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) ELSE NULL END = 5) AND CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(LEN([g].[LeaderNickname]) AS int) ELSE NULL END IS NOT NULL"); } public override async Task Select_null_propagation_optimization7(bool async) { await base.Select_null_propagation_optimization7(async); // issue #16050 AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN [g].[LeaderNickname] + [g].[LeaderNickname] ELSE NULL END FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_optimization8(bool async) { await base.Select_null_propagation_optimization8(async); AssertSql( @"SELECT [g].[LeaderNickname] + [g].[LeaderNickname] FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_optimization9(bool async) { await base.Select_null_propagation_optimization9(async); AssertSql( @"SELECT CAST(LEN([g].[FullName]) AS int) FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_negative1(bool async) { await base.Select_null_propagation_negative1(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE WHEN CAST(LEN([g].[Nickname]) AS int) = 5 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL END FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_negative2(bool async) { await base.Select_null_propagation_negative2(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN [g0].[LeaderNickname] ELSE NULL END FROM [Gears] AS [g] CROSS JOIN [Gears] AS [g0]"); } public override async Task Select_null_propagation_negative3(bool async) { await base.Select_null_propagation_negative3(async); AssertSql( @"SELECT [g0].[Nickname], CASE WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CASE WHEN [g0].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL END AS [Condition] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g0].[Nickname]"); } public override async Task Select_null_propagation_negative4(bool async) { await base.Select_null_propagation_negative4(async); AssertSql( @"SELECT CASE WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [g0].[Nickname] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g0].[Nickname]"); } public override async Task Select_null_propagation_negative5(bool async) { await base.Select_null_propagation_negative5(async); AssertSql( @"SELECT CASE WHEN [g0].[Nickname] IS NOT NULL AND [g0].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [g0].[Nickname] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g0].[Nickname]"); } public override async Task Select_null_propagation_negative6(bool async) { await base.Select_null_propagation_negative6(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE WHEN CAST(LEN([g].[LeaderNickname]) AS int) <> CAST(LEN([g].[LeaderNickname]) AS int) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL END FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_negative7(bool async) { await base.Select_null_propagation_negative7(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE NULL END FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_negative8(bool async) { await base.Select_null_propagation_negative8(async); AssertSql( @"SELECT CASE WHEN [s].[Id] IS NOT NULL THEN [c].[Name] ELSE NULL END FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name]"); } public override async Task Select_null_propagation_negative9(bool async) { await base.Select_null_propagation_negative9(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN COALESCE(CASE WHEN CAST(LEN([g].[Nickname]) AS int) = 5 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, CAST(0 AS bit)) ELSE NULL END FROM [Gears] AS [g]"); } public override async Task Select_null_propagation_works_for_navigations_with_composite_keys(bool async) { await base.Select_null_propagation_works_for_navigations_with_composite_keys(async); AssertSql( @"SELECT [g].[Nickname] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId])"); } public override async Task Select_null_propagation_works_for_multiple_navigations_with_composite_keys(bool async) { await base.Select_null_propagation_works_for_multiple_navigations_with_composite_keys(async); AssertSql( @"SELECT CASE WHEN [c].[Name] IS NOT NULL THEN [c].[Name] ELSE NULL END FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Tags] AS [t0] ON (([g].[Nickname] = [t0].[GearNickName]) OR ([g].[Nickname] IS NULL AND [t0].[GearNickName] IS NULL)) AND (([g].[SquadId] = [t0].[GearSquadId]) OR ([g].[SquadId] IS NULL AND [t0].[GearSquadId] IS NULL)) LEFT JOIN [Gears] AS [g0] ON ([t0].[GearNickName] = [g0].[Nickname]) AND ([t0].[GearSquadId] = [g0].[SquadId]) LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name]"); } public override async Task Select_conditional_with_anonymous_type_and_null_constant(bool async) { await base.Select_conditional_with_anonymous_type_and_null_constant(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [g].[HasSoulPatch] FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } public override async Task Select_conditional_with_anonymous_types(bool async) { await base.Select_conditional_with_anonymous_types(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [g].[Nickname], [g].[FullName] FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } public override async Task Where_conditional_equality_1(bool async) { await base.Where_conditional_equality_1(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] WHERE [g].[LeaderNickname] IS NULL ORDER BY [g].[Nickname]"); } public override async Task Where_conditional_equality_2(bool async) { await base.Where_conditional_equality_2(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] WHERE [g].[LeaderNickname] IS NULL ORDER BY [g].[Nickname]"); } public override async Task Where_conditional_equality_3(bool async) { await base.Where_conditional_equality_3(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } public override async Task Select_coalesce_with_anonymous_types(bool async) { await base.Select_coalesce_with_anonymous_types(async); AssertSql( @"SELECT [g].[LeaderNickname], [g].[FullName] FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } public override async Task Where_compare_anonymous_types(bool async) { await base.Where_compare_anonymous_types(async); AssertSql( " "); } public override async Task Where_member_access_on_anonymous_type(bool async) { await base.Where_member_access_on_anonymous_type(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] WHERE [g].[LeaderNickname] = N'Marcus'"); } public override async Task Where_compare_anonymous_types_with_uncorrelated_members(bool async) { await base.Where_compare_anonymous_types_with_uncorrelated_members(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] WHERE 0 = 1"); } public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(bool async) { await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] FROM [Tags] AS [t] CROSS JOIN [Tags] AS [t0] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON ([t0].[GearNickName] = [g0].[Nickname]) AND ([t0].[GearSquadId] = [g0].[SquadId]) WHERE ([g].[Nickname] = [g0].[Nickname]) OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL)"); } public override async Task Select_Singleton_Navigation_With_Member_Access(bool async) { await base.Select_Singleton_Navigation_With_Member_Access(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([g].[Nickname] = N'Marcus') AND (([g].[CityOfBirthName] <> N'Ephyra') OR [g].[CityOfBirthName] IS NULL)"); } public override async Task Select_Where_Navigation(bool async) { await base.Select_Where_Navigation(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE [g].[Nickname] = N'Marcus'"); } public override async Task Select_Where_Navigation_Equals_Navigation(bool async) { await base.Select_Where_Navigation_Equals_Navigation(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] FROM [Tags] AS [t] CROSS JOIN [Tags] AS [t0] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON ([t0].[GearNickName] = [g0].[Nickname]) AND ([t0].[GearSquadId] = [g0].[SquadId]) WHERE (([g].[Nickname] = [g0].[Nickname]) OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL)) AND (([g].[SquadId] = [g0].[SquadId]) OR ([g].[SquadId] IS NULL AND [g0].[SquadId] IS NULL))"); } public override async Task Select_Where_Navigation_Null(bool async) { await base.Select_Where_Navigation_Null(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE [g].[Nickname] IS NULL OR [g].[SquadId] IS NULL"); } public override async Task Select_Where_Navigation_Null_Reverse(bool async) { await base.Select_Where_Navigation_Null_Reverse(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE [g].[Nickname] IS NULL OR [g].[SquadId] IS NULL"); } public override async Task Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(bool async) { await base.Select_Where_Navigation_Scalar_Equals_Navigation_Scalar_Projected(async); AssertSql( @"SELECT [t].[Id] AS [Id1], [t0].[Id] AS [Id2] FROM [Tags] AS [t] CROSS JOIN [Tags] AS [t0] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON ([t0].[GearNickName] = [g0].[Nickname]) AND ([t0].[GearSquadId] = [g0].[SquadId]) WHERE ([g].[Nickname] = [g0].[Nickname]) OR ([g].[Nickname] IS NULL AND [g0].[Nickname] IS NULL)"); } public override async Task Optional_Navigation_Null_Coalesce_To_Clr_Type(bool async) { await base.Optional_Navigation_Null_Coalesce_To_Clr_Type(async); AssertSql( @"SELECT TOP(1) COALESCE([w0].[IsAutomatic], CAST(0 AS bit)) AS [IsAutomatic] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY [w].[Id]"); } public override async Task Where_subquery_boolean(bool async) { await base.Where_subquery_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE COALESCE(( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), CAST(0 AS bit)) = CAST(1 AS bit)"); } public override async Task Where_subquery_boolean_with_pushdown(bool async) { await base.Where_subquery_boolean_with_pushdown(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]) = CAST(1 AS bit)"); } public override async Task Where_subquery_distinct_firstordefault_boolean(bool async) { await base.Where_subquery_distinct_firstordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (COALESCE(( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]), CAST(0 AS bit)) = CAST(1 AS bit))"); } public override async Task Where_subquery_distinct_firstordefault_boolean_with_pushdown(bool async) { await base.Where_subquery_distinct_firstordefault_boolean_with_pushdown(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_distinct_first_boolean(bool async) { await base.Where_subquery_distinct_first_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]) = CAST(1 AS bit)) ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_singleordefault_boolean1(bool async) { await base.Where_subquery_distinct_singleordefault_boolean1(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (COALESCE(( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] LIKE N'%Lancer%') ) AS [t]), CAST(0 AS bit)) = CAST(1 AS bit)) ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_singleordefault_boolean2(bool async) { await base.Where_subquery_distinct_singleordefault_boolean2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (COALESCE(( SELECT DISTINCT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] LIKE N'%Lancer%')), CAST(0 AS bit)) = CAST(1 AS bit)) ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { await base.Where_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] LIKE N'%Lancer%') ) AS [t]) = CAST(1 AS bit)) ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_lastordefault_boolean(bool async) { await base.Where_subquery_distinct_lastordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id] DESC) = CAST(0 AS bit) ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_last_boolean(bool async) { await base.Where_subquery_distinct_last_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(0 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id] DESC) = CAST(1 AS bit)) ORDER BY [g].[Nickname]"); } public override async Task Where_subquery_distinct_orderby_firstordefault_boolean(bool async) { await base.Where_subquery_distinct_orderby_firstordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (COALESCE(( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]), CAST(0 AS bit)) = CAST(1 AS bit))"); } public override async Task Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(bool async) { await base.Where_subquery_distinct_orderby_firstordefault_boolean_with_pushdown(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_union_firstordefault_boolean(bool async) { await base.Where_subquery_union_firstordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_join_firstordefault_boolean(bool async) { await base.Where_subquery_join_firstordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] INNER JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_left_join_firstordefault_boolean(bool async) { await base.Where_subquery_left_join_firstordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ON [w].[Id] = [t].[Id] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]) = CAST(1 AS bit))"); } public override async Task Where_subquery_concat_firstordefault_boolean(bool async) { await base.Where_subquery_concat_firstordefault_boolean(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND (( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]) = CAST(1 AS bit))"); } public override async Task Concat_with_count(bool async) { await base.Concat_with_count(async); AssertSql( @"SELECT COUNT(*) FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] UNION ALL SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] ) AS [t]"); } public override async Task Concat_scalars_with_count(bool async) { await base.Concat_scalars_with_count(async); AssertSql( @"SELECT COUNT(*) FROM ( SELECT [g].[Nickname] FROM [Gears] AS [g] UNION ALL SELECT [g0].[FullName] AS [Nickname] FROM [Gears] AS [g0] ) AS [t]"); } public override async Task Concat_anonymous_with_count(bool async) { await base.Concat_anonymous_with_count(async); AssertSql( @"SELECT COUNT(*) FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g].[Nickname] AS [Name] FROM [Gears] AS [g] UNION ALL SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g0].[FullName] AS [Name] FROM [Gears] AS [g0] ) AS [t]"); } public override async Task Concat_with_scalar_projection(bool async) { await base.Concat_with_scalar_projection(async); AssertSql( @"SELECT [t].[Nickname] FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] UNION ALL SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] ) AS [t]"); } public override async Task Select_navigation_with_concat_and_count(bool async) { await base.Select_navigation_with_concat_and_count(async); AssertSql( @"SELECT ( SELECT COUNT(*) FROM ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION ALL SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t]) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit)"); } public override async Task Concat_with_collection_navigations(bool async) { await base.Concat_with_collection_navigations(async); AssertSql( @"SELECT ( SELECT COUNT(*) FROM ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] UNION SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ) AS [t]) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Union_with_collection_navigations(bool async) { await base.Union_with_collection_navigations(async); AssertSql( @"SELECT ( SELECT COUNT(*) FROM ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g1].[Nickname] = [g].[LeaderNickname]) AND ([g1].[SquadId] = [g].[LeaderSquadId]) UNION SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] WHERE ([g1].[Nickname] = [g0].[LeaderNickname]) AND ([g1].[SquadId] = [g0].[LeaderSquadId]) ) AS [t]) FROM [Gears] AS [g1] WHERE [g1].[Discriminator] = N'Officer'"); } public override async Task Select_subquery_distinct_firstordefault(bool async) { await base.Select_subquery_distinct_firstordefault(async); AssertSql( @"SELECT ( SELECT TOP(1) [t].[Name] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ) AS [t] ORDER BY [t].[Id]) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Singleton_Navigation_With_Member_Access(bool async) { await base.Singleton_Navigation_With_Member_Access(async); AssertSql( @"SELECT [g].[CityOfBirthName] AS [B] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([g].[Nickname] = N'Marcus') AND (([g].[CityOfBirthName] <> N'Ephyra') OR [g].[CityOfBirthName] IS NULL)"); } public override async Task GroupJoin_Composite_Key(bool async) { await base.GroupJoin_Composite_Key(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] INNER JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId])"); } public override async Task Join_navigation_translated_to_subquery_composite_key(bool async) { await base.Join_navigation_translated_to_subquery_composite_key(async); AssertSql( @"SELECT [g].[FullName], [t0].[Note] FROM [Gears] AS [g] INNER JOIN ( SELECT [t].[Note], [g0].[FullName] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) ) AS [t0] ON [g].[FullName] = [t0].[FullName]"); } public override async Task Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(bool async) { await base.Join_with_order_by_on_inner_sequence_navigation_translated_to_subquery_composite_key(async); AssertSql( @"SELECT [g].[FullName], [t0].[Note] FROM [Gears] AS [g] INNER JOIN ( SELECT [t].[Note], [g0].[FullName] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) ) AS [t0] ON [g].[FullName] = [t0].[FullName]"); } public override async Task Join_with_order_by_without_skip_or_take(bool async) { await base.Join_with_order_by_without_skip_or_take(async); AssertSql( @"SELECT [t].[Name], [g].[FullName] FROM [Gears] AS [g] INNER JOIN ( SELECT [w].[Name], [w].[OwnerFullName] FROM [Weapons] AS [w] ) AS [t] ON [g].[FullName] = [t].[OwnerFullName]"); } public override async Task Join_with_order_by_without_skip_or_take_nested(bool async) { await base.Join_with_order_by_without_skip_or_take_nested(async); AssertSql( @"SELECT [t0].[Name], [t].[FullName] FROM [Squads] AS [s] INNER JOIN ( SELECT [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] ) AS [t] ON [s].[Id] = [t].[SquadId] INNER JOIN ( SELECT [w].[Name], [w].[OwnerFullName] FROM [Weapons] AS [w] ) AS [t0] ON [t].[FullName] = [t0].[OwnerFullName]"); } public override async Task Collection_with_inheritance_and_join_include_joined(bool async) { await base.Collection_with_inheritance_and_join_include_joined(async); AssertSql( @"SELECT [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [t1].[Id], [t1].[GearNickName], [t1].[GearSquadId], [t1].[IssueDate], [t1].[Note] FROM [Tags] AS [t] INNER JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t0] ON ([t].[GearSquadId] = [t0].[SquadId]) AND ([t].[GearNickName] = [t0].[Nickname]) LEFT JOIN [Tags] AS [t1] ON ([t0].[Nickname] = [t1].[GearNickName]) AND ([t0].[SquadId] = [t1].[GearSquadId])"); } public override async Task Collection_with_inheritance_and_join_include_source(bool async) { await base.Collection_with_inheritance_and_join_include_source(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t0].[Id], [t0].[GearNickName], [t0].[GearSquadId], [t0].[IssueDate], [t0].[Note] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON ([g].[SquadId] = [t].[GearSquadId]) AND ([g].[Nickname] = [t].[GearNickName]) LEFT JOIN [Tags] AS [t0] ON ([g].[Nickname] = [t0].[GearNickName]) AND ([g].[SquadId] = [t0].[GearSquadId]) WHERE [g].[Discriminator] = N'Officer'"); } public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column(bool async) { await base.Non_unicode_string_literal_is_used_for_non_unicode_column(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE [c].[Location] = 'Unknown'"); } public override async Task Non_unicode_string_literal_is_used_for_non_unicode_column_right(bool async) { await base.Non_unicode_string_literal_is_used_for_non_unicode_column_right(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE 'Unknown' = [c].[Location]"); } public override async Task Non_unicode_parameter_is_used_for_non_unicode_column(bool async) { await base.Non_unicode_parameter_is_used_for_non_unicode_column(async); AssertSql( @"@__value_0='Unknown' (Size = 100) (DbType = AnsiString) SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE [c].[Location] = @__value_0"); } public override async Task Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(bool async) { await base.Non_unicode_string_literals_in_contains_is_used_for_non_unicode_column(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE [c].[Location] IN ('Unknown', 'Jacinto''s location', 'Ephyra''s location')"); } public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(bool async) { await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_subquery(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE ([c].[Location] = 'Unknown') AND (( SELECT COUNT(*) FROM [Gears] AS [g] WHERE ([c].[Name] = [g].[CityOfBirthName]) AND ([g].[Nickname] = N'Paduk')) = 1)"); } public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(bool async) { await base.Non_unicode_string_literals_is_used_for_non_unicode_column_in_subquery(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] WHERE ([g].[Nickname] = N'Marcus') AND ([c].[Location] = 'Jacinto''s location')"); } public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(bool async) { await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_contains(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE [c].[Location] LIKE '%Jacinto%'"); } public override async Task Non_unicode_string_literals_is_used_for_non_unicode_column_with_concat(bool async) { await base.Non_unicode_string_literals_is_used_for_non_unicode_column_with_concat(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE COALESCE([c].[Location], '') + 'Added' LIKE '%Add%'"); } public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1() { base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result1(); // Issue#16897 AssertSql( @"SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id]"); } public override void Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2() { base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result2(); // Issue#16897 AssertSql( @"SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(bool async) { await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result3(async); // Issue#16897 AssertSql( @"SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [w].[Id], [w0].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(bool async) { await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_coalesce_result4(async); // Issue#16897 AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g2].* FROM [Gears] AS [g2] WHERE [g2].[Discriminator] IN (N'Officer', N'Gear') ) AS [t] ON [g].[LeaderNickname] = [t].[Nickname] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[FullName], [t].[FullName]", // @"SELECT [g.Weapons].[Id], [g.Weapons].[AmmunitionType], [g.Weapons].[IsAutomatic], [g.Weapons].[Name], [g.Weapons].[OwnerFullName], [g.Weapons].[SynergyWithId] FROM [Weapons] AS [g.Weapons] INNER JOIN ( SELECT DISTINCT [g0].[FullName] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [g20].* FROM [Gears] AS [g20] WHERE [g20].[Discriminator] IN (N'Officer', N'Gear') ) AS [t0] ON [g0].[LeaderNickname] = [t0].[Nickname] WHERE [g0].[Discriminator] IN (N'Officer', N'Gear') ) AS [t1] ON [g.Weapons].[OwnerFullName] = [t1].[FullName] ORDER BY [t1].[FullName]", // @"SELECT [g2.Weapons].[Id], [g2.Weapons].[AmmunitionType], [g2.Weapons].[IsAutomatic], [g2.Weapons].[Name], [g2.Weapons].[OwnerFullName], [g2.Weapons].[SynergyWithId] FROM [Weapons] AS [g2.Weapons] INNER JOIN ( SELECT DISTINCT [t2].[FullName], [g1].[FullName] AS [FullName0] FROM [Gears] AS [g1] LEFT JOIN ( SELECT [g21].* FROM [Gears] AS [g21] WHERE [g21].[Discriminator] IN (N'Officer', N'Gear') ) AS [t2] ON [g1].[LeaderNickname] = [t2].[Nickname] WHERE [g1].[Discriminator] IN (N'Officer', N'Gear') ) AS [t3] ON [g2.Weapons].[OwnerFullName] = [t3].[FullName] ORDER BY [t3].[FullName0], [t3].[FullName]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(bool async) { await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_inheritance_and_coalesce_result(async); // Issue#16897 AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] WHERE [g0].[Discriminator] = N'Officer' ) AS [t] ON [g].[LeaderNickname] = [t].[Nickname] LEFT JOIN [Weapons] AS [w] ON [t].[FullName] = [w].[OwnerFullName] LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [w].[Id], [w0].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(bool async) { await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_conditional_result(async); // Issue#16897 AssertSql( @"SELECT CASE WHEN [g0].[Nickname] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g0].[FullName] = [w].[OwnerFullName] LEFT JOIN [Weapons] AS [w0] ON [g].[FullName] = [w0].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id], [w0].[Id]"); } public override async Task Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(bool async) { await base.Include_on_GroupJoin_SelectMany_DefaultIfEmpty_with_complex_projection_result(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g2].* FROM [Gears] AS [g2] WHERE [g2].[Discriminator] IN (N'Officer', N'Gear') ) AS [t] ON [g].[LeaderNickname] = [t].[Nickname] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[FullName], [t].[FullName]", // @"SELECT [g.Weapons].[Id], [g.Weapons].[AmmunitionType], [g.Weapons].[IsAutomatic], [g.Weapons].[Name], [g.Weapons].[OwnerFullName], [g.Weapons].[SynergyWithId] FROM [Weapons] AS [g.Weapons] INNER JOIN ( SELECT DISTINCT [g0].[FullName] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [g20].* FROM [Gears] AS [g20] WHERE [g20].[Discriminator] IN (N'Officer', N'Gear') ) AS [t0] ON [g0].[LeaderNickname] = [t0].[Nickname] WHERE [g0].[Discriminator] IN (N'Officer', N'Gear') AND ([g0].[Nickname] IS NOT NULL AND [t0].[Nickname] IS NULL) ) AS [t1] ON [g.Weapons].[OwnerFullName] = [t1].[FullName] ORDER BY [t1].[FullName]", // @"SELECT [g2.Weapons].[Id], [g2.Weapons].[AmmunitionType], [g2.Weapons].[IsAutomatic], [g2.Weapons].[Name], [g2.Weapons].[OwnerFullName], [g2.Weapons].[SynergyWithId] FROM [Weapons] AS [g2.Weapons] INNER JOIN ( SELECT DISTINCT [t2].[FullName], [g1].[FullName] AS [FullName0] FROM [Gears] AS [g1] LEFT JOIN ( SELECT [g21].* FROM [Gears] AS [g21] WHERE [g21].[Discriminator] IN (N'Officer', N'Gear') ) AS [t2] ON [g1].[LeaderNickname] = [t2].[Nickname] WHERE [g1].[Discriminator] IN (N'Officer', N'Gear') AND [t2].[Nickname] IS NOT NULL ) AS [t3] ON [g2.Weapons].[OwnerFullName] = [t3].[FullName] ORDER BY [t3].[FullName0], [t3].[FullName]"); } public override async Task Coalesce_operator_in_predicate(bool async) { await base.Coalesce_operator_in_predicate(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit)"); } public override async Task Coalesce_operator_in_predicate_with_other_conditions(bool async) { await base.Coalesce_operator_in_predicate_with_other_conditions(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] = 1) AND (COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit))"); } public override async Task Coalesce_operator_in_projection_with_other_conditions(bool async) { await base.Coalesce_operator_in_projection_with_other_conditions(async); AssertSql( @"SELECT CASE WHEN (([w].[AmmunitionType] = 1) AND [w].[AmmunitionType] IS NOT NULL) AND (COALESCE([w].[IsAutomatic], CAST(0 AS bit)) = CAST(1 AS bit)) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Weapons] AS [w]"); } public override async Task Optional_navigation_type_compensation_works_with_predicate(bool async) { await base.Optional_navigation_type_compensation_works_with_predicate(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE (([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL) AND ([g].[HasSoulPatch] = CAST(1 AS bit))"); } public override async Task Optional_navigation_type_compensation_works_with_predicate2(bool async) { await base.Optional_navigation_type_compensation_works_with_predicate2(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_predicate_negated(bool async) { await base.Optional_navigation_type_compensation_works_with_predicate_negated(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE [g].[HasSoulPatch] = CAST(0 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex1(bool async) { await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex1(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE CASE WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE [g].[HasSoulPatch] END = CAST(0 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_predicate_negated_complex2(bool async) { await base.Optional_navigation_type_compensation_works_with_predicate_negated_complex2(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE CASE WHEN [g].[HasSoulPatch] = CAST(0 AS bit) THEN CAST(0 AS bit) ELSE [g].[HasSoulPatch] END = CAST(0 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_conditional_expression(bool async) { await base.Optional_navigation_type_compensation_works_with_conditional_expression(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE CASE WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END = CAST(1 AS bit)"); } public override async Task Optional_navigation_type_compensation_works_with_binary_expression(bool async) { await base.Optional_navigation_type_compensation_works_with_binary_expression(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) OR ([t].[Note] LIKE N'%Cole%')"); } public override async Task Optional_navigation_type_compensation_works_with_binary_and_expression(bool async) { await base.Optional_navigation_type_compensation_works_with_binary_and_expression(async); AssertSql( @"SELECT CASE WHEN ([g].[HasSoulPatch] = CAST(1 AS bit)) AND ([t].[Note] LIKE N'%Cole%') THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId])"); } public override async Task Optional_navigation_type_compensation_works_with_projection(bool async) { await base.Optional_navigation_type_compensation_works_with_projection(async); AssertSql( @"SELECT [g].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL"); } public override async Task Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(bool async) { await base.Optional_navigation_type_compensation_works_with_projection_into_anonymous_type(async); AssertSql( @"SELECT [g].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL"); } public override async Task Optional_navigation_type_compensation_works_with_DTOs(bool async) { await base.Optional_navigation_type_compensation_works_with_DTOs(async); AssertSql( @"SELECT [g].[SquadId] AS [Id] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL"); } public override async Task Optional_navigation_type_compensation_works_with_list_initializers(bool async) { await base.Optional_navigation_type_compensation_works_with_list_initializers(async); AssertSql( @"SELECT [g].[SquadId], [g].[SquadId] + 1 FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL ORDER BY [t].[Note]"); } public override async Task Optional_navigation_type_compensation_works_with_array_initializers(bool async) { await base.Optional_navigation_type_compensation_works_with_array_initializers(async); AssertSql( @"SELECT [g].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL"); } public override async Task Optional_navigation_type_compensation_works_with_orderby(bool async) { await base.Optional_navigation_type_compensation_works_with_orderby(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL ORDER BY [g].[SquadId]"); } public override async Task Optional_navigation_type_compensation_works_with_all(bool async) { await base.Optional_navigation_type_compensation_works_with_all(async); AssertSql( @"SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE (([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL) AND ([g].[HasSoulPatch] = CAST(0 AS bit))) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task Optional_navigation_type_compensation_works_with_negated_predicate(bool async) { await base.Optional_navigation_type_compensation_works_with_negated_predicate(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE (([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL) AND ([g].[HasSoulPatch] = CAST(0 AS bit))"); } public override async Task Optional_navigation_type_compensation_works_with_contains(bool async) { await base.Optional_navigation_type_compensation_works_with_contains(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE (([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL) AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] WHERE [g0].[SquadId] = [g].[SquadId])"); } public override async Task Optional_navigation_type_compensation_works_with_skip(bool async) { await base.Optional_navigation_type_compensation_works_with_skip(async); AssertSql( @"SELECT [t0].[SquadId] FROM [Tags] AS [t] LEFT JOIN ( SELECT [t.Gear].* FROM [Gears] AS [t.Gear] WHERE [t.Gear].[Discriminator] IN (N'Officer', N'Gear') ) AS [t0] ON ([t].[GearNickName] = [t0].[Nickname]) AND ([t].[GearSquadId] = [t0].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL ORDER BY [t].[Note]", // @"@_outer_SquadId='1' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname] OFFSET @_outer_SquadId ROWS", // @"@_outer_SquadId='1' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname] OFFSET @_outer_SquadId ROWS", // @"@_outer_SquadId='1' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname] OFFSET @_outer_SquadId ROWS", // @"@_outer_SquadId='1' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname] OFFSET @_outer_SquadId ROWS", // @"@_outer_SquadId='2' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname] OFFSET @_outer_SquadId ROWS"); } public override async Task Optional_navigation_type_compensation_works_with_take(bool async) { await base.Optional_navigation_type_compensation_works_with_take(async); AssertSql( @"SELECT [t0].[SquadId] FROM [Tags] AS [t] LEFT JOIN ( SELECT [t.Gear].* FROM [Gears] AS [t.Gear] WHERE [t.Gear].[Discriminator] IN (N'Officer', N'Gear') ) AS [t0] ON ([t].[GearNickName] = [t0].[Nickname]) AND ([t].[GearSquadId] = [t0].[SquadId]) WHERE ([t].[Note] <> N'K.I.A.') OR [t].[Note] IS NULL ORDER BY [t].[Note]", // @"@_outer_SquadId='1' SELECT TOP(@_outer_SquadId) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname]", // @"@_outer_SquadId='1' SELECT TOP(@_outer_SquadId) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname]", // @"@_outer_SquadId='1' SELECT TOP(@_outer_SquadId) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname]", // @"@_outer_SquadId='1' SELECT TOP(@_outer_SquadId) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname]", // @"@_outer_SquadId='2' SELECT TOP(@_outer_SquadId) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname]"); } public override async Task Select_correlated_filtered_collection(bool async) { await base.Select_correlated_filtered_collection(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [c].[Name], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[Name] <> N'Lancer') OR [w].[Name] IS NULL ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [c].[Name] IN (N'Ephyra', N'Hanover') ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name], [t].[Id]"); } public override async Task Select_correlated_filtered_collection_with_composite_key(bool async) { await base.Select_correlated_filtered_collection_with_composite_key(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] WHERE [g0].[Nickname] <> N'Dom' ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Select_correlated_filtered_collection_works_with_caching(bool async) { await base.Select_correlated_filtered_collection_works_with_caching(async); AssertSql( @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId]"); } public override async Task Join_predicate_value_equals_condition(bool async) { await base.Join_predicate_value_equals_condition(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL"); } public override async Task Join_predicate_value(bool async) { await base.Join_predicate_value(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Join_predicate_condition_equals_condition(bool async) { await base.Join_predicate_condition_equals_condition(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL"); } public override async Task Left_join_predicate_value_equals_condition(bool async) { await base.Left_join_predicate_value_equals_condition(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL"); } public override async Task Left_join_predicate_value(bool async) { await base.Left_join_predicate_value(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Left_join_predicate_condition_equals_condition(bool async) { await base.Left_join_predicate_condition_equals_condition(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [w].[SynergyWithId] IS NOT NULL"); } public override async Task Where_datetimeoffset_now(bool async) { await base.Where_datetimeoffset_now(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Timeline] <> SYSDATETIMEOFFSET()"); } public override async Task Where_datetimeoffset_utcnow(bool async) { await base.Where_datetimeoffset_utcnow(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE [m].[Timeline] <> CAST(SYSUTCDATETIME() AS datetimeoffset)"); } public override async Task Where_datetimeoffset_date_component(bool async) { await base.Where_datetimeoffset_date_component(async); AssertSql( @"@__Date_0='0001-01-01T00:00:00.0000000' SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE CONVERT(date, [m].[Timeline]) > @__Date_0"); } public override async Task Where_datetimeoffset_year_component(bool async) { await base.Where_datetimeoffset_year_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(year, [m].[Timeline]) = 2"); } public override async Task Where_datetimeoffset_month_component(bool async) { await base.Where_datetimeoffset_month_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(month, [m].[Timeline]) = 1"); } public override async Task Where_datetimeoffset_dayofyear_component(bool async) { await base.Where_datetimeoffset_dayofyear_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(dayofyear, [m].[Timeline]) = 2"); } public override async Task Where_datetimeoffset_day_component(bool async) { await base.Where_datetimeoffset_day_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(day, [m].[Timeline]) = 2"); } public override async Task Where_datetimeoffset_hour_component(bool async) { await base.Where_datetimeoffset_hour_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Timeline]) = 10"); } public override async Task Where_datetimeoffset_minute_component(bool async) { await base.Where_datetimeoffset_minute_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Timeline]) = 0"); } public override async Task Where_datetimeoffset_second_component(bool async) { await base.Where_datetimeoffset_second_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Timeline]) = 0"); } public override async Task Where_datetimeoffset_millisecond_component(bool async) { await base.Where_datetimeoffset_millisecond_component(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Timeline]) = 0"); } public override async Task DateTimeOffset_DateAdd_AddMonths(bool async) { await base.DateTimeOffset_DateAdd_AddMonths(async); AssertSql( @"SELECT DATEADD(month, CAST(1 AS int), [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task DateTimeOffset_DateAdd_AddDays(bool async) { await base.DateTimeOffset_DateAdd_AddDays(async); AssertSql( @"SELECT DATEADD(day, CAST(1.0E0 AS int), [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task DateTimeOffset_DateAdd_AddHours(bool async) { await base.DateTimeOffset_DateAdd_AddHours(async); AssertSql( @"SELECT DATEADD(hour, CAST(1.0E0 AS int), [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task DateTimeOffset_DateAdd_AddMinutes(bool async) { await base.DateTimeOffset_DateAdd_AddMinutes(async); AssertSql( @"SELECT DATEADD(minute, CAST(1.0E0 AS int), [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task DateTimeOffset_DateAdd_AddSeconds(bool async) { await base.DateTimeOffset_DateAdd_AddSeconds(async); AssertSql( @"SELECT DATEADD(second, CAST(1.0E0 AS int), [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task DateTimeOffset_DateAdd_AddMilliseconds(bool async) { await base.DateTimeOffset_DateAdd_AddMilliseconds(async); AssertSql( @"SELECT DATEADD(millisecond, CAST(300.0E0 AS int), [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task Where_datetimeoffset_milliseconds_parameter_and_constant(bool async) { await base.Where_datetimeoffset_milliseconds_parameter_and_constant(async); AssertSql( @"SELECT COUNT(*) FROM [Missions] AS [m] WHERE [m].[Timeline] = '1902-01-02T10:00:00.1234567+01:30'"); } public override async Task Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used( bool async) { await base.Orderby_added_for_client_side_GroupJoin_composite_dependent_to_principal_LOJ_when_incomplete_key_is_used(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].* FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ) AS [t0] ON [t].[GearNickName] = [t0].[Nickname] ORDER BY [t].[GearNickName]"); } public override async Task Complex_predicate_with_AndAlso_and_nullable_bool_property(bool async) { await base.Complex_predicate_with_AndAlso_and_nullable_bool_property(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] WHERE ([w].[Id] <> 50) AND ([g].[HasSoulPatch] = CAST(0 AS bit))"); } public override async Task Distinct_with_optional_navigation_is_translated_to_sql(bool async) { await base.Distinct_with_optional_navigation_is_translated_to_sql(async); AssertSql( @"SELECT DISTINCT [g].[HasSoulPatch] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([t].[Note] <> N'Foo') OR [t].[Note] IS NULL"); } public override async Task Sum_with_optional_navigation_is_translated_to_sql(bool async) { await base.Sum_with_optional_navigation_is_translated_to_sql(async); AssertSql( @"SELECT COALESCE(SUM([g].[SquadId]), 0) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([t].[Note] <> N'Foo') OR [t].[Note] IS NULL"); } public override async Task Count_with_optional_navigation_is_translated_to_sql(bool async) { await base.Count_with_optional_navigation_is_translated_to_sql(async); AssertSql( @"SELECT COUNT(*) FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([t].[Note] <> N'Foo') OR [t].[Note] IS NULL"); } public override async Task FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(bool async) { await base.FirstOrDefault_with_manually_created_groupjoin_is_translated_to_sql(async); AssertSql( @"SELECT TOP(1) [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] WHERE [s].[Name] = N'Kilo'"); } public override async Task Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(bool async) { await base.Any_with_optional_navigation_as_subquery_predicate_is_translated_to_sql(async); AssertSql( @"SELECT [s].[Name] FROM [Squads] AS [s] WHERE NOT (EXISTS ( SELECT 1 FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([s].[Id] = [g].[SquadId]) AND ([t].[Note] = N'Dom''s Tag')))"); } public override async Task All_with_optional_navigation_is_translated_to_sql(bool async) { await base.All_with_optional_navigation_is_translated_to_sql(async); AssertSql( @"SELECT CASE WHEN NOT EXISTS ( SELECT 1 FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([t].[Note] = N'Foo') AND [t].[Note] IS NOT NULL) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task Contains_with_local_nullable_guid_list_closure(bool async) { await base.Contains_with_local_nullable_guid_list_closure(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] WHERE [t].[Id] IN ('d2c26679-562b-44d1-ab96-23d1775e0926', '23cbcf9b-ce14-45cf-aafa-2c2667ebfdd3', 'ab1b82d7-88db-42bd-a132-7eef9aa68af4')"); } public override async Task Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(bool async) { await base.Unnecessary_include_doesnt_get_added_complex_when_projecting_EF_Property(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g].[Rank]"); } public override async Task Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(bool async) { await base.Multiple_order_bys_are_properly_lifted_from_subquery_created_by_include(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ORDER BY [g].[FullName]"); } public override async Task Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(bool async) { await base.Order_by_is_properly_lifted_from_subquery_with_same_order_by_in_the_outer_query(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ORDER BY [g].[FullName]"); } public override async Task Where_is_properly_lifted_from_subquery_created_by_include(bool async) { await base.Where_is_properly_lifted_from_subquery_created_by_include(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([g].[FullName] <> N'Augustus Cole') AND ([g].[HasSoulPatch] = CAST(0 AS bit)) ORDER BY [g].[FullName]"); } public override async Task Subquery_is_lifted_from_main_from_clause_of_SelectMany(bool async) { await base.Subquery_is_lifted_from_main_from_clause_of_SelectMany(async); AssertSql( @"SELECT [g].[FullName] AS [Name1], [g0].[FullName] AS [Name2] FROM [Gears] AS [g] CROSS JOIN [Gears] AS [g0] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND ([g0].[HasSoulPatch] = CAST(0 AS bit)) ORDER BY [g].[FullName]"); } public override async Task Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(bool async) { await base.Subquery_containing_SelectMany_projecting_main_from_clause_gets_lifted(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] CROSS JOIN [Tags] AS [t] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g].[FullName]"); } public override async Task Subquery_containing_join_projecting_main_from_clause_gets_lifted(bool async) { await base.Subquery_containing_join_projecting_main_from_clause_gets_lifted(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] ORDER BY [g].[Nickname]"); } public override async Task Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(bool async) { await base.Subquery_containing_left_join_projecting_main_from_clause_gets_lifted(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] ORDER BY [g].[Nickname]"); } public override async Task Subquery_containing_join_gets_lifted_clashing_names(bool async) { await base.Subquery_containing_join_gets_lifted_clashing_names(async); AssertSql( @"SELECT [g].[Nickname] FROM [Gears] AS [g] INNER JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] INNER JOIN [Tags] AS [t0] ON [g].[Nickname] = [t0].[GearNickName] WHERE ([t].[GearNickName] <> N'Cole Train') OR [t].[GearNickName] IS NULL ORDER BY [g].[Nickname], [t0].[Id]"); } public override async Task Subquery_created_by_include_gets_lifted_nested(bool async) { await base.Subquery_created_by_include_gets_lifted_nested(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [c].[Name], [c].[Location], [c].[Nation] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] WHERE EXISTS ( SELECT 1 FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]) AND ([g].[HasSoulPatch] = CAST(0 AS bit)) ORDER BY [g].[Nickname]"); } public override async Task Subquery_is_lifted_from_additional_from_clause(bool async) { await base.Subquery_is_lifted_from_additional_from_clause(async); AssertSql( @"SELECT [g].[FullName] AS [Name1], [t].[FullName] AS [Name2] FROM [Gears] AS [g] CROSS JOIN ( SELECT [g0].[FullName], [g0].[HasSoulPatch] FROM [Gears] AS [g0] ) AS [t] WHERE ([g].[HasSoulPatch] = CAST(1 AS bit)) AND ([t].[HasSoulPatch] = CAST(0 AS bit)) ORDER BY [g].[FullName]"); } public override async Task Subquery_with_result_operator_is_not_lifted(bool async) { await base.Subquery_with_result_operator_is_not_lifted(async); AssertSql( @"@__p_0='2' SELECT [t].[FullName] FROM ( SELECT TOP(@__p_0) [g].[FullName], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ORDER BY [g].[FullName] ) AS [t] ORDER BY [t].[Rank]"); } public override async Task Skip_with_orderby_followed_by_orderBy_is_pushed_down(bool async) { await base.Skip_with_orderby_followed_by_orderBy_is_pushed_down(async); AssertSql( @"@__p_0='1' SELECT [t].[FullName] FROM ( SELECT [g].[FullName], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ORDER BY [g].[FullName] OFFSET @__p_0 ROWS ) AS [t] ORDER BY [t].[Rank]"); } public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down1(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down1(async); AssertSql( @"@__p_0='999' SELECT [t].[FullName] FROM ( SELECT TOP(@__p_0) [g].[FullName], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ) AS [t] ORDER BY [t].[Rank]"); } public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down2(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down2(async); AssertSql( @"@__p_0='999' SELECT [t].[FullName] FROM ( SELECT TOP(@__p_0) [g].[FullName], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ) AS [t] ORDER BY [t].[Rank]"); } public override async Task Take_without_orderby_followed_by_orderBy_is_pushed_down3(bool async) { await base.Take_without_orderby_followed_by_orderBy_is_pushed_down3(async); AssertSql( @"@__p_0='999' SELECT [t].[FullName] FROM ( SELECT TOP(@__p_0) [g].[FullName], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ) AS [t] ORDER BY [t].[FullName], [t].[Rank]"); } public override async Task Select_length_of_string_property(bool async) { await base.Select_length_of_string_property(async); AssertSql( @"SELECT [w].[Name], CAST(LEN([w].[Name]) AS int) AS [Length] FROM [Weapons] AS [w]"); } public override async Task Client_method_on_collection_navigation_in_outer_join_key(bool async) { await base.Client_method_on_collection_navigation_in_outer_join_key(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear')", // @"@_outer_FullName1='Damon Baird' (Size = 450) SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE @_outer_FullName1 = [w0].[OwnerFullName]", // @"@_outer_FullName1='Augustus Cole' (Size = 450) SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE @_outer_FullName1 = [w0].[OwnerFullName]", // @"@_outer_FullName1='Dominic Santiago' (Size = 450) SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE @_outer_FullName1 = [w0].[OwnerFullName]", // @"@_outer_FullName1='Marcus Fenix' (Size = 450) SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE @_outer_FullName1 = [w0].[OwnerFullName]", // @"@_outer_FullName1='Garron Paduk' (Size = 450) SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE @_outer_FullName1 = [w0].[OwnerFullName]", // @"SELECT [o].[FullName], [o].[Nickname] AS [o] FROM [Gears] AS [o] WHERE ([o].[Discriminator] = N'Officer') AND ([o].[HasSoulPatch] = 1)", // @"@_outer_FullName='Damon Baird' (Size = 450) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE @_outer_FullName = [w].[OwnerFullName]", // @"@_outer_FullName='Marcus Fenix' (Size = 450) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE @_outer_FullName = [w].[OwnerFullName]"); } public override async Task Member_access_on_derived_entity_using_cast(bool async) { await base.Member_access_on_derived_entity_using_cast(async); AssertSql( @"SELECT [f].[Name], [f].[Eradicated] FROM [Factions] AS [f] ORDER BY [f].[Name]"); } public override async Task Member_access_on_derived_materialized_entity_using_cast(bool async) { await base.Member_access_on_derived_materialized_entity_using_cast(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] ORDER BY [f].[Name]"); } public override async Task Member_access_on_derived_entity_using_cast_and_let(bool async) { await base.Member_access_on_derived_entity_using_cast_and_let(async); AssertSql( @"SELECT [f].[Name], [f].[Eradicated] FROM [Factions] AS [f] ORDER BY [f].[Name]"); } public override async Task Property_access_on_derived_entity_using_cast(bool async) { await base.Property_access_on_derived_entity_using_cast(async); AssertSql( @"SELECT [f].[Name], [f].[Eradicated] FROM [Factions] AS [f] ORDER BY [f].[Name]"); } public override async Task Navigation_access_on_derived_entity_using_cast(bool async) { await base.Navigation_access_on_derived_entity_using_cast(async); AssertSql( @"SELECT [f].[Name], [t].[ThreatLevel] AS [Threat] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[ThreatLevel] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] ORDER BY [f].[Name]"); } public override async Task Navigation_access_on_derived_materialized_entity_using_cast(bool async) { await base.Navigation_access_on_derived_materialized_entity_using_cast(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated], [t].[ThreatLevel] AS [Threat] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[ThreatLevel] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] ORDER BY [f].[Name]"); } public override async Task Navigation_access_via_EFProperty_on_derived_entity_using_cast(bool async) { await base.Navigation_access_via_EFProperty_on_derived_entity_using_cast(async); AssertSql( @"SELECT [f].[Name], [t].[ThreatLevel] AS [Threat] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[ThreatLevel] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] ORDER BY [f].[Name]"); } public override async Task Navigation_access_fk_on_derived_entity_using_cast(bool async) { await base.Navigation_access_fk_on_derived_entity_using_cast(async); AssertSql( @"SELECT [f].[Name], [t].[Name] AS [CommanderName] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] ORDER BY [f].[Name]"); } public override async Task Collection_navigation_access_on_derived_entity_using_cast(bool async) { await base.Collection_navigation_access_on_derived_entity_using_cast(async); AssertSql( @"SELECT [f].[Name], ( SELECT COUNT(*) FROM [LocustLeaders] AS [l] WHERE [f].[Id] = [l].[LocustHordeId]) AS [LeadersCount] FROM [Factions] AS [f] ORDER BY [f].[Name]"); } public override async Task Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(bool async) { await base.Collection_navigation_access_on_derived_entity_using_cast_in_SelectMany(async); AssertSql( @"SELECT [f].[Name], [l].[Name] AS [LeaderName] FROM [Factions] AS [f] INNER JOIN [LocustLeaders] AS [l] ON [f].[Id] = [l].[LocustHordeId] ORDER BY [l].[Name]"); } public override async Task Include_on_derived_entity_using_OfType(bool async) { await base.Include_on_derived_entity_using_OfType(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated], [t].[Name], [t].[Discriminator], [t].[LocustHordeId], [t].[ThreatLevel], [t].[ThreatLevelByte], [t].[ThreatLevelNullableByte], [t].[DefeatedByNickname], [t].[DefeatedBySquadId], [t].[HighCommandId], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [LocustLeaders] AS [l0] ON [f].[Id] = [l0].[LocustHordeId] ORDER BY [f].[Name], [f].[Id], [t].[Name], [l0].[Name]"); } public override async Task Distinct_on_subquery_doesnt_get_lifted(bool async) { await base.Distinct_on_subquery_doesnt_get_lifted(async); AssertSql( @"SELECT [t].[HasSoulPatch] FROM ( SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] ) AS [t]"); } public override async Task Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(bool async) { await base.Cast_result_operator_on_subquery_is_properly_lifted_to_a_convert(async); AssertSql( @"SELECT [f].[Eradicated] FROM [Factions] AS [f]"); } public override async Task Comparing_two_collection_navigations_composite_key(bool async) { await base.Comparing_two_collection_navigations_composite_key(async); AssertSql( @"SELECT [g].[Nickname] AS [Nickname1], [g0].[Nickname] AS [Nickname2] FROM [Gears] AS [g] CROSS JOIN [Gears] AS [g0] WHERE ([g].[Nickname] = [g0].[Nickname]) AND ([g].[SquadId] = [g0].[SquadId]) ORDER BY [g].[Nickname]"); } public override async Task Comparing_two_collection_navigations_inheritance(bool async) { await base.Comparing_two_collection_navigations_inheritance(async); AssertSql( @"SELECT [f].[Name], [t].[Nickname] FROM [Factions] AS [f] CROSS JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[HasSoulPatch] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t] LEFT JOIN ( SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t0] ON [f].[CommanderName] = [t0].[Name] LEFT JOIN [Gears] AS [g0] ON ([t0].[DefeatedByNickname] = [g0].[Nickname]) AND ([t0].[DefeatedBySquadId] = [g0].[SquadId]) WHERE ([t].[HasSoulPatch] = CAST(1 AS bit)) AND (([g0].[Nickname] = [t].[Nickname]) AND ([g0].[SquadId] = [t].[SquadId]))"); } public override async Task Comparing_entities_using_Equals_inheritance(bool async) { await base.Comparing_entities_using_Equals_inheritance(async); AssertSql( @"SELECT [g].[Nickname] AS [Nickname1], [t].[Nickname] AS [Nickname2] FROM [Gears] AS [g] CROSS JOIN ( SELECT [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] WHERE [g0].[Discriminator] = N'Officer' ) AS [t] WHERE ([g].[Nickname] = [t].[Nickname]) AND ([g].[SquadId] = [t].[SquadId]) ORDER BY [g].[Nickname], [t].[Nickname]"); } public override async Task Contains_on_nullable_array_produces_correct_sql(bool async) { await base.Contains_on_nullable_array_produces_correct_sql(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] WHERE ([g].[SquadId] < 2) AND (([c].[Name] = N'Ephyra') OR [c].[Name] IS NULL)"); } public override async Task Optional_navigation_with_collection_composite_key(bool async) { await base.Optional_navigation_with_collection_composite_key(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) WHERE ([g].[Discriminator] = N'Officer') AND (( SELECT COUNT(*) FROM [Gears] AS [g0] WHERE (([g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL) AND (([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]))) AND ([g0].[Nickname] = N'Dom')) > 0)"); } public override async Task Select_null_conditional_with_inheritance(bool async) { await base.Select_null_conditional_with_inheritance(async); AssertSql( @"SELECT CASE WHEN [f].[CommanderName] IS NOT NULL THEN [f].[CommanderName] ELSE NULL END FROM [Factions] AS [f]"); } public override async Task Select_null_conditional_with_inheritance_negative(bool async) { await base.Select_null_conditional_with_inheritance_negative(async); AssertSql( @"SELECT CASE WHEN [f].[CommanderName] IS NOT NULL THEN [f].[Eradicated] ELSE NULL END FROM [Factions] AS [f]"); } public override async Task Project_collection_navigation_with_inheritance1(bool async) { await base.Project_collection_navigation_with_inheritance1(async); AssertSql( @"SELECT [f].[Id], [t].[Name], [f0].[Id], [l0].[Name], [l0].[Discriminator], [l0].[LocustHordeId], [l0].[ThreatLevel], [l0].[ThreatLevelByte], [l0].[ThreatLevelNullableByte], [l0].[DefeatedByNickname], [l0].[DefeatedBySquadId], [l0].[HighCommandId] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Factions] AS [f0] ON [t].[Name] = [f0].[CommanderName] LEFT JOIN [LocustLeaders] AS [l0] ON [f0].[Id] = [l0].[LocustHordeId] ORDER BY [f].[Id], [t].[Name], [f0].[Id], [l0].[Name]"); } public override async Task Project_collection_navigation_with_inheritance2(bool async) { await base.Project_collection_navigation_with_inheritance2(async); AssertSql( @"SELECT [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Project_collection_navigation_with_inheritance3(bool async) { await base.Project_collection_navigation_with_inheritance3(async); AssertSql( @"SELECT [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[DefeatedByNickname], [l].[DefeatedBySquadId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_reference_on_derived_type_using_string(bool async) { await base.Include_reference_on_derived_type_using_string(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId])"); } public override async Task Include_reference_on_derived_type_using_string_nested1(bool async) { await base.Include_reference_on_derived_type_using_string_nested1(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id]"); } public override async Task Include_reference_on_derived_type_using_string_nested2(bool async) { await base.Include_reference_on_derived_type_using_string_nested2(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [t].[Name], [t].[Location], [t].[Nation] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [c].[Name], [c].[Location], [c].[Nation] FROM [Gears] AS [g0] INNER JOIN [Cities] AS [c] ON [g0].[CityOfBirthName] = [c].[Name] ) AS [t] ON (([g].[Nickname] = [t].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [t].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [t].[LeaderSquadId]) ORDER BY [l].[Name], [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[Name]"); } public override async Task Include_reference_on_derived_type_using_lambda(bool async) { await base.Include_reference_on_derived_type_using_lambda(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId])"); } public override async Task Include_reference_on_derived_type_using_lambda_with_soft_cast(bool async) { await base.Include_reference_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId])"); } public override async Task Include_reference_on_derived_type_using_lambda_with_tracking(bool async) { await base.Include_reference_on_derived_type_using_lambda_with_tracking(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId])"); } public override async Task Include_collection_on_derived_type_using_string(bool async) { await base.Include_collection_on_derived_type_using_string(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_collection_on_derived_type_using_lambda(bool async) { await base.Include_collection_on_derived_type_using_lambda(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_collection_on_derived_type_using_lambda_with_soft_cast(bool async) { await base.Include_collection_on_derived_type_using_lambda_with_soft_cast(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_base_navigation_on_derived_entity(bool async) { await base.Include_base_navigation_on_derived_entity(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [w].[Id]"); } public override async Task ThenInclude_collection_on_derived_after_base_reference(bool async) { await base.ThenInclude_collection_on_derived_after_base_reference(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task ThenInclude_collection_on_derived_after_derived_reference(bool async) { await base.ThenInclude_collection_on_derived_after_derived_reference(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated], [t].[Name], [t].[Discriminator], [t].[LocustHordeId], [t].[ThreatLevel], [t].[ThreatLevelByte], [t].[ThreatLevelNullableByte], [t].[DefeatedByNickname], [t].[DefeatedBySquadId], [t].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task ThenInclude_collection_on_derived_after_derived_collection(bool async) { await base.ThenInclude_collection_on_derived_after_derived_collection(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [t].[Nickname0], [t].[SquadId0], [t].[AssignedCityName0], [t].[CityOfBirthName0], [t].[Discriminator0], [t].[FullName0], [t].[HasSoulPatch0], [t].[LeaderNickname0], [t].[LeaderSquadId0], [t].[Rank0] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g1].[Nickname] AS [Nickname0], [g1].[SquadId] AS [SquadId0], [g1].[AssignedCityName] AS [AssignedCityName0], [g1].[CityOfBirthName] AS [CityOfBirthName0], [g1].[Discriminator] AS [Discriminator0], [g1].[FullName] AS [FullName0], [g1].[HasSoulPatch] AS [HasSoulPatch0], [g1].[LeaderNickname] AS [LeaderNickname0], [g1].[LeaderSquadId] AS [LeaderSquadId0], [g1].[Rank] AS [Rank0] FROM [Gears] AS [g0] LEFT JOIN [Gears] AS [g1] ON ([g0].[Nickname] = [g1].[LeaderNickname]) AND ([g0].[SquadId] = [g1].[LeaderSquadId]) ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[Nickname0], [t].[SquadId0]"); } public override async Task ThenInclude_reference_on_derived_after_derived_collection(bool async) { await base.ThenInclude_reference_on_derived_after_derived_collection(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated], [t].[Name], [t].[Discriminator], [t].[LocustHordeId], [t].[ThreatLevel], [t].[ThreatLevelByte], [t].[ThreatLevelNullableByte], [t].[DefeatedByNickname], [t].[DefeatedBySquadId], [t].[HighCommandId], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator0], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) ) AS [t] ON [f].[Id] = [t].[LocustHordeId] ORDER BY [f].[Id], [t].[Name], [t].[Nickname], [t].[SquadId]"); } public override async Task Multiple_derived_included_on_one_method(bool async) { await base.Multiple_derived_included_on_one_method(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated], [t].[Name], [t].[Discriminator], [t].[LocustHordeId], [t].[ThreatLevel], [t].[ThreatLevelByte], [t].[ThreatLevelNullableByte], [t].[DefeatedByNickname], [t].[DefeatedBySquadId], [t].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] LEFT JOIN [Gears] AS [g] ON ([t].[DefeatedByNickname] = [g].[Nickname]) AND ([t].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [f].[Id], [t].[Name], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_on_derived_multi_level(bool async) { await base.Include_on_derived_multi_level(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [t].[Id], [t].[Banner], [t].[Banner5], [t].[InternalNumber], [t].[Name], [t].[SquadId0], [t].[MissionId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [s0].[SquadId] AS [SquadId0], [s0].[MissionId] FROM [Gears] AS [g0] INNER JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] LEFT JOIN [SquadMissions] AS [s0] ON [s].[Id] = [s0].[SquadId] ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[Id], [t].[SquadId0], [t].[MissionId]"); } public override async Task Projecting_nullable_bool_in_conditional_works(bool async) { await base.Projecting_nullable_bool_in_conditional_works(async); AssertSql( @"SELECT CASE WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN [g].[HasSoulPatch] ELSE CAST(0 AS bit) END AS [Prop] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId])"); } public override async Task Enum_ToString_is_client_eval(bool async) { await base.Enum_ToString_is_client_eval(async); AssertSql( @"SELECT [g].[Rank] FROM [Gears] AS [g] ORDER BY [g].[SquadId], [g].[Nickname]"); } public override async Task Correlated_collections_naked_navigation_with_ToList(bool async) { await base.Correlated_collections_naked_navigation_with_ToList(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(bool async) { await base.Correlated_collections_naked_navigation_with_ToList_followed_by_projecting_count(async); AssertSql( @"SELECT ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]) FROM [Gears] AS [g] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname]"); } public override async Task Correlated_collections_naked_navigation_with_ToArray(bool async) { await base.Correlated_collections_naked_navigation_with_ToArray(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_basic_projection(bool async) { await base.Correlated_collections_basic_projection(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); } public override async Task Correlated_collections_basic_projection_explicit_to_list(bool async) { await base.Correlated_collections_basic_projection_explicit_to_list(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); } public override async Task Correlated_collections_basic_projection_explicit_to_array(bool async) { await base.Correlated_collections_basic_projection_explicit_to_array(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); } public override async Task Correlated_collections_basic_projection_ordered(bool async) { await base.Correlated_collections_basic_projection_ordered(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Name] DESC, [t].[Id]"); } public override async Task Correlated_collections_basic_projection_composite_key(bool async) { await base.Correlated_collections_basic_projection_composite_key(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[FullName], [t].[SquadId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[FullName], [g0].[SquadId], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) WHERE ([g].[Discriminator] = N'Officer') AND ([g].[Nickname] <> N'Foo') ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Correlated_collections_basic_projecting_single_property(bool async) { await base.Correlated_collections_basic_projecting_single_property(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Name], [t].[Id] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Name], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); } public override async Task Correlated_collections_basic_projecting_constant(bool async) { await base.Correlated_collections_basic_projecting_constant(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[c], [t].[Id] FROM [Gears] AS [g] LEFT JOIN ( SELECT N'BFG' AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); } public override async Task Correlated_collections_basic_projecting_constant_bool(bool async) { await base.Correlated_collections_basic_projecting_constant_bool(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[c], [t].[Id] FROM [Gears] AS [g] LEFT JOIN ( SELECT CAST(1 AS bit) AS [c], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id]"); } public override async Task Correlated_collections_projection_of_collection_thru_navigation(bool async) { await base.Correlated_collections_projection_of_collection_thru_navigation(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [s].[Id], [t].[SquadId], [t].[MissionId] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [s0].[SquadId], [s0].[MissionId] FROM [SquadMissions] AS [s0] WHERE [s0].[MissionId] <> 17 ) AS [t] ON [s].[Id] = [t].[SquadId] WHERE [g].[Nickname] <> N'Marcus' ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [s].[Id], [t].[SquadId], [t].[MissionId]"); } public override async Task Correlated_collections_project_anonymous_collection_result(bool async) { await base.Correlated_collections_project_anonymous_collection_result(async); AssertSql( @"SELECT [s].[Name], [s].[Id], [g].[FullName], [g].[Rank], [g].[Nickname], [g].[SquadId] FROM [Squads] AS [s] LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] WHERE [s].[Id] < 20 ORDER BY [s].[Id], [g].[Nickname], [g].[SquadId]"); } public override async Task Correlated_collections_nested(bool async) { await base.Correlated_collections_nested(async); AssertSql( @"SELECT [s].[Id], [t0].[SquadId], [t0].[MissionId], [t0].[Id], [t0].[SquadId0], [t0].[MissionId0] FROM [Squads] AS [s] LEFT JOIN ( SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [t].[SquadId] AS [SquadId0], [t].[MissionId] AS [MissionId0] FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] LEFT JOIN ( SELECT [s1].[SquadId], [s1].[MissionId] FROM [SquadMissions] AS [s1] WHERE [s1].[SquadId] < 7 ) AS [t] ON [m].[Id] = [t].[MissionId] WHERE [s0].[MissionId] < 42 ) AS [t0] ON [s].[Id] = [t0].[SquadId] ORDER BY [s].[Id], [t0].[SquadId], [t0].[MissionId], [t0].[Id], [t0].[SquadId0], [t0].[MissionId0]"); } public override async Task Correlated_collections_nested_mixed_streaming_with_buffer1(bool async) { await base.Correlated_collections_nested_mixed_streaming_with_buffer1(async); AssertSql( @"SELECT [s].[Id], [t0].[SquadId], [t0].[MissionId], [t0].[Id], [t0].[SquadId0], [t0].[MissionId0] FROM [Squads] AS [s] LEFT JOIN ( SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [t].[SquadId] AS [SquadId0], [t].[MissionId] AS [MissionId0] FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] LEFT JOIN ( SELECT [s1].[SquadId], [s1].[MissionId] FROM [SquadMissions] AS [s1] WHERE [s1].[SquadId] < 2 ) AS [t] ON [m].[Id] = [t].[MissionId] WHERE [s0].[MissionId] < 3 ) AS [t0] ON [s].[Id] = [t0].[SquadId] ORDER BY [s].[Id], [t0].[SquadId], [t0].[MissionId], [t0].[Id], [t0].[SquadId0], [t0].[MissionId0]"); } public override async Task Correlated_collections_nested_mixed_streaming_with_buffer2(bool async) { await base.Correlated_collections_nested_mixed_streaming_with_buffer2(async); AssertSql( @"SELECT [s].[Id], [t0].[SquadId], [t0].[MissionId], [t0].[Id], [t0].[SquadId0], [t0].[MissionId0] FROM [Squads] AS [s] LEFT JOIN ( SELECT [s0].[SquadId], [s0].[MissionId], [m].[Id], [t].[SquadId] AS [SquadId0], [t].[MissionId] AS [MissionId0] FROM [SquadMissions] AS [s0] INNER JOIN [Missions] AS [m] ON [s0].[MissionId] = [m].[Id] LEFT JOIN ( SELECT [s1].[SquadId], [s1].[MissionId] FROM [SquadMissions] AS [s1] WHERE [s1].[SquadId] < 7 ) AS [t] ON [m].[Id] = [t].[MissionId] WHERE [s0].[MissionId] < 42 ) AS [t0] ON [s].[Id] = [t0].[SquadId] ORDER BY [s].[Id], [t0].[SquadId], [t0].[MissionId], [t0].[Id], [t0].[SquadId0], [t0].[MissionId0]"); } public override async Task Correlated_collections_nested_with_custom_ordering(bool async) { await base.Correlated_collections_nested_with_custom_ordering(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId], [g0].[Rank], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[Name] <> N'Bar') OR [w].[Name] IS NULL ) AS [t] ON [g0].[FullName] = [t].[OwnerFullName] WHERE [g0].[FullName] <> N'Foo' ) AS [t0] ON ([g].[Nickname] = [t0].[LeaderNickname]) AND ([g].[SquadId] = [t0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[HasSoulPatch] DESC, [g].[Nickname], [g].[SquadId], [t0].[Rank], [t0].[Nickname], [t0].[SquadId], [t0].[IsAutomatic], [t0].[Id]"); } public override async Task Correlated_collections_same_collection_projected_multiple_times(bool async) { await base.Correlated_collections_same_collection_projected_multiple_times(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = CAST(1 AS bit) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [w0].[IsAutomatic] = CAST(1 AS bit) ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [t0].[Id]"); } public override async Task Correlated_collections_similar_collection_projected_multiple_times(bool async) { await base.Correlated_collections_similar_collection_projected_multiple_times(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = CAST(1 AS bit) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [w0].[IsAutomatic] = CAST(0 AS bit) ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] ORDER BY [g].[Rank], [g].[Nickname], [g].[SquadId], [t].[OwnerFullName], [t].[Id], [t0].[IsAutomatic], [t0].[Id]"); } public override async Task Correlated_collections_different_collections_projected(bool async) { await base.Correlated_collections_different_collections_projected(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Name], [t].[IsAutomatic], [t].[Id], [t0].[Nickname], [t0].[Rank], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Name], [w].[IsAutomatic], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = CAST(1 AS bit) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[Rank], [g0].[SquadId], [g0].[FullName], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] ) AS [t0] ON ([g].[Nickname] = [t0].[LeaderNickname]) AND ([g].[SquadId] = [t0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [t0].[FullName], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(bool async) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) WHERE ([g].[Discriminator] = N'Officer') AND EXISTS ( SELECT 1 FROM [Gears] AS [g0] WHERE ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId])) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note]"); } public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(bool async) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g1].[Nickname], [g1].[SquadId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] WHERE ([g].[Discriminator] = N'Officer') AND EXISTS ( SELECT 1 FROM [Gears] AS [g2] WHERE ([g].[Nickname] = [g2].[LeaderNickname]) AND ([g].[SquadId] = [g2].[LeaderSquadId])) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id], [t0].[SquadId]"); } public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings( bool async) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_duplicated_orderings(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], [g1].[Nickname], [g1].[SquadId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] WHERE ([g].[Discriminator] = N'Officer') AND EXISTS ( SELECT 1 FROM [Gears] AS [g2] WHERE ([g].[Nickname] = [g2].[LeaderNickname]) AND ([g].[SquadId] = [g2].[LeaderSquadId])) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[IsAutomatic], [t0].[Nickname] DESC, [t0].[Id], [t0].[SquadId]"); } public override async Task Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings( bool async) { await base.Multiple_orderby_with_navigation_expansion_on_one_of_the_order_bys_inside_subquery_complex_orderings(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId], [g1].[Nickname], [g1].[SquadId], ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g1].[FullName] IS NOT NULL AND ([g1].[FullName] = [w].[OwnerFullName])) AS [c] FROM [Weapons] AS [w0] LEFT JOIN [Gears] AS [g1] ON [w0].[OwnerFullName] = [g1].[FullName] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] WHERE ([g].[Discriminator] = N'Officer') AND EXISTS ( SELECT 1 FROM [Gears] AS [g2] WHERE ([g].[Nickname] = [g2].[LeaderNickname]) AND ([g].[SquadId] = [g2].[LeaderSquadId])) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t0].[Id] DESC, [t0].[c], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Correlated_collections_multiple_nested_complex_collections(bool async) { await base.Correlated_collections_multiple_nested_complex_collections(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t2].[FullName], [t2].[Nickname], [t2].[SquadId], [t2].[Id], [t2].[Nickname0], [t2].[SquadId0], [t2].[Id0], [t2].[Name], [t2].[IsAutomatic], [t2].[Id1], [t2].[Nickname00], [t2].[HasSoulPatch], [t2].[SquadId00], [t3].[Id], [t3].[AmmunitionType], [t3].[IsAutomatic], [t3].[Name], [t3].[OwnerFullName], [t3].[SynergyWithId], [t3].[Nickname], [t3].[SquadId] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) LEFT JOIN ( SELECT [g1].[FullName], [g1].[Nickname], [g1].[SquadId], [t1].[Id], [t1].[Nickname] AS [Nickname0], [t1].[SquadId] AS [SquadId0], [t1].[Id0], [t1].[Name], [t1].[IsAutomatic], [t1].[Id1], [t1].[Nickname0] AS [Nickname00], [t1].[HasSoulPatch], [t1].[SquadId0] AS [SquadId00], [g1].[Rank], [t1].[IsAutomatic0], [g1].[LeaderNickname], [g1].[LeaderSquadId] FROM [Gears] AS [g1] LEFT JOIN ( SELECT [w].[Id], [g2].[Nickname], [g2].[SquadId], [s].[Id] AS [Id0], [w0].[Name], [w0].[IsAutomatic], [w0].[Id] AS [Id1], [t0].[Nickname] AS [Nickname0], [t0].[HasSoulPatch], [t0].[SquadId] AS [SquadId0], [w].[IsAutomatic] AS [IsAutomatic0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g2] ON [w].[OwnerFullName] = [g2].[FullName] LEFT JOIN [Squads] AS [s] ON [g2].[SquadId] = [s].[Id] LEFT JOIN [Weapons] AS [w0] ON [g2].[FullName] = [w0].[OwnerFullName] LEFT JOIN ( SELECT [g3].[Nickname], [g3].[HasSoulPatch], [g3].[SquadId] FROM [Gears] AS [g3] ) AS [t0] ON [s].[Id] = [t0].[SquadId] WHERE ([w].[Name] <> N'Bar') OR [w].[Name] IS NULL ) AS [t1] ON [g1].[FullName] = [t1].[OwnerFullName] WHERE [g1].[FullName] <> N'Foo' ) AS [t2] ON ([g].[Nickname] = [t2].[LeaderNickname]) AND ([g].[SquadId] = [t2].[LeaderSquadId]) LEFT JOIN ( SELECT [w1].[Id], [w1].[AmmunitionType], [w1].[IsAutomatic], [w1].[Name], [w1].[OwnerFullName], [w1].[SynergyWithId], [g4].[Nickname], [g4].[SquadId] FROM [Weapons] AS [w1] LEFT JOIN [Gears] AS [g4] ON [w1].[OwnerFullName] = [g4].[FullName] ) AS [t3] ON [g0].[FullName] = [t3].[OwnerFullName] WHERE ([g].[Discriminator] = N'Officer') AND EXISTS ( SELECT 1 FROM [Gears] AS [g5] WHERE ([g].[Nickname] = [g5].[LeaderNickname]) AND ([g].[SquadId] = [g5].[LeaderSquadId])) ORDER BY [g].[HasSoulPatch] DESC, [t].[Note], [g].[Nickname], [g].[SquadId], [t].[Id], [g0].[Nickname], [g0].[SquadId], [t2].[Rank], [t2].[Nickname], [t2].[SquadId], [t2].[IsAutomatic0], [t2].[Id], [t2].[Nickname0], [t2].[SquadId0], [t2].[Id0], [t2].[Id1], [t2].[Nickname00], [t2].[SquadId00], [t3].[IsAutomatic], [t3].[Nickname] DESC, [t3].[Id], [t3].[SquadId]"); } public override async Task Correlated_collections_inner_subquery_selector_references_outer_qsre(bool async) { await base.Correlated_collections_inner_subquery_selector_references_outer_qsre(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[ReportName], [t].[OfficerName], [t].[Nickname], [t].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] WHERE ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ) AS [t] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Correlated_collections_inner_subquery_predicate_references_outer_qsre(bool async) { await base.Correlated_collections_inner_subquery_predicate_references_outer_qsre(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[ReportName], [t].[Nickname], [t].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( SELECT [g0].[FullName] AS [ReportName], [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] WHERE ([g].[FullName] <> N'Foo') AND (([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId])) ) AS [t] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(bool async) { await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_one_level_up(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Name], [t0].[Nickname0], [t0].[Id] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Name], [t].[Nickname] AS [Nickname0], [t].[Id], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] OUTER APPLY ( SELECT [w].[Name], [g0].[Nickname], [w].[Id] FROM [Weapons] AS [w] WHERE (([w].[Name] <> N'Bar') OR [w].[Name] IS NULL) AND ([g0].[FullName] = [w].[OwnerFullName]) ) AS [t] WHERE [g0].[FullName] <> N'Foo' ) AS [t0] ON ([g].[Nickname] = [t0].[LeaderNickname]) AND ([g].[SquadId] = [t0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[SquadId], [t0].[Id]"); } public override async Task Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(bool async) { await base.Correlated_collections_nested_inner_subquery_references_outer_qsre_two_levels_up(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[FullName], [t0].[Nickname], [t0].[SquadId], [t0].[Name], [t0].[Nickname0], [t0].[Id] FROM [Gears] AS [g] OUTER APPLY ( SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t].[Name], [t].[Nickname] AS [Nickname0], [t].[Id] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Name], [g].[Nickname], [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE ([w].[Name] <> N'Bar') OR [w].[Name] IS NULL ) AS [t] ON [g0].[FullName] = [t].[OwnerFullName] WHERE ([g0].[FullName] <> N'Foo') AND (([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId])) ) AS [t0] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[SquadId], [t0].[Id]"); } public override async Task Correlated_collections_on_select_many(bool async) { await base.Correlated_collections_on_select_many(async); AssertSql( @"SELECT [g].[Nickname], [s].[Name], [g].[SquadId], [s].[Id], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank] FROM [Gears] AS [g] CROSS JOIN [Squads] AS [s] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[IsAutomatic] = CAST(1 AS bit)) OR (([w].[Name] <> N'foo') OR [w].[Name] IS NULL) ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) ) AS [t0] ON [s].[Id] = [t0].[SquadId] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ORDER BY [g].[Nickname], [s].[Id] DESC, [g].[SquadId], [t].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Correlated_collections_with_Skip(bool async) { await base.Correlated_collections_with_Skip(async); AssertSql( @"SELECT [s].[Id] FROM [Squads] AS [s] ORDER BY [s].[Name]", // @"@_outer_Id='1' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE @_outer_Id = [g].[SquadId] ORDER BY [g].[Nickname] OFFSET 1 ROWS", // @"@_outer_Id='2' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE @_outer_Id = [g].[SquadId] ORDER BY [g].[Nickname] OFFSET 1 ROWS"); } public override async Task Correlated_collections_with_Take(bool async) { await base.Correlated_collections_with_Take(async); AssertSql( @"SELECT [s].[Id] FROM [Squads] AS [s] ORDER BY [s].[Name]", // @"@_outer_Id='1' SELECT TOP(2) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE @_outer_Id = [g].[SquadId] ORDER BY [g].[Nickname]", // @"@_outer_Id='2' SELECT TOP(2) [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE @_outer_Id = [g].[SquadId] ORDER BY [g].[Nickname]"); } public override async Task Correlated_collections_with_Distinct(bool async) { await base.Correlated_collections_with_Distinct(async); AssertSql( @"SELECT [s].[Id], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Squads] AS [s] LEFT JOIN ( SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] ) AS [t] ON [s].[Id] = [t].[SquadId] ORDER BY [s].[Name], [s].[Id], [t].[Nickname], [t].[SquadId]"); } public override async Task Correlated_collections_with_FirstOrDefault(bool async) { await base.Correlated_collections_with_FirstOrDefault(async); AssertSql( @"SELECT ( SELECT TOP(1) [g].[FullName] FROM [Gears] AS [g] WHERE [s].[Id] = [g].[SquadId] ORDER BY [g].[Nickname]) FROM [Squads] AS [s] ORDER BY [s].[Name]"); } public override async Task Correlated_collections_on_left_join_with_predicate(bool async) { await base.Correlated_collections_on_left_join_with_predicate(async); AssertSql( @"SELECT [g].[Nickname], [t].[Id], [g].[SquadId], [w].[Name], [w].[Id] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[HasSoulPatch] = CAST(0 AS bit) ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_on_left_join_with_null_value(bool async) { await base.Correlated_collections_on_left_join_with_null_value(async); AssertSql( @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Correlated_collections_left_join_with_self_reference(bool async) { await base.Correlated_collections_left_join_with_self_reference(async); AssertSql( @"SELECT [t].[Note], [t].[Id], [t0].[Nickname], [t0].[SquadId], [g0].[FullName], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer' ) AS [t0] ON [t].[GearNickName] = [t0].[Nickname] LEFT JOIN [Gears] AS [g0] ON (([t0].[Nickname] = [g0].[LeaderNickname]) OR ([t0].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([t0].[SquadId] = [g0].[LeaderSquadId]) ORDER BY [t].[Id], [t0].[Nickname], [t0].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Correlated_collections_deeply_nested_left_join(bool async) { await base.Correlated_collections_deeply_nested_left_join(async); AssertSql( @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[AmmunitionType], [t1].[IsAutomatic], [t1].[Name], [t1].[OwnerFullName], [t1].[SynergyWithId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON [t].[GearNickName] = [g].[Nickname] LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = CAST(1 AS bit) ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] WHERE [g0].[HasSoulPatch] = CAST(1 AS bit) ) AS [t1] ON [s].[Id] = [t1].[SquadId] ORDER BY [t].[Note], [g].[Nickname] DESC, [t].[Id], [g].[SquadId], [s].[Id], [t1].[Nickname], [t1].[SquadId], [t1].[Id]"); } public override async Task Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(bool async) { await base.Correlated_collections_from_left_join_with_additional_elements_projected_of_that_join(async); AssertSql( @"SELECT [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [t0].[Rank], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [g0].[Rank], [g0].[Nickname], [g0].[SquadId], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId], [g0].[FullName] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w0] WHERE [w0].[IsAutomatic] = CAST(0 AS bit) ) AS [t] ON [g0].[FullName] = [t].[OwnerFullName] ) AS [t0] ON [s].[Id] = [t0].[SquadId] ORDER BY [w].[Name], [w].[Id], [g].[Nickname], [g].[SquadId], [s].[Id], [t0].[FullName] DESC, [t0].[Nickname], [t0].[SquadId], [t0].[Id]"); } public override async Task Correlated_collections_complex_scenario1(bool async) { await base.Correlated_collections_complex_scenario1(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId], [t0].[Id0], [t0].[Nickname0], [t0].[HasSoulPatch], [t0].[SquadId0] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [t].[Nickname] AS [Nickname0], [t].[HasSoulPatch], [t].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId] FROM [Gears] AS [g1] ) AS [t] ON [s].[Id] = [t].[SquadId] ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId], [t0].[Id0], [t0].[Nickname0], [t0].[SquadId0]"); } public override async Task Correlated_collections_complex_scenario2(bool async) { await base.Correlated_collections_complex_scenario2(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t1].[FullName], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[Nickname0], [t1].[SquadId0], [t1].[Id0], [t1].[Nickname00], [t1].[HasSoulPatch], [t1].[SquadId00] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[Nickname] AS [Nickname0], [t0].[SquadId] AS [SquadId0], [t0].[Id0], [t0].[Nickname0] AS [Nickname00], [t0].[HasSoulPatch], [t0].[SquadId0] AS [SquadId00], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [t].[Nickname] AS [Nickname0], [t].[HasSoulPatch], [t].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId] FROM [Gears] AS [g2] ) AS [t] ON [s].[Id] = [t].[SquadId] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] ) AS [t1] ON ([g].[Nickname] = [t1].[LeaderNickname]) AND ([g].[SquadId] = [t1].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[Nickname0], [t1].[SquadId0], [t1].[Id0], [t1].[Nickname00], [t1].[SquadId00]"); } public override async Task Correlated_collections_with_funky_orderby_complex_scenario1(bool async) { await base.Correlated_collections_with_funky_orderby_complex_scenario1(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId], [t0].[Id0], [t0].[Nickname0], [t0].[HasSoulPatch], [t0].[SquadId0] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [g0].[Nickname], [g0].[SquadId], [s].[Id] AS [Id0], [t].[Nickname] AS [Nickname0], [t].[HasSoulPatch], [t].[SquadId] AS [SquadId0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] LEFT JOIN [Squads] AS [s] ON [g0].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [g1].[Nickname], [g1].[HasSoulPatch], [g1].[SquadId] FROM [Gears] AS [g1] ) AS [t] ON [s].[Id] = [t].[SquadId] ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] ORDER BY [g].[FullName], [g].[Nickname] DESC, [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId], [t0].[Id0], [t0].[Nickname0], [t0].[SquadId0]"); } public override async Task Correlated_collections_with_funky_orderby_complex_scenario2(bool async) { await base.Correlated_collections_with_funky_orderby_complex_scenario2(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t1].[FullName], [t1].[Nickname], [t1].[SquadId], [t1].[Id], [t1].[Nickname0], [t1].[SquadId0], [t1].[Id0], [t1].[Nickname00], [t1].[HasSoulPatch], [t1].[SquadId00] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[FullName], [g0].[Nickname], [g0].[SquadId], [t0].[Id], [t0].[Nickname] AS [Nickname0], [t0].[SquadId] AS [SquadId0], [t0].[Id0], [t0].[Nickname0] AS [Nickname00], [t0].[HasSoulPatch], [t0].[SquadId0] AS [SquadId00], [g0].[HasSoulPatch] AS [HasSoulPatch0], [t0].[IsAutomatic], [t0].[Name], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] LEFT JOIN ( SELECT [w].[Id], [g1].[Nickname], [g1].[SquadId], [s].[Id] AS [Id0], [t].[Nickname] AS [Nickname0], [t].[HasSoulPatch], [t].[SquadId] AS [SquadId0], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g1] ON [w].[OwnerFullName] = [g1].[FullName] LEFT JOIN [Squads] AS [s] ON [g1].[SquadId] = [s].[Id] LEFT JOIN ( SELECT [g2].[Nickname], [g2].[HasSoulPatch], [g2].[SquadId] FROM [Gears] AS [g2] ) AS [t] ON [s].[Id] = [t].[SquadId] ) AS [t0] ON [g0].[FullName] = [t0].[OwnerFullName] ) AS [t1] ON ([g].[Nickname] = [t1].[LeaderNickname]) AND ([g].[SquadId] = [t1].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[HasSoulPatch], [g].[LeaderNickname], [g].[FullName], [g].[Nickname], [g].[SquadId], [t1].[FullName], [t1].[HasSoulPatch0] DESC, [t1].[Nickname], [t1].[SquadId], [t1].[IsAutomatic], [t1].[Name] DESC, [t1].[Id], [t1].[Nickname0], [t1].[SquadId0], [t1].[Id0], [t1].[Nickname00], [t1].[SquadId00]"); } public override async Task Correlated_collection_with_top_level_FirstOrDefault(bool async) { await base.Correlated_collection_with_top_level_FirstOrDefault(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] ORDER BY [g].[Nickname] ) AS [t] LEFT JOIN [Weapons] AS [w] ON [t].[FullName] = [w].[OwnerFullName] ORDER BY [t].[Nickname], [t].[SquadId], [w].[Id]"); } public override async Task Correlated_collection_with_top_level_Count(bool async) { await base.Correlated_collection_with_top_level_Count(async); AssertSql( @"SELECT COUNT(*) FROM [Gears] AS [g]"); } public override async Task Correlated_collection_with_top_level_Last_with_orderby_on_outer(bool async) { await base.Correlated_collection_with_top_level_Last_with_orderby_on_outer(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] ORDER BY [g].[FullName] ) AS [t] LEFT JOIN [Weapons] AS [w] ON [t].[FullName] = [w].[OwnerFullName] ORDER BY [t].[FullName], [t].[Nickname], [t].[SquadId], [w].[Id]"); } public override async Task Correlated_collection_with_top_level_Last_with_order_by_on_inner(bool async) { await base.Correlated_collection_with_top_level_Last_with_order_by_on_inner(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM ( SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] ORDER BY [g].[FullName] DESC ) AS [t] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] ) AS [t0] ON [t].[FullName] = [t0].[OwnerFullName] ORDER BY [t].[FullName] DESC, [t].[Nickname], [t].[SquadId], [t0].[Name], [t0].[Id]"); } public override async Task Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(bool async) { await base.Null_semantics_on_nullable_bool_from_inner_join_subquery_is_fully_applied(async); AssertSql( @"SELECT [t].[Id], [t].[CapitalName], [t].[Discriminator], [t].[Name], [t].[CommanderName], [t].[Eradicated] FROM [LocustLeaders] AS [l] INNER JOIN ( SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] WHERE [f].[Name] = N'Swarm' ) AS [t] ON [l].[Name] = [t].[CommanderName] WHERE ([t].[Eradicated] <> CAST(1 AS bit)) OR [t].[Eradicated] IS NULL"); } public override async Task Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(bool async) { await base.Null_semantics_on_nullable_bool_from_left_join_subquery_is_fully_applied(async); AssertSql( @"SELECT [t].[Id], [t].[CapitalName], [t].[Discriminator], [t].[Name], [t].[CommanderName], [t].[Eradicated] FROM [LocustLeaders] AS [l] LEFT JOIN ( SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] WHERE [f].[Name] = N'Swarm' ) AS [t] ON [l].[Name] = [t].[CommanderName] WHERE ([t].[Eradicated] <> CAST(1 AS bit)) OR [t].[Eradicated] IS NULL"); } public override async Task Include_on_derived_type_with_order_by_and_paging(bool async) { await base.Include_on_derived_type_with_order_by_and_paging(async); AssertSql( @"@__p_0='10' SELECT [t0].[Name], [t0].[Discriminator], [t0].[LocustHordeId], [t0].[ThreatLevel], [t0].[ThreatLevelByte], [t0].[ThreatLevelNullableByte], [t0].[DefeatedByNickname], [t0].[DefeatedBySquadId], [t0].[HighCommandId], [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator0], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank], [t0].[Id], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM ( SELECT TOP(@__p_0) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator] AS [Discriminator0], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[Note] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) LEFT JOIN [Tags] AS [t] ON (([g].[Nickname] = [t].[GearNickName]) OR ([g].[Nickname] IS NULL AND [t].[GearNickName] IS NULL)) AND (([g].[SquadId] = [t].[GearSquadId]) OR ([g].[SquadId] IS NULL AND [t].[GearSquadId] IS NULL)) ORDER BY [t].[Note] ) AS [t0] LEFT JOIN [Weapons] AS [w] ON [t0].[FullName] = [w].[OwnerFullName] ORDER BY [t0].[Note], [t0].[Name], [t0].[Nickname], [t0].[SquadId], [t0].[Id], [w].[Id]"); } public override async Task Select_required_navigation_on_derived_type(bool async) { await base.Select_required_navigation_on_derived_type(async); AssertSql( @"SELECT [l0].[Name] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id]"); } public override async Task Select_required_navigation_on_the_same_type_with_cast(bool async) { await base.Select_required_navigation_on_the_same_type_with_cast(async); AssertSql( @"SELECT [c].[Name] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name]"); } public override async Task Where_required_navigation_on_derived_type(bool async) { await base.Where_required_navigation_on_derived_type(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] LEFT JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] WHERE [l0].[IsOperational] = CAST(1 AS bit)"); } public override async Task Outer_parameter_in_join_key(bool async) { await base.Outer_parameter_in_join_key(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t0].[Note], [t0].[Id], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] INNER JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] ) AS [t0] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Outer_parameter_in_join_key_inner_and_outer(bool async) { await base.Outer_parameter_in_join_key_inner_and_outer(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t0].[Note], [t0].[Id], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] INNER JOIN [Gears] AS [g0] ON [g].[FullName] = [g].[Nickname] ) AS [t0] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Outer_parameter_in_group_join_with_DefaultIfEmpty(bool async) { await base.Outer_parameter_in_group_join_with_DefaultIfEmpty(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t0].[Note], [t0].[Id], [t0].[Nickname], [t0].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( SELECT [t].[Note], [t].[Id], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g0] ON [g].[FullName] = [g0].[FullName] ) AS [t0] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Negated_bool_ternary_inside_anonymous_type_in_projection(bool async) { await base.Negated_bool_ternary_inside_anonymous_type_in_projection(async); AssertSql( @"SELECT CASE WHEN CASE WHEN [g].[HasSoulPatch] = CAST(1 AS bit) THEN CAST(1 AS bit) ELSE COALESCE([g].[HasSoulPatch], CAST(1 AS bit)) END = CAST(0 AS bit) THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [c] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId])"); } public override async Task Order_by_entity_qsre(bool async) { await base.Order_by_entity_qsre(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] ORDER BY [c].[Name], [g].[Nickname] DESC"); } public override async Task Order_by_entity_qsre_with_inheritance(bool async) { await base.Order_by_entity_qsre_with_inheritance(async); AssertSql( @"SELECT [l].[Name] FROM [LocustLeaders] AS [l] INNER JOIN [LocustHighCommands] AS [l0] ON [l].[HighCommandId] = [l0].[Id] WHERE [l].[Discriminator] = N'LocustCommander' ORDER BY [l0].[Id], [l].[Name]"); } public override async Task Order_by_entity_qsre_composite_key(bool async) { await base.Order_by_entity_qsre_composite_key(async); AssertSql( @"SELECT [w].[Name] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Order_by_entity_qsre_with_other_orderbys(bool async) { await base.Order_by_entity_qsre_with_other_orderbys(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY [w].[IsAutomatic], [g].[Nickname] DESC, [g].[SquadId] DESC, [w0].[Id], [w].[Name]"); } public override async Task Join_on_entity_qsre_keys(bool async) { await base.Join_on_entity_qsre_keys(async); AssertSql( @"SELECT [w].[Name] AS [Name1], [w0].[Name] AS [Name2] FROM [Weapons] AS [w] INNER JOIN [Weapons] AS [w0] ON [w].[Id] = [w0].[Id]"); } public override async Task Join_on_entity_qsre_keys_composite_key(bool async) { await base.Join_on_entity_qsre_keys_composite_key(async); AssertSql( @"SELECT [g].[FullName] AS [GearName1], [g0].[FullName] AS [GearName2] FROM [Gears] AS [g] INNER JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[Nickname]) AND ([g].[SquadId] = [g0].[SquadId])"); } public override async Task Join_on_entity_qsre_keys_inheritance(bool async) { await base.Join_on_entity_qsre_keys_inheritance(async); AssertSql( @"SELECT [g].[FullName] AS [GearName], [t].[FullName] AS [OfficerName] FROM [Gears] AS [g] INNER JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[FullName] FROM [Gears] AS [g0] WHERE [g0].[Discriminator] = N'Officer' ) AS [t] ON ([g].[Nickname] = [t].[Nickname]) AND ([g].[SquadId] = [t].[SquadId])"); } public override async Task Join_on_entity_qsre_keys_outer_key_is_navigation(bool async) { await base.Join_on_entity_qsre_keys_outer_key_is_navigation(async); AssertSql( @"SELECT [w].[Name] AS [Name1], [w1].[Name] AS [Name2] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] INNER JOIN [Weapons] AS [w1] ON [w0].[Id] = [w1].[Id]"); } public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation(bool async) { await base.Join_on_entity_qsre_keys_inner_key_is_navigation(async); AssertSql( @"SELECT [c].[Name] AS [CityName], [t].[Nickname] AS [GearNickname] FROM [Cities] AS [c] INNER JOIN ( SELECT [g].[Nickname], [c0].[Name] FROM [Gears] AS [g] LEFT JOIN [Cities] AS [c0] ON [g].[AssignedCityName] = [c0].[Name] ) AS [t] ON [c].[Name] = [t].[Name]"); } public override async Task Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(bool async) { await base.Join_on_entity_qsre_keys_inner_key_is_navigation_composite_key(async); AssertSql( @"SELECT [g].[Nickname], [t0].[Note] FROM [Gears] AS [g] INNER JOIN ( SELECT [t].[Note], [g0].[Nickname], [g0].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g0] ON ([t].[GearNickName] = [g0].[Nickname]) AND ([t].[GearSquadId] = [g0].[SquadId]) WHERE [t].[Note] IN (N'Cole''s Tag', N'Dom''s Tag') ) AS [t0] ON ([g].[Nickname] = [t0].[Nickname]) AND ([g].[SquadId] = [t0].[SquadId])"); } public override async Task Join_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { await base.Join_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( @"SELECT [s].[Name] AS [SquadName], [t].[Name] AS [WeaponName] FROM [Squads] AS [s] INNER JOIN ( SELECT [w].[Name], [s0].[Id] AS [Id0] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Squads] AS [s0] ON [g].[SquadId] = [s0].[Id] WHERE [w].[IsAutomatic] = CAST(1 AS bit) ) AS [t] ON [s].[Id] = [t].[Id0]"); } public override async Task GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(bool async) { await base.GroupJoin_on_entity_qsre_keys_inner_key_is_nested_navigation(async); AssertSql( @"SELECT [s].[Name] AS [SquadName], [t].[Name] AS [WeaponName] FROM [Squads] AS [s] LEFT JOIN ( SELECT [w].[Name], [s0].[Id] AS [Id0] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Squads] AS [s0] ON [g].[SquadId] = [s0].[Id] ) AS [t] ON [s].[Id] = [t].[Id0]"); } public override async Task Streaming_correlated_collection_issue_11403(bool async) { await base.Streaming_correlated_collection_issue_11403(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM ( SELECT TOP(1) [g].[Nickname], [g].[SquadId], [g].[FullName] FROM [Gears] AS [g] ORDER BY [g].[Nickname] ) AS [t] LEFT JOIN ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = CAST(0 AS bit) ) AS [t0] ON [t].[FullName] = [t0].[OwnerFullName] ORDER BY [t].[Nickname], [t].[SquadId], [t0].[Id]"); } public override async Task Project_one_value_type_from_empty_collection(bool async) { await base.Project_one_value_type_from_empty_collection(async); AssertSql( @"SELECT [s].[Name], COALESCE(( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] WHERE ([s].[Id] = [g].[SquadId]) AND ([g].[HasSoulPatch] = CAST(1 AS bit))), 0) AS [SquadId] FROM [Squads] AS [s] WHERE [s].[Name] = N'Kilo'"); } public override async Task Project_one_value_type_converted_to_nullable_from_empty_collection(bool async) { await base.Project_one_value_type_converted_to_nullable_from_empty_collection(async); AssertSql( @"SELECT [s].[Name], ( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] WHERE ([s].[Id] = [g].[SquadId]) AND ([g].[HasSoulPatch] = CAST(1 AS bit))) AS [SquadId] FROM [Squads] AS [s] WHERE [s].[Name] = N'Kilo'"); } public override async Task Project_one_value_type_with_client_projection_from_empty_collection(bool async) { await base.Project_one_value_type_with_client_projection_from_empty_collection(async); AssertSql( @"SELECT [s].[Name], [t0].[SquadId], [t0].[LeaderSquadId], [t0].[c] FROM [Squads] AS [s] LEFT JOIN ( SELECT [t].[SquadId], [t].[LeaderSquadId], [t].[c] FROM ( SELECT [g].[SquadId], [g].[LeaderSquadId], 1 AS [c], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ) AS [t] WHERE [t].[row] <= 1 ) AS [t0] ON [s].[Id] = [t0].[SquadId] WHERE [s].[Name] = N'Kilo'"); } public override async Task Filter_on_subquery_projecting_one_value_type_from_empty_collection(bool async) { await base.Filter_on_subquery_projecting_one_value_type_from_empty_collection(async); AssertSql( @"SELECT [s].[Name] FROM [Squads] AS [s] WHERE ([s].[Name] = N'Kilo') AND (COALESCE(( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] WHERE ([g].[Discriminator] IN (N'Officer', N'Gear') AND ([s].[Id] = [g].[SquadId])) AND ([g].[HasSoulPatch] = CAST(1 AS bit)) ), 0) <> 0)"); } public override async Task Select_subquery_projecting_single_constant_int(bool async) { await base.Select_subquery_projecting_single_constant_int(async); AssertSql( @"SELECT [s].[Name], COALESCE(( SELECT TOP(1) 42 FROM [Gears] AS [g] WHERE ([s].[Id] = [g].[SquadId]) AND ([g].[HasSoulPatch] = CAST(1 AS bit))), 0) AS [Gear] FROM [Squads] AS [s]"); } public override async Task Select_subquery_projecting_single_constant_string(bool async) { await base.Select_subquery_projecting_single_constant_string(async); AssertSql( @"SELECT [s].[Name], ( SELECT TOP(1) N'Foo' FROM [Gears] AS [g] WHERE ([s].[Id] = [g].[SquadId]) AND ([g].[HasSoulPatch] = CAST(1 AS bit))) AS [Gear] FROM [Squads] AS [s]"); } public override async Task Select_subquery_projecting_single_constant_bool(bool async) { await base.Select_subquery_projecting_single_constant_bool(async); AssertSql( @"SELECT [s].[Name], COALESCE(( SELECT TOP(1) CAST(1 AS bit) FROM [Gears] AS [g] WHERE ([s].[Id] = [g].[SquadId]) AND ([g].[HasSoulPatch] = CAST(1 AS bit))), CAST(0 AS bit)) AS [Gear] FROM [Squads] AS [s]"); } public override async Task Select_subquery_projecting_single_constant_inside_anonymous(bool async) { await base.Select_subquery_projecting_single_constant_inside_anonymous(async); AssertSql( @"SELECT [s].[Name], [t0].[One] FROM [Squads] AS [s] LEFT JOIN ( SELECT [t].[One], [t].[SquadId] FROM ( SELECT 1 AS [One], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ) AS [t] WHERE [t].[row] <= 1 ) AS [t0] ON [s].[Id] = [t0].[SquadId]"); } public override async Task Select_subquery_projecting_multiple_constants_inside_anonymous(bool async) { await base.Select_subquery_projecting_multiple_constants_inside_anonymous(async); AssertSql( @"SELECT [s].[Name], [t0].[True1], [t0].[False1], [t0].[c] FROM [Squads] AS [s] LEFT JOIN ( SELECT [t].[True1], [t].[False1], [t].[c], [t].[SquadId] FROM ( SELECT CAST(1 AS bit) AS [True1], CAST(0 AS bit) AS [False1], 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ) AS [t] WHERE [t].[row] <= 1 ) AS [t0] ON [s].[Id] = [t0].[SquadId]"); } public override async Task Include_with_order_by_constant(bool async) { await base.Include_with_order_by_constant(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Squads] AS [s] LEFT JOIN [Gears] AS [g] ON [s].[Id] = [g].[SquadId] ORDER BY [s].[Id], [g].[Nickname], [g].[SquadId]"); } public override async Task Correlated_collection_order_by_constant(bool async) { await base.Correlated_collection_order_by_constant(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [w].[Name], [w].[Id] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Select_subquery_projecting_single_constant_null_of_non_mapped_type(bool async) { await base.Select_subquery_projecting_single_constant_null_of_non_mapped_type(async); AssertSql( @"SELECT [s].[Name], [t0].[c] FROM [Squads] AS [s] LEFT JOIN ( SELECT [t].[c], [t].[SquadId] FROM ( SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ) AS [t] WHERE [t].[row] <= 1 ) AS [t0] ON [s].[Id] = [t0].[SquadId]"); } public override async Task Select_subquery_projecting_single_constant_of_non_mapped_type(bool async) { await base.Select_subquery_projecting_single_constant_of_non_mapped_type(async); AssertSql( @"SELECT [s].[Name], [t0].[c] FROM [Squads] AS [s] LEFT JOIN ( SELECT [t].[c], [t].[SquadId] FROM ( SELECT 1 AS [c], [g].[SquadId], ROW_NUMBER() OVER(PARTITION BY [g].[SquadId] ORDER BY [g].[Nickname], [g].[SquadId]) AS [row] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit) ) AS [t] WHERE [t].[row] <= 1 ) AS [t0] ON [s].[Id] = [t0].[SquadId]"); } public override async Task Include_collection_OrderBy_aggregate(bool async) { await base.Include_collection_OrderBy_aggregate(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_collection_with_complex_OrderBy2(bool async) { await base.Include_collection_with_complex_OrderBy2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY ( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Include_collection_with_complex_OrderBy3(bool async) { await base.Include_collection_with_complex_OrderBy3(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY COALESCE(( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), CAST(0 AS bit)), [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Correlated_collection_with_complex_OrderBy(bool async) { await base.Correlated_collection_with_complex_OrderBy(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]), [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Correlated_collection_with_very_complex_order_by(bool async) { await base.Correlated_collection_with_very_complex_order_by(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [Gears] AS [g] LEFT JOIN ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g0] WHERE [g0].[HasSoulPatch] = CAST(0 AS bit) ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[IsAutomatic] = COALESCE(( SELECT TOP(1) [g1].[HasSoulPatch] FROM [Gears] AS [g1] WHERE [g1].[Nickname] = N'Marcus'), CAST(0 AS bit)))), [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Cast_to_derived_type_after_OfType_works(bool async) { await base.Cast_to_derived_type_after_OfType_works(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer'"); } public override async Task Select_subquery_boolean(bool async) { await base.Select_subquery_boolean(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), CAST(0 AS bit)) FROM [Gears] AS [g]"); } public override async Task Select_subquery_boolean_with_pushdown(bool async) { await base.Select_subquery_boolean_with_pushdown(async); AssertSql( @"SELECT ( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]) FROM [Gears] AS [g]"); } public override async Task Select_subquery_int_with_inside_cast_and_coalesce(bool async) { await base.Select_subquery_int_with_inside_cast_and_coalesce(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [w].[Id] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), 42) FROM [Gears] AS [g]"); } public override async Task Select_subquery_int_with_outside_cast_and_coalesce(bool async) { await base.Select_subquery_int_with_outside_cast_and_coalesce(async); AssertSql( @"SELECT COALESCE(COALESCE(( SELECT TOP(1) [w].[Id] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), 0), 42) FROM [Gears] AS [g]"); } public override async Task Select_subquery_int_with_pushdown_and_coalesce(bool async) { await base.Select_subquery_int_with_pushdown_and_coalesce(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [w].[Id] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), 42) FROM [Gears] AS [g]"); } public override async Task Select_subquery_int_with_pushdown_and_coalesce2(bool async) { await base.Select_subquery_int_with_pushdown_and_coalesce2(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [w].[Id] FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName] ORDER BY [w].[Id]), ( SELECT TOP(1) [w0].[Id] FROM [Weapons] AS [w0] WHERE [g].[FullName] = [w0].[OwnerFullName] ORDER BY [w0].[Id])) FROM [Gears] AS [g]"); } public override async Task Select_subquery_boolean_empty(bool async) { await base.Select_subquery_boolean_empty(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] = N'BFG') ORDER BY [w].[Id]), CAST(0 AS bit)) FROM [Gears] AS [g]"); } public override async Task Select_subquery_boolean_empty_with_pushdown(bool async) { await base.Select_subquery_boolean_empty_with_pushdown(async); AssertSql( @"SELECT ( SELECT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] = N'BFG') ORDER BY [w].[Id]) FROM [Gears] AS [g]"); } public override async Task Select_subquery_distinct_singleordefault_boolean1(bool async) { await base.Select_subquery_distinct_singleordefault_boolean1(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] LIKE N'%Lancer%') ) AS [t]), CAST(0 AS bit)) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Select_subquery_distinct_singleordefault_boolean2(bool async) { await base.Select_subquery_distinct_singleordefault_boolean2(async); AssertSql( @"SELECT COALESCE(( SELECT DISTINCT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] LIKE N'%Lancer%')), CAST(0 AS bit)) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Select_subquery_distinct_singleordefault_boolean_with_pushdown(bool async) { await base.Select_subquery_distinct_singleordefault_boolean_with_pushdown(async); AssertSql( @"SELECT ( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] LIKE N'%Lancer%') ) AS [t]) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Select_subquery_distinct_singleordefault_boolean_empty1(bool async) { await base.Select_subquery_distinct_singleordefault_boolean_empty1(async); AssertSql( @"SELECT COALESCE(( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] = N'BFG') ) AS [t]), CAST(0 AS bit)) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Select_subquery_distinct_singleordefault_boolean_empty2(bool async) { await base.Select_subquery_distinct_singleordefault_boolean_empty2(async); AssertSql( @"SELECT COALESCE(( SELECT DISTINCT TOP(1) [w].[IsAutomatic] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] = N'BFG')), CAST(0 AS bit)) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(bool async) { await base.Select_subquery_distinct_singleordefault_boolean_empty_with_pushdown(async); AssertSql( @"SELECT ( SELECT TOP(1) [t].[IsAutomatic] FROM ( SELECT DISTINCT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[Name] = N'BFG') ) AS [t]) FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] = CAST(1 AS bit)"); } public override async Task Cast_subquery_to_base_type_using_typed_ToList(bool async) { await base.Cast_subquery_to_base_type_using_typed_ToList(async); AssertSql( @"SELECT [c].[Name], [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId] FROM [Cities] AS [c] LEFT JOIN [Gears] AS [g] ON [c].[Name] = [g].[AssignedCityName] WHERE [c].[Name] = N'Ephyra' ORDER BY [c].[Name], [g].[Nickname], [g].[SquadId]"); } public override async Task Cast_ordered_subquery_to_base_type_using_typed_ToArray(bool async) { await base.Cast_ordered_subquery_to_base_type_using_typed_ToArray(async); AssertSql( @"SELECT [c].[Name], [t].[CityOfBirthName], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Nickname], [t].[Rank], [t].[SquadId] FROM [Cities] AS [c] LEFT JOIN ( SELECT [g].[CityOfBirthName], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Nickname], [g].[Rank], [g].[SquadId], [g].[AssignedCityName] FROM [Gears] AS [g] ) AS [t] ON [c].[Name] = [t].[AssignedCityName] WHERE [c].[Name] = N'Ephyra' ORDER BY [c].[Name], [t].[Nickname] DESC, [t].[SquadId]"); } public override async Task Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(bool async) { await base.Correlated_collection_with_complex_order_by_funcletized_to_constant_bool(async); AssertSql( @"SELECT [g].[Nickname], [g].[FullName] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Nickname], [g].[SquadId], [g].[FullName]", // @"SELECT [t].[c], [t].[Nickname], [t].[SquadId], [t].[FullName], [g.Weapons].[Name], [g.Weapons].[OwnerFullName] FROM [Weapons] AS [g.Weapons] INNER JOIN ( SELECT CAST(0 AS bit) AS [c], [g0].[Nickname], [g0].[SquadId], [g0].[FullName] FROM [Gears] AS [g0] WHERE [g0].[Discriminator] IN (N'Officer', N'Gear') ) AS [t] ON [g.Weapons].[OwnerFullName] = [t].[FullName] ORDER BY [t].[c] DESC, [t].[Nickname], [t].[SquadId], [t].[FullName]"); } public override async Task Double_order_by_on_nullable_bool_coming_from_optional_navigation(bool async) { await base.Double_order_by_on_nullable_bool_coming_from_optional_navigation(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY [w0].[IsAutomatic], [w0].[Id]"); } public override async Task Double_order_by_on_Like(bool async) { await base.Double_order_by_on_Like(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE WHEN [w0].[Name] LIKE N'%Lancer' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task Double_order_by_on_is_null(bool async) { await base.Double_order_by_on_is_null(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE WHEN [w0].[Name] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task Double_order_by_on_string_compare(bool async) { await base.Double_order_by_on_string_compare(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] ORDER BY CASE WHEN ([w].[Name] = N'Marcus'' Lancer') AND [w].[Name] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [w].[Id]"); } public override async Task Double_order_by_binary_expression(bool async) { await base.Double_order_by_binary_expression(async); AssertSql( @"SELECT [w].[Id] + 2 AS [Binary] FROM [Weapons] AS [w] ORDER BY [w].[Id] + 2"); } public override async Task String_compare_with_null_conditional_argument(bool async) { await base.String_compare_with_null_conditional_argument(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE WHEN ([w0].[Name] = N'Marcus'' Lancer') AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task String_compare_with_null_conditional_argument2(bool async) { await base.String_compare_with_null_conditional_argument2(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY CASE WHEN (N'Marcus'' Lancer' = [w0].[Name]) AND [w0].[Name] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task String_concat_with_null_conditional_argument(bool async) { await base.String_concat_with_null_conditional_argument(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY COALESCE([w0].[Name], N'') + CAST(5 AS nvarchar(max))"); } public override async Task String_concat_with_null_conditional_argument2(bool async) { await base.String_concat_with_null_conditional_argument2(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY COALESCE([w0].[Name], N'') + N'Marcus'' Lancer'"); } public override async Task String_concat_on_various_types(bool async) { await base.String_concat_on_various_types(async); AssertSql( ""); } public override async Task Time_of_day_datetimeoffset(bool async) { await base.Time_of_day_datetimeoffset(async); AssertSql( @"SELECT CONVERT(time, [m].[Timeline]) FROM [Missions] AS [m]"); } public override async Task GroupBy_Property_Include_Select_Average(bool async) { await base.GroupBy_Property_Include_Select_Average(async); AssertSql( @"SELECT AVG(CAST([g].[SquadId] AS float)) FROM [Gears] AS [g] GROUP BY [g].[Rank]"); } public override async Task GroupBy_Property_Include_Select_Sum(bool async) { await base.GroupBy_Property_Include_Select_Sum(async); AssertSql( @"SELECT COALESCE(SUM([g].[SquadId]), 0) FROM [Gears] AS [g] GROUP BY [g].[Rank]"); } public override async Task GroupBy_Property_Include_Select_Count(bool async) { await base.GroupBy_Property_Include_Select_Count(async); AssertSql( @"SELECT COUNT(*) FROM [Gears] AS [g] GROUP BY [g].[Rank]"); } public override async Task GroupBy_Property_Include_Select_LongCount(bool async) { await base.GroupBy_Property_Include_Select_LongCount(async); AssertSql( @"SELECT COUNT_BIG(*) FROM [Gears] AS [g] GROUP BY [g].[Rank]"); } public override async Task GroupBy_Property_Include_Select_Min(bool async) { await base.GroupBy_Property_Include_Select_Min(async); AssertSql( @"SELECT MIN([g].[SquadId]) FROM [Gears] AS [g] GROUP BY [g].[Rank]"); } public override async Task GroupBy_Property_Include_Aggregate_with_anonymous_selector(bool async) { await base.GroupBy_Property_Include_Aggregate_with_anonymous_selector(async); AssertSql( @"SELECT [g].[Nickname] AS [Key], COUNT(*) AS [c] FROM [Gears] AS [g] GROUP BY [g].[Nickname] ORDER BY [g].[Nickname]"); } public override async Task Group_by_entity_key_with_include_on_that_entity_with_key_in_result_selector(bool async) { await base.Group_by_entity_key_with_include_on_that_entity_with_key_in_result_selector(async); AssertSql( ""); } public override async Task Group_by_entity_key_with_include_on_that_entity_with_key_in_result_selector_using_EF_Property( bool async) { await base.Group_by_entity_key_with_include_on_that_entity_with_key_in_result_selector_using_EF_Property(async); AssertSql( ""); } public override async Task Group_by_with_include_with_entity_in_result_selector(bool async) { await base.Group_by_with_include_with_entity_in_result_selector(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g.CityOfBirth].[Name], [g.CityOfBirth].[Location], [g.CityOfBirth].[Nation] FROM [Gears] AS [g] INNER JOIN [Cities] AS [g.CityOfBirth] ON [g].[CityOfBirthName] = [g.CityOfBirth].[Name] WHERE [g].[Discriminator] IN (N'Officer', N'Gear') ORDER BY [g].[Rank]"); } public override async Task GroupBy_Property_Include_Select_Max(bool async) { await base.GroupBy_Property_Include_Select_Max(async); AssertSql( @"SELECT MAX([g].[SquadId]) FROM [Gears] AS [g] GROUP BY [g].[Rank]"); } public override async Task Include_with_group_by_and_FirstOrDefault_gets_properly_applied(bool async) { await base.Include_with_group_by_and_FirstOrDefault_gets_properly_applied(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g.CityOfBirth].[Name], [g.CityOfBirth].[Location], [g.CityOfBirth].[Nation] FROM [Gears] AS [g] INNER JOIN [Cities] AS [g.CityOfBirth] ON [g].[CityOfBirthName] = [g.CityOfBirth].[Name] ORDER BY [g].[Rank]"); } public override async Task Include_collection_with_Cast_to_base(bool async) { await base.Include_collection_with_Cast_to_base(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Include_with_client_method_and_member_access_still_applies_includes(bool async) { await base.Include_with_client_method_and_member_access_still_applies_includes(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId])"); } public override async Task Include_with_projection_of_unmapped_property_still_gets_applied(bool async) { await base.Include_with_projection_of_unmapped_property_still_gets_applied(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection() { await base.Multiple_includes_with_client_method_around_entity_and_also_projecting_included_collection(); AssertSql( @"SELECT [s].[Name], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Squads] AS [s] LEFT JOIN ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ) AS [t] ON [s].[Id] = [t].[SquadId] WHERE [s].[Name] = N'Delta' ORDER BY [s].[Id], [t].[Nickname], [t].[SquadId], [t].[Id]"); } public override async Task OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(bool async) { await base.OrderBy_same_expression_containing_IsNull_correctly_deduplicates_the_ordering(async); AssertSql( @"SELECT CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE WHEN CAST(LEN([g].[Nickname]) AS int) = 5 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL END FROM [Gears] AS [g] ORDER BY CASE WHEN CASE WHEN [g].[LeaderNickname] IS NOT NULL THEN CASE WHEN CAST(LEN([g].[Nickname]) AS int) = 5 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE NULL END IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task GetValueOrDefault_in_projection(bool async) { await base.GetValueOrDefault_in_projection(async); AssertSql( @"SELECT COALESCE([w].[SynergyWithId], 0) FROM [Weapons] AS [w]"); } public override async Task GetValueOrDefault_in_filter(bool async) { await base.GetValueOrDefault_in_filter(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE COALESCE([w].[SynergyWithId], 0) = 0"); } public override async Task GetValueOrDefault_in_filter_non_nullable_column(bool async) { await base.GetValueOrDefault_in_filter_non_nullable_column(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE COALESCE([w].[Id], 0) = 0"); } public override async Task GetValueOrDefault_in_order_by(bool async) { await base.GetValueOrDefault_in_order_by(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] ORDER BY COALESCE([w].[SynergyWithId], 0), [w].[Id]"); } public override async Task GetValueOrDefault_with_argument(bool async) { await base.GetValueOrDefault_with_argument(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE COALESCE([w].[SynergyWithId], [w].[Id]) = 1"); } public override async Task GetValueOrDefault_with_argument_complex(bool async) { await base.GetValueOrDefault_with_argument_complex(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE COALESCE([w].[SynergyWithId], CAST(LEN([w].[Name]) AS int) + 42) > 10"); } public override async Task Filter_with_complex_predicate_containing_subquery(bool async) { await base.Filter_with_complex_predicate_containing_subquery(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[FullName] <> N'Dom') AND ( SELECT TOP(1) [w].[Id] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[IsAutomatic] = CAST(1 AS bit)) ORDER BY [w].[Id]) IS NOT NULL"); } public override async Task Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let( bool async) { await base.Query_with_complex_let_containing_ordering_and_filter_projecting_firstOrDefault_element_of_let(async); AssertSql( @"SELECT [g].[Nickname], ( SELECT TOP(1) [w].[Name] FROM [Weapons] AS [w] WHERE ([g].[FullName] = [w].[OwnerFullName]) AND ([w].[IsAutomatic] = CAST(1 AS bit)) ORDER BY [w].[AmmunitionType] DESC) AS [WeaponName] FROM [Gears] AS [g] WHERE [g].[Nickname] <> N'Dom'"); } public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(bool async) { await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation(async); AssertSql( @""); } public override async Task Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex(bool async) { await base.Null_semantics_is_correctly_applied_for_function_comparisons_that_take_arguments_from_optional_navigation_complex( async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] WHERE (SUBSTRING([t].[Note], 0 + 1, CAST(LEN([s].[Name]) AS int)) = [t].[GearNickName]) OR (([t].[Note] IS NULL OR [s].[Name] IS NULL) AND [t].[GearNickName] IS NULL)"); } public override async Task Filter_with_new_Guid(bool async) { await base.Filter_with_new_Guid(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note] FROM [Tags] AS [t] WHERE [t].[Id] = 'df36f493-463f-4123-83f9-6b135deeb7ba'"); } public override async Task Filter_with_new_Guid_closure(bool async) { await base.Filter_with_new_Guid_closure(async); AssertSql( @"@__p_0='df36f493-463f-4123-83f9-6b135deeb7bd' SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] FROM [Tags] AS [t] WHERE [t].[Id] = @__p_0", // @"@__p_0='b39a6fba-9026-4d69-828e-fd7068673e57' SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[Note] FROM [Tags] AS [t] WHERE [t].[Id] = @__p_0"); } public override async Task OfTypeNav1(bool async) { await base.OfTypeNav1(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Tags] AS [t0] ON ([g].[Nickname] = [t0].[GearNickName]) AND ([g].[SquadId] = [t0].[GearSquadId]) WHERE ((([t].[Note] <> N'Foo') OR [t].[Note] IS NULL) AND ([g].[Discriminator] = N'Officer')) AND (([t0].[Note] <> N'Bar') OR [t0].[Note] IS NULL)"); } public override async Task OfTypeNav2(bool async) { await base.OfTypeNav2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] WHERE ((([t].[Note] <> N'Foo') OR [t].[Note] IS NULL) AND ([g].[Discriminator] = N'Officer')) AND (([c].[Location] <> 'Bar') OR [c].[Location] IS NULL)"); } public override async Task OfTypeNav3(bool async) { await base.OfTypeNav3(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t] ON ([g].[Nickname] = [t].[GearNickName]) AND ([g].[SquadId] = [t].[GearSquadId]) INNER JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] LEFT JOIN [Tags] AS [t0] ON ([g].[Nickname] = [t0].[GearNickName]) AND ([g].[SquadId] = [t0].[GearSquadId]) WHERE ((([t].[Note] <> N'Foo') OR [t].[Note] IS NULL) AND ([g].[Discriminator] = N'Officer')) AND (([t0].[Note] <> N'Bar') OR [t0].[Note] IS NULL)"); } public override void Nav_rewrite_Distinct_with_convert() { base.Nav_rewrite_Distinct_with_convert(); AssertSql( @""); } public override void Nav_rewrite_Distinct_with_convert_anonymous() { base.Nav_rewrite_Distinct_with_convert_anonymous(); AssertSql( @""); } public override async Task Nav_rewrite_with_convert1(bool async) { await base.Nav_rewrite_with_convert1(async); AssertSql( @"SELECT [t].[Name], [t].[Discriminator], [t].[LocustHordeId], [t].[ThreatLevel], [t].[ThreatLevelByte], [t].[ThreatLevelNullableByte], [t].[DefeatedByNickname], [t].[DefeatedBySquadId], [t].[HighCommandId] FROM [Factions] AS [f] LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] WHERE ([c].[Name] <> N'Foo') OR [c].[Name] IS NULL"); } public override async Task Nav_rewrite_with_convert2(bool async) { await base.Nav_rewrite_with_convert2(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] LEFT JOIN ( SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] WHERE (([c].[Name] <> N'Foo') OR [c].[Name] IS NULL) AND (([t].[Name] <> N'Bar') OR [t].[Name] IS NULL)"); } public override async Task Nav_rewrite_with_convert3(bool async) { await base.Nav_rewrite_with_convert3(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] LEFT JOIN ( SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] WHERE (([c].[Name] <> N'Foo') OR [c].[Name] IS NULL) AND (([t].[Name] <> N'Bar') OR [t].[Name] IS NULL)"); } public override async Task Where_contains_on_navigation_with_composite_keys(bool async) { await base.Where_contains_on_navigation_with_composite_keys(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[Discriminator] IN (N'Gear', N'Officer') AND EXISTS ( SELECT 1 FROM [Cities] AS [c] WHERE EXISTS ( SELECT 1 FROM [Gears] AS [g0] WHERE ([g0].[Discriminator] IN (N'Gear', N'Officer') AND ([c].[Name] = [g0].[CityOfBirthName])) AND (([g0].[Nickname] = [g].[Nickname]) AND ([g0].[SquadId] = [g].[SquadId]))))"); } public override async Task Include_with_complex_order_by(bool async) { await base.Include_with_complex_order_by(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON [g].[FullName] = [w].[OwnerFullName] ORDER BY ( SELECT TOP(1) [w0].[Name] FROM [Weapons] AS [w0] WHERE ([g].[FullName] = [w0].[OwnerFullName]) AND ([w0].[Name] LIKE N'%Gnasher%')), [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(bool async) { await base.Anonymous_projection_take_followed_by_projecting_single_element_from_collection_navigation(async); AssertSql( @""); } public override async Task Bool_projection_from_subquery_treated_appropriately_in_where(bool async) { await base.Bool_projection_from_subquery_treated_appropriately_in_where(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE ( SELECT TOP(1) [g].[HasSoulPatch] FROM [Gears] AS [g] ORDER BY [g].[Nickname], [g].[SquadId]) = CAST(1 AS bit)"); } public override async Task DateTimeOffset_Contains_Less_than_Greater_than(bool async) { await base.DateTimeOffset_Contains_Less_than_Greater_than(async); AssertSql( @"@__start_0='1902-01-01T10:00:00.1234567+01:30' @__end_1='1902-01-03T10:00:00.1234567+01:30' SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE ((@__start_0 <= CAST(CONVERT(date, [m].[Timeline]) AS datetimeoffset)) AND ([m].[Timeline] < @__end_1)) AND ([m].[Timeline] = '1902-01-02T10:00:00.1234567+01:30')"); } public override async Task Navigation_inside_interpolated_string_expanded(bool async) { await base.Navigation_inside_interpolated_string_expanded(async); AssertSql( @"SELECT CASE WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [w0].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id]"); } public override async Task Left_join_projection_using_coalesce_tracking(bool async) { await base.Left_join_projection_using_coalesce_tracking(async); AssertSql( @"SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname]"); } public override async Task Left_join_projection_using_conditional_tracking(bool async) { await base.Left_join_projection_using_conditional_tracking(async); AssertSql( @"SELECT CASE WHEN [g0].[Nickname] IS NULL OR [g0].[SquadId] IS NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Gears] AS [g] LEFT JOIN [Gears] AS [g0] ON [g].[LeaderNickname] = [g0].[Nickname]"); } public override async Task Project_collection_navigation_nested_with_take_composite_key(bool async) { await base.Project_collection_navigation_nested_with_take_composite_key(async); AssertSql( @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [t1].[Nickname], [t1].[SquadId], [t1].[AssignedCityName], [t1].[CityOfBirthName], [t1].[Discriminator], [t1].[FullName], [t1].[HasSoulPatch], [t1].[LeaderNickname], [t1].[LeaderSquadId], [t1].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN ( SELECT [t0].[Nickname], [t0].[SquadId], [t0].[AssignedCityName], [t0].[CityOfBirthName], [t0].[Discriminator], [t0].[FullName], [t0].[HasSoulPatch], [t0].[LeaderNickname], [t0].[LeaderSquadId], [t0].[Rank] FROM ( SELECT [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank], ROW_NUMBER() OVER(PARTITION BY [g0].[LeaderNickname], [g0].[LeaderSquadId] ORDER BY [g0].[Nickname], [g0].[SquadId]) AS [row] FROM [Gears] AS [g0] ) AS [t0] WHERE [t0].[row] <= 50 ) AS [t1] ON (([g].[Nickname] = [t1].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [t1].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [t1].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [t1].[LeaderNickname], [t1].[LeaderSquadId], [t1].[Nickname], [t1].[SquadId]"); } public override async Task Project_collection_navigation_nested_composite_key(bool async) { await base.Project_collection_navigation_nested_composite_key(async); AssertSql( @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId], [g0].[AssignedCityName], [g0].[CityOfBirthName], [g0].[Discriminator], [g0].[FullName], [g0].[HasSoulPatch], [g0].[LeaderNickname], [g0].[LeaderSquadId], [g0].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Gears] AS [g0] ON (([g].[Nickname] = [g0].[LeaderNickname]) OR ([g].[Nickname] IS NULL AND [g0].[LeaderNickname] IS NULL)) AND ([g].[SquadId] = [g0].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer' ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId], [g0].[Nickname], [g0].[SquadId]"); } public override async Task Null_checks_in_correlated_predicate_are_correctly_translated(bool async) { await base.Null_checks_in_correlated_predicate_are_correctly_translated(async); AssertSql( @"SELECT [t].[Id], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON (([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId])) AND [t].[Note] IS NOT NULL ORDER BY [t].[Id], [g].[Nickname], [g].[SquadId]"); } public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(bool async) { await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector(async); AssertSql( @"@__isAutomatic_0='True' SELECT [g].[Nickname], [g].[FullName], CASE WHEN [t].[Id] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Collection] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] = @__isAutomatic_0 ) AS [t] ON [g].[FullName] = [t].[OwnerFullName]"); } public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_not_equal(bool async) { await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_not_equal(async); AssertSql( @"@__isAutomatic_0='True' SELECT [g].[Nickname], [g].[FullName], CASE WHEN [t].[Id] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Collection] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE [w].[IsAutomatic] <> @__isAutomatic_0 ) AS [t] ON [g].[FullName] = [t].[OwnerFullName]"); } public override async Task SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(bool async) { await base.SelectMany_Where_DefaultIfEmpty_with_navigation_in_the_collection_selector_order_comparison(async); AssertSql( @"@__prm_0='1' SELECT [g].[Nickname], [g].[FullName], CASE WHEN [t].[Id] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [Collection] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[OwnerFullName] FROM [Weapons] AS [w] WHERE [w].[Id] > @__prm_0 ) AS [t] ON [g].[FullName] = [t].[OwnerFullName]"); } public override async Task Join_with_inner_being_a_subquery_projecting_single_property(bool async) { await base.Join_with_inner_being_a_subquery_projecting_single_property(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname]"); } public override async Task Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(bool async) { await base.Join_with_inner_being_a_subquery_projecting_anonymous_type_with_single_property(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Gears] AS [g0] ON [g].[Nickname] = [g0].[Nickname]"); } public override async Task Navigation_based_on_complex_expression1(bool async) { await base.Navigation_based_on_complex_expression1(async); AssertSql( @""); } public override async Task Navigation_based_on_complex_expression2(bool async) { await base.Navigation_based_on_complex_expression2(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name] WHERE [t].[Name] IS NOT NULL"); } public override async Task Navigation_based_on_complex_expression3(bool async) { await base.Navigation_based_on_complex_expression3(async); AssertSql( @"SELECT [t].[Name], [t].[Discriminator], [t].[LocustHordeId], [t].[ThreatLevel], [t].[ThreatLevelByte], [t].[ThreatLevelNullableByte], [t].[DefeatedByNickname], [t].[DefeatedBySquadId], [t].[HighCommandId] FROM [Factions] AS [f] LEFT JOIN ( SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander' ) AS [t] ON [f].[CommanderName] = [t].[Name]"); } public override async Task Navigation_based_on_complex_expression4(bool async) { await base.Navigation_based_on_complex_expression4(async); AssertSql( @""); } public override async Task Navigation_based_on_complex_expression5(bool async) { await base.Navigation_based_on_complex_expression5(async); AssertSql( @""); } public override async Task Navigation_based_on_complex_expression6(bool async) { await base.Navigation_based_on_complex_expression6(async); AssertSql( @""); } public override async Task Select_as_operator(bool async) { await base.Select_as_operator(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l]"); } public override async Task Select_datetimeoffset_comparison_in_projection(bool async) { await base.Select_datetimeoffset_comparison_in_projection(async); AssertSql( @"SELECT CASE WHEN [m].[Timeline] > SYSDATETIMEOFFSET() THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Missions] AS [m]"); } public override async Task OfType_in_subquery_works(bool async) { await base.OfType_in_subquery_works(async); AssertSql( @"SELECT [t].[Name], [t].[Location], [t].[Nation] FROM [Gears] AS [g] INNER JOIN ( SELECT [c].[Name], [c].[Location], [c].[Nation], [g0].[LeaderNickname], [g0].[LeaderSquadId] FROM [Gears] AS [g0] LEFT JOIN [Cities] AS [c] ON [g0].[AssignedCityName] = [c].[Name] WHERE [g0].[Discriminator] = N'Officer' ) AS [t] ON ([g].[Nickname] = [t].[LeaderNickname]) AND ([g].[SquadId] = [t].[LeaderSquadId]) WHERE [g].[Discriminator] = N'Officer'"); } public override async Task Nullable_bool_comparison_is_translated_to_server(bool async) { await base.Nullable_bool_comparison_is_translated_to_server(async); AssertSql( @"SELECT CASE WHEN ([f].[Eradicated] = CAST(1 AS bit)) AND [f].[Eradicated] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsEradicated] FROM [Factions] AS [f]"); } public override async Task Acessing_reference_navigation_collection_composition_generates_single_query(bool async) { await base.Acessing_reference_navigation_collection_composition_generates_single_query(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [t].[Id], [t].[IsAutomatic], [t].[Name], [t].[Id0] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w].[Id], [w].[IsAutomatic], [w0].[Name], [w0].[Id] AS [Id0], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ) AS [t] ON [g].[FullName] = [t].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [t].[Id], [t].[Id0]"); } public override async Task Reference_include_chain_loads_correctly_when_middle_is_null(bool async) { await base.Reference_include_chain_loads_correctly_when_middle_is_null(async); AssertSql( @"SELECT [t].[Id], [t].[GearNickName], [t].[GearSquadId], [t].[IssueDate], [t].[Note], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] ORDER BY [t].[Note]"); } public override async Task Accessing_property_of_optional_navigation_in_child_projection_works(bool async) { await base.Accessing_property_of_optional_navigation_in_child_projection_works(async); AssertSql( @"SELECT CASE WHEN [g].[Nickname] IS NOT NULL AND [g].[SquadId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END, [t].[Id], [g].[Nickname], [g].[SquadId], [t0].[Nickname], [t0].[Id], [t0].[SquadId] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN ( SELECT [g0].[Nickname], [w].[Id], [g0].[SquadId], [w].[OwnerFullName] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g0] ON [w].[OwnerFullName] = [g0].[FullName] ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] ORDER BY [t].[Note], [t].[Id], [g].[Nickname], [g].[SquadId], [t0].[Id], [t0].[Nickname], [t0].[SquadId]"); } public override async Task Collection_navigation_ofType_filter_works(bool async) { await base.Collection_navigation_ofType_filter_works(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE EXISTS ( SELECT 1 FROM [Gears] AS [g] WHERE (([c].[Name] = [g].[CityOfBirthName]) AND ([g].[Discriminator] = N'Officer')) AND ([g].[Nickname] = N'Marcus'))"); } public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter(bool async) { await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter(async); AssertSql( @"@__prm_Inner_Nickname_0='Marcus' (Size = 450) SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM ( SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Nickname] <> @__prm_Inner_Nickname_0) AND ([g].[Nickname] <> @__prm_Inner_Nickname_0) ) AS [t] ORDER BY [t].[FullName]"); } public override async Task Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(bool async) { await base.Query_reusing_parameter_doesnt_declare_duplicate_parameter_complex(async); AssertSql( @"@__entity_equality_prm_Inner_Squad_0_Id='1' (Nullable = true) SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM ( SELECT DISTINCT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] WHERE [s].[Id] = @__entity_equality_prm_Inner_Squad_0_Id ) AS [t] INNER JOIN [Squads] AS [s0] ON [t].[SquadId] = [s0].[Id] WHERE [s0].[Id] = @__entity_equality_prm_Inner_Squad_0_Id ORDER BY [t].[FullName]"); } public override async Task Complex_GroupBy_after_set_operator(bool async) { await base.Complex_GroupBy_after_set_operator(async); AssertSql( @"SELECT [t].[Name], [t].[Count], COALESCE(SUM([t].[Count]), 0) AS [Sum] FROM ( SELECT [c].[Name], ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] FROM [Gears] AS [g] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] UNION ALL SELECT [c0].[Name], ( SELECT COUNT(*) FROM [Weapons] AS [w0] WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] FROM [Gears] AS [g0] INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] ) AS [t] GROUP BY [t].[Name], [t].[Count]"); } public override async Task Complex_GroupBy_after_set_operator_using_result_selector(bool async) { await base.Complex_GroupBy_after_set_operator_using_result_selector(async); AssertSql( @"SELECT [t].[Name], [t].[Count], COALESCE(SUM([t].[Count]), 0) AS [Sum] FROM ( SELECT [c].[Name], ( SELECT COUNT(*) FROM [Weapons] AS [w] WHERE [g].[FullName] = [w].[OwnerFullName]) AS [Count] FROM [Gears] AS [g] LEFT JOIN [Cities] AS [c] ON [g].[AssignedCityName] = [c].[Name] UNION ALL SELECT [c0].[Name], ( SELECT COUNT(*) FROM [Weapons] AS [w0] WHERE [g0].[FullName] = [w0].[OwnerFullName]) AS [Count] FROM [Gears] AS [g0] INNER JOIN [Cities] AS [c0] ON [g0].[CityOfBirthName] = [c0].[Name] ) AS [t] GROUP BY [t].[Name], [t].[Count]"); } public override async Task Left_join_with_GroupBy_with_composite_group_key(bool async) { await base.Left_join_with_GroupBy_with_composite_group_key(async); AssertSql( @"SELECT [g].[CityOfBirthName], [g].[HasSoulPatch] FROM [Gears] AS [g] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] LEFT JOIN [Tags] AS [t] ON [g].[Nickname] = [t].[GearNickName] GROUP BY [g].[CityOfBirthName], [g].[HasSoulPatch]"); } public override async Task GroupBy_with_boolean_grouping_key(bool async) { await base.GroupBy_with_boolean_grouping_key(async); AssertSql( @"SELECT [g].[CityOfBirthName], [g].[HasSoulPatch], CASE WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END AS [IsMarcus], COUNT(*) AS [Count] FROM [Gears] AS [g] GROUP BY [g].[CityOfBirthName], [g].[HasSoulPatch], CASE WHEN [g].[Nickname] = N'Marcus' THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task GroupBy_with_boolean_groupin_key_thru_navigation_access(bool async) { await base.GroupBy_with_boolean_groupin_key_thru_navigation_access(async); AssertSql( @"SELECT [g].[HasSoulPatch], LOWER([s].[Name]) AS [Name] FROM [Tags] AS [t] LEFT JOIN [Gears] AS [g] ON ([t].[GearNickName] = [g].[Nickname]) AND ([t].[GearSquadId] = [g].[SquadId]) LEFT JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] GROUP BY [g].[HasSoulPatch], [s].[Name]"); } public override async Task Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(bool async) { await base.Group_by_over_projection_with_multiple_properties_accessed_thru_navigation(async); AssertSql( @"SELECT [c].[Name] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN [Cities] AS [c0] ON [g].[AssignedCityName] = [c0].[Name] INNER JOIN [Squads] AS [s] ON [g].[SquadId] = [s].[Id] GROUP BY [c].[Name]"); } public override async Task Group_by_on_StartsWith_with_null_parameter_as_argument(bool async) { await base.Group_by_on_StartsWith_with_null_parameter_as_argument(async); AssertSql( @"SELECT CAST(0 AS bit) FROM [Gears] AS [g]"); } public override async Task Group_by_with_having_StartsWith_with_null_parameter_as_argument(bool async) { await base.Group_by_with_having_StartsWith_with_null_parameter_as_argument(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] GROUP BY [g].[FullName] HAVING 0 = 1"); } public override async Task Select_StartsWith_with_null_parameter_as_argument(bool async) { await base.Select_StartsWith_with_null_parameter_as_argument(async); AssertSql( @"SELECT CAST(0 AS bit) FROM [Gears] AS [g]"); } public override async Task Select_null_parameter_is_not_null(bool async) { await base.Select_null_parameter_is_not_null(async); AssertSql( @"@__p_0='False' SELECT @__p_0 FROM [Gears] AS [g]"); } public override async Task Where_null_parameter_is_not_null(bool async) { await base.Where_null_parameter_is_not_null(async); AssertSql( @"@__p_0='False' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE @__p_0 = CAST(1 AS bit)"); } public override async Task OrderBy_StartsWith_with_null_parameter_as_argument(bool async) { await base.OrderBy_StartsWith_with_null_parameter_as_argument(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } public override async Task OrderBy_Contains_empty_list(bool async) { await base.OrderBy_Contains_empty_list(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g]"); } public override async Task Where_with_enum_flags_parameter(bool async) { await base.Where_with_enum_flags_parameter(async); AssertSql( @"@__rank_0='1' (Nullable = true) SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & @__rank_0) = @__rank_0", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g]", // @"@__rank_0='2' (Nullable = true) SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] | @__rank_0) <> @__rank_0", // @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE 0 = 1"); } public override async Task FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(bool async) { await base.FirstOrDefault_navigation_access_entity_equality_in_where_predicate_apply_peneding_selector(async); AssertSql( @"SELECT [f].[Id], [f].[CapitalName], [f].[Discriminator], [f].[Name], [f].[CommanderName], [f].[Eradicated] FROM [Factions] AS [f] LEFT JOIN [Cities] AS [c] ON [f].[CapitalName] = [c].[Name] WHERE ([c].[Name] = ( SELECT TOP(1) [c0].[Name] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c0] ON [g].[CityOfBirthName] = [c0].[Name] ORDER BY [g].[Nickname])) OR ([c].[Name] IS NULL AND ( SELECT TOP(1) [c0].[Name] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c0] ON [g].[CityOfBirthName] = [c0].[Name] ORDER BY [g].[Nickname]) IS NULL)"); } public override async Task Bitwise_operation_with_non_null_parameter_optimizes_null_checks(bool async) { await base.Bitwise_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( @"@__ranks_0='134' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE ([g].[Rank] & @__ranks_0) <> 0", // @"@__ranks_0='134' SELECT CASE WHEN ([g].[Rank] | @__ranks_0) = @__ranks_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Gears] AS [g]", // @"@__ranks_0='134' SELECT CASE WHEN ([g].[Rank] | ([g].[Rank] | (@__ranks_0 | ([g].[Rank] | @__ranks_0)))) = @__ranks_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Gears] AS [g]"); } public override async Task Bitwise_operation_with_null_arguments(bool async) { await base.Bitwise_operation_with_null_arguments(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL", // @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL", // @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE [w].[AmmunitionType] IS NULL", // @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w]", // @"@__prm_0='2' (Nullable = true) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE (([w].[AmmunitionType] & @__prm_0) <> 0) OR [w].[AmmunitionType] IS NULL", // @"@__prm_0='1' (Nullable = true) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[AmmunitionType] & @__prm_0) = @__prm_0"); } public override async Task Logical_operation_with_non_null_parameter_optimizes_null_checks(bool async) { await base.Logical_operation_with_non_null_parameter_optimizes_null_checks(async); AssertSql( @"@__prm_0='True' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] <> @__prm_0", // @"@__prm_0='False' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE [g].[HasSoulPatch] <> @__prm_0"); } public override async Task Cast_OfType_works_correctly(bool async) { await base.Cast_OfType_works_correctly(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer'"); } public override async Task Join_inner_source_custom_projection_followed_by_filter(bool async) { await base.Join_inner_source_custom_projection_followed_by_filter(async); AssertSql( @"SELECT CASE WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) ELSE NULL END AS [IsEradicated], [f].[CommanderName], [f].[Name] FROM [LocustLeaders] AS [l] INNER JOIN [Factions] AS [f] ON [l].[Name] = [f].[CommanderName] WHERE (CASE WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) ELSE NULL END <> CAST(1 AS bit)) OR CASE WHEN [f].[Name] = N'Locust' THEN CAST(1 AS bit) ELSE NULL END IS NULL"); } public override async Task Byte_array_contains_literal(bool async) { await base.Byte_array_contains_literal(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE CHARINDEX(0x01, [s].[Banner]) > 0"); } public override async Task Byte_array_filter_by_length_literal(bool async) { await base.Byte_array_filter_by_length_literal(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE CAST(DATALENGTH([s].[Banner]) AS int) = 1"); } public override async Task Byte_array_filter_by_length_parameter(bool async) { await base.Byte_array_filter_by_length_parameter(async); AssertSql( @"@__p_0='1' SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE CAST(DATALENGTH([s].[Banner]) AS int) = @__p_0"); } public override void Byte_array_filter_by_length_parameter_compiled() { base.Byte_array_filter_by_length_parameter_compiled(); AssertSql( @"@__byteArrayParam='0x2A80' (Size = 8000) SELECT COUNT(*) FROM [Squads] AS [s] WHERE CAST(DATALENGTH([s].[Banner]) AS int) = CAST(DATALENGTH(@__byteArrayParam) AS int)"); } public override async Task Byte_array_contains_parameter(bool async) { await base.Byte_array_contains_parameter(async); AssertSql( @"@__someByte_0='1' (Size = 1) SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE CHARINDEX(CAST(@__someByte_0 AS varbinary(max)), [s].[Banner]) > 0"); } public override async Task Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(bool async) { await base.Byte_array_filter_by_length_literal_does_not_cast_on_varbinary_n(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE DATALENGTH([s].[Banner5]) = 5"); } public override async Task Conditional_expression_with_test_being_simplified_to_constant_simple(bool isAsync) { await base.Conditional_expression_with_test_being_simplified_to_constant_simple(isAsync); AssertSql( @"@__prm_0='True' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE CASE WHEN [g].[HasSoulPatch] = @__prm_0 THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END = CAST(1 AS bit)"); } public override async Task Conditional_expression_with_test_being_simplified_to_constant_complex(bool isAsync) { await base.Conditional_expression_with_test_being_simplified_to_constant_complex(isAsync); AssertSql( @"@__prm_0='True' @__prm2_1='Dom's Lancer' (Size = 4000) SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE CASE WHEN [g].[HasSoulPatch] = @__prm_0 THEN CASE WHEN (( SELECT TOP(1) [w].[Name] FROM [Weapons] AS [w] WHERE [w].[Id] = [g].[SquadId]) = @__prm2_1) AND ( SELECT TOP(1) [w].[Name] FROM [Weapons] AS [w] WHERE [w].[Id] = [g].[SquadId]) IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END ELSE CAST(0 AS bit) END = CAST(1 AS bit)"); } public override async Task OrderBy_bool_coming_from_optional_navigation(bool async) { await base.OrderBy_bool_coming_from_optional_navigation(async); AssertSql( @"SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ORDER BY [w0].[IsAutomatic]"); } public override async Task DateTimeOffset_Date_returns_datetime(bool async) { await base.DateTimeOffset_Date_returns_datetime(async); AssertSql( @"@__dateTimeOffset_Date_0='0002-03-01T00:00:00.0000000' SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE CONVERT(date, [m].[Timeline]) >= @__dateTimeOffset_Date_0"); } public override async Task Conditional_with_conditions_evaluating_to_false_gets_optimized(bool async) { await base.Conditional_with_conditions_evaluating_to_false_gets_optimized(async); AssertSql( @"SELECT [g].[FullName] FROM [Gears] AS [g]"); } public override async Task Conditional_with_conditions_evaluating_to_true_gets_optimized(bool async) { await base.Conditional_with_conditions_evaluating_to_true_gets_optimized(async); AssertSql( @"SELECT [g].[CityOfBirthName] FROM [Gears] AS [g]"); } public override async Task Projecting_required_string_column_compared_to_null_parameter(bool async) { await base.Projecting_required_string_column_compared_to_null_parameter(async); AssertSql( @"SELECT CAST(0 AS bit) FROM [Gears] AS [g]"); } public override async Task Byte_array_filter_by_SequenceEqual(bool isAsync) { await base.Byte_array_filter_by_SequenceEqual(isAsync); AssertSql( @"@__byteArrayParam_0='0x0405060708' (Size = 5) SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE [s].[Banner5] = @__byteArrayParam_0"); } public override async Task Group_by_nullable_property_HasValue_and_project_the_grouping_key(bool async) { await base.Group_by_nullable_property_HasValue_and_project_the_grouping_key(async); AssertSql( @"SELECT CASE WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Weapons] AS [w] GROUP BY CASE WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END"); } public override async Task Group_by_nullable_property_and_project_the_grouping_key_HasValue(bool async) { await base.Group_by_nullable_property_and_project_the_grouping_key_HasValue(async); AssertSql( @"SELECT CASE WHEN [w].[SynergyWithId] IS NOT NULL THEN CAST(1 AS bit) ELSE CAST(0 AS bit) END FROM [Weapons] AS [w] GROUP BY [w].[SynergyWithId]"); } public override async Task Checked_context_with_cast_does_not_fail(bool isAsync) { await base.Checked_context_with_cast_does_not_fail(isAsync); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE CAST([l].[ThreatLevel] AS tinyint) >= CAST(5 AS tinyint)"); } public override async Task Checked_context_with_addition_does_not_fail(bool isAsync) { await base.Checked_context_with_addition_does_not_fail(isAsync); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE CAST([l].[ThreatLevel] AS bigint) >= (CAST(5 AS bigint) + CAST([l].[ThreatLevel] AS bigint))"); } public override async Task TimeSpan_Hours(bool async) { await base.TimeSpan_Hours(async); AssertSql( @"SELECT DATEPART(hour, [m].[Duration]) FROM [Missions] AS [m]"); } public override async Task TimeSpan_Minutes(bool async) { await base.TimeSpan_Minutes(async); AssertSql( @"SELECT DATEPART(minute, [m].[Duration]) FROM [Missions] AS [m]"); } public override async Task TimeSpan_Seconds(bool async) { await base.TimeSpan_Seconds(async); AssertSql( @"SELECT DATEPART(second, [m].[Duration]) FROM [Missions] AS [m]"); } public override async Task TimeSpan_Milliseconds(bool async) { await base.TimeSpan_Milliseconds(async); AssertSql( @"SELECT DATEPART(millisecond, [m].[Duration]) FROM [Missions] AS [m]"); } public override async Task Where_TimeSpan_Hours(bool async) { await base.Where_TimeSpan_Hours(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(hour, [m].[Duration]) = 1"); } public override async Task Where_TimeSpan_Minutes(bool async) { await base.Where_TimeSpan_Minutes(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(minute, [m].[Duration]) = 1"); } public override async Task Where_TimeSpan_Seconds(bool async) { await base.Where_TimeSpan_Seconds(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(second, [m].[Duration]) = 1"); } public override async Task Where_TimeSpan_Milliseconds(bool async) { await base.Where_TimeSpan_Milliseconds(async); AssertSql( @"SELECT [m].[Id], [m].[CodeName], [m].[Duration], [m].[Rating], [m].[Timeline] FROM [Missions] AS [m] WHERE DATEPART(millisecond, [m].[Duration]) = 1"); } public override async Task Contains_on_collection_of_byte_subquery(bool async) { await base.Contains_on_collection_of_byte_subquery(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte])"); } public override async Task Contains_on_collection_of_nullable_byte_subquery(bool async) { await base.Contains_on_collection_of_nullable_byte_subquery(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE ([l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte]) OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL))"); } public override async Task Contains_on_collection_of_nullable_byte_subquery_null_constant(bool async) { await base.Contains_on_collection_of_nullable_byte_subquery_null_constant(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE [l0].[ThreatLevelNullableByte] IS NULL)"); } public override async Task Contains_on_collection_of_nullable_byte_subquery_null_parameter(bool async) { await base.Contains_on_collection_of_nullable_byte_subquery_null_parameter(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE [l0].[ThreatLevelNullableByte] IS NULL)"); } public override async Task Contains_on_byte_array_property_using_byte_column(bool async) { await base.Contains_on_byte_array_property_using_byte_column(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name], [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [Squads] AS [s] CROSS JOIN [LocustLeaders] AS [l] WHERE CHARINDEX(CAST([l].[ThreatLevelByte] AS varbinary(max)), [s].[Banner]) > 0"); } public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion( bool async) { await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [LocustLeaders] AS [l] CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte]) ) AS [t]"); } public override async Task Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated( bool async) { await base.Subquery_projecting_non_nullable_scalar_contains_non_nullable_value_doesnt_need_null_expansion_negated(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [LocustLeaders] AS [l] CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE NOT (EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE [l0].[ThreatLevelByte] = [l].[ThreatLevelByte])) ) AS [t]"); } public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(bool async) { await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [LocustLeaders] AS [l] CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE ([l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte]) OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL)) ) AS [t]"); } public override async Task Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(bool async) { await base.Subquery_projecting_nullable_scalar_contains_nullable_value_needs_null_expansion_negated(async); AssertSql( @"SELECT [t].[Nickname], [t].[SquadId], [t].[AssignedCityName], [t].[CityOfBirthName], [t].[Discriminator], [t].[FullName], [t].[HasSoulPatch], [t].[LeaderNickname], [t].[LeaderSquadId], [t].[Rank] FROM [LocustLeaders] AS [l] CROSS APPLY ( SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE NOT (EXISTS ( SELECT 1 FROM [LocustLeaders] AS [l0] WHERE ([l0].[ThreatLevelNullableByte] = [l].[ThreatLevelNullableByte]) OR ([l0].[ThreatLevelNullableByte] IS NULL AND [l].[ThreatLevelNullableByte] IS NULL))) ) AS [t]"); } public override async Task Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { await base.Enum_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( @"@__prm_0='1' (Nullable = true) SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE @__prm_0 = [w].[AmmunitionType]"); } public override async Task Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(bool async) { await base.Enum_flags_closure_typed_as_underlying_type_generates_correct_parameter_type(async); AssertSql( @"@__prm_0='133' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (@__prm_0 & [g].[Rank]) = [g].[Rank]"); } public override async Task Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(bool async) { await base.Enum_flags_closure_typed_as_different_type_generates_correct_parameter_type(async); AssertSql( @"@__prm_0='5' SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [Gears] AS [g] WHERE (@__prm_0 & CAST([g].[Rank] AS int)) = CAST([g].[Rank] AS int)"); } public override async Task Constant_enum_with_same_underlying_value_as_previously_parameterized_int(bool async) { await base.Constant_enum_with_same_underlying_value_as_previously_parameterized_int(async); AssertSql( @"@__p_0='1' SELECT TOP(@__p_0) [g].[Rank] & @__p_0 FROM [Gears] AS [g] ORDER BY [g].[Nickname]"); } public override async Task Enum_array_contains(bool async) { await base.Enum_array_contains(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] WHERE [w0].[Id] IS NOT NULL AND (([w0].[AmmunitionType] = 1) OR [w0].[AmmunitionType] IS NULL)"); } [ConditionalTheory] [MemberData(nameof(IsAsyncData))] public async Task DataLength_function_for_string_parameter(bool async) { await AssertQueryScalar( async, ss => ss.Set<Mission>().Select(m => EF.Functions.DataLength(m.CodeName)), ss => ss.Set<Mission>().Select(m => (int?)(m.CodeName.Length * 2))); AssertSql( @"SELECT CAST(DATALENGTH([m].[CodeName]) AS int) FROM [Missions] AS [m]"); } public override async Task CompareTo_used_with_non_unicode_string_column_and_constant(bool async) { await base.CompareTo_used_with_non_unicode_string_column_and_constant(async); AssertSql( @"SELECT [c].[Name], [c].[Location], [c].[Nation] FROM [Cities] AS [c] WHERE [c].[Location] = 'Unknown'"); } public override async Task Coalesce_used_with_non_unicode_string_column_and_constant(bool async) { await base.Coalesce_used_with_non_unicode_string_column_and_constant(async); AssertSql( @"SELECT COALESCE([c].[Location], 'Unknown') FROM [Cities] AS [c]"); } public override async Task Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(bool async) { await base.Groupby_anonymous_type_with_navigations_followed_up_by_anonymous_projection_and_orderby(async); AssertSql( @"SELECT [c].[Name], [c].[Location], COUNT(*) AS [Count] FROM [Weapons] AS [w] LEFT JOIN [Gears] AS [g] ON [w].[OwnerFullName] = [g].[FullName] LEFT JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] GROUP BY [c].[Name], [c].[Location] ORDER BY [c].[Location]"); } public override async Task SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(bool async) { await base.SelectMany_predicate_with_non_equality_comparison_converted_to_inner_join(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] INNER JOIN [Weapons] AS [w] ON ([g].[FullName] <> [w].[OwnerFullName]) OR [w].[OwnerFullName] IS NULL ORDER BY [g].[Nickname], [w].[Id]"); } public override async Task SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(bool async) { await base.SelectMany_predicate_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON ([g].[FullName] <> [w].[OwnerFullName]) OR [w].[OwnerFullName] IS NULL ORDER BY [g].[Nickname], [w].[Id]"); } public override async Task SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join( bool async) { await base.SelectMany_predicate_after_navigation_with_non_equality_comparison_DefaultIfEmpty_converted_to_left_join(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN ( SELECT [w0].[Id], [w0].[AmmunitionType], [w0].[IsAutomatic], [w0].[Name], [w0].[OwnerFullName], [w0].[SynergyWithId] FROM [Weapons] AS [w] LEFT JOIN [Weapons] AS [w0] ON [w].[SynergyWithId] = [w0].[Id] ) AS [t] ON ([g].[FullName] <> [t].[OwnerFullName]) OR [t].[OwnerFullName] IS NULL ORDER BY [g].[Nickname], [t].[Id]"); } public override async Task SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(bool async) { await base.SelectMany_without_result_selector_and_non_equality_comparison_converted_to_join(async); AssertSql( @"SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON ([g].[FullName] <> [w].[OwnerFullName]) OR [w].[OwnerFullName] IS NULL"); } public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(bool async) { await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON ([g].[FullName] = [w].[OwnerFullName]) AND ([g].[SquadId] < [w].[Id]) ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(bool async) { await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join2(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON ([g].[FullName] = [w].[OwnerFullName]) AND ([g].[SquadId] <= [w].[Id]) ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(bool async) { await base.Filtered_collection_projection_with_order_comparison_predicate_converted_to_join3(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Gears] AS [g] LEFT JOIN [Weapons] AS [w] ON ([g].[FullName] = [w].[OwnerFullName]) AND ([g].[SquadId] >= [w].[Id]) ORDER BY [g].[Nickname], [g].[SquadId], [w].[Id]"); } public override async Task SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(bool async) { await base.SelectMany_predicate_with_non_equality_comparison_with_Take_doesnt_convert_to_join(async); AssertSql( @"SELECT [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank], [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM [Gears] AS [g] CROSS APPLY ( SELECT TOP(3) [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId] FROM [Weapons] AS [w] WHERE ([w].[OwnerFullName] <> [g].[FullName]) OR [w].[OwnerFullName] IS NULL ORDER BY [w].[Id] ) AS [t] ORDER BY [g].[Nickname], [t].[Id]"); } public override async Task FirstOrDefault_over_int_compared_to_zero(bool async) { await base.FirstOrDefault_over_int_compared_to_zero(async); AssertSql( @"SELECT [s].[Name] FROM [Squads] AS [s] WHERE ([s].[Name] = N'Kilo') AND (COALESCE(( SELECT TOP(1) [g].[SquadId] FROM [Gears] AS [g] WHERE ([s].[Id] = [g].[SquadId]) AND ([g].[HasSoulPatch] = CAST(1 AS bit))), 0) <> 0)"); } public override async Task Correlated_collection_with_inner_collection_references_element_two_levels_up(bool async) { await base.Correlated_collection_with_inner_collection_references_element_two_levels_up(async); AssertSql( @"SELECT [g].[FullName], [g].[Nickname], [g].[SquadId], [t].[ReportName], [t].[OfficerName], [t].[Nickname], [t].[SquadId] FROM [Gears] AS [g] OUTER APPLY ( SELECT [g0].[FullName] AS [ReportName], [g].[FullName] AS [OfficerName], [g0].[Nickname], [g0].[SquadId] FROM [Gears] AS [g0] WHERE ([g].[Nickname] = [g0].[LeaderNickname]) AND ([g].[SquadId] = [g0].[LeaderSquadId]) ) AS [t] WHERE [g].[Discriminator] = N'Officer' ORDER BY [g].[Nickname], [g].[SquadId], [t].[Nickname], [t].[SquadId]"); } public override async Task Accessing_derived_property_using_hard_and_soft_cast(bool async) { await base.Accessing_derived_property_using_hard_and_soft_cast(async); AssertSql( @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE ([l].[Discriminator] = N'LocustCommander') AND (([l].[HighCommandId] <> 0) OR [l].[HighCommandId] IS NULL)", // @"SELECT [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId] FROM [LocustLeaders] AS [l] WHERE ([l].[Discriminator] = N'LocustCommander') AND (([l].[HighCommandId] <> 0) OR [l].[HighCommandId] IS NULL)"); } public override async Task Cast_to_derived_followed_by_include_and_FirstOrDefault(bool async) { await base.Cast_to_derived_followed_by_include_and_FirstOrDefault(async); AssertSql( @"SELECT TOP(1) [l].[Name], [l].[Discriminator], [l].[LocustHordeId], [l].[ThreatLevel], [l].[ThreatLevelByte], [l].[ThreatLevelNullableByte], [l].[DefeatedByNickname], [l].[DefeatedBySquadId], [l].[HighCommandId], [g].[Nickname], [g].[SquadId], [g].[AssignedCityName], [g].[CityOfBirthName], [g].[Discriminator], [g].[FullName], [g].[HasSoulPatch], [g].[LeaderNickname], [g].[LeaderSquadId], [g].[Rank] FROM [LocustLeaders] AS [l] LEFT JOIN [Gears] AS [g] ON ([l].[DefeatedByNickname] = [g].[Nickname]) AND ([l].[DefeatedBySquadId] = [g].[SquadId]) WHERE [l].[Name] LIKE N'%Queen%'"); } public override async Task Correlated_collection_take(bool async) { await base.Correlated_collection_take(async); AssertSql( @"SELECT [g].[Nickname], [c].[Name], [c].[Location], [c].[Nation], [g].[SquadId], [t0].[Id], [t0].[AmmunitionType], [t0].[IsAutomatic], [t0].[Name], [t0].[OwnerFullName], [t0].[SynergyWithId] FROM [Gears] AS [g] INNER JOIN [Cities] AS [c] ON [g].[CityOfBirthName] = [c].[Name] LEFT JOIN ( SELECT [t].[Id], [t].[AmmunitionType], [t].[IsAutomatic], [t].[Name], [t].[OwnerFullName], [t].[SynergyWithId] FROM ( SELECT [w].[Id], [w].[AmmunitionType], [w].[IsAutomatic], [w].[Name], [w].[OwnerFullName], [w].[SynergyWithId], ROW_NUMBER() OVER(PARTITION BY [w].[OwnerFullName] ORDER BY [w].[Id]) AS [row] FROM [Weapons] AS [w] ) AS [t] WHERE [t].[row] <= 10 ) AS [t0] ON [g].[FullName] = [t0].[OwnerFullName] ORDER BY [g].[Nickname], [g].[SquadId], [c].[Name], [t0].[OwnerFullName], [t0].[Id]"); } public override async Task FirstOrDefault_on_empty_collection_of_DateTime_in_subquery(bool async) { await base.FirstOrDefault_on_empty_collection_of_DateTime_in_subquery(async); AssertSql( @"SELECT [g].[Nickname], COALESCE(( SELECT TOP(1) [t].[IssueDate] FROM [Tags] AS [t] WHERE [t].[GearNickName] = [g].[FullName] ORDER BY [t].[Id]), '0001-01-01T00:00:00.0000000') AS [invalidTagIssueDate] FROM [Gears] AS [g] LEFT JOIN [Tags] AS [t0] ON ([g].[Nickname] = [t0].[GearNickName]) AND ([g].[SquadId] = [t0].[GearSquadId]) WHERE [t0].[IssueDate] > COALESCE(( SELECT TOP(1) [t1].[IssueDate] FROM [Tags] AS [t1] WHERE [t1].[GearNickName] = [g].[FullName] ORDER BY [t1].[Id]), '0001-01-01T00:00:00.0000000')"); } public override async Task First_on_byte_array(bool async) { await base.First_on_byte_array(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE CAST(SUBSTRING([s].[Banner], 1, 1) AS tinyint) = CAST(2 AS tinyint)"); } public override async Task Array_access_on_byte_array(bool async) { await base.Array_access_on_byte_array(async); AssertSql( @"SELECT [s].[Id], [s].[Banner], [s].[Banner5], [s].[InternalNumber], [s].[Name] FROM [Squads] AS [s] WHERE CAST(SUBSTRING([s].[Banner5], 2 + 1, 1) AS tinyint) = CAST(6 AS tinyint)"); } public override async Task Project_shadow_properties(bool async) { await base.Project_shadow_properties(async); AssertSql( @"SELECT [g].[Nickname], [g].[AssignedCityName] FROM [Gears] AS [g]"); } public override async Task Project_discriminator_columns(bool async) { await base.Project_discriminator_columns(async); AssertSql( @"SELECT [g].[Nickname], [g].[Discriminator] FROM [Gears] AS [g]", // @"SELECT [g].[Nickname], [g].[Discriminator] FROM [Gears] AS [g] WHERE [g].[Discriminator] = N'Officer'", // @"SELECT [f].[Id], [f].[Discriminator] FROM [Factions] AS [f]", // @"SELECT [f].[Id], [f].[Discriminator] FROM [Factions] AS [f]", // @"SELECT [l].[Name], [l].[Discriminator] FROM [LocustLeaders] AS [l]", // @"SELECT [l].[Name], [l].[Discriminator] FROM [LocustLeaders] AS [l] WHERE [l].[Discriminator] = N'LocustCommander'"); } private void AssertSql(params string[] expected) => Fixture.TestSqlLoggerFactory.AssertBaseline(expected); } }
46.480691
713
0.611389
[ "Apache-2.0" ]
FriendsTmCo/efcore
test/EFCore.SqlServer.FunctionalTests/Query/GearsOfWarQuerySqlServerTest.cs
344,236
C#
/* * Copyright (c) .NET Foundation and Contributors * * This software may be modified and distributed under the terms * of the MIT license. See the LICENSE file for details. * * https://github.com/piranhacms/piranha.core * */ using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Dynamic; using System.Linq; using System.Threading.Tasks; using Piranha.Extend; using Piranha.Extend.Fields; using Piranha.Manager.Extensions; using Piranha.Models; using Piranha.Manager.Models; using Piranha.Manager.Models.Content; using Piranha.Services; namespace Piranha.Manager.Services { public class PageService { private readonly IApi _api; private readonly IContentFactory _factory; private readonly ManagerLocalizer _localizer; /// <summary> /// Default constructor. /// </summary> /// <param name="api">The current api</param> /// <param name="factory">The content factory</param> /// <param name="localizer">The manager localizer</param> public PageService(IApi api, IContentFactory factory, ManagerLocalizer localizer) { _api = api; _factory = factory; _localizer = localizer; } /// <summary> /// Gets the list model. /// </summary> /// <returns>The list model</returns> public async Task<PageListModel> GetList() { var model = new PageListModel { Sites = (await _api.Sites.GetAllAsync()) .OrderByDescending(s => s.IsDefault) .Select(s => new PageListModel.PageSite { Id = s.Id, Title = s.Title, Slug = "/", EditUrl = "manager/site/edit/" }).ToList(), PageTypes = App.PageTypes.Select(t => new ContentTypeModel { Id = t.Id, Title = t.Title, AddUrl = "manager/page/add/" }).ToList() }; foreach (var site in model.Sites) { site.Pages.AddRange(await GetPageStructure(site.Id)); } return model; } /// <summary> /// Gets the hierachical page structure for the specified site. /// </summary> /// <param name="siteId">The site id</param> /// <returns>The structure</returns> public async Task<List<PageListModel.PageItem>> GetPageStructure(Guid siteId) { var pages = new List<PageListModel.PageItem>(); // Get the configured expanded levels var expandedLevels = 0; using (var config = new Config(_api)) { expandedLevels = config.ManagerExpandedSitemapLevels; } // Get the sitemap and transform var sitemap = await _api.Sites.GetSitemapAsync(siteId, false); var drafts = await _api.Pages.GetAllDraftsAsync(siteId); foreach (var item in sitemap) { pages.Add(MapRecursive(siteId, item, 0, expandedLevels, drafts)); } return pages; } /// <summary> /// Gets the site list with the page structure of the selected site for /// the page picker. /// </summary> /// <param name="siteId">The current site</param> /// <returns>The model</returns> public async Task<SiteListModel> GetSiteList(Guid siteId) { var site = await _api.Sites.GetByIdAsync(siteId); var model = new SiteListModel { SiteId = siteId, SiteTitle = site.Title, Sites = (await _api.Sites.GetAllAsync()) .OrderByDescending(s => s.IsDefault) .Select(s => new PageListModel.PageSite { Id = s.Id, Title = s.Title, Slug = "/", EditUrl = "manager/site/edit/" }).ToList(), Items = await GetPageStructure(siteId) }; return model; } /// <summary> /// Gets the sitemap model. /// </summary> /// <returns>The list model</returns> public async Task<Sitemap> GetSitemap(Guid? siteId = null) { return await _api.Sites.GetSitemapAsync(siteId, false); } public async Task<PageEditModel> Create(Guid siteId, string typeId) { var page = await _api.Pages.CreateAsync<DynamicPage>(typeId); if (page != null) { page.Id = Guid.NewGuid(); page.SiteId = siteId; page.SortOrder = (await _api.Sites.GetSitemapAsync(page.SiteId)).Count; // Perform manager init await _factory.InitDynamicManagerAsync(page, App.PageTypes.GetById(page.TypeId)); return Transform(page, false); } return null; } public async Task<PageEditModel> CreateRelative(Guid pageId, string typeId, bool after) { var relative = await _api.Pages.GetByIdAsync<PageInfo>(pageId); if (relative != null) { var page = await _api.Pages.CreateAsync<DynamicPage>(typeId); page.Id = Guid.NewGuid(); page.SiteId = relative.SiteId; page.ParentId = after ? relative.ParentId : relative.Id; page.SortOrder = after ? relative.SortOrder + 1 : 0; if (page != null) { // Perform manager init await _factory.InitDynamicManagerAsync(page, App.PageTypes.GetById(page.TypeId)); return Transform(page, false); } } return null; } public async Task<PageEditModel> CopyRelative(Guid sourceId, Guid pageId, bool after) { var relative = await _api.Pages.GetByIdAsync<PageInfo>(pageId); if (relative != null) { var original = await _api.Pages.GetByIdAsync(sourceId); if (original != null) { var page = await _api.Pages.CopyAsync(original); page.SiteId = relative.SiteId; page.ParentId = after ? relative.ParentId : relative.Id; page.SortOrder = after ? relative.SortOrder + 1 : 0; // Perform manager init await _factory.InitDynamicManagerAsync(page, App.PageTypes.GetById(page.TypeId)); return Transform(page, false); } } return null; } public async Task<PageEditModel> GetById(Guid id, bool useDraft = true) { var isDraft = true; var page = useDraft ? await _api.Pages.GetDraftByIdAsync(id) : null; if (page == null) { page = await _api.Pages.GetByIdAsync(id); isDraft = false; } if (page != null) { // Perform manager init await _factory.InitDynamicManagerAsync(page, App.PageTypes.GetById(page.TypeId)); var model = Transform(page, isDraft); model.PendingCommentCount = (await _api.Pages.GetAllPendingCommentsAsync(id)) .Count(); return model; } return null; } public async Task<PageEditModel> Detach(Guid id) { var page = await _api.Pages.GetByIdAsync(id); if (page != null) { await _api.Pages.DetachAsync(page); page = await _api.Pages.GetByIdAsync(id); // Perform manager init await _factory.InitDynamicManagerAsync(page, App.PageTypes.GetById(page.TypeId)); return Transform(page, false); } return null; } public async Task Save(PageEditModel model, bool draft) { var pageType = App.PageTypes.GetById(model.TypeId); if (pageType != null) { if (model.Id == Guid.Empty) { model.Id = Guid.NewGuid(); } var page = await _api.Pages.GetByIdAsync(model.Id); if (page == null) { page = await _factory.CreateAsync<DynamicPage>(pageType); page.Id = model.Id; } page.SiteId = model.SiteId; page.ParentId = model.ParentId; page.OriginalPageId = model.OriginalId; page.SortOrder = model.SortOrder; page.TypeId = model.TypeId; page.Title = model.Title; page.NavigationTitle = model.NavigationTitle; page.Slug = model.Slug; page.MetaTitle = model.MetaTitle; page.MetaKeywords = model.MetaKeywords; page.MetaDescription = model.MetaDescription; page.MetaIndex = model.MetaIndex; page.MetaFollow = model.MetaFollow; page.MetaPriority = model.MetaPriority; page.OgTitle = model.OgTitle; page.OgDescription = model.OgDescription; page.OgImage = model.OgImage; page.PrimaryImage = model.PrimaryImage; page.Excerpt = model.Excerpt; page.IsHidden = model.IsHidden; page.Published = ParsePublishedDate(model); // !string.IsNullOrEmpty(model.Published) ? DateTime.Parse(model.Published) : (DateTime?)null; page.RedirectUrl = model.RedirectUrl; page.RedirectType = (RedirectType)Enum.Parse(typeof(RedirectType), model.RedirectType); page.EnableComments = model.EnableComments; page.CloseCommentsAfterDays = model.CloseCommentsAfterDays; page.Permissions = model.SelectedPermissions; if (pageType.Routes.Count > 1) { page.Route = pageType.Routes.FirstOrDefault(r => r.Route == model.SelectedRoute?.Route) ?? pageType.Routes.First(); } // // Make sure we only keep permissions for pages are registered // var currentPermissions = App.Permissions.GetPublicPermissions().Select(p => p.Name); page.Permissions = page.Permissions.Where(p => currentPermissions.Contains(p)).ToList(); // // We only need to save regions & blocks for pages that are not copies // if (!page.OriginalPageId.HasValue) { // Save regions foreach (var region in pageType.Regions) { var modelRegion = model.Regions .FirstOrDefault(r => r.Meta.Id == region.Id); if (region.Collection) { var listRegion = (IRegionList)((IDictionary<string, object>)page.Regions)[region.Id]; listRegion.Clear(); foreach (var item in modelRegion.Items) { if (region.Fields.Count == 1) { listRegion.Add(item.Fields[0].Model); } else { var pageRegion = new ExpandoObject(); foreach (var field in region.Fields) { var modelField = item.Fields .FirstOrDefault(f => f.Meta.Id == field.Id); ((IDictionary<string, object>)pageRegion)[field.Id] = modelField.Model; } listRegion.Add(pageRegion); } } } else { var pageRegion = ((IDictionary<string, object>)page.Regions)[region.Id]; if (region.Fields.Count == 1) { ((IDictionary<string, object>)page.Regions)[region.Id] = modelRegion.Items[0].Fields[0].Model; } else { foreach (var field in region.Fields) { var modelField = modelRegion.Items[0].Fields .FirstOrDefault(f => f.Meta.Id == field.Id); ((IDictionary<string, object>)pageRegion)[field.Id] = modelField.Model; } } } } // Save blocks page.Blocks.Clear(); foreach (var block in model.Blocks) { if (block is BlockGroupModel blockGroup) { var groupType = App.Blocks.GetByType(blockGroup.Type); if (groupType != null) { var pageBlock = (BlockGroup)Activator.CreateInstance(groupType.Type); pageBlock.Id = blockGroup.Id; pageBlock.Type = blockGroup.Type; foreach (var field in blockGroup.Fields) { var prop = pageBlock.GetType().GetProperty(field.Meta.Id, App.PropertyBindings); prop.SetValue(pageBlock, field.Model); } foreach (var item in blockGroup.Items) { if (item is BlockItemModel blockItem) { pageBlock.Items.Add(blockItem.Model); } else if (item is BlockGenericModel blockGeneric) { var transformed = ContentUtils.TransformGenericBlock(blockGeneric); if (transformed != null) { pageBlock.Items.Add(transformed); } } } page.Blocks.Add(pageBlock); } } else if (block is BlockItemModel blockItem) { page.Blocks.Add(blockItem.Model); } else if (block is BlockGenericModel blockGeneric) { var transformed = ContentUtils.TransformGenericBlock(blockGeneric); if (transformed != null) { page.Blocks.Add(transformed); } } } } // Save page if (draft) { await _api.Pages.SaveDraftAsync(page); } else { await _api.Pages.SaveAsync(page); } } else { throw new ValidationException("Invalid Page Type."); } } /// <summary> /// Deletes the page with the given id. /// </summary> /// <param name="id">The unique id</param> public Task Delete(Guid id) { return _api.Pages.DeleteAsync(id); } /// <summary> /// Updates the sitemap according to the given structure. Please note /// that only the first page that has changed position is moved. /// </summary> /// <param name="structure">The page structure</param> public async Task<bool> MovePages(StructureModel structure) { var pos = GetPosition(structure.Id, structure.Items); if (pos != null) { var page = await _api.Pages.GetByIdAsync<PageInfo>(structure.Id); if (page != null) { await _api.Pages.MoveAsync(page, pos.Item1, pos.Item2); return true; } } return false; } private Tuple<Guid?,int> GetPosition(Guid id, IList<StructureModel.StructureItem> items, Guid? parentId = null) { for (var n = 0; n < items.Count; n++) { if (id == new Guid(items[n].Id)) { return new Tuple<Guid?, int>(parentId, n); } else if (items[n].Children.Count > 0) { var pos = GetPosition(id, items[n].Children, new Guid(items[n].Id)); if (pos != null) { return pos; } } } return null; } private PageListModel.PageItem MapRecursive(Guid siteId, SitemapItem item, int level, int expandedLevels, IEnumerable<Guid> drafts) { var model = new PageListModel.PageItem { Id = item.Id, SiteId = siteId, Title = item.MenuTitle, TypeName = item.PageTypeName, Published = item.Published.HasValue ? item.Published.Value.ToString("yyyy-MM-dd") : null, Status = drafts.Contains(item.Id) ? _localizer.General[PageListModel.PageItem.Draft] : !item.Published.HasValue ? _localizer.General[PageListModel.PageItem.Unpublished] : "", EditUrl = "manager/page/edit/", IsExpanded = level < expandedLevels, IsCopy = item.OriginalPageId.HasValue, IsRestricted = item.Permissions.Count > 0, IsScheduled = item.Published.HasValue && item.Published.Value > DateTime.Now, IsUnpublished = !item.Published.HasValue, Permalink = item.Permalink }; foreach (var child in item.Items) { model.Items.Add(MapRecursive(siteId, child, level + 1, expandedLevels, drafts)); } return model; } private PageEditModel Transform(DynamicPage page, bool isDraft) { var config = new Config(_api); var type = App.PageTypes.GetById(page.TypeId); var route = type.Routes.FirstOrDefault(r => r.Route == page.Route) ?? type.Routes.FirstOrDefault(); var model = new PageEditModel { Id = page.Id, SiteId = page.SiteId, ParentId = page.ParentId, OriginalId = page.OriginalPageId, SortOrder = page.SortOrder, TypeId = page.TypeId, Title = page.Title, NavigationTitle = page.NavigationTitle, Slug = page.Slug, MetaTitle = page.MetaTitle, MetaKeywords = page.MetaKeywords, MetaDescription = page.MetaDescription, MetaIndex = page.MetaIndex, MetaFollow = page.MetaFollow, MetaPriority = page.MetaPriority, OgTitle = page.OgTitle, OgDescription = page.OgDescription, OgImage = page.OgImage, PrimaryImage = page.PrimaryImage, Excerpt = page.Excerpt, IsHidden = page.IsHidden, IsScheduled = page.Published.HasValue && page.Published.Value > DateTime.Now, Published = page.Published.HasValue ? page.Published.Value.ToString("yyyy-MM-dd") : null, PublishedTime = page.Published.HasValue ? page.Published.Value.ToString("HH:mm") : null, RedirectUrl = page.RedirectUrl, RedirectType = page.RedirectType.ToString(), EnableComments = page.EnableComments, CloseCommentsAfterDays = page.CloseCommentsAfterDays, CommentCount = page.CommentCount, State = page.GetState(isDraft), UseBlocks = type.UseBlocks, UsePrimaryImage = type.UsePrimaryImage, UseExcerpt = type.UseExcerpt, UseHtmlExcerpt = config.HtmlExcerpt, SelectedRoute = route == null ? null : new RouteModel { Title = route.Title, Route = route.Route }, Permissions = App.Permissions .GetPublicPermissions() .Select(p => new KeyValuePair<string, string>(p.Name, p.Title)) .ToList(), SelectedPermissions = page.Permissions }; foreach (var r in type.Routes) { model.Routes.Add(new RouteModel { Title = r.Title, Route = r.Route }); } foreach (var regionType in type.Regions) { var region = new RegionModel { Meta = new RegionMeta { Id = regionType.Id, Name = regionType.Title, Description = regionType.Description, Placeholder = regionType.ListTitlePlaceholder, IsCollection = regionType.Collection, Expanded = regionType.ListExpand, Icon = regionType.Icon, Display = regionType.Display.ToString().ToLower(), Width = regionType.Width.ToString().ToLower() } }; var regionListModel = ((IDictionary<string, object>)page.Regions)[regionType.Id]; if (!regionType.Collection) { var regionModel = (IRegionList)Activator.CreateInstance(typeof(RegionList<>).MakeGenericType(regionListModel.GetType())); regionModel.Add(regionListModel); regionListModel = regionModel; } foreach (var regionModel in (IEnumerable)regionListModel) { var regionItem = new RegionItemModel(); foreach (var fieldType in regionType.Fields) { var appFieldType = App.Fields.GetByType(fieldType.Type); var field = new FieldModel { Meta = new FieldMeta { Id = fieldType.Id, Name = fieldType.Title, Component = appFieldType.Component, Placeholder = fieldType.Placeholder, IsHalfWidth = fieldType.Options.HasFlag(FieldOption.HalfWidth), Description = fieldType.Description, Settings = fieldType.Settings } }; if (typeof(SelectFieldBase).IsAssignableFrom(appFieldType.Type)) { foreach(var item in ((SelectFieldBase)Activator.CreateInstance(appFieldType.Type)).Items) { field.Meta.Options.Add(Convert.ToInt32(item.Value), item.Title); } } if (regionType.Fields.Count > 1) { field.Model = (IField)((IDictionary<string, object>)regionModel)[fieldType.Id]; if (regionType.ListTitleField == fieldType.Id) { regionItem.Title = field.Model.GetTitle(); field.Meta.NotifyChange = true; } } else { field.Model = (IField)regionModel; field.Meta.NotifyChange = true; regionItem.Title = field.Model.GetTitle(); } regionItem.Fields.Add(field); } if (string.IsNullOrWhiteSpace(regionItem.Title)) { regionItem.Title = "..."; } region.Items.Add(regionItem); } model.Regions.Add(region); } foreach (var block in page.Blocks) { var blockType = App.Blocks.GetByType(block.Type); if (block is BlockGroup) { var group = new BlockGroupModel { Id = block.Id, Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Icon = blockType.Icon, Component = blockType.Component, Width = blockType.Width.ToString().ToLower(), IsGroup = true, IsReadonly = page.OriginalPageId.HasValue, isCollapsed = config.ManagerDefaultCollapsedBlocks, ShowHeader = !config.ManagerDefaultCollapsedBlockGroupHeaders } }; group.Fields = ContentUtils.GetBlockFields(block); bool firstChild = true; foreach (var child in ((BlockGroup)block).Items) { blockType = App.Blocks.GetByType(child.Type); if (!blockType.IsGeneric) { // Regular block item model group.Items.Add(new BlockItemModel { IsActive = firstChild, Model = child, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, Width = blockType.Width.ToString().ToLower() } }); } else { // Generic block item model group.Items.Add(new BlockGenericModel { Id = child.Id, IsActive = firstChild, Model = ContentUtils.GetBlockFields(child), Type = child.Type, Meta = new BlockMeta { Name = blockType.Name, Title = child.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, Width = blockType.Width.ToString().ToLower() } }); } firstChild = false; } model.Blocks.Add(group); } else { if (!blockType.IsGeneric) { // Regular block item model model.Blocks.Add(new BlockItemModel { Model = block, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, Width = blockType.Width.ToString().ToLower(), IsReadonly = page.OriginalPageId.HasValue, isCollapsed = config.ManagerDefaultCollapsedBlocks } }); } else { // Generic block item model model.Blocks.Add(new BlockGenericModel { Id = block.Id, Model = ContentUtils.GetBlockFields(block), Type = block.Type, Meta = new BlockMeta { Name = blockType.Name, Title = block.GetTitle(), Icon = blockType.Icon, Component = blockType.Component, Width = blockType.Width.ToString().ToLower(), IsReadonly = page.OriginalPageId.HasValue, isCollapsed = config.ManagerDefaultCollapsedBlocks } }); } } } // Custom editors foreach (var editor in type.CustomEditors) { model.Editors.Add(new EditorModel { Component = editor.Component, Icon = editor.Icon, Name = editor.Title }); } return model; } private DateTime? ParsePublishedDate(PageEditModel model) { if (!string.IsNullOrEmpty(model.Published)) { var str = model.Published.Substring(0, 10); if (!string.IsNullOrEmpty(model.PublishedTime)) { str += $" { model.PublishedTime }"; } return DateTime.Parse(str); } return null; } } }
39.565644
154
0.439
[ "MIT" ]
AhmedSultanDev/Dashboard-RC
core/Piranha.Manager/Services/PageService.cs
32,246
C#
// <copyright file="RealTimeEventListenerHelper.cs" company="Google Inc."> // Copyright (C) 2014 Google Inc. 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. // 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. // </copyright> #if (UNITY_ANDROID) namespace GooglePlayGames.Native.PInvoke { using System; using System.Runtime.InteropServices; using GooglePlayGames.OurUtils; using C = GooglePlayGames.Native.Cwrapper.RealTimeEventListenerHelper; using Types = GooglePlayGames.Native.Cwrapper.Types; using Status = GooglePlayGames.Native.Cwrapper.CommonErrorStatus; internal class RealTimeEventListenerHelper : BaseReferenceHolder { internal RealTimeEventListenerHelper(IntPtr selfPointer) : base(selfPointer) { } protected override void CallDispose(HandleRef selfPointer) { C.RealTimeEventListenerHelper_Dispose(selfPointer); } internal RealTimeEventListenerHelper SetOnRoomStatusChangedCallback( Action<NativeRealTimeRoom> callback) { C.RealTimeEventListenerHelper_SetOnRoomStatusChangedCallback(SelfPtr(), InternalOnRoomStatusChangedCallback, ToCallbackPointer(callback)); return this; } [AOT.MonoPInvokeCallback(typeof(C.OnRoomStatusChangedCallback))] internal static void InternalOnRoomStatusChangedCallback(IntPtr response, IntPtr data) { Callbacks.PerformInternalCallback( "RealTimeEventListenerHelper#InternalOnRoomStatusChangedCallback", Callbacks.Type.Permanent, response, data); } internal RealTimeEventListenerHelper SetOnRoomConnectedSetChangedCallback( Action<NativeRealTimeRoom> callback) { C.RealTimeEventListenerHelper_SetOnRoomConnectedSetChangedCallback(SelfPtr(), InternalOnRoomConnectedSetChangedCallback, ToCallbackPointer(callback)); return this; } [AOT.MonoPInvokeCallback(typeof(C.OnRoomConnectedSetChangedCallback))] internal static void InternalOnRoomConnectedSetChangedCallback(IntPtr response, IntPtr data) { Callbacks.PerformInternalCallback( "RealTimeEventListenerHelper#InternalOnRoomConnectedSetChangedCallback", Callbacks.Type.Permanent, response, data); } internal RealTimeEventListenerHelper SetOnP2PConnectedCallback( Action<NativeRealTimeRoom, MultiplayerParticipant> callback) { C.RealTimeEventListenerHelper_SetOnP2PConnectedCallback(SelfPtr(), InternalOnP2PConnectedCallback, Callbacks.ToIntPtr(callback)); return this; } [AOT.MonoPInvokeCallback(typeof(C.OnP2PConnectedCallback))] internal static void InternalOnP2PConnectedCallback( IntPtr room, IntPtr participant, IntPtr data) { PerformRoomAndParticipantCallback( "InternalOnP2PConnectedCallback", room, participant, data); } internal RealTimeEventListenerHelper SetOnP2PDisconnectedCallback( Action<NativeRealTimeRoom, MultiplayerParticipant> callback) { C.RealTimeEventListenerHelper_SetOnP2PDisconnectedCallback(SelfPtr(), InternalOnP2PDisconnectedCallback, Callbacks.ToIntPtr(callback)); return this; } [AOT.MonoPInvokeCallback(typeof(C.OnP2PDisconnectedCallback))] internal static void InternalOnP2PDisconnectedCallback( IntPtr room, IntPtr participant, IntPtr data) { PerformRoomAndParticipantCallback( "InternalOnP2PDisconnectedCallback", room, participant, data); } internal RealTimeEventListenerHelper SetOnParticipantStatusChangedCallback( Action<NativeRealTimeRoom, MultiplayerParticipant> callback) { C.RealTimeEventListenerHelper_SetOnParticipantStatusChangedCallback(SelfPtr(), InternalOnParticipantStatusChangedCallback, Callbacks.ToIntPtr(callback)); return this; } [AOT.MonoPInvokeCallback(typeof(C.OnParticipantStatusChangedCallback))] internal static void InternalOnParticipantStatusChangedCallback( IntPtr room, IntPtr participant, IntPtr data) { PerformRoomAndParticipantCallback( "InternalOnParticipantStatusChangedCallback", room, participant, data); } internal static void PerformRoomAndParticipantCallback(string callbackName, IntPtr room, IntPtr participant, IntPtr data) { Logger.d("Entering " + callbackName); try { // This is a workaround to the fact that we're lacking proper copy constructors - // see comment below. var nativeRoom = NativeRealTimeRoom.FromPointer(room); using (var nativeParticipant = MultiplayerParticipant.FromPointer(participant)) { var callback = Callbacks.IntPtrToPermanentCallback <Action<NativeRealTimeRoom, MultiplayerParticipant>>(data); if (callback != null) { callback(nativeRoom, nativeParticipant); } } } catch (Exception e) { Logger.e("Error encountered executing " + callbackName + ". " + "Smothering to avoid passing exception into Native: " + e); } } internal RealTimeEventListenerHelper SetOnDataReceivedCallback( Action<NativeRealTimeRoom, MultiplayerParticipant, byte[], bool> callback) { IntPtr onData = Callbacks.ToIntPtr(callback); Logger.d("OnData Callback has addr: " + onData.ToInt64()); C.RealTimeEventListenerHelper_SetOnDataReceivedCallback(SelfPtr(), InternalOnDataReceived, onData); return this; } [AOT.MonoPInvokeCallback(typeof(C.OnDataReceivedCallback))] internal static void InternalOnDataReceived( IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable, IntPtr userData) { Logger.d("Entering InternalOnDataReceived: " + userData.ToInt64()); var callback = Callbacks.IntPtrToPermanentCallback <Action<NativeRealTimeRoom, MultiplayerParticipant, byte[], bool>>(userData); using (var nativeRoom = NativeRealTimeRoom.FromPointer(room)) { using (var nativeParticipant = MultiplayerParticipant.FromPointer(participant)) { if (callback == null) { return; } byte[] convertedData = null; if (dataLength.ToUInt64() != 0) { convertedData = new byte[dataLength.ToUInt32()]; Marshal.Copy(data, convertedData, 0, (int)dataLength.ToUInt32()); } try { callback(nativeRoom, nativeParticipant, convertedData, isReliable); } catch (Exception e) { Logger.e("Error encountered executing InternalOnDataReceived. " + "Smothering to avoid passing exception into Native: " + e); } } } } // This is a workaround to the fact that we're lacking proper copy constructors on the cwrapper // structs. Clients of the RealTimeEventListener need to hold long-lived references to the // room returned by the callback, but the default implementation of the utility callback method // cleans up all arguments to the callback. This can be gotten rid of when copy constructors // are present in the native sdk. private static IntPtr ToCallbackPointer(Action<NativeRealTimeRoom> callback) { Action<IntPtr> pointerReceiver = result => { NativeRealTimeRoom converted = NativeRealTimeRoom.FromPointer(result); if (callback != null) { callback(converted); } else { if (converted != null) { converted.Dispose(); } } }; return Callbacks.ToIntPtr(pointerReceiver); } internal static RealTimeEventListenerHelper Create() { return new RealTimeEventListenerHelper(C.RealTimeEventListenerHelper_Construct()); } } } #endif
40.008333
104
0.613622
[ "MIT" ]
FeikoJoosten/CatClicker
Assets/Third party/GooglePlayGames/Platforms/Native/PInvoke/RealTimeEventListenerHelper.cs
9,602
C#
using TinyVFS; using TinyVFS.VirtualFileSystem; namespace Microsoft.Extensions.DependencyInjection { public static class ServiceCollectionExtensions { /// <summary> /// Adds virtual files service to the specified <see cref="IServiceCollection" />. /// </summary> /// <param name="services">The <see cref="IServiceCollection" /> to add services to.</param> /// <returns>The <see cref="IServiceCollection"/> so that additional calls can be chained.</returns> public static IServiceCollection AddVirtualFilesService(this IServiceCollection services) { services.AddSingleton<IWebContentFileProvider, WebContentFileProvider>(); services.AddSingleton<IVirtualFileProvider, VirtualFileProvider>(); services.AddSingleton<IDynamicFileProvider, DynamicFileProvider>(); return services; } } }
39.521739
108
0.689769
[ "Apache-2.0" ]
hueifeng/TinyVFS
src/TinyVFS/DependencyInjection/ServiceCollectionExtensions.cs
911
C#
using System; using System.Collections.Generic; using System.Linq; using System.Runtime.Serialization; using System.Text; using System.Threading.Tasks; namespace Program1 { public class Order { public List<OrderDetails> List { set; get; } = new List<OrderDetails>(); public Client Client { set; get; } = new Client(); public string Id { set; get; } = DateTime.Now.ToString("yyyyMMddfff"); private static string _ids; public static string Ids { set => _ids = value; get => _ids; } private decimal _cost = 0; public decimal Cost { set => _cost = value; get { try { return _cost = List.Sum(orderDetails => orderDetails.Cost); } catch (NullReferenceException) { return _cost = 0; } } } public Order() { } public Order(Order order) { List = new List<OrderDetails>(order.List); Client = new Client(order.Client); Id = order.Id; } public Order(Client client) { Client = client; // Id = Ids++; } /* public static bool IsIdValid(string idString) { if (idString.Length != 11 || ulong.TryParse(idString, out ulong id) == false) return false; ulong yyyy = id / 10000000L, MM = id % 10000000L / 100000L, dd = id % 100000L / 1000L; bool leap = (yyyy % 400 == 0 || yyyy % 4 == 0 && yyyy % 100 != 0); var days = new ulong[] { 0, 31, (ulong)(leap ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; if (MM < 1 || MM > 12) return false; if (dd < 1 || dd > days[MM]) return false; // _ids = idString; return true; }*/ public void AddOrderDetails(OrderDetails orderDetails) { List.Add(orderDetails); } public bool RemoveOrderDetails(int index) { if (index < 0 || index > List.Count) return false; List.RemoveAt(index); return true; } public override string ToString() { StringBuilder stringBuilder = new StringBuilder($"#{Id}\nClient: {Client}\n"); foreach (var orderDetails in List) { stringBuilder.AppendLine(orderDetails.ToString()); } return stringBuilder.ToString(); } public override bool Equals(object obj) { return obj is Order order && //EqualityComparer<List<OrderDetails>>.Default.Equals(List, order.List) && List.SequenceEqual(order.List) && EqualityComparer<Client>.Default.Equals(Client, order.Client) && Id == order.Id && Cost == order.Cost; } public override int GetHashCode() { /* var hashCode = -1948411825; hashCode = hashCode * -1521134295 + EqualityComparer<List<OrderDetails>>.Default.GetHashCode(List); hashCode = hashCode * -1521134295 + EqualityComparer<Client>.Default.GetHashCode(Client); hashCode = hashCode * -1521134295 + Id.GetHashCode(); hashCode = hashCode * -1521134295 + Cost.GetHashCode(); return hashCode;*/ return Id.GetHashCode(); } } }
25.392857
105
0.638889
[ "Apache-2.0" ]
BrangPakdring/CSharpHomework
Homework8/Program1/Order.cs
2,846
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("lab_01_hello_world")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("lab_01_hello_world")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2019")] [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("8884be66-2532-43eb-9ef0-1080d6a9f04c")] // 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")]
38.324324
84
0.749647
[ "MIT" ]
mohssin19/2019-09-c-sharp-labs
labs/lab_01_hello_world/Properties/AssemblyInfo.cs
1,421
C#
namespace NineCubed.Memo.Plugins.SearchForm { partial class SearchInputForm { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.label1 = new System.Windows.Forms.Label(); this.txtSearch = new System.Windows.Forms.TextBox(); this.txtReplace = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.btnSearchBackward = new System.Windows.Forms.Button(); this.btnSearchForward = new System.Windows.Forms.Button(); this.chkCase = new System.Windows.Forms.CheckBox(); this.btnReplaceForward = new System.Windows.Forms.Button(); this.btnReplaceBackward = new System.Windows.Forms.Button(); this.btnReplaceAll = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 // this.label1.AutoSize = true; this.label1.Location = new System.Drawing.Point(14, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(29, 12); this.label1.TabIndex = 0; this.label1.Text = "検索"; // // txtSearch // this.txtSearch.Location = new System.Drawing.Point(49, 12); this.txtSearch.Name = "txtSearch"; this.txtSearch.Size = new System.Drawing.Size(230, 19); this.txtSearch.TabIndex = 1; this.txtSearch.TextChanged += new System.EventHandler(this.txtSearch_TextChanged); this.txtSearch.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtSearch_KeyDown); // // txtReplace // this.txtReplace.Location = new System.Drawing.Point(329, 12); this.txtReplace.Name = "txtReplace"; this.txtReplace.Size = new System.Drawing.Size(230, 19); this.txtReplace.TabIndex = 3; this.txtReplace.TextChanged += new System.EventHandler(this.txtReplace_TextChanged); this.txtReplace.KeyDown += new System.Windows.Forms.KeyEventHandler(this.txtReplace_KeyDown); // // label2 // this.label2.AutoSize = true; this.label2.Location = new System.Drawing.Point(294, 16); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(29, 12); this.label2.TabIndex = 2; this.label2.Text = "置換"; // // btnSearchBackward // this.btnSearchBackward.Location = new System.Drawing.Point(49, 37); this.btnSearchBackward.Name = "btnSearchBackward"; this.btnSearchBackward.Size = new System.Drawing.Size(32, 24); this.btnSearchBackward.TabIndex = 4; this.btnSearchBackward.Text = "<"; this.btnSearchBackward.UseVisualStyleBackColor = true; this.btnSearchBackward.Click += new System.EventHandler(this.btnSearchBackward_Click); // // btnSearchForward // this.btnSearchForward.Location = new System.Drawing.Point(87, 37); this.btnSearchForward.Name = "btnSearchForward"; this.btnSearchForward.Size = new System.Drawing.Size(32, 24); this.btnSearchForward.TabIndex = 5; this.btnSearchForward.Text = ">"; this.btnSearchForward.UseVisualStyleBackColor = true; this.btnSearchForward.Click += new System.EventHandler(this.btnSearchForward_Click); // // chkCase // this.chkCase.AutoSize = true; this.chkCase.Location = new System.Drawing.Point(125, 42); this.chkCase.Name = "chkCase"; this.chkCase.Size = new System.Drawing.Size(154, 16); this.chkCase.TabIndex = 6; this.chkCase.Text = "大文字・小文字を無視する"; this.chkCase.UseVisualStyleBackColor = true; this.chkCase.CheckedChanged += new System.EventHandler(this.chkCase_CheckedChanged); // // btnReplaceForward // this.btnReplaceForward.Location = new System.Drawing.Point(367, 37); this.btnReplaceForward.Name = "btnReplaceForward"; this.btnReplaceForward.Size = new System.Drawing.Size(32, 24); this.btnReplaceForward.TabIndex = 8; this.btnReplaceForward.Text = ">"; this.btnReplaceForward.UseVisualStyleBackColor = true; this.btnReplaceForward.Click += new System.EventHandler(this.btnReplaceForward_Click); // // btnReplaceBackward // this.btnReplaceBackward.Location = new System.Drawing.Point(329, 37); this.btnReplaceBackward.Name = "btnReplaceBackward"; this.btnReplaceBackward.Size = new System.Drawing.Size(32, 24); this.btnReplaceBackward.TabIndex = 7; this.btnReplaceBackward.Text = "<"; this.btnReplaceBackward.UseVisualStyleBackColor = true; this.btnReplaceBackward.Click += new System.EventHandler(this.btnReplaceBackward_Click); // // btnReplaceAll // this.btnReplaceAll.Location = new System.Drawing.Point(405, 37); this.btnReplaceAll.Name = "btnReplaceAll"; this.btnReplaceAll.Size = new System.Drawing.Size(64, 24); this.btnReplaceAll.TabIndex = 9; this.btnReplaceAll.Text = "全置換"; this.btnReplaceAll.UseVisualStyleBackColor = true; this.btnReplaceAll.Click += new System.EventHandler(this.btnReplaceAll_Click); // // btnClose // this.btnClose.DialogResult = System.Windows.Forms.DialogResult.Cancel; this.btnClose.Location = new System.Drawing.Point(495, 37); this.btnClose.Name = "btnClose"; this.btnClose.Size = new System.Drawing.Size(64, 24); this.btnClose.TabIndex = 10; this.btnClose.Text = "閉じる"; this.btnClose.UseVisualStyleBackColor = true; this.btnClose.Click += new System.EventHandler(this.btnClose_Click); // // SearchInputForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.btnClose; this.ClientSize = new System.Drawing.Size(572, 71); this.Controls.Add(this.btnClose); this.Controls.Add(this.btnReplaceAll); this.Controls.Add(this.btnReplaceForward); this.Controls.Add(this.btnReplaceBackward); this.Controls.Add(this.chkCase); this.Controls.Add(this.btnSearchForward); this.Controls.Add(this.btnSearchBackward); this.Controls.Add(this.txtReplace); this.Controls.Add(this.label2); this.Controls.Add(this.txtSearch); this.Controls.Add(this.label1); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog; this.MaximizeBox = false; this.Name = "SearchInputForm"; this.Text = "検索・置換"; this.TopMost = true; this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.SearchInputForm_FormClosed); this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.SearchForm_KeyDown); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.Label label1; private System.Windows.Forms.TextBox txtSearch; private System.Windows.Forms.TextBox txtReplace; private System.Windows.Forms.Label label2; private System.Windows.Forms.Button btnSearchBackward; private System.Windows.Forms.Button btnSearchForward; private System.Windows.Forms.CheckBox chkCase; private System.Windows.Forms.Button btnReplaceForward; private System.Windows.Forms.Button btnReplaceBackward; private System.Windows.Forms.Button btnReplaceAll; private System.Windows.Forms.Button btnClose; } }
48.123077
113
0.590793
[ "MIT" ]
9cubed/NineCubedMemo
src/NineCubedMemo/NineCubedMemo/Memo/Plugins/SearchForm/SearchInputForm.Designer.cs
9,440
C#
using DataAccessLayer.Abstract; using DataAccessLayer.Concrete.Repository; using EntityLayer.Concrete; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace DataAccessLayer.Concrete.EntityFramework { public class EfImageFileDal : GenericRepository<ImageFile>, IImageFileDal { } }
22.875
77
0.808743
[ "MIT" ]
rabianur412/FeedMe
DataAccessLayer/Concrete/EntityFramework/EfImageFileDal.cs
368
C#
// // Copyright (c) 2004-2019 Jaroslaw Kowalski <jaak@jkowalski.net>, Kim Christensen, Julian Verdurmen // // 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 Jaroslaw Kowalski 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 OWNER 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. // namespace NLog.UnitTests.MessageTemplates { using System; using System.Globalization; using NLog.MessageTemplates; using Xunit; using Xunit.Extensions; public class RendererTests { [Theory] [InlineData("{0}", new object[] { "a" }, "a")] [InlineData(" {0}", new object[] { "a" }, " a")] [InlineData(" {0} ", new object[] { "a" }, " a ")] [InlineData(" {0} {1} ", new object[] { "a", "b" }, " a b ")] [InlineData(" {1} {0} ", new object[] { "a", "b" }, " b a ")] [InlineData(" {1} {0} {0}", new object[] { "a", "b" }, " b a a")] [InlineData(" message {1} {0} {0}", new object[] { "a", "b" }, " message b a a")] [InlineData(" message {1} {0} {0}", new object[] { 'a', 'b' }, " message b a a")] [InlineData("char {one}", new object[] { 'X' }, "char \"X\"")] [InlineData("char {one:l}", new object[] { 'X' }, "char X")] [InlineData(" message {{{1}}} {0} {0}", new object[] { "a", "b" }, " message {b} a a")] [InlineData(" message {{{one}}} {two} {three}", new object[] { "a", "b", "c" }, " message {\"a\"} \"b\" \"c\"")] [InlineData(" message {{{1} {0} {0}}}", new object[] { "a", "b" }, " message {b a a}")] [InlineData(" completed in {time} sec", new object[] { 10 }, " completed in 10 sec")] [InlineData(" completed task {name} in {time} sec", new object[] { "test", 10 }, " completed task \"test\" in 10 sec")] [InlineData(" completed task {name:l} in {time} sec", new object[] { "test", 10 }, " completed task test in 10 sec")] [InlineData(" completed task {0} in {1} sec", new object[] { "test", 10 }, " completed task test in 10 sec")] [InlineData(" completed task {0} in {1:000} sec", new object[] { "test", 10 }, " completed task test in 010 sec")] [InlineData(" completed task {name} in {time:000} sec", new object[] { "test", 10 }, " completed task \"test\" in 010 sec")] [InlineData(" completed tasks {tasks} in {time:000} sec", new object[] { new [] { "parsing", "testing", "fixing"}, 10 }, " completed tasks \"parsing\", \"testing\", \"fixing\" in 010 sec")] [InlineData(" completed tasks {tasks:l} in {time:000} sec", new object[] { new [] { "parsing", "testing", "fixing"}, 10 }, " completed tasks parsing, testing, fixing in 010 sec")] #if !MONO [InlineData(" completed tasks {$tasks} in {time:000} sec", new object[] { new [] { "parsing", "testing", "fixing"}, 10 }, " completed tasks \"System.String[]\" in 010 sec")] [InlineData(" completed tasks {0} in {1:000} sec", new object[] { new [] { "parsing", "testing", "fixing"}, 10 }, " completed tasks System.String[] in 010 sec")] #endif [InlineData("{{{0:d}}}", new object[] { 3 }, "{d}")] //format is here "d}" ... because escape from left-to-right [InlineData("{{{0:d} }}", new object[] { 3 }, "{3 }")] [InlineData("{{{0:dd}}}", new object[] { 3 }, "{dd}")] [InlineData("{{{0:0{{}", new object[] { 3 }, "{3{")] //format is here "0{" [InlineData("hello {0}", new object[] { null }, "hello NULL")] [InlineData("if its {yes}, it should not be {no}", new object[] { true, false }, "if its true, it should not be false")] [InlineData("Always use the correct {enum}", new object[] { NLog.Config.ExceptionRenderingFormat.Method }, "Always use the correct Method")] [InlineData("Always use the correct {enum:D}", new object[] { NLog.Config.ExceptionRenderingFormat.Method }, "Always use the correct 4")] [InlineData("hello {0,-10}", new object[] { null }, "hello NULL ")] [InlineData("hello {0,10}", new object[] { null }, "hello NULL")] public void RenderTest(string input, object[] args, string expected) { var culture = CultureInfo.InvariantCulture; RenderAndTest(input, culture, args, expected); } [Theory] [InlineData("test {0}", "nl", new object[] { 12.3 }, "test 12,3")] [InlineData("test {0}", "en-gb", new object[] { 12.3 }, "test 12.3")] public void RenderCulture(string input, string language, object[] args, string expected) { var culture = new CultureInfo(language); RenderAndTest(input, culture, args, expected); } [Theory] [InlineData("test {0:u}", "1970-01-01", "test 1970-01-01 00:00:00Z")] [InlineData("test {0:MM/dd/yy}", "1970-01-01", "test 01/01/70")] public void RenderDateTime(string input, string arg, string expected) { var culture = CultureInfo.InvariantCulture; DateTime dt = DateTime.Parse(arg, culture, DateTimeStyles.AdjustToUniversal); RenderAndTest(input, culture, new object[] { dt }, expected); } [Theory] [InlineData("test {0:c}", "1:2:3:4.5", "test 1.02:03:04.5000000")] [InlineData("test {0:hh\\:mm\\:ss\\.ff}", "1:2:3:4.5", "test 02:03:04.50")] public void RenderTimeSpan(string input, string arg, string expected) { var culture = CultureInfo.InvariantCulture; TimeSpan ts = TimeSpan.Parse(arg, culture); RenderAndTest(input, culture, new object[] { ts }, expected); } [Theory] [InlineData("test {0:u}", "1 Jan 1970 01:02:03Z", "test 1970-01-01 01:02:03Z")] [InlineData("test {0:s}", "1 Jan 1970 01:02:03Z", "test 1970-01-01T01:02:03")] public void RenderDateTimeOffset(string input, string arg, string expected) { var culture = CultureInfo.InvariantCulture; DateTimeOffset dto = DateTimeOffset.Parse(arg, culture, DateTimeStyles.AdjustToUniversal); RenderAndTest(input, culture, new object[] { dto }, expected); } private static void RenderAndTest(string input, CultureInfo culture, object[] args, string expected) { var template = TemplateParser.Parse(input); var sb = new System.Text.StringBuilder(); template.Render(sb, culture, args); Assert.Equal(expected, sb.ToString()); sb.Length = 0; TemplateRenderer.Render(input, culture, args, true, sb, out var messageTemplateParameters); Assert.Equal(expected, sb.ToString()); } } }
55.951049
197
0.6028
[ "BSD-3-Clause" ]
ALFNeT/NLog
tests/NLog.UnitTests/MessageTemplates/RendererTests.cs
8,001
C#
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; using ToDoList.Controllers; using ToDoList.Models; namespace ToDoList.Tests { [TestClass] public class ItemsControllerTests { [TestMethod] public void Create_ReturnsCorrectActionType_RedirectToActionResult() { //Arrange ItemsController controller = new ItemsController(); //Act IActionResult view = controller.Create("Walk the dog"); //Assert Assert.IsInstanceOfType(view, typeof(RedirectToActionResult)); } [TestMethod] public void Create_RedirectsToCorrectAction_Index() { //Arrange ItemsController controller = new ItemsController(); RedirectToActionResult actionResult = controller.Create("Walk the dog") as RedirectToActionResult; //Act string result = actionResult.ActionName; //Assert Assert.AreEqual(result, "Index"); } } }
26.25
108
0.662857
[ "MIT" ]
Zebrozkii/CsharpTo-Do-List
ToDoList.Tests/ControllerTests/ItemsControllerTests.cs
1,050
C#
//! \file ArcHXP.cs //! \date Sun Nov 08 18:04:58 2015 //! \brief SH System resource archive. // // Copyright (C) 2015 by morkt // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to // deal in the Software without restriction, including without limitation the // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or // sell copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in // all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS // IN THE SOFTWARE. // using System; using System.Collections.Generic; using System.ComponentModel.Composition; using System.IO; using System.Linq; using GameRes.Utility; using System.Text; namespace GameRes.Formats.SHSystem { [Export(typeof(ArchiveFormat))] public class Him4Opener : ArchiveFormat { public override string Tag { get { return "HIM4"; } } public override string Description { get { return "SH System engine resource archive"; } } public override uint Signature { get { return 0x346D6948; } } // 'Him4' public override bool IsHierarchic { get { return false; } } public override bool CanWrite { get { return false; } } public Him4Opener () { Signatures = new uint[] { 0x346D6948, 0x36534853 }; // 'Him4', 'SHS6' Extensions = new string[] { "hxp" }; } public override ArcFile TryOpen (ArcView file) { int count = file.View.ReadInt32 (4); if (!IsSaneCount (count)) return null; long next_offset = file.View.ReadUInt32 (8); uint index_offset = 0xC; var dir = new List<Entry> (count); for (int i = 0; i < count; ++i) { if (next_offset > file.MaxOffset) return null; var entry = new PackedEntry { Name = i.ToString ("D5"), Offset = next_offset, }; next_offset = i + 1 == count ? file.MaxOffset : file.View.ReadUInt32 (index_offset); index_offset += 4; entry.Size = (uint)(next_offset - entry.Offset); dir.Add (entry); } DetectFileTypes (file, dir); return new ArcFile (file, this, dir); } static protected void DetectFileTypes (ArcView file, List<Entry> dir) { byte[] signature_buffer = new byte[4]; foreach (PackedEntry entry in dir) { uint packed_size = file.View.ReadUInt32 (entry.Offset); uint unpacked_size = file.View.ReadUInt32 (entry.Offset+4); entry.IsPacked = 0 != packed_size; if (!entry.IsPacked) packed_size = unpacked_size; entry.Size = packed_size; entry.UnpackedSize = unpacked_size; entry.Offset += 8; uint signature; if (entry.IsPacked) { using (var input = file.CreateStream (entry.Offset, Math.Min (packed_size, 0x20u))) using (var reader = new ShsCompression (input)) { reader.Unpack (signature_buffer); signature = LittleEndian.ToUInt32 (signature_buffer, 0); } } else { signature = file.View.ReadUInt32 (entry.Offset); } if (0 != signature) { Resource res; if (0x020000 == signature || 0x0A0000 == signature) res = ImageFormat.Tga; else res = AutoEntry.DetectFileType (signature); if (res != null) entry.ChangeType (res); } } } public override Stream OpenEntry (ArcFile arc, Entry entry) { var input = arc.File.CreateStream (entry.Offset, entry.Size, entry.Name); var pent = entry as PackedEntry; if (null == pent || !pent.IsPacked) return input; var data = new byte[pent.UnpackedSize]; using (var reader = new ShsCompression (input)) { reader.Unpack (data); return new BinMemoryStream (data, entry.Name); } } } [Export(typeof(ArchiveFormat))] public class Him5Opener : Him4Opener { public override string Tag { get { return "HIM5"; } } public override string Description { get { return "SH System engine resource archive"; } } public override uint Signature { get { return 0x356D6948; } } // 'Him5' public override bool IsHierarchic { get { return false; } } public override bool CanWrite { get { return false; } } public Him5Opener () { Signatures = new uint[] { 0x356D6948, 0x37534853 }; // 'Him5', 'SHS7' Extensions = new string[] { "hxp" }; } public override ArcFile TryOpen (ArcView file) { int version = file.View.ReadByte (3) - '0'; int count = file.View.ReadInt32 (4); if (!IsSaneCount (count)) return null; var index = ReadIndex (file, 8, count); var dir = new List<Entry>(); foreach (var section in index) { int index_offset = section.Item1; for (int section_size = section.Item2; section_size > 0; ) { int entry_size = file.View.ReadByte (index_offset); if (entry_size < 5) break; var entry = new PackedEntry { Offset = Binary.BigEndian (file.View.ReadUInt32 (index_offset+1)), Name = file.View.ReadString (index_offset+5, (uint)entry_size-5), }; if (entry.Offset > file.MaxOffset) return null; index_offset += entry_size; section_size -= entry_size; dir.Add (entry); } } DetectFileTypes (file, dir); return new ArcFile (file, this, dir); } internal static List<Tuple<int, int>> ReadIndex (ArcView file, uint index_offset, int count) { var index = new List<Tuple<int, int>> (count); for (int i = 0; i < count; ++i) { int size = file.View.ReadInt32 (index_offset); int offset = file.View.ReadInt32 (index_offset+4); index_offset += 8; if (size != 0) index.Add (Tuple.Create (offset, size)); } return index; } } internal class ShsCompression : IDisposable { IBinaryStream m_input; public ShsCompression (IBinaryStream input) { m_input = input; } public int Unpack (byte[] output) { int dst = 0; while (dst < output.Length) { int count; int ctl = m_input.ReadUInt8(); if (ctl < 32) { switch (ctl) { case 0x1D: count = m_input.ReadUInt8() + 0x1E; break; case 0x1E: count = Binary.BigEndian (m_input.ReadUInt16()) + 0x11E; break; case 0x1F: count = Binary.BigEndian (m_input.ReadInt32()); break; default: count = ctl + 1; break; } count = Math.Min (count, output.Length - dst); m_input.Read (output, dst, count); } else { int offset; if (0 == (ctl & 0x80)) { if (0x20 == (ctl & 0x60)) { offset = (ctl >> 2) & 7; count = ctl & 3; } else { offset = m_input.ReadUInt8(); if (0x40 == (ctl & 0x60)) count = (ctl & 0x1F) + 4; else { offset |= (ctl & 0x1F) << 8; ctl = m_input.ReadUInt8(); if (0xFE == ctl) count = Binary.BigEndian (m_input.ReadUInt16()) + 0x102; else if (0xFF == ctl) count = Binary.BigEndian (m_input.ReadInt32()); else count = ctl + 4; } } } else { count = (ctl >> 5) & 3; offset = ((ctl & 0x1F) << 8) | m_input.ReadUInt8(); } count += 3; offset++; count = Math.Min (count, output.Length-dst); Binary.CopyOverlapped (output, dst-offset, dst, count); } dst += count; } return dst; } #region IDisposable Members public void Dispose () { } #endregion } }
38.128571
103
0.467966
[ "MIT" ]
Sagilio/GARbro
ArcFormats/SHSystem/ArcHXP.cs
10,676
C#
// Cfg.Net // An Alternative .NET Configuration Handler // Copyright 2015-2018 Dale Newman // // 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; using System.Collections.Generic; using Cfg.Net.Contracts; namespace Cfg.Net.Parsers { internal sealed class ObjectNode : INode { private readonly Dictionary<string, IAttribute> _attributes = new Dictionary<string, IAttribute>(); public ObjectNode(object cfgNode, string name) { var type = cfgNode.GetType(); var metadata = CfgMetadataCache.GetMetadata(type); Name = name; Attributes = new List<IAttribute>(); SubNodes = new List<INode>(); foreach (var pair in metadata) { if (pair.Value.ListType == null) { // get the value, create attribute var value = pair.Value.Getter(cfgNode); var attribute = new NodeAttribute(pair.Value.Attribute.name, value); _attributes[attribute.Name] = attribute; Attributes.Add(attribute); } else { // get the list, transfer it to collection node of sub nodes var list = (IList)pair.Value.Getter(cfgNode); if (list == null) continue; var collection = new CollectionNode(pair.Value.Attribute.name); foreach (var item in list) { collection.SubNodes.Add(new ObjectNode(item, "add")); } SubNodes.Add(collection); } } } public string Name { get; } public List<IAttribute> Attributes { get; } public List<INode> SubNodes { get; } public bool TryAttribute(string name, out IAttribute attr) { if (_attributes.ContainsKey(name)) { attr = _attributes[name]; return true; } attr = null; return false; } } }
39.212121
107
0.580371
[ "Apache-2.0" ]
dalenewman/Cfg-NET
src/Main/Cfg.Net.Shared/Parsers/ObjectNode.cs
2,588
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace _12._1.IndexOfLetters { class Program { //other solution of problem static void Main(string[] args) { Console.WriteLine("Please, enter a word: "); string str = Console.ReadLine(); for (int k = 0; k < str.Length; k++) { if ((int)str[k] > 64 && (int)str[k] < 91) { Console.Write((int)str[k]-65 + " "); } else { Console.Write((int)str[k] - 97 + " "); } } Console.WriteLine(); } } }
24.548387
58
0.444152
[ "MIT" ]
aliv59git/C-2N_HomeAndExam
1.HomeArrays/12.1.IndexOfLetters/12._1.IndexOfLetters.cs
763
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. /****************************************************************************** * This file is auto-generated from a template file by the GenerateTests.csx * * script in tests\src\JIT\HardwareIntrinsics\X86\Shared. In order to make * * changes, please update the corresponding template and run according to the * * directions listed in the file. * ******************************************************************************/ using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Intrinsics; using System.Runtime.Intrinsics.X86; namespace JIT.HardwareIntrinsics.X86 { public static partial class Program { private static void MultiplySubtractDouble() { var test = new SimpleTernaryOpTest__MultiplySubtractDouble(); if (test.IsSupported) { // Validates basic functionality works, using Unsafe.Read test.RunBasicScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates basic functionality works, using Load test.RunBasicScenario_Load(); // Validates basic functionality works, using LoadAligned test.RunBasicScenario_LoadAligned(); } // Validates calling via reflection works, using Unsafe.Read test.RunReflectionScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates calling via reflection works, using Load test.RunReflectionScenario_Load(); // Validates calling via reflection works, using LoadAligned test.RunReflectionScenario_LoadAligned(); } // Validates passing a static member works test.RunClsVarScenario(); // Validates passing a local works, using Unsafe.Read test.RunLclVarScenario_UnsafeRead(); if (Sse2.IsSupported) { // Validates passing a local works, using Load test.RunLclVarScenario_Load(); // Validates passing a local works, using LoadAligned test.RunLclVarScenario_LoadAligned(); } // Validates passing the field of a local class works test.RunClassLclFldScenario(); // Validates passing an instance member of a class works test.RunClassFldScenario(); // Validates passing the field of a local struct works test.RunStructLclFldScenario(); // Validates passing an instance member of a struct works test.RunStructFldScenario(); } else { // Validates we throw on unsupported hardware test.RunUnsupportedScenario(); } if (!test.Succeeded) { throw new Exception("One or more scenarios did not complete as expected."); } } } public sealed unsafe class SimpleTernaryOpTest__MultiplySubtractDouble { private struct TestStruct { public Vector128<Double> _fld1; public Vector128<Double> _fld2; public Vector128<Double> _fld3; public static TestStruct Create() { var testStruct = new TestStruct(); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref testStruct._fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar3), ref Unsafe.As<Double, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); return testStruct; } public void RunStructFldScenario(SimpleTernaryOpTest__MultiplySubtractDouble testClass) { var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); Unsafe.Write(testClass._dataTable.outArrayPtr, result); testClass.ValidateResult(_fld1, _fld2, _fld3, testClass._dataTable.outArrayPtr); } } private static readonly int LargestVectorSize = 16; private static readonly int Op1ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int Op2ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int Op3ElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static readonly int RetElementCount = Unsafe.SizeOf<Vector128<Double>>() / sizeof(Double); private static Double[] _data1 = new Double[Op1ElementCount]; private static Double[] _data2 = new Double[Op2ElementCount]; private static Double[] _data3 = new Double[Op3ElementCount]; private static Vector128<Double> _clsVar1; private static Vector128<Double> _clsVar2; private static Vector128<Double> _clsVar3; private Vector128<Double> _fld1; private Vector128<Double> _fld2; private Vector128<Double> _fld3; private SimpleTernaryOpTest__DataTable<Double, Double, Double, Double> _dataTable; static SimpleTernaryOpTest__MultiplySubtractDouble() { for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _clsVar3), ref Unsafe.As<Double, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); } public SimpleTernaryOpTest__MultiplySubtractDouble() { Succeeded = true; for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld1), ref Unsafe.As<Double, byte>(ref _data1[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld2), ref Unsafe.As<Double, byte>(ref _data2[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } Unsafe.CopyBlockUnaligned(ref Unsafe.As<Vector128<Double>, byte>(ref _fld3), ref Unsafe.As<Double, byte>(ref _data3[0]), (uint)Unsafe.SizeOf<Vector128<Double>>()); for (var i = 0; i < Op1ElementCount; i++) { _data1[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op2ElementCount; i++) { _data2[i] = TestLibrary.Generator.GetDouble(); } for (var i = 0; i < Op3ElementCount; i++) { _data3[i] = TestLibrary.Generator.GetDouble(); } _dataTable = new SimpleTernaryOpTest__DataTable<Double, Double, Double, Double>(_data1, _data2, _data3, new Double[RetElementCount], LargestVectorSize); } public bool IsSupported => Fma.IsSupported; public bool Succeeded { get; set; } public void RunBasicScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_UnsafeRead)); var result = Fma.MultiplySubtract( Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray3Ptr) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_Load)); var result = Fma.MultiplySubtract( Sse2.LoadVector128((Double*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Double*)(_dataTable.inArray2Ptr)), Sse2.LoadVector128((Double*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunBasicScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunBasicScenario_LoadAligned)); var result = Fma.MultiplySubtract( Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray2Ptr)), Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray3Ptr)) ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_UnsafeRead)); var result = typeof(Fma).GetMethod(nameof(Fma.MultiplySubtract), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr), Unsafe.Read<Vector128<Double>>(_dataTable.inArray3Ptr) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_Load)); var result = typeof(Fma).GetMethod(nameof(Fma.MultiplySubtract), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { Sse2.LoadVector128((Double*)(_dataTable.inArray1Ptr)), Sse2.LoadVector128((Double*)(_dataTable.inArray2Ptr)), Sse2.LoadVector128((Double*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunReflectionScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunReflectionScenario_LoadAligned)); var result = typeof(Fma).GetMethod(nameof(Fma.MultiplySubtract), new Type[] { typeof(Vector128<Double>), typeof(Vector128<Double>), typeof(Vector128<Double>) }) .Invoke(null, new object[] { Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray1Ptr)), Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray2Ptr)), Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray3Ptr)) }); Unsafe.Write(_dataTable.outArrayPtr, (Vector128<Double>)(result)); ValidateResult(_dataTable.inArray1Ptr, _dataTable.inArray2Ptr, _dataTable.inArray3Ptr, _dataTable.outArrayPtr); } public void RunClsVarScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClsVarScenario)); var result = Fma.MultiplySubtract( _clsVar1, _clsVar2, _clsVar3 ); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_clsVar1, _clsVar2, _clsVar3, _dataTable.outArrayPtr); } public void RunLclVarScenario_UnsafeRead() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_UnsafeRead)); var firstOp = Unsafe.Read<Vector128<Double>>(_dataTable.inArray1Ptr); var secondOp = Unsafe.Read<Vector128<Double>>(_dataTable.inArray2Ptr); var thirdOp = Unsafe.Read<Vector128<Double>>(_dataTable.inArray3Ptr); var result = Fma.MultiplySubtract(firstOp, secondOp, thirdOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_Load() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_Load)); var firstOp = Sse2.LoadVector128((Double*)(_dataTable.inArray1Ptr)); var secondOp = Sse2.LoadVector128((Double*)(_dataTable.inArray2Ptr)); var thirdOp = Sse2.LoadVector128((Double*)(_dataTable.inArray3Ptr)); var result = Fma.MultiplySubtract(firstOp, secondOp, thirdOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } public void RunLclVarScenario_LoadAligned() { TestLibrary.TestFramework.BeginScenario(nameof(RunLclVarScenario_LoadAligned)); var firstOp = Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray1Ptr)); var secondOp = Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray2Ptr)); var thirdOp = Sse2.LoadAlignedVector128((Double*)(_dataTable.inArray3Ptr)); var result = Fma.MultiplySubtract(firstOp, secondOp, thirdOp); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(firstOp, secondOp, thirdOp, _dataTable.outArrayPtr); } public void RunClassLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassLclFldScenario)); var test = new SimpleTernaryOpTest__MultiplySubtractDouble(); var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunClassFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunClassFldScenario)); var result = Fma.MultiplySubtract(_fld1, _fld2, _fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(_fld1, _fld2, _fld3, _dataTable.outArrayPtr); } public void RunStructLclFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructLclFldScenario)); var test = TestStruct.Create(); var result = Fma.MultiplySubtract(test._fld1, test._fld2, test._fld3); Unsafe.Write(_dataTable.outArrayPtr, result); ValidateResult(test._fld1, test._fld2, test._fld3, _dataTable.outArrayPtr); } public void RunStructFldScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunStructFldScenario)); var test = TestStruct.Create(); test.RunStructFldScenario(this); } public void RunUnsupportedScenario() { TestLibrary.TestFramework.BeginScenario(nameof(RunUnsupportedScenario)); Succeeded = false; try { RunBasicScenario_UnsafeRead(); } catch (PlatformNotSupportedException) { Succeeded = true; } } private void ValidateResult(Vector128<Double> firstOp, Vector128<Double> secondOp, Vector128<Double> thirdOp, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] inArray3 = new Double[Op3ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), firstOp); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), secondOp); Unsafe.WriteUnaligned(ref Unsafe.As<Double, byte>(ref inArray3[0]), thirdOp); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(void* firstOp, void* secondOp, void* thirdOp, void* result, [CallerMemberName] string method = "") { Double[] inArray1 = new Double[Op1ElementCount]; Double[] inArray2 = new Double[Op2ElementCount]; Double[] inArray3 = new Double[Op3ElementCount]; Double[] outArray = new Double[RetElementCount]; Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray1[0]), ref Unsafe.AsRef<byte>(firstOp), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray2[0]), ref Unsafe.AsRef<byte>(secondOp), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref inArray3[0]), ref Unsafe.AsRef<byte>(thirdOp), (uint)Unsafe.SizeOf<Vector128<Double>>()); Unsafe.CopyBlockUnaligned(ref Unsafe.As<Double, byte>(ref outArray[0]), ref Unsafe.AsRef<byte>(result), (uint)Unsafe.SizeOf<Vector128<Double>>()); ValidateResult(inArray1, inArray2, inArray3, outArray, method); } private void ValidateResult(Double[] firstOp, Double[] secondOp, Double[] thirdOp, Double[] result, [CallerMemberName] string method = "") { if (BitConverter.DoubleToInt64Bits(Math.Round((firstOp[0] * secondOp[0]) - thirdOp[0], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[0], 9))) { Succeeded = false; } else { for (var i = 1; i < RetElementCount; i++) { if (BitConverter.DoubleToInt64Bits(Math.Round((firstOp[i] * secondOp[i]) - thirdOp[i], 9)) != BitConverter.DoubleToInt64Bits(Math.Round(result[i], 9))) { Succeeded = false; break; } } } if (!Succeeded) { TestLibrary.TestFramework.LogInformation($"{nameof(Fma)}.{nameof(Fma.MultiplySubtract)}<Double>(Vector128<Double>, Vector128<Double>, Vector128<Double>): {method} failed:"); TestLibrary.TestFramework.LogInformation($" firstOp: ({string.Join(", ", firstOp)})"); TestLibrary.TestFramework.LogInformation($" secondOp: ({string.Join(", ", secondOp)})"); TestLibrary.TestFramework.LogInformation($" thirdOp: ({string.Join(", ", thirdOp)})"); TestLibrary.TestFramework.LogInformation($" result: ({string.Join(", ", result)})"); TestLibrary.TestFramework.LogInformation(string.Empty); } } } }
49.081206
190
0.615203
[ "MIT" ]
Frassle/coreclr
tests/src/JIT/HardwareIntrinsics/X86/Fma_Vector128/MultiplySubtract.Double.cs
21,154
C#
/* * Ory Kratos API * * Documentation for all public and administrative Ory Kratos APIs. Public and administrative APIs are exposed on different ports. Public APIs can face the public internet without any protection while administrative APIs should never be exposed without prior authorization. To protect the administative API port you should use something like Nginx, Ory Oathkeeper, or any other technology capable of authorizing incoming requests. * * The version of the OpenAPI document: v0.8.2-alpha.1 * Contact: hi@ory.sh * Generated by: https://github.com/openapitools/openapi-generator.git */ using Xunit; using System; using System.Linq; using System.IO; using System.Collections.Generic; using Ory.Kratos.Client.Api; using Ory.Kratos.Client.Model; using Ory.Kratos.Client.Client; using System.Reflection; using Newtonsoft.Json; namespace Ory.Kratos.Client.Test.Model { /// <summary> /// Class for testing KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody /// </summary> /// <remarks> /// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech). /// Please update the test case below to test the model. /// </remarks> public class KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBodyTests : IDisposable { // TODO uncomment below to declare an instance variable for KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody //private KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody instance; public KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBodyTests() { // TODO uncomment below to create an instance of KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody //instance = new KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody(); } public void Dispose() { // Cleanup when everything is done. } /// <summary> /// Test an instance of KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody /// </summary> [Fact] public void KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBodyInstanceTest() { // TODO uncomment below to test "IsType" KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody //Assert.IsType<KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBody>(instance); } /// <summary> /// Test the property 'CsrfToken' /// </summary> [Fact] public void CsrfTokenTest() { // TODO unit test for the property 'CsrfToken' } /// <summary> /// Test the property 'Email' /// </summary> [Fact] public void EmailTest() { // TODO unit test for the property 'Email' } /// <summary> /// Test the property 'Method' /// </summary> [Fact] public void MethodTest() { // TODO unit test for the property 'Method' } } }
34.136364
431
0.675766
[ "Apache-2.0" ]
ALTELMA/sdk
clients/kratos/dotnet/src/Ory.Kratos.Client.Test/Model/KratosSubmitSelfServiceRecoveryFlowWithLinkMethodBodyTests.cs
3,004
C#
// SPDX-FileCopyrightText: Copyright (c) 2009-2020 TRUMPF Laser GmbH, authors: C-Labs // // SPDX-License-Identifier: MPL-2.0 using nsCDEngine.Activation; using System; namespace nsCDEngine.ActivationKey { public class TheActivationRequestKeyManager { /// <summary> /// Retrieves information from a token generated using the GetActivationRequestKey method. /// Typically used by a cdeEngine applicationId owner to generate activation keys. /// </summary> /// <param name="activationRequestKey">The token obtained from GetActivationRequestKey.</param> /// <param name="creationTime">The time when the token was created (local machine time, truncated to 10 minute boundary)</param> /// <param name="skuId">Application owner-defined SKU identifier, that is typically used to identify the set of licenses to included in the activation key.</param> /// <param name="deviceId">NodeId of the node where the activationRequestKey was generated. The activation key is typically bound to this node id.</param> /// <returns></returns> public static bool ParseActivationRequestKey(string activationRequestKey, out DateTime creationTime, out uint skuId, out Guid deviceId) { creationTime = DateTime.MinValue; skuId = 0; deviceId = Guid.Empty; var normalizedKey = activationRequestKey.Replace("-", "").ToUpper().Replace('O', '0').Replace('U', 'V').Replace('I', 'J').Replace('L', 'J'); if (normalizedKey.Length != 36) { return false; } byte[] activationRequestKeyArray = TheActivationUtils.Base32Decode(normalizedKey); if (activationRequestKeyArray.Length != 23) { return false; } byte checksum = 0; int j = 0; byte[] tGu = new byte[16]; uint tenMinuteIntervalsSinceUnixEpoch = 0; for (int i = 0; i < tGu.Length; i++) { if (i < 3) { tenMinuteIntervalsSinceUnixEpoch += (uint)(activationRequestKeyArray[j] ^ checksum) << (i * 8); checksum += activationRequestKeyArray[j]; j++; } else if (i < 5) { skuId += (uint)(activationRequestKeyArray[j] ^ checksum) << ((i - 3) * 8); checksum += activationRequestKeyArray[j]; j++; } tGu[i] = (byte)(activationRequestKeyArray[j] ^ checksum); checksum += activationRequestKeyArray[j]; j++; } if (activationRequestKeyArray[j] != (checksum & 0xff) || activationRequestKeyArray[j + 1] != 15) { skuId = 0; return false; } //if (activationRequestKeyArray[j+1] != (byte) ((checksum >> 8) + activationRequestKeyArray[0])) //{ // return Guid.Empty; //} //if (activationRequestKeyArray[j + 2] != (byte)(((activationRequestKeyArray[0]) | 0x02) & 0x03)) //{ // return Guid.Empty; //} creationTime = new DateTime(1970, 1, 1) + new TimeSpan(0, (int)(tenMinuteIntervalsSinceUnixEpoch * 10), 0); deviceId = new Guid(tGu); return true; } public static string GetActivationRequestKey(Guid deviceId, uint SkuId) { if (deviceId == Guid.Empty) { //TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(eEngineName.ThingService, "Unable to generate activation key: device id not configured.", eMsgLevel.l2_Warning, "")); return null; } byte[] tGu = deviceId.ToByteArray(); uint tenMinuteIntervalsSinceUnixEpoch = (uint)((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMinutes) / 10; // Base 32 encoded, 22 Bytes: // 0,2,4 - Creation Time (10 Minute intervals since Unix Epoch, little endian) // 6,8 - SkuId (little endian) // 1,3,5,7,9-20 - Device Id (16 byte GUID) // 21 - Checksum // 22 - Padding (to ensure 6x6 chars in base32) byte[] activationRequestKey = new byte[3 + tGu.Length + 2 + 1 + 1]; int j = 0; //activationRequestKey[0] = (byte) (DateTime.UtcNow.Ticks & 0xff); //j++; byte checksum = 0;// activationRequestKey[0]; for (int i = 0; i < tGu.Length; i++) { if (i < 3) { activationRequestKey[j] = (byte)((tenMinuteIntervalsSinceUnixEpoch & 0xff) ^ checksum); tenMinuteIntervalsSinceUnixEpoch = tenMinuteIntervalsSinceUnixEpoch >>= 8; checksum += activationRequestKey[j]; j++; } else if (i < 5) { activationRequestKey[j] = (byte)((SkuId & 0xff) ^ checksum); SkuId = SkuId >>= 8; checksum += activationRequestKey[j]; j++; } activationRequestKey[j] = (byte)(tGu[i] ^ checksum); checksum += activationRequestKey[j]; j++; } activationRequestKey[j] = (byte)(checksum & 0xff); j++; //activationRequestKey[j + 1] = (byte) ((checksum >> 8) + activationRequestKey[0]); //activationRequestKey[j + 2] = (byte) (((activationRequestKey[0]) | 0x02) & 0x03); // ensure positive big int and 36 chars in output activationRequestKey[j] = 15; // padding return TheActivationUtils.Base32Encode(activationRequestKey); } } }
43.07971
218
0.538604
[ "Apache-2.0", "MIT", "MPL-2.0-no-copyleft-exception", "MPL-2.0", "BSD-3-Clause" ]
TRUMPF-IoT/C-DEngine
src/C-DEngine/C-DSecurity/ActivationRequestKey.cs
5,947
C#
using P09.InfernoInfinityRefactoring.Attributes; using P09.InfernoInfinityRefactoring.Contracts; namespace P09.InfernoInfinityRefactoring.Core.Commands { public class PrintCommand : Command { [Inject] private readonly IRepository repository; public PrintCommand(string[] data, IRepository repository) : base(data) { this.repository = repository; } public override void Execute() { string weaponName = this.Data[0]; this.repository.Print(weaponName); } } }
23.4
66
0.630769
[ "MIT" ]
ViktorAleksandrov/SoftUni--CSharp-Fundamentals
3. CSharp OOP Advanced/04. Reflection and Attributes/2. Exercise/P09.InfernoInfinityRefactoring/Core/Commands/PrintCommand.cs
587
C#
//------------------------------------------------------------------------------ // <auto-generated> // O código foi gerado por uma ferramenta. // Versão de Tempo de Execução:4.0.30319.42000 // // As alterações ao arquivo poderão causar comportamento incorreto e serão perdidas se // o código for gerado novamente. // </auto-generated> //------------------------------------------------------------------------------ using System; using System.Reflection; [assembly: System.Reflection.AssemblyCompanyAttribute("ResolucaoTriangulo")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")] [assembly: System.Reflection.AssemblyProductAttribute("ResolucaoTriangulo")] [assembly: System.Reflection.AssemblyTitleAttribute("ResolucaoTriangulo")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] // Gerado pela classe WriteCodeFragment do MSBuild.
43.333333
90
0.664423
[ "MIT" ]
BeckenbauerRijiirkd/Estudos
ResolucaoTriangulo/ResolucaoTriangulo/obj/Debug/netcoreapp3.1/ResolucaoTriangulo.AssemblyInfo.cs
1,049
C#
using System; using CommandDotNet; namespace IntervalCronGeneratorCLI { class Program { static int Main(string[] args) { return new AppRunner<CronCLI>().Run(args); } } }
16.846154
54
0.589041
[ "MIT" ]
egiraffe/IntervalCronGenerator
IntervalCronGeneratorCLI/Program.cs
221
C#
// Copyright (c) Source Tree Solutions, LLC. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. // Author: Joe Audette // Created: 2015-07-11 // Last Modified: 2016-05-17 // using cloudscribe.Web.Navigation.Helpers; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.Extensions.Logging; using System; namespace cloudscribe.Web.Navigation { public class NavigationNodePermissionResolver : INavigationNodePermissionResolver { public NavigationNodePermissionResolver( IHttpContextAccessor httpContextAccessor, IAuthorizationService authorizationService, ILogger<NavigationNodePermissionResolver> logger ) { _httpContextAccessor = httpContextAccessor; _authorizationService = authorizationService; _log = logger; } private IHttpContextAccessor _httpContextAccessor; private IAuthorizationService _authorizationService; private ILogger _log; public virtual bool ShouldAllowView(TreeNode<NavigationNode> menuNode) { if(!string.IsNullOrEmpty(menuNode.Value.AuthorizationPolicy)) { try { var authResult = _authorizationService.AuthorizeAsync(_httpContextAccessor.HttpContext.User, menuNode.Value.AuthorizationPolicy).GetAwaiter().GetResult(); return authResult.Succeeded; } catch(InvalidOperationException ex) { _log.LogError($"InvalidOperation exception thrown when trying to authorize node with key {menuNode.Value.Key} which has authorization policy named {menuNode.Value.AuthorizationPolicy}, the error was {ex.Message}"); return false; } } if (string.IsNullOrEmpty(menuNode.Value.ViewRoles)) { return true; } if (menuNode.Value.ViewRoles == "All Users;") { return true; } if (_httpContextAccessor.HttpContext.User.IsInRoles(menuNode.Value.ViewRoles)) { return true; } return false; } } }
37.274194
234
0.643012
[ "Apache-2.0" ]
axunonb/cloudscribe.Web.Navigation
src/cloudscribe.Web.Navigation/NavigationNodePermissionResolver.cs
2,313
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. using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.Immutable; using System.Diagnostics; using System.Linq; using System.Threading; using System.Threading.Tasks; using Microsoft.CodeAnalysis.CodeActions; using Microsoft.CodeAnalysis.Editing; using Microsoft.CodeAnalysis.Host; using Microsoft.CodeAnalysis.Internal.Log; using Microsoft.CodeAnalysis.LanguageServices; using Microsoft.CodeAnalysis.Packaging; using Microsoft.CodeAnalysis.PooledObjects; using Microsoft.CodeAnalysis.Remote; using Microsoft.CodeAnalysis.Shared.Extensions; using Microsoft.CodeAnalysis.SymbolSearch; using Microsoft.CodeAnalysis.Text; using Roslyn.Utilities; namespace Microsoft.CodeAnalysis.AddImport { internal abstract partial class AbstractAddImportFeatureService<TSimpleNameSyntax> : IAddImportFeatureService, IEqualityComparer<PortableExecutableReference> where TSimpleNameSyntax : SyntaxNode { protected abstract bool CanAddImport(SyntaxNode node, bool allowInHiddenRegions, CancellationToken cancellationToken); protected abstract bool CanAddImportForMethod(string diagnosticId, ISyntaxFacts syntaxFacts, SyntaxNode node, out TSimpleNameSyntax nameNode); protected abstract bool CanAddImportForNamespace(string diagnosticId, SyntaxNode node, out TSimpleNameSyntax nameNode); protected abstract bool CanAddImportForDeconstruct(string diagnosticId, SyntaxNode node); protected abstract bool CanAddImportForGetAwaiter(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node); protected abstract bool CanAddImportForGetEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node); protected abstract bool CanAddImportForGetAsyncEnumerator(string diagnosticId, ISyntaxFacts syntaxFactsService, SyntaxNode node); protected abstract bool CanAddImportForQuery(string diagnosticId, SyntaxNode node); protected abstract bool CanAddImportForType(string diagnosticId, SyntaxNode node, out TSimpleNameSyntax nameNode); protected abstract ISet<INamespaceSymbol> GetImportNamespacesInScope(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken); protected abstract ITypeSymbol GetDeconstructInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken); protected abstract ITypeSymbol GetQueryClauseInfo(SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken); protected abstract bool IsViableExtensionMethod(IMethodSymbol method, SyntaxNode expression, SemanticModel semanticModel, ISyntaxFacts syntaxFacts, CancellationToken cancellationToken); protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, INamespaceOrTypeSymbol symbol, Document document, bool specialCaseSystem, bool allowInHiddenRegions, CancellationToken cancellationToken); protected abstract Task<Document> AddImportAsync(SyntaxNode contextNode, IReadOnlyList<string> nameSpaceParts, Document document, bool specialCaseSystem, bool allowInHiddenRegions, CancellationToken cancellationToken); protected abstract bool IsAddMethodContext(SyntaxNode node, SemanticModel semanticModel); protected abstract string GetDescription(IReadOnlyList<string> nameParts); protected abstract (string description, bool hasExistingImport) GetDescription(Document document, INamespaceOrTypeSymbol symbol, SemanticModel semanticModel, SyntaxNode root, CancellationToken cancellationToken); public async Task<ImmutableArray<AddImportFixData>> GetFixesAsync( Document document, TextSpan span, string diagnosticId, int maxResults, bool placeSystemNamespaceFirst, bool allowInHiddenRegions, ISymbolSearchService symbolSearchService, bool searchReferenceAssemblies, ImmutableArray<PackageSource> packageSources, CancellationToken cancellationToken) { var client = await RemoteHostClient.TryGetClientAsync(document.Project, cancellationToken).ConfigureAwait(false); if (client != null) { var result = await client.TryInvokeAsync<IRemoteMissingImportDiscoveryService, ImmutableArray<AddImportFixData>>( document.Project.Solution, (service, solutionInfo, callbackId, cancellationToken) => service.GetFixesAsync(solutionInfo, callbackId, document.Id, span, diagnosticId, maxResults, placeSystemNamespaceFirst, allowInHiddenRegions, searchReferenceAssemblies, packageSources, cancellationToken), callbackTarget: symbolSearchService, cancellationToken).ConfigureAwait(false); return result.HasValue ? result.Value : ImmutableArray<AddImportFixData>.Empty; } return await GetFixesInCurrentProcessAsync( document, span, diagnosticId, maxResults, placeSystemNamespaceFirst, allowInHiddenRegions, symbolSearchService, searchReferenceAssemblies, packageSources, cancellationToken).ConfigureAwait(false); } private async Task<ImmutableArray<AddImportFixData>> GetFixesInCurrentProcessAsync( Document document, TextSpan span, string diagnosticId, int maxResults, bool placeSystemNamespaceFirst, bool allowInHiddenRegions, ISymbolSearchService symbolSearchService, bool searchReferenceAssemblies, ImmutableArray<PackageSource> packageSources, CancellationToken cancellationToken) { var root = await document.GetRequiredSyntaxRootAsync(cancellationToken).ConfigureAwait(false); var node = root.FindToken(span.Start, findInsideTrivia: true) .GetAncestor(n => n.Span.Contains(span) && n != root); using var _ = ArrayBuilder<AddImportFixData>.GetInstance(out var result); if (node != null) { using (Logger.LogBlock(FunctionId.Refactoring_AddImport, cancellationToken)) { if (!cancellationToken.IsCancellationRequested) { if (CanAddImport(node, allowInHiddenRegions, cancellationToken)) { var semanticModel = await document.GetRequiredSemanticModelAsync(cancellationToken).ConfigureAwait(false); var allSymbolReferences = await FindResultsAsync( document, semanticModel, diagnosticId, node, maxResults, symbolSearchService, searchReferenceAssemblies, packageSources, cancellationToken).ConfigureAwait(false); // Nothing found at all. No need to proceed. foreach (var reference in allSymbolReferences) { cancellationToken.ThrowIfCancellationRequested(); var fixData = await reference.TryGetFixDataAsync(document, node, placeSystemNamespaceFirst, allowInHiddenRegions, cancellationToken).ConfigureAwait(false); result.AddIfNotNull(fixData); } } } } } return result.ToImmutable(); } private async Task<ImmutableArray<Reference>> FindResultsAsync( Document document, SemanticModel semanticModel, string diagnosticId, SyntaxNode node, int maxResults, ISymbolSearchService symbolSearchService, bool searchReferenceAssemblies, ImmutableArray<PackageSource> packageSources, CancellationToken cancellationToken) { // Caches so we don't produce the same data multiple times while searching // all over the solution. var project = document.Project; var projectToAssembly = new ConcurrentDictionary<Project, AsyncLazy<IAssemblySymbol>>(concurrencyLevel: 2, capacity: project.Solution.ProjectIds.Count); var referenceToCompilation = new ConcurrentDictionary<PortableExecutableReference, Compilation>(concurrencyLevel: 2, capacity: project.Solution.Projects.Sum(p => p.MetadataReferences.Count)); var finder = new SymbolReferenceFinder( this, document, semanticModel, diagnosticId, node, symbolSearchService, searchReferenceAssemblies, packageSources, cancellationToken); // Look for exact matches first: var exactReferences = await FindResultsAsync(projectToAssembly, referenceToCompilation, project, maxResults, finder, exact: true, cancellationToken: cancellationToken).ConfigureAwait(false); if (exactReferences.Length > 0) { return exactReferences; } // No exact matches found. Fall back to fuzzy searching. // Only bother doing this for host workspaces. We don't want this for // things like the Interactive workspace as this will cause us to // create expensive bk-trees which we won't even be able to save for // future use. if (!IsHostOrRemoteWorkspace(project)) { return ImmutableArray<Reference>.Empty; } var fuzzyReferences = await FindResultsAsync(projectToAssembly, referenceToCompilation, project, maxResults, finder, exact: false, cancellationToken: cancellationToken).ConfigureAwait(false); return fuzzyReferences; } private static bool IsHostOrRemoteWorkspace(Project project) { return project.Solution.Workspace.Kind == WorkspaceKind.Host || project.Solution.Workspace.Kind == WorkspaceKind.RemoteWorkspace || project.Solution.Workspace.Kind == WorkspaceKind.RemoteTemporaryWorkspace; } private async Task<ImmutableArray<Reference>> FindResultsAsync( ConcurrentDictionary<Project, AsyncLazy<IAssemblySymbol>> projectToAssembly, ConcurrentDictionary<PortableExecutableReference, Compilation> referenceToCompilation, Project project, int maxResults, SymbolReferenceFinder finder, bool exact, CancellationToken cancellationToken) { using var _ = ArrayBuilder<Reference>.GetInstance(out var allReferences); // First search the current project to see if any symbols (source or metadata) match the // search string. await FindResultsInAllSymbolsInStartingProjectAsync( allReferences, maxResults, finder, exact, cancellationToken).ConfigureAwait(false); // Only bother doing this for host workspaces. We don't want this for // things like the Interactive workspace as we can't even add project // references to the interactive window. We could consider adding metadata // references with #r in the future. if (IsHostOrRemoteWorkspace(project)) { // Now search unreferenced projects, and see if they have any source symbols that match // the search string. await FindResultsInUnreferencedProjectSourceSymbolsAsync(projectToAssembly, project, allReferences, maxResults, finder, exact, cancellationToken).ConfigureAwait(false); // Finally, check and see if we have any metadata symbols that match the search string. await FindResultsInUnreferencedMetadataSymbolsAsync(referenceToCompilation, project, allReferences, maxResults, finder, exact, cancellationToken).ConfigureAwait(false); // We only support searching NuGet in an exact manner currently. if (exact) { await finder.FindNugetOrReferenceAssemblyReferencesAsync(allReferences, cancellationToken).ConfigureAwait(false); } } return allReferences.ToImmutable(); } private static async Task FindResultsInAllSymbolsInStartingProjectAsync( ArrayBuilder<Reference> allSymbolReferences, int maxResults, SymbolReferenceFinder finder, bool exact, CancellationToken cancellationToken) { var references = await finder.FindInAllSymbolsInStartingProjectAsync(exact, cancellationToken).ConfigureAwait(false); AddRange(allSymbolReferences, references, maxResults); } private static async Task FindResultsInUnreferencedProjectSourceSymbolsAsync( ConcurrentDictionary<Project, AsyncLazy<IAssemblySymbol>> projectToAssembly, Project project, ArrayBuilder<Reference> allSymbolReferences, int maxResults, SymbolReferenceFinder finder, bool exact, CancellationToken cancellationToken) { // If we didn't find enough hits searching just in the project, then check // in any unreferenced projects. if (allSymbolReferences.Count >= maxResults) { return; } var viableUnreferencedProjects = GetViableUnreferencedProjects(project); // Search all unreferenced projects in parallel. var findTasks = new HashSet<Task<ImmutableArray<SymbolReference>>>(); // Create another cancellation token so we can both search all projects in parallel, // but also stop any searches once we get enough results. using var nestedTokenSource = new CancellationTokenSource(); using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(nestedTokenSource.Token, cancellationToken); foreach (var unreferencedProject in viableUnreferencedProjects) { // Search in this unreferenced project. But don't search in any of its' // direct references. i.e. we don't want to search in its metadata references // or in the projects it references itself. We'll be searching those entities // individually. findTasks.Add(finder.FindInSourceSymbolsInProjectAsync( projectToAssembly, unreferencedProject, exact, linkedTokenSource.Token)); } await WaitForTasksAsync(allSymbolReferences, maxResults, findTasks, nestedTokenSource, cancellationToken).ConfigureAwait(false); } private async Task FindResultsInUnreferencedMetadataSymbolsAsync( ConcurrentDictionary<PortableExecutableReference, Compilation> referenceToCompilation, Project project, ArrayBuilder<Reference> allSymbolReferences, int maxResults, SymbolReferenceFinder finder, bool exact, CancellationToken cancellationToken) { if (allSymbolReferences.Count > 0) { // Only do this if none of the project searches produced any results. We may have a // lot of metadata to search through, and it would be good to avoid that if we can. return; } // Keep track of the references we've seen (so that we don't process them multiple times // across many sibling projects). Prepopulate it with our own metadata references since // we know we don't need to search in that. var seenReferences = new HashSet<PortableExecutableReference>(comparer: this); seenReferences.AddAll(project.MetadataReferences.OfType<PortableExecutableReference>()); var newReferences = GetUnreferencedMetadataReferences(project, seenReferences); // Search all metadata references in parallel. var findTasks = new HashSet<Task<ImmutableArray<SymbolReference>>>(); // Create another cancellation token so we can both search all projects in parallel, // but also stop any searches once we get enough results. using var nestedTokenSource = new CancellationTokenSource(); using var linkedTokenSource = CancellationTokenSource.CreateLinkedTokenSource(nestedTokenSource.Token, cancellationToken); foreach (var (referenceProjectId, reference) in newReferences) { var compilation = referenceToCompilation.GetOrAdd( reference, r => CreateCompilation(project, r)); // Ignore netmodules. First, they're incredibly esoteric and barely used. // Second, the SymbolFinder API doesn't even support searching them. if (compilation.GetAssemblyOrModuleSymbol(reference) is IAssemblySymbol assembly) { findTasks.Add(finder.FindInMetadataSymbolsAsync( assembly, referenceProjectId, reference, exact, linkedTokenSource.Token)); } } await WaitForTasksAsync(allSymbolReferences, maxResults, findTasks, nestedTokenSource, cancellationToken).ConfigureAwait(false); } /// <summary> /// Returns the set of PEReferences in the solution that are not currently being referenced /// by this project. The set returned will be tuples containing the PEReference, and the project-id /// for the project we found the pe-reference in. /// </summary> private static ImmutableArray<(ProjectId, PortableExecutableReference)> GetUnreferencedMetadataReferences( Project project, HashSet<PortableExecutableReference> seenReferences) { var result = ArrayBuilder<(ProjectId, PortableExecutableReference)>.GetInstance(); var solution = project.Solution; foreach (var p in solution.Projects) { if (p == project) { continue; } foreach (var reference in p.MetadataReferences) { if (reference is PortableExecutableReference peReference && !IsInPackagesDirectory(peReference) && seenReferences.Add(peReference)) { result.Add((p.Id, peReference)); } } } return result.ToImmutableAndFree(); } private static async Task WaitForTasksAsync( ArrayBuilder<Reference> allSymbolReferences, int maxResults, HashSet<Task<ImmutableArray<SymbolReference>>> findTasks, CancellationTokenSource nestedTokenSource, CancellationToken cancellationToken) { try { while (findTasks.Count > 0) { // Keep on looping through the 'find' tasks, processing each when they finish. cancellationToken.ThrowIfCancellationRequested(); var doneTask = await Task.WhenAny(findTasks).ConfigureAwait(false); // One of the tasks finished. Remove it from the list we're waiting on. findTasks.Remove(doneTask); // Add its results to the final result set we're keeping. AddRange(allSymbolReferences, await doneTask.ConfigureAwait(false), maxResults); // Once we get enough, just stop. if (allSymbolReferences.Count >= maxResults) { return; } } } finally { // Cancel any nested work that's still happening. nestedTokenSource.Cancel(); } } /// <summary> /// We ignore references that are in a directory that contains the names /// "Packages", "packs", "NuGetFallbackFolder", or "NuGetPackages" /// These directories are most likely the ones produced by NuGet, and we don't want /// to offer to add .dll reference manually for dlls that are part of NuGet packages. /// /// Note that this is only a heuristic (though a good one), and we should remove this /// when we can get an API from NuGet that tells us if a reference is actually provided /// by a nuget packages. /// Tracking issue: https://github.com/dotnet/project-system/issues/5275 /// /// This heuristic will do the right thing in practically all cases for all. It /// prevents the very unpleasant experience of us offering to add a direct metadata /// reference to something that should only be referenced as a nuget package. /// /// It does mean that if the following is true: /// You have a project that has a non-nuget metadata reference to something in a "packages" /// directory, and you are in another project that uses a type name that would have matched /// an accessible type from that dll. then we will not offer to add that .dll reference to /// that other project. /// /// However, that would be an exceedingly uncommon case that is degraded. Whereas we're /// vastly improved in the common case. This is a totally acceptable and desirable outcome /// for such a heuristic. /// </summary> private static bool IsInPackagesDirectory(PortableExecutableReference reference) { return ContainsPathComponent(reference, "packages") || ContainsPathComponent(reference, "packs") || ContainsPathComponent(reference, "NuGetFallbackFolder") || ContainsPathComponent(reference, "NuGetPackages"); static bool ContainsPathComponent(PortableExecutableReference reference, string pathComponent) { return PathUtilities.ContainsPathComponent(reference.FilePath, pathComponent, ignoreCase: true); } } /// <summary> /// Called when we want to search a metadata reference. We create a dummy compilation /// containing just that reference and we search that. That way we can get actual symbols /// returned. /// /// We don't want to use the project that the reference is actually associated with as /// getting the compilation for that project may be extremely expensive. For example, /// in a large solution it may cause us to build an enormous amount of skeleton assemblies. /// </summary> private static Compilation CreateCompilation(Project project, PortableExecutableReference reference) { var compilationService = project.LanguageServices.GetRequiredService<ICompilationFactoryService>(); var compilation = compilationService.CreateCompilation("TempAssembly", compilationService.GetDefaultCompilationOptions()); return compilation.WithReferences(reference); } bool IEqualityComparer<PortableExecutableReference>.Equals(PortableExecutableReference? x, PortableExecutableReference? y) => StringComparer.OrdinalIgnoreCase.Equals(x?.FilePath ?? x?.Display, y?.FilePath ?? y?.Display); int IEqualityComparer<PortableExecutableReference>.GetHashCode(PortableExecutableReference obj) { var identifier = obj.FilePath ?? obj.Display; Contract.ThrowIfNull(identifier, "Either FilePath or Display must be non-null"); return StringComparer.OrdinalIgnoreCase.GetHashCode(identifier); } private static HashSet<Project> GetViableUnreferencedProjects(Project project) { var solution = project.Solution; var viableProjects = new HashSet<Project>(solution.Projects); // Clearly we can't reference ourselves. viableProjects.Remove(project); // We can't reference any project that transitively depends on us. Doing so would // cause a circular reference between projects. var dependencyGraph = solution.GetProjectDependencyGraph(); var projectsThatTransitivelyDependOnThisProject = dependencyGraph.GetProjectsThatTransitivelyDependOnThisProject(project.Id); viableProjects.RemoveAll(projectsThatTransitivelyDependOnThisProject.Select(id => solution.GetRequiredProject(id))); // We also aren't interested in any projects we're already directly referencing. viableProjects.RemoveAll(project.ProjectReferences.Select(r => solution.GetRequiredProject(r.ProjectId))); return viableProjects; } private static void AddRange<TReference>(ArrayBuilder<Reference> allSymbolReferences, ImmutableArray<TReference> proposedReferences, int maxResults) where TReference : Reference { allSymbolReferences.AddRange(proposedReferences.Take(maxResults - allSymbolReferences.Count)); } protected static bool IsViableExtensionMethod(IMethodSymbol method, ITypeSymbol receiver) { if (receiver == null || method == null) { return false; } // It's possible that the 'method' we're looking at is from a different language than // the language we're currently in. For example, we might find the extension method // in an unreferenced VB project while we're in C#. However, in order to 'reduce' // the extension method, the compiler requires both the method and receiver to be // from the same language. // // So, if they're not from the same language, we simply can't proceed. Now in this // case we decide that the method is not viable. But we could, in the future, decide // to just always consider such methods viable. if (receiver.Language != method.Language) { return false; } return method.ReduceExtensionMethod(receiver) != null; } private static bool NotGlobalNamespace(SymbolReference reference) { var symbol = reference.SymbolResult.Symbol; return symbol.IsNamespace ? !((INamespaceSymbol)symbol).IsGlobalNamespace : true; } private static bool NotNull(SymbolReference reference) => reference.SymbolResult.Symbol != null; public async Task<ImmutableArray<(Diagnostic Diagnostic, ImmutableArray<AddImportFixData> Fixes)>> GetFixesForDiagnosticsAsync( Document document, TextSpan span, ImmutableArray<Diagnostic> diagnostics, int maxResultsPerDiagnostic, ISymbolSearchService symbolSearchService, bool searchReferenceAssemblies, ImmutableArray<PackageSource> packageSources, CancellationToken cancellationToken) { // We might have multiple different diagnostics covering the same span. Have to // process them all as we might produce different fixes for each diagnostic. var documentOptions = await document.GetOptionsAsync(cancellationToken).ConfigureAwait(false); var placeSystemNamespaceFirst = documentOptions.GetOption(GenerationOptions.PlaceSystemNamespaceFirst); // Normally we don't allow generation into a hidden region in the file. However, if we have a // modern span mapper at our disposal, we do allow it as that host span mapper can handle mapping // our edit to their domain appropriate. var allowInHiddenRegions = document.CanAddImportsInHiddenRegions(); var fixesForDiagnosticBuilder = ArrayBuilder<(Diagnostic, ImmutableArray<AddImportFixData>)>.GetInstance(); foreach (var diagnostic in diagnostics) { var fixes = await GetFixesAsync( document, span, diagnostic.Id, maxResultsPerDiagnostic, placeSystemNamespaceFirst, allowInHiddenRegions, symbolSearchService, searchReferenceAssemblies, packageSources, cancellationToken).ConfigureAwait(false); fixesForDiagnosticBuilder.Add((diagnostic, fixes)); } return fixesForDiagnosticBuilder.ToImmutableAndFree(); } public ImmutableArray<CodeAction> GetCodeActionsForFixes( Document document, ImmutableArray<AddImportFixData> fixes, IPackageInstallerService? installerService, int maxResults) { var codeActionsBuilder = ArrayBuilder<CodeAction>.GetInstance(); foreach (var fix in fixes) { var codeAction = TryCreateCodeAction(document, fix, installerService); codeActionsBuilder.AddIfNotNull(codeAction); if (codeActionsBuilder.Count >= maxResults) { break; } } return codeActionsBuilder.ToImmutableAndFree(); } private static CodeAction? TryCreateCodeAction(Document document, AddImportFixData fixData, IPackageInstallerService? installerService) => fixData.Kind switch { AddImportFixKind.ProjectSymbol => new ProjectSymbolReferenceCodeAction(document, fixData), AddImportFixKind.MetadataSymbol => new MetadataSymbolReferenceCodeAction(document, fixData), AddImportFixKind.ReferenceAssemblySymbol => new AssemblyReferenceCodeAction(document, fixData), AddImportFixKind.PackageSymbol => installerService?.IsInstalled(document.Project.Solution.Workspace, document.Project.Id, fixData.PackageName) == false ? new ParentInstallPackageCodeAction(document, fixData, installerService) : null, _ => throw ExceptionUtilities.Unreachable, }; private static ITypeSymbol? GetAwaitInfo(SemanticModel semanticModel, ISyntaxFacts syntaxFactsService, SyntaxNode node) { var awaitExpression = FirstAwaitExpressionAncestor(syntaxFactsService, node); if (awaitExpression is null) return null; Debug.Assert(syntaxFactsService.IsAwaitExpression(awaitExpression)); var innerExpression = syntaxFactsService.GetExpressionOfAwaitExpression(awaitExpression); return semanticModel.GetTypeInfo(innerExpression).Type; } private static ITypeSymbol? GetCollectionExpressionType(SemanticModel semanticModel, ISyntaxFacts syntaxFactsService, SyntaxNode node) { var collectionExpression = FirstForeachCollectionExpressionAncestor(syntaxFactsService, node); if (collectionExpression is null) { return null; } return semanticModel.GetTypeInfo(collectionExpression).Type; } protected static bool AncestorOrSelfIsAwaitExpression(ISyntaxFacts syntaxFactsService, SyntaxNode node) => FirstAwaitExpressionAncestor(syntaxFactsService, node) != null; private static SyntaxNode? FirstAwaitExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node) => node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFacts>((n, syntaxFactsService) => syntaxFactsService.IsAwaitExpression(n), syntaxFactsService); private static SyntaxNode? FirstForeachCollectionExpressionAncestor(ISyntaxFacts syntaxFactsService, SyntaxNode node) => node.FirstAncestorOrSelf<SyntaxNode, ISyntaxFacts>((n, syntaxFactsService) => syntaxFactsService.IsExpressionOfForeach(n), syntaxFactsService); } }
55.33506
228
0.674178
[ "MIT" ]
Acidburn0zzz/roslyn
src/Features/Core/Portable/AddImport/AbstractAddImportFeatureService.cs
32,041
C#
using System; using HDWallet.Core; using Ed25519; using NBitcoin.DataEncoders; using dotnetstandard_bip32; namespace HDWallet.Ed25519 { public abstract class Wallet : IWallet { public string Path {get; set;} byte[] privateKey; public byte[] PrivateKey { get { return privateKey; } set{ if(value.Length != 32) { throw new InvalidOperationException(); } privateKey = value; ReadOnlySpan<byte> privateKeySpan = privateKey.AsSpan(); var publicKey = privateKeySpan.ExtractPublicKey(); PublicKey = publicKey.ToArray(); } } public byte[] ExpandedPrivateKey { get { return GetExpandedPrivateKey(PrivateKey); } } public byte[] GetExpandedPrivateKey(byte[] privateKey) { Chaos.NaCl.Ed25519.KeyPairFromSeed(out _, out var expandedPrivateKey, privateKey); var zero = new byte[] { 0 }; var buffer = new BigEndianBuffer(); buffer.Write(expandedPrivateKey); return buffer.ToArray(); } public byte[] PublicKey; public uint Index; public string Address => AddressGenerator.GenerateAddress(PublicKey); public IAddressGenerator AddressGenerator {get; private set; } public Wallet(){ AddressGenerator = GetAddressGenerator(); } public Wallet(byte[] privateKey) : this() { PrivateKey = privateKey; } public Wallet(string privateKeyHex) : this(Encoders.Hex.DecodeData( privateKeyHex.StartsWith("0x") ? privateKeyHex.Substring(2) : privateKeyHex )) { } protected abstract IAddressGenerator GetAddressGenerator(); public Signature Sign(byte[] message) { // if (message.Length != 32) throw new ArgumentException(paramName: nameof(message), message: "Message should be 32 bytes"); var signature = Signer.Sign(message, this.PrivateKey, this.PublicKey); var signatureHex = signature.ToArray().ToHexString(); var rsigPad = new byte[32]; Array.Copy(signature.ToArray(), 0, rsigPad, rsigPad.Length - 32, 32); var ssigPad = new byte[32]; Array.Copy(signature.ToArray(), 32, ssigPad, ssigPad.Length - 32, 32); return new Signature() { R = rsigPad, S = ssigPad }; } } }
28.744681
136
0.547002
[ "MIT" ]
TurgutKanceltik/HDWallet
src/HDWallet.Ed25519/Wallet.cs
2,702
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 Microsoft.CSharp.RuntimeBinder.Syntax { internal class NameTable { private class Entry { internal readonly Name name; internal readonly int hashCode; internal Entry next; internal Entry(Name name, int hashCode, Entry next) { this.name = name; this.hashCode = hashCode; this.next = next; } } private Entry[] _entries; private int _count; private int _mask; private int _hashCodeRandomizer; internal NameTable() { _mask = 31; _entries = new Entry[_mask + 1]; //hashCodeRandomizer = Environment.TickCount; _hashCodeRandomizer = 0; } public Name Add(string key) { int hashCode = ComputeHashCode(key); for (Entry e = _entries[hashCode & _mask]; e != null; e = e.next) { if (e.hashCode == hashCode && e.name.Text.Equals(key)) { return e.name; } } return this.AddEntry(new Name(key), hashCode); } internal void Add(Name name) { int hashCode = ComputeHashCode(name.Text); // make sure it doesn't already exist for (Entry e = _entries[hashCode & _mask]; e != null; e = e.next) { if (e.hashCode == hashCode && e.name.Text.Equals(name.Text)) { throw Error.InternalCompilerError(); } } this.AddEntry(name, hashCode); } public Name Lookup(string key) { int hashCode = ComputeHashCode(key); for (Entry e = _entries[hashCode & _mask]; e != null; e = e.next) { if (e.hashCode == hashCode && e.name.Text.Equals(key)) { return e.name; } } return null; } private int ComputeHashCode(string key) { int len = key.Length; int hashCode = len + _hashCodeRandomizer; // use key.Length to eliminate the range check for (int i = 0; i < key.Length; i++) { hashCode += (hashCode << 7) ^ key[i]; } // mix it a bit more hashCode -= hashCode >> 17; hashCode -= hashCode >> 11; hashCode -= hashCode >> 5; return hashCode; } private Name AddEntry(Name name, int hashCode) { int index = hashCode & _mask; Entry e = new Entry(name, hashCode, _entries[index]); _entries[index] = e; if (_count++ == _mask) { this.Grow(); } return e.name; } private void Grow() { int newMask = _mask * 2 + 1; Entry[] oldEntries = _entries; Entry[] newEntries = new Entry[newMask + 1]; // use oldEntries.Length to eliminate the range check for (int i = 0; i < oldEntries.Length; i++) { Entry e = oldEntries[i]; while (e != null) { int newIndex = e.hashCode & newMask; Entry tmp = e.next; e.next = newEntries[newIndex]; newEntries[newIndex] = e; e = tmp; } } _entries = newEntries; _mask = newMask; } } }
30.263566
77
0.462859
[ "MIT" ]
OceanYan/corefx
src/Microsoft.CSharp/src/Microsoft/CSharp/RuntimeBinder/Syntax/NameTable.cs
3,904
C#
// Copyright 2019 Google LLC // // 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 CommandLine; using Google.Ads.GoogleAds.Lib; using Google.Ads.GoogleAds.V10.Errors; using Google.Ads.GoogleAds.V10.Services; using System; using System.Collections.Generic; namespace Google.Ads.GoogleAds.Examples.V10 { /// <summary> /// This code example illustrates getting GeoTargetConstants by given location names. /// </summary> public class GetGeoTargetConstantsByNames : ExampleBase { /// <summary> /// Command line options for running the <see cref="GetGeoTargetConstantsByNames"/> example. /// </summary> public class Options : OptionsBase { } /// <summary> /// Main method, to run this code example as a standalone application. /// </summary> /// <param name="args">The command line arguments.</param> public static void Main(string[] args) { Options options = new Options(); CommandLine.Parser.Default.ParseArguments<Options>(args).MapResult( delegate (Options o) { options = o; return 0; }, delegate (IEnumerable<Error> errors) { return 0; }); GetGeoTargetConstantsByNames codeExample = new GetGeoTargetConstantsByNames(); Console.WriteLine(codeExample.Description); codeExample.Run(new GoogleAdsClient()); } /// <summary> /// Returns a description about the code example. /// </summary> public override string Description => "This code example illustrates getting GeoTargetConstants by given location names."; /// <summary> /// Runs the code example. /// </summary> /// <param name="client">The Google Ads client.</param> // [START get_geo_target_constants_by_names] public void Run(GoogleAdsClient client) { // Get the GeoTargetConstantServiceClient. GeoTargetConstantServiceClient geoService = client.GetService(Services.V10.GeoTargetConstantService); // Locale is using ISO 639-1 format. If an invalid locale is given, // 'en' is used by default. string locale = "en"; // A list of country codes can be referenced here: // https://developers.google.com/google-ads/api/reference/data/geotargets string countryCode = "FR"; string[] locations = { "Paris", "Quebec", "Spain", "Deutschland" }; SuggestGeoTargetConstantsRequest request = new SuggestGeoTargetConstantsRequest() { Locale = locale, CountryCode = countryCode, LocationNames = new SuggestGeoTargetConstantsRequest.Types.LocationNames() }; request.LocationNames.Names.AddRange(locations); try { SuggestGeoTargetConstantsResponse response = geoService.SuggestGeoTargetConstants(request); foreach (GeoTargetConstantSuggestion suggestion in response.GeoTargetConstantSuggestions) { Console.WriteLine( $"{suggestion.GeoTargetConstant.ResourceName} " + $"({suggestion.GeoTargetConstant.Name}, " + $"{suggestion.GeoTargetConstant.CountryCode}, " + $"{suggestion.GeoTargetConstant.TargetType}, " + $"{suggestion.GeoTargetConstant.Status}) is found in locale " + $"({suggestion.Locale}) with reach ({suggestion.Reach}) " + $"for search term ({suggestion.SearchTerm})."); } } catch (GoogleAdsException e) { Console.WriteLine("Failure:"); Console.WriteLine($"Message: {e.Message}"); Console.WriteLine($"Failure: {e.Failure}"); Console.WriteLine($"Request ID: {e.RequestId}"); throw; } } // [END get_geo_target_constants_by_names] } }
38.782258
100
0.585777
[ "Apache-2.0" ]
friedenberg/google-ads-dotnet
examples/Targeting/GetGeoTargetConstantsByNames.cs
4,809
C#
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Collections.Generic; namespace Yarp.ReverseProxy.Transforms.Builder { /// <summary> /// Validates and builds transforms from the given parameters /// </summary> public interface ITransformFactory { /// <summary> /// Checks if the given transform values match a known transform, and if those values have any errors. /// </summary> /// <param name="context">The context to add any generated errors to.</param> /// <param name="transformValues">The transform values to validate.</param> /// <returns>True if this factory matches the given transform, otherwise false.</returns> bool Validate(TransformRouteValidationContext context, IReadOnlyDictionary<string, string> transformValues); /// <summary> /// Checks if the given transform values match a known transform, and if so, generates a transform and /// adds it to the context. This can throw if the transform values are invalid. /// </summary> /// <param name="context">The context to add any generated transforms to.</param> /// <param name="transformValues">The transform values to use as input.</param> /// <returns>True if this factory matches the given transform, otherwise false.</returns> bool Build(TransformBuilderContext context, IReadOnlyDictionary<string, string> transformValues); } }
47.870968
116
0.688679
[ "MIT" ]
BennyM/reverse-proxy
src/ReverseProxy/Transforms/Builder/ITransformFactory.cs
1,484
C#
/// This code was generated by /// \ / _ _ _| _ _ /// | (_)\/(_)(_|\/| |(/_ v1.0.0 /// / / /// <summary> /// PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution. /// /// ExecutionContextResource /// </summary> using Newtonsoft.Json; using System; using System.Collections.Generic; using Twilio.Base; using Twilio.Clients; using Twilio.Converters; using Twilio.Exceptions; using Twilio.Http; namespace Twilio.Rest.Studio.V2.Flow.Execution { public class ExecutionContextResource : Resource { private static Request BuildFetchRequest(FetchExecutionContextOptions options, ITwilioRestClient client) { return new Request( HttpMethod.Get, Rest.Domain.Studio, "/v2/Flows/" + options.PathFlowSid + "/Executions/" + options.PathExecutionSid + "/Context", client.Region, queryParams: options.GetParams() ); } /// <summary> /// Retrieve the most recent context for an Execution. /// </summary> /// <param name="options"> Fetch ExecutionContext parameters </param> /// <param name="client"> Client to make requests to Twilio </param> /// <returns> A single instance of ExecutionContext </returns> public static ExecutionContextResource Fetch(FetchExecutionContextOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = client.Request(BuildFetchRequest(options, client)); return FromJson(response.Content); } #if !NET35 /// <summary> /// Retrieve the most recent context for an Execution. /// </summary> /// <param name="options"> Fetch ExecutionContext parameters </param> /// <param name="client"> Client to make requests to Twilio </param> /// <returns> Task that resolves to A single instance of ExecutionContext </returns> public static async System.Threading.Tasks.Task<ExecutionContextResource> FetchAsync(FetchExecutionContextOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildFetchRequest(options, client)); return FromJson(response.Content); } #endif /// <summary> /// Retrieve the most recent context for an Execution. /// </summary> /// <param name="pathFlowSid"> The SID of the Flow </param> /// <param name="pathExecutionSid"> The SID of the Execution </param> /// <param name="client"> Client to make requests to Twilio </param> /// <returns> A single instance of ExecutionContext </returns> public static ExecutionContextResource Fetch(string pathFlowSid, string pathExecutionSid, ITwilioRestClient client = null) { var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); return Fetch(options, client); } #if !NET35 /// <summary> /// Retrieve the most recent context for an Execution. /// </summary> /// <param name="pathFlowSid"> The SID of the Flow </param> /// <param name="pathExecutionSid"> The SID of the Execution </param> /// <param name="client"> Client to make requests to Twilio </param> /// <returns> Task that resolves to A single instance of ExecutionContext </returns> public static async System.Threading.Tasks.Task<ExecutionContextResource> FetchAsync(string pathFlowSid, string pathExecutionSid, ITwilioRestClient client = null) { var options = new FetchExecutionContextOptions(pathFlowSid, pathExecutionSid); return await FetchAsync(options, client); } #endif /// <summary> /// Converts a JSON string into a ExecutionContextResource object /// </summary> /// <param name="json"> Raw JSON string </param> /// <returns> ExecutionContextResource object represented by the provided JSON </returns> public static ExecutionContextResource FromJson(string json) { // Convert all checked exceptions to Runtime try { return JsonConvert.DeserializeObject<ExecutionContextResource>(json); } catch (JsonException e) { throw new ApiException(e.Message, e); } } /// <summary> /// The SID of the Account that created the resource /// </summary> [JsonProperty("account_sid")] public string AccountSid { get; private set; } /// <summary> /// The current state of the flow /// </summary> [JsonProperty("context")] public object Context { get; private set; } /// <summary> /// The SID of the Flow /// </summary> [JsonProperty("flow_sid")] public string FlowSid { get; private set; } /// <summary> /// The SID of the Execution /// </summary> [JsonProperty("execution_sid")] public string ExecutionSid { get; private set; } /// <summary> /// The absolute URL of the resource /// </summary> [JsonProperty("url")] public Uri Url { get; private set; } private ExecutionContextResource() { } } }
40.401361
130
0.568446
[ "MIT" ]
ashish-s/twilio-csharp
src/Twilio/Rest/Studio/V2/Flow/Execution/ExecutionContextResource.cs
5,939
C#
#if FEATURE_BREAKITERATOR using System; using System.Collections.Generic; using System.Globalization; using System.Linq; using System.Text; namespace Lucene.Net.Support { /* * 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. */ /// <summary> /// A <see cref="BreakIterator"/> implementation that encapsulates the functionality /// of icu.net's <see cref="Icu.BreakIterator"/> static class. A <see cref="BreakIterator"/> /// provides methods to move forward, reverse, and randomly through a set of text breaks /// defined by the <see cref="Icu.BreakIterator.UBreakIteratorType"/> enumeration. /// </summary> // LUCENENET specific type public class IcuBreakIterator : BreakIterator { private readonly Icu.Locale locale; private readonly Icu.BreakIterator.UBreakIteratorType type; private List<int> boundaries = new List<int>(); private int currentBoundaryIndex; // Index (not the value) of the current boundary in boundaries private string text; /// <summary> /// The start offset for the string, if supplied by a <see cref="CharacterIterator"/> /// </summary> protected int m_start; /// <summary> /// The end offset for the string, if supplied by a <see cref="CharacterIterator"/> /// </summary> protected int m_end; private bool enableHacks = false; public IcuBreakIterator(Icu.BreakIterator.UBreakIteratorType type) : this(type, CultureInfo.CurrentCulture) { } public IcuBreakIterator(Icu.BreakIterator.UBreakIteratorType type, CultureInfo locale) { if (locale == null) throw new ArgumentNullException("locale"); this.locale = new Icu.Locale(locale.Name); this.type = type; } public virtual bool EnableHacks { get { return enableHacks; } set { enableHacks = value; } } /// <summary> /// Sets the current iteration position to the beginning of the text. /// </summary> /// <returns>The offset of the beginning of the text.</returns> public override int First() { currentBoundaryIndex = 0; return ReturnCurrent(); } /// <summary> /// Sets the current iteration position to the end of the text. /// </summary> /// <returns>The text's past-the-end offset.</returns> public override int Last() { currentBoundaryIndex = boundaries.Count - 1; return ReturnCurrent(); } /// <summary> /// Advances the iterator either forward or backward the specified number of steps. /// Negative values move backward, and positive values move forward. This is /// equivalent to repeatedly calling <see cref="Next()"/> or <see cref="Previous()"/>. /// </summary> /// <param name="n">The number of steps to move. The sign indicates the direction /// (negative is backwards, and positive is forwards).</param> /// <returns>The character offset of the boundary position n boundaries away from /// the current one.</returns> public override int Next(int n) { int result = Current; while (n > 0) { result = Next(); --n; } while (n < 0) { result = Previous(); ++n; } return result; } /// <summary> /// Advances the iterator to the next boundary position. /// </summary> /// <returns>The position of the first boundary after this one.</returns> public override int Next() { if (currentBoundaryIndex >= boundaries.Count - 1 || boundaries.Count == 0) { return DONE; } currentBoundaryIndex++; return ReturnCurrent(); } /// <summary> /// Advances the iterator backwards, to the last boundary preceding this one. /// </summary> /// <returns>The position of the last boundary position preceding this one.</returns> public override int Previous() { if (currentBoundaryIndex == 0 || boundaries.Count == 0) { return DONE; } currentBoundaryIndex--; return ReturnCurrent(); } /// <summary> /// Throw <see cref="ArgumentException"/> unless begin &lt;= offset &lt; end. /// </summary> /// <param name="offset"></param> private void CheckOffset(int offset) { if (offset < m_start || offset > m_end) { throw new ArgumentException("offset out of bounds"); } } /// <summary> /// Sets the iterator to refer to the first boundary position following /// the specified position. /// </summary> /// <param name="offset">The position from which to begin searching for a break position.</param> /// <returns>The position of the first break after the current position.</returns> public override int Following(int offset) { CheckOffset(offset); if (boundaries.Count == 0) { return DONE; } int following = GetLowestIndexGreaterThan(offset); if (following == -1) { currentBoundaryIndex = boundaries.Count - 1; return DONE; } else { currentBoundaryIndex = following; } return ReturnCurrent(); } private int GetLowestIndexGreaterThan(int offset) { int index = boundaries.BinarySearch(offset); if (index < 0) { return ~index; } else if (index + 1 < boundaries.Count) { return index + 1; } return -1; } /// <summary> /// Sets the iterator to refer to the last boundary position before the /// specified position. /// </summary> /// <param name="offset">The position to begin searching for a break from.</param> /// <returns>The position of the last boundary before the starting position.</returns> public override int Preceding(int offset) { CheckOffset(offset); if (boundaries.Count == 0) { return DONE; } int preceeding = GetHighestIndexLessThan(offset); if (preceeding == -1) { currentBoundaryIndex = 0; return DONE; } else { currentBoundaryIndex = preceeding; } return ReturnCurrent(); } private int GetHighestIndexLessThan(int offset) { int index = boundaries.BinarySearch(offset); if (index < 0) { return ~index - 1; } else { // NOTE: This is intentionally allowed to return -1 in the case // where index == 0. This state indicates we are before the first boundary. return index - 1; } } /// <summary> /// Returns the current iteration position. /// </summary> public override int Current { get { return ReturnCurrent(); } } /// <summary> /// Gets the text being analyzed. /// </summary> public override string Text { get { return text; } } /// <summary> /// Set the iterator to analyze a new piece of text. This function resets /// the current iteration position to the beginning of the text. /// </summary> /// <param name="newText">The text to analyze.</param> public override void SetText(string newText) { text = newText; currentBoundaryIndex = 0; m_start = 0; m_end = newText.Length; LoadBoundaries(m_start, m_end); } public override void SetText(CharacterIterator newText) { text = newText.GetTextAsString(); currentBoundaryIndex = 0; m_start = newText.BeginIndex; m_end = newText.EndIndex; LoadBoundaries(m_start, m_end); } private void LoadBoundaries(int start, int end) { IEnumerable<Icu.Boundary> icuBoundaries; string offsetText = text.Substring(start, end - start); #if !NETSTANDARD try { #endif if (type == Icu.BreakIterator.UBreakIteratorType.WORD) { if (enableHacks) { // LUCENENET TODO: HACK - replacing hyphen with "a" so hyphenated words aren't broken offsetText = offsetText.Replace("-", "a"); } icuBoundaries = Icu.BreakIterator.GetWordBoundaries(locale, offsetText, true); } else { if (enableHacks && type == Icu.BreakIterator.UBreakIteratorType.SENTENCE) { // LUCENENET TODO: HACK - newline character causes incorrect sentence breaking. offsetText = offsetText.Replace("\n", " "); // LUCENENET TODO: HACK - the ICU sentence logic doesn't work (in English anyway) when sentences don't // begin with capital letters. offsetText = CapitalizeFirst(offsetText); } icuBoundaries = Icu.BreakIterator.GetBoundaries(type, locale, offsetText); } #if !NETSTANDARD } catch (AccessViolationException ace) { // LUCENENET TODO: Find a reliable way to reproduce and report the // AccessViolationException that happens here to the icu-dotnet project team throw new Exception("Hit AccessViolationException: " + ace.ToString(), ace); } #endif boundaries = icuBoundaries .Select(t => new[] { t.Start + start, t.End + start }) .SelectMany(b => b) .Distinct() .ToList(); } /// <summary> /// Returns true if the specified character offset is a text boundary. /// </summary> /// <param name="offset">the character offset to check.</param> /// <returns><c>true</c> if "offset" is a boundary position, <c>false</c> otherwise.</returns> public override bool IsBoundary(int offset) { CheckOffset(offset); return boundaries.Contains(offset); } private int ReturnCurrent() { if (boundaries.Count > 0) { return currentBoundaryIndex < boundaries.Count && currentBoundaryIndex > -1 ? boundaries[currentBoundaryIndex] : DONE; } // If there are no boundaries, we must return the start offset return m_start; } /// <summary> /// LUCENENET TODO: This is a temporary workaround for an issue with icu-dotnet /// where it doesn't correctly break sentences unless they begin with a capital letter. /// If/when ICU is fixed, this method should be deleted and the IcuBreakIterator /// code changed to remove calls to this method. /// </summary> public static string CapitalizeFirst(string s) { bool isNewSentence = true; var result = new StringBuilder(s.Length); for (int i = 0; i < s.Length; i++) { if (isNewSentence && char.IsLetter(s[i])) { result.Append(char.ToUpper(s[i])); isNewSentence = false; } else result.Append(s[i]); if (s[i] == '!' || s[i] == '?' || s[i] == '.') { isNewSentence = true; } } return result.ToString(); } } } #endif
34.192893
126
0.533328
[ "Apache-2.0" ]
b9chris/lucenenet
src/dotnet/Lucene.Net.ICU/Support/IcuBreakIterator.cs
13,474
C#
namespace Microsoft.Azure.PowerShell.Cmdlets.Databricks.Models.Api20180401 { using static Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Extensions; /// <summary>The workspace provider authorization.</summary> public partial class WorkspaceProviderAuthorization { /// <summary> /// <c>AfterFromJson</c> will be called after the json deserialization has finished, allowing customization of the object /// before it is returned. Implement this method in a partial class to enable this behavior /// </summary> /// <param name="json">The JsonNode that should be deserialized into this object.</param> partial void AfterFromJson(Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject json); /// <summary> /// <c>AfterToJson</c> will be called after the json erialization has finished, allowing customization of the <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject" /// /> before it is returned. Implement this method in a partial class to enable this behavior /// </summary> /// <param name="container">The JSON container that the serialization result will be placed in.</param> partial void AfterToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject container); /// <summary> /// <c>BeforeFromJson</c> will be called before the json deserialization has commenced, allowing complete customization of /// the object before it is deserialized. /// If you wish to disable the default deserialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter. /// Implement this method in a partial class to enable this behavior. /// </summary> /// <param name="json">The JsonNode that should be deserialized into this object.</param> /// <param name="returnNow">Determines if the rest of the deserialization should be processed, or if the method should return /// instantly.</param> partial void BeforeFromJson(Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject json, ref bool returnNow); /// <summary> /// <c>BeforeToJson</c> will be called before the json serialization has commenced, allowing complete customization of the /// object before it is serialized. /// If you wish to disable the default serialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter. /// Implement this method in a partial class to enable this behavior. /// </summary> /// <param name="container">The JSON container that the serialization result will be placed in.</param> /// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return /// instantly.</param> partial void BeforeToJson(ref Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject container, ref bool returnNow); /// <summary> /// Deserializes a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode"/> into an instance of Microsoft.Azure.PowerShell.Cmdlets.Databricks.Models.Api20180401.IWorkspaceProviderAuthorization. /// </summary> /// <param name="node">a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode" /> to deserialize from.</param> /// <returns> /// an instance of Microsoft.Azure.PowerShell.Cmdlets.Databricks.Models.Api20180401.IWorkspaceProviderAuthorization. /// </returns> public static Microsoft.Azure.PowerShell.Cmdlets.Databricks.Models.Api20180401.IWorkspaceProviderAuthorization FromJson(Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode node) { return node is Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject json ? new WorkspaceProviderAuthorization(json) : null; } /// <summary> /// Serializes this instance of <see cref="WorkspaceProviderAuthorization" /> into a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode" />. /// </summary> /// <param name="container">The <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject"/> container to serialize this object into. If the caller /// passes in <c>null</c>, a new instance will be created and returned to the caller.</param> /// <param name="serializationMode">Allows the caller to choose the depth of the serialization. See <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.SerializationMode"/>.</param> /// <returns> /// a serialized instance of <see cref="WorkspaceProviderAuthorization" /> as a <see cref="Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode" />. /// </returns> public Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode ToJson(Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject container, Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.SerializationMode serializationMode) { container = container ?? new Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject(); bool returnNow = false; BeforeToJson(ref container, ref returnNow); if (returnNow) { return container; } AddIf( null != (((object)this._principalId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonString(this._principalId.ToString()) : null, "principalId" ,container.Add ); AddIf( null != (((object)this._roleDefinitionId)?.ToString()) ? (Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonNode) new Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonString(this._roleDefinitionId.ToString()) : null, "roleDefinitionId" ,container.Add ); AfterToJson(ref container); return container; } /// <summary> /// Deserializes a Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject into a new instance of <see cref="WorkspaceProviderAuthorization" />. /// </summary> /// <param name="json">A Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject instance to deserialize from.</param> internal WorkspaceProviderAuthorization(Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonObject json) { bool returnNow = false; BeforeFromJson(json, ref returnNow); if (returnNow) { return; } {_principalId = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonString>("principalId"), out var __jsonPrincipalId) ? (string)__jsonPrincipalId : (string)PrincipalId;} {_roleDefinitionId = If( json?.PropertyT<Microsoft.Azure.PowerShell.Cmdlets.Databricks.Runtime.Json.JsonString>("roleDefinitionId"), out var __jsonRoleDefinitionId) ? (string)__jsonRoleDefinitionId : (string)RoleDefinitionId;} AfterFromJson(json); } } }
72.058252
300
0.696174
[ "MIT" ]
3quanfeng/azure-powershell
src/Databricks/generated/api/Models/Api20180401/WorkspaceProviderAuthorization.json.cs
7,320
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. using Microsoft.DotNet.DarcLib.Helpers; using Microsoft.DotNet.Maestro.Client.Models; using Microsoft.Extensions.Logging; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Threading.Tasks; namespace Microsoft.DotNet.DarcLib { public enum NodeDiff { /// <summary> /// No node diff done /// </summary> None, /// <summary> /// Diff each node from the latest build of each repo in the graph. /// The latest build of all nodes is chosen. /// </summary> LatestInGraph, /// <summary> /// Diff each node from the latest build in the channel that the node's /// build was applied to. /// /// Generally this will give good results, though results may be confusing if some /// nodes in the graph came from builds applied to different channel. /// </summary> LatestInChannel, } public class DependencyGraphBuildOptions { /// <summary> /// Include toolset dependencies in the build. /// </summary> public bool IncludeToolset { get; set; } /// <summary> /// Lookup build information for each node. Only valid for remote builds. /// </summary> public bool LookupBuilds { get; set; } /// <summary> /// Determine which dependencies are missing builds /// </summary> public bool ComputeMissingBuilds { get; set; } /// <summary> /// Type of node diff to perform. Local build only supports 'None' /// </summary> public NodeDiff NodeDiff { get; set; } = NodeDiff.None; /// <summary> /// If true, cycles are computed as part of the graph build /// if cycles are encountered, and the Cycles member of DependencyGraph /// will be non-empty /// </summary> public bool ComputeCyclePaths { get; set; } = false; /// <summary> /// Location of git executable for use if any git commands need to be run. /// </summary> public string GitExecutable { get; set; } = "git"; } public class DependencyGraph { private static Dictionary<string, string> _remotesMapping = null; public DependencyGraph( DependencyGraphNode root, IEnumerable<DependencyDetail> uniqueDependencies, IEnumerable<DependencyDetail> incoherentDependencies, IEnumerable<DependencyGraphNode> allNodes, IEnumerable<DependencyGraphNode> incoherentNodes, IEnumerable<Build> contributingBuilds, IEnumerable<IEnumerable<DependencyGraphNode>> cycles) { Root = root; UniqueDependencies = uniqueDependencies; Nodes = allNodes; IncoherentNodes = incoherentNodes; IncoherentDependencies = incoherentDependencies; ContributingBuilds = contributingBuilds; Cycles = cycles; } public DependencyGraphNode Root { get; set; } public IEnumerable<DependencyDetail> UniqueDependencies { get; set; } /// <summary> /// Incoherent dependencies in the graph. /// This is the list of dependencies that have the same name but different versions. /// This list could contain more incoherencies than the other incoherent nodes list, /// if multiple builds were done of the same sha in a repo. /// </summary> public IEnumerable<DependencyDetail> IncoherentDependencies { get; set; } /// <summary> /// All nodes in the graph (unique repo+sha combinations) /// </summary> public IEnumerable<DependencyGraphNode> Nodes { get; set; } /// <summary> /// Incoherent nodes in the graph. /// Incoherencies are cases where the same repository appears multiple times in the graph /// at different commits. For instance, if two different versions of core-setup appear in the graph, /// these are incoherent nodes. /// </summary> public IEnumerable<DependencyGraphNode> IncoherentNodes { get; set; } /// <summary> /// Builds that contributed dependencies to the graph. /// </summary> public IEnumerable<Build> ContributingBuilds { get; set; } /// <summary> /// A list of cycles. Each cycle is represented as a list of nodes /// in the cycle. The "topmost" node (closest to root of the graph) is the first node. /// </summary> public IEnumerable<IEnumerable<DependencyGraphNode>> Cycles { get; set; } /// <summary> /// Builds a dependency graph given a root repo and commit using remotes. /// </summary> /// <param name="remoteFactory">Factory that can create remotes based on repo uris</param> /// <param name="repoUri">Root repository URI</param> /// <param name="commit">Root commit</param> /// <param name="options">Graph build options.</param> /// <param name="logger">Logger</param> /// <returns>New dependency graph.</returns> public static async Task<DependencyGraph> BuildRemoteDependencyGraphAsync( IRemoteFactory remoteFactory, string repoUri, string commit, DependencyGraphBuildOptions options, ILogger logger) { return await BuildDependencyGraphImplAsync( remoteFactory, null, /* no initial root dependencies */ repoUri, commit, options, true, logger, null, null, null); } /// <summary> /// Builds a dependency graph given a root repo and commit. /// </summary> /// <param name="remoteFactory">Factory that can create remotes based on repo uris</param> /// <param name="rootDependencies">Root set of dependencies</param> /// <param name="repoUri">Root repository URI</param> /// <param name="commit">Root commit</param> /// <param name="options">Graph build options.</param> /// <param name="logger">Logger</param> /// <returns>New dependency graph.</returns> public static async Task<DependencyGraph> BuildRemoteDependencyGraphAsync( IRemoteFactory remoteFactory, IEnumerable<DependencyDetail> rootDependencies, string repoUri, string commit, DependencyGraphBuildOptions options, ILogger logger) { return await BuildDependencyGraphImplAsync( remoteFactory, rootDependencies, repoUri, commit, options, true, logger, null, null, null); } /// <summary> /// Builds a dependency graph using only local resources /// </summary> /// <param name="remoteFactory">Factory that can create remotes based on repo uris</param> /// <param name="rootDependencies">Root set of dependencies</param> /// <param name="rootRepoFolder">Root repository folder</param> /// <param name="rootRepoCommit">Root commit</param> /// <param name="options">Graph build options</param> /// <param name="logger">Logger</param> /// <param name="testPath">If running unit tests, commits will be looked up as folders under this path</param> /// <param name="remotesMap">Map of remote uris to local paths</param> /// <param name="reposFolder">Folder containing local repositories.</param> /// <returns>New dependency graph.</returns> public static async Task<DependencyGraph> BuildLocalDependencyGraphAsync( IEnumerable<DependencyDetail> rootDependencies, DependencyGraphBuildOptions options, ILogger logger, string rootRepoFolder, string rootRepoCommit, string reposFolder, IEnumerable<string> remotesMap, string testPath = null) { return await BuildDependencyGraphImplAsync( null, rootDependencies, rootRepoFolder, rootRepoCommit, options, false, logger, reposFolder, remotesMap, testPath); } /// <summary> /// Validate that the graph build options are correct. /// </summary> /// <param name="remoteFactory"></param> /// <param name="rootDependencies"></param> /// <param name="repoUri"></param> /// <param name="commit"></param> /// <param name="options"></param> /// <param name="remote"></param> /// <param name="logger"></param> /// <param name="reposFolder"></param> /// <param name="remotesMap"></param> /// <param name="testPath"></param> private static void ValidateBuildOptions( IRemoteFactory remoteFactory, IEnumerable<DependencyDetail> rootDependencies, string repoUri, string commit, DependencyGraphBuildOptions options, bool remote, ILogger logger, string reposFolder, IEnumerable<string> remotesMap, string testPath) { // Fail fast if darcSettings is null in a remote scenario if (remote && remoteFactory == null) { throw new DarcException("Remote graph build requires a remote factory."); } if (rootDependencies != null && !rootDependencies.Any()) { throw new DarcException("Root dependencies were not supplied."); } if (!remote) { if (options.LookupBuilds) { throw new DarcException("Build lookup only available in remote build mode."); } if (options.NodeDiff != NodeDiff.None) { throw new DarcException($"Node diff type '{options.NodeDiff}' only available in remote build mode."); } } else { if (options.NodeDiff != NodeDiff.None && !options.LookupBuilds) { throw new DarcException("Node diff requires build lookup."); } } } private static async Task DoLatestInChannelGraphNodeDiffAsync( IRemoteFactory remoteFactory, ILogger logger, Dictionary<string, DependencyGraphNode> nodeCache, Dictionary<string, DependencyGraphNode> visitedRepoUriNodes) { logger.LogInformation("Running latest in channel node diff."); IRemote barOnlyRemote = await remoteFactory.GetBarOnlyRemoteAsync(logger); // Walk each node in the graph and diff against the latest build in the channel // that was also applied to the node. Dictionary<string, string> latestCommitCache = new Dictionary<string, string>(); foreach (DependencyGraphNode node in nodeCache.Values) { // Start with an unknown diff. node.DiffFrom = GitDiff.UnknownDiff(); if (node.ContributingBuilds.Any()) { // Choose latest build of node that has a channel. Build newestBuildWithChannel = node.ContributingBuilds.OrderByDescending(b => b.DateProduced).FirstOrDefault( b => b.Channels != null && b.Channels.Any()); // If no build was found (e.g. build was flowed without a channel or channel was removed from // a build, then no diff from latest. if (newestBuildWithChannel != null) { int channelId = newestBuildWithChannel.Channels.First().Id; // Just choose the first channel. This algorithm is mostly just heuristic. string latestCommitKey = $"{node.Repository}@{channelId}"; string latestCommit = null; if (!latestCommitCache.TryGetValue(latestCommitKey, out latestCommit)) { // Look up latest build in the channel var latestBuild = await barOnlyRemote.GetLatestBuildAsync(node.Repository, channelId); // Could be null, if the only build was removed from the channel if (latestBuild != null) { latestCommit = latestBuild.Commit; } // Add to cache latestCommitCache.Add(latestCommitKey, latestCommit); } // Perform diff if there is a latest commit. if (!string.IsNullOrEmpty(latestCommit)) { IRemote repoRemote = await remoteFactory.GetRemoteAsync(node.Repository, logger); // This will return a no-diff if latestCommit == node.Commit node.DiffFrom = await repoRemote.GitDiffAsync(node.Repository, latestCommit, node.Commit); } } } } } /// <summary> /// Diff each node in the graph against the latest build in /// the graph. /// </summary> /// <param name="remoteFactory"></param> /// <param name="logger"></param> /// <param name="nodeCache"></param> /// <param name="visitedRepoUriNodes"></param> /// <returns></returns> private static async Task DoLatestInGraphNodeDiffAsync( IRemoteFactory remoteFactory, ILogger logger, Dictionary<string, DependencyGraphNode> nodeCache, Dictionary<string, DependencyGraphNode> visitedRepoUriNodes) { logger.LogInformation("Running latest in graph node diff."); // Find the build of each repo in the graph, then // get the diff info from the latest foreach (string repo in visitedRepoUriNodes.Keys) { // Get all nodes with this value List<DependencyGraphNode> nodes = nodeCache.Values.Where(n => n.Repository == repo).ToList(); // If only one, determine latest if (nodes.Count > 1) { // Find latest DependencyGraphNode newestNode = null; Build newestBuild = null; foreach (DependencyGraphNode node in nodes) { if (newestNode == null) { newestNode = node; if (newestNode.ContributingBuilds.Any()) { newestBuild = newestNode.ContributingBuilds.OrderByDescending(b => b.DateProduced).First(); } } else if (node.ContributingBuilds.Any(b => b.DateProduced > newestBuild?.DateProduced)) { newestNode = node; newestBuild = newestNode.ContributingBuilds.OrderByDescending(b => b.DateProduced).First(); } } // Compare all other nodes to the latest foreach (DependencyGraphNode node in nodes) { IRemote repoRemote = await remoteFactory.GetRemoteAsync(node.Repository, logger); // If node == newestNode, returns no diff. node.DiffFrom = await repoRemote.GitDiffAsync(node.Repository, newestNode.Commit, node.Commit); } } else { DependencyGraphNode singleNode = nodes.Single(); singleNode.DiffFrom = GitDiff.NoDiff(singleNode.Commit); } } } /// <summary> /// Creates a new dependency graph /// </summary> /// <param name="remoteFactory">Remote for factory for obtaining remotes to</param> /// <param name="rootDependencies">Root set of dependencies. If null, then repoUri and commit should be set</param> /// <param name="repoUri">Root repository uri. Must be valid if no root dependencies are passed.</param> /// <param name="commit">Root commit. Must be valid if no root dependencies were passed.</param> /// <param name="includeToolset">If true, toolset dependencies are included.</param> /// <param name="lookupBuilds">If true, the builds contributing to each node are looked up. Must be a remote build.</param> /// <param name="remote">If true, remote graph build is used.</param> /// <param name="logger">Logger</param> /// <param name="reposFolder">Path to repos</param> /// <param name="remotesMap">Map of remotes (e.g. https://github.com/dotnet/corefx) to folders</param> /// <param name="testPath">If running unit tests, commits will be looked up as folders under this path</param> /// <returns>New dependency graph</returns> private static async Task<DependencyGraph> BuildDependencyGraphImplAsync( IRemoteFactory remoteFactory, IEnumerable<DependencyDetail> rootDependencies, string repoUri, string commit, DependencyGraphBuildOptions options, bool remote, ILogger logger, string reposFolder, IEnumerable<string> remotesMap, string testPath) { List<DependencyDetail> rootDependencyList = rootDependencies?.ToList(); List<string> remotesList = remotesMap?.ToList(); ValidateBuildOptions(remoteFactory, rootDependencyList, repoUri, commit, options, remote, logger, reposFolder, remotesList, testPath); if (rootDependencies != null) { logger.LogInformation($"Starting build of graph from {rootDependencyList.Count} root dependencies " + $"({repoUri}@{commit})"); foreach (DependencyDetail dependency in rootDependencyList) { logger.LogInformation($" {dependency.Name}@{dependency.Version}"); } } else { logger.LogInformation($"Starting build of graph from ({repoUri}@{commit})"); } IRemote barOnlyRemote = null; if (remote) { // Look up the dependency and get the creating build. barOnlyRemote = await remoteFactory.GetBarOnlyRemoteAsync(logger); } List<LinkedList<DependencyGraphNode>> cycles = new List<LinkedList<DependencyGraphNode>>(); Dictionary<string, List<Build>> buildLookups = null; if (options.LookupBuilds) { buildLookups = new Dictionary<string, List<Build>>(); // Look up the dependency and get the creating build. buildLookups.Add($"{repoUri}@{commit}", (await barOnlyRemote.GetBuildsAsync(repoUri, commit)).ToList()); } // Create the root node and add the repo to the visited bit vector. List<Build> allContributingBuilds = null; DependencyGraphNode rootGraphNode = new DependencyGraphNode(repoUri, commit, rootDependencyList, null); rootGraphNode.VisitedNodes.Add(repoUri); // Nodes to visit is a queue, so that the evaluation order // of the graph is breadth first. Queue<DependencyGraphNode> nodesToVisit = new Queue<DependencyGraphNode>(); nodesToVisit.Enqueue(rootGraphNode); HashSet<DependencyDetail> uniqueDependencyDetails; if (rootGraphNode.Dependencies != null) { uniqueDependencyDetails = new HashSet<DependencyDetail>( rootGraphNode.Dependencies, new DependencyDetailComparer()); } else { uniqueDependencyDetails = new HashSet<DependencyDetail>( new DependencyDetailComparer()); } // Cache of nodes we've visited. If we reach a repo/commit combo already in the cache, // we can just add these nodes as a child. The cache key is '{repoUri}@{commit}' Dictionary<string, DependencyGraphNode> nodeCache = new Dictionary<string, DependencyGraphNode>(); nodeCache.Add($"{rootGraphNode.Repository}@{rootGraphNode.Commit}", rootGraphNode); // Cache of incoherent nodes, looked up by repo URI. Dictionary<string, DependencyGraphNode> visitedRepoUriNodes = new Dictionary<string, DependencyGraphNode>(); HashSet<DependencyGraphNode> incoherentNodes = new HashSet<DependencyGraphNode>(); // Cache of incoherent dependencies, looked up by name Dictionary<string, DependencyDetail> incoherentDependenciesCache = new Dictionary<string, DependencyDetail>(); HashSet<DependencyDetail> incoherentDependencies = new HashSet<DependencyDetail>(new LooseDependencyDetailComparer()); while (nodesToVisit.Count > 0) { DependencyGraphNode node = nodesToVisit.Dequeue(); logger.LogInformation($"Visiting {node.Repository}@{node.Commit}"); List<DependencyDetail> dependencies; // In case of the root node which is initially put on the stack, // we already have the set of dependencies to start at (this may have been // filtered by the caller). So no need to get the dependencies again. if (node.Dependencies != null) { dependencies = node.Dependencies; } else { logger.LogInformation($"Getting dependencies at {node.Repository}@{node.Commit}"); dependencies = (await GetDependenciesAsync( remoteFactory, remote, logger, options.GitExecutable, node.Repository, node.Commit, options.IncludeToolset, remotesList, reposFolder, testPath))?.ToList(); // Set the dependencies on the current node. node.Dependencies = dependencies; } if (dependencies != null) { foreach (DependencyDetail dependency in dependencies) { // If this dependency is missing information, then skip it. if (string.IsNullOrEmpty(dependency.RepoUri) || string.IsNullOrEmpty(dependency.Commit)) { logger.LogInformation($"Dependency {dependency.Name}@{dependency.Version} in " + $"{node.Repository}@{node.Commit} " + $"is missing repository uri or commit information, skipping"); continue; } if (options.LookupBuilds) { if (!buildLookups.ContainsKey($"{dependency.RepoUri}@{dependency.Commit}")) { buildLookups.Add($"{dependency.RepoUri}@{dependency.Commit}", (await barOnlyRemote.GetBuildsAsync(dependency.RepoUri, dependency.Commit)) .ToList()); } } // If the dependency's repo uri has been traversed, we've reached a cycle in this subgraph // and should break. if (node.VisitedNodes.Contains(dependency.RepoUri)) { logger.LogInformation($"Node {node.Repository}@{node.Commit} " + $"introduces a cycle to {dependency.RepoUri}, skipping"); if (options.ComputeCyclePaths) { var newCycles = ComputeCyclePaths(node, dependency.RepoUri); cycles.AddRange(newCycles); } continue; } // Add the individual dependency to the set of unique dependencies seen // in the whole graph. uniqueDependencyDetails.Add(dependency); if (incoherentDependenciesCache.TryGetValue(dependency.Name, out DependencyDetail existingDependency)) { incoherentDependencies.Add(existingDependency); incoherentDependencies.Add(dependency); } else { incoherentDependenciesCache.Add(dependency.Name, dependency); } // We may have visited this node before. If so, add it as a child and avoid additional walks. // Update the list of contributing builds. if (nodeCache.TryGetValue($"{dependency.RepoUri}@{dependency.Commit}", out DependencyGraphNode existingNode)) { logger.LogInformation( $"Node {dependency.RepoUri}@{dependency.Commit} has already been created, adding as child"); node.AddChild(existingNode, dependency); continue; } // Otherwise, create a new node for this dependency. DependencyGraphNode newNode = new DependencyGraphNode( dependency.RepoUri, dependency.Commit, null, node.VisitedNodes, null); // Cache the dependency and add it to the visitation stack. nodeCache.Add($"{dependency.RepoUri}@{dependency.Commit}", newNode); nodesToVisit.Enqueue(newNode); newNode.VisitedNodes.Add(dependency.RepoUri); node.AddChild(newNode, dependency); // Calculate incoherencies. If we've not yet visited the repo uri, add the // new node based on its repo uri. Otherwise, add both the new node and the visited // node to the incoherent nodes. if (visitedRepoUriNodes.TryGetValue(dependency.RepoUri, out DependencyGraphNode visitedNode)) { incoherentNodes.Add(visitedNode); incoherentNodes.Add(newNode); } else { visitedRepoUriNodes.Add(newNode.Repository, newNode); } } } } if (options.LookupBuilds) { allContributingBuilds = ComputeContributingBuilds( buildLookups, nodeCache.Values, logger); } switch (options.NodeDiff) { case NodeDiff.None: // Nothing break; case NodeDiff.LatestInGraph: await DoLatestInGraphNodeDiffAsync(remoteFactory, logger, nodeCache, visitedRepoUriNodes); break; case NodeDiff.LatestInChannel: await DoLatestInChannelGraphNodeDiffAsync(remoteFactory, logger, nodeCache, visitedRepoUriNodes); break; } return new DependencyGraph(rootGraphNode, uniqueDependencyDetails, incoherentDependencies, nodeCache.Values, incoherentNodes, allContributingBuilds, cycles); } /// <summary> /// Compute which builds contribute to each node in the graph, as well as the overall graph /// </summary> /// <param name="buildLookups">Set of tasks that are looking up builds</param> /// <param name="allNodes">All nodes in the graph</param> /// <param name="logger">Logger</param> /// <returns></returns> private static List<Build> ComputeContributingBuilds( Dictionary<string, List<Build>> buildLookups, IEnumerable<DependencyGraphNode> allNodes, ILogger logger) { logger.LogInformation("Computing contributing builds"); List<Build> allContributingBuilds = new List<Build>(); foreach (DependencyGraphNode node in allNodes) { node.ContributingBuilds = new HashSet<Build>(new BuildComparer()); IEnumerable<Build> potentiallyContributingBuilds = buildLookups[$"{node.Repository}@{node.Commit}"]; // Filter down. The parent nodes of this node may have specific dependency versions that narrow down // which potential builds this could be. For instance, if sha A was built twice, producing asset B.1 and B.2, // we wouldn't know which by a simple query. But we can narrow the potential // builds by any of those that produced assets that match any parent's dependency name+version foreach (Build potentialContributingBuild in potentiallyContributingBuilds) { if (BuildContributesToNode(node, potentialContributingBuild)) { allContributingBuilds.Add(potentialContributingBuild); node.ContributingBuilds.Add(potentialContributingBuild); } } } logger.LogInformation("Done computing contributing builds"); return allContributingBuilds; } /// <summary> /// Determines whether a build contributes to a given node by looking at the parents' /// input dependencies. If there are no parents, then we assume that the build could contribute. This /// would happen for the root node. /// </summary> /// <param name="node">Node</param> /// <param name="potentialContributingBuild">Potentially contributing build</param> /// <returns>True if the build contributes, false otherwise.</returns> private static bool BuildContributesToNode(DependencyGraphNode node, Build potentialContributingBuild) { if (!node.Parents.Any()) { return true; } AssetComparer assetEqualityComparer = new AssetComparer(); foreach (DependencyGraphNode parentNode in node.Parents) { foreach (var dependency in parentNode.Dependencies) { if (dependency.Commit == node.Commit && dependency.RepoUri == node.Repository && potentialContributingBuild.Assets.Any(a => assetEqualityComparer.Equals(a, dependency))) { return true; } } } return false; } /// <summary> /// Given that the <paramref name="currentNode"/> introduces one or more cycles to <paramref name="repoCycleRoot"/> /// compute the cycles that it introduces. /// </summary> /// <param name="currentNode">Current node</param> /// <param name="repoCycleRoot">Repo uri of dependency introducing cycle</param> /// <returns>List of cycles</returns> /// <remarks></remarks> private static List<LinkedList<DependencyGraphNode>> ComputeCyclePaths( DependencyGraphNode currentNode, string repoCycleRoot) { List<LinkedList<DependencyGraphNode>> allCyclesRootedAtNode = new List<LinkedList<DependencyGraphNode>>(); // Find all parents who have a path to the root node. This set might also // be the root node, since the root node has itself marked in VisitedNodes. // After reaching the root along all paths, this set will be empty var parentsInCycles = currentNode.Parents.Where(p => p.VisitedNodes.Contains(repoCycleRoot)).ToList(); if (parentsInCycles.Any()) { // Recurse into each parent, combining the returned cycles together and // appending on the current node. foreach (DependencyGraphNode parent in parentsInCycles) { List<LinkedList<DependencyGraphNode>> cyclesRootedAtParentNode = ComputeCyclePaths(parent, repoCycleRoot); foreach (LinkedList<DependencyGraphNode> cycleRootedAtNode in cyclesRootedAtParentNode) { cycleRootedAtNode.AddLast(currentNode); allCyclesRootedAtNode.Add(cycleRootedAtNode); } } } else { // Create a segment containing just this node and return that var newCycleSegment = new LinkedList<DependencyGraphNode>(); allCyclesRootedAtNode.Add(newCycleSegment); newCycleSegment.AddFirst(currentNode); } return allCyclesRootedAtNode; } private static string GetRepoPath( string repoUri, string commit, IEnumerable<string> remotesMap, string reposFolder, ILogger logger, string gitExecutable) { string repoPath = null; if (remotesMap != null) { if (_remotesMapping == null) { _remotesMapping = CreateRemotesMapping(remotesMap); } if (!_remotesMapping.ContainsKey(repoPath)) { throw new DarcException($"A key matching '{repoUri}' was not " + $"found in the mapping. Please make sure to include it..."); } repoPath = _remotesMapping[repoPath]; } else { string folder = null; if (!string.IsNullOrEmpty(reposFolder)) { folder = reposFolder; } else { // If a repo folder or a mapping was not set we use the current parent's // parent folder. string parent = LocalHelpers.GetRootDir(gitExecutable, logger); folder = Directory.GetParent(parent).FullName; } repoPath = LocalHelpers.GetRepoPathFromFolder(gitExecutable, folder, commit, logger); if (string.IsNullOrEmpty(repoPath)) { throw new DarcException($"Commit '{commit}' was not found in any " + $"folder in '{folder}'. Make sure a folder for '{repoUri}' exists " + $"and it has all the latest changes..."); } } return repoPath; } private static async Task<IEnumerable<DependencyDetail>> GetDependenciesAsync( IRemoteFactory remoteFactory, bool remote, ILogger logger, string gitExecutable, string repoUri, string commit, bool includeToolset, IEnumerable<string> remotesMap, string reposFolder, string testPath = null) { try { IEnumerable<DependencyDetail> dependencies = null; if (!string.IsNullOrEmpty(testPath)) { testPath = Path.Combine( testPath, repoUri, commit); if (Directory.Exists(testPath)) { Local local = new Local(logger, testPath); dependencies = await local.GetDependenciesAsync(); } } else if (remote) { IRemote remoteClient = await remoteFactory.GetRemoteAsync(repoUri, logger); dependencies = await remoteClient.GetDependenciesAsync( repoUri, commit); } else { string repoPath = GetRepoPath(repoUri, commit, remotesMap, reposFolder, logger, gitExecutable); if (!string.IsNullOrEmpty(repoPath)) { Local local = new Local(logger); string fileContents = LocalHelpers.GitShow( gitExecutable, repoPath, commit, VersionFiles.VersionDetailsXml, logger); dependencies = local.GetDependenciesFromFileContents(fileContents); } } if (!includeToolset && dependencies != null) { dependencies = dependencies.Where(dependency => dependency.Type != DependencyType.Toolset); } return dependencies; } catch (GithubApplicationInstallationException gexc) { // This means the Maestro APP was not installed in the repo's org. Just keep going. logger.LogWarning($"Failed to retrieve dependency information from {repoUri}@{commit}. Error: {gexc.Message}"); return null; } catch (DependencyFileNotFoundException) { // This is not an error. Dependencies can be specified with explicit shas that // may not have eng/Version.Details.xml at that point. logger.LogWarning($"{repoUri}@{commit} does not have an eng/Version.Details.xml."); return null; } catch (Exception exc) { logger.LogError(exc, $"Something failed while trying the fetch the " + $"dependencies of repo '{repoUri}' at sha " + $"'{commit}'"); throw; } } private static Dictionary<string, string> CreateRemotesMapping(IEnumerable<string> remotesMap) { Dictionary<string, string> remotesMapping = new Dictionary<string, string>(); foreach (string remotes in remotesMap) { string[] keyValuePairs = remotes.Split(';'); foreach (string keyValue in keyValuePairs) { string[] kv = keyValue.Split(','); remotesMapping.Add(kv[0], kv[1]); } } return remotesMapping; } } public class LooseDependencyDetailComparer : IEqualityComparer<DependencyDetail> { public bool Equals(DependencyDetail x, DependencyDetail y) { return x.Commit == y.Commit && x.Name == y.Name && x.Version == y.Version; } public int GetHashCode(DependencyDetail obj) { return (obj.Commit, obj.Name, obj.Version).GetHashCode(); } } }
43.840168
131
0.532884
[ "MIT" ]
AlitzelMendez/arcade-services
src/Microsoft.DotNet.Darc/src/DarcLib/Models/Darc/DependencyGraph.cs
41,692
C#
// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System.Threading.Tasks; using Microsoft.Coyote.Actors; using Microsoft.Coyote.Actors.SharedObjects; using Xunit; using Xunit.Abstractions; namespace Microsoft.Coyote.Production.Tests.Actors.SharedObjects { public class SharedDictionaryTests : BaseProductionTest { public SharedDictionaryTests(ITestOutputHelper output) : base(output) { } private class E : Event { public SharedDictionary<int, string> Counter; public TaskCompletionSource<bool> Tcs; public E(SharedDictionary<int, string> counter, TaskCompletionSource<bool> tcs) { this.Counter = counter; this.Tcs = tcs; } } private class M1 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var tcs = (e as E).Tcs; this.CreateActor(typeof(N1), e); string v; while (counter.TryRemove(1, out v) == false) { } this.Assert(v == "N"); tcs.SetResult(true); } } private class N1 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var b = counter.TryAdd(1, "N"); this.Assert(b == true); } } private class M2 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { this.CreateActor(typeof(N2), e); } } private class N2 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var tcs = (e as E).Tcs; counter.TryAdd(1, "N"); // Key doesn't exist. _ = counter[2]; tcs.SetResult(true); } } private class M3 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var tcs = (e as E).Tcs; for (int i = 0; i < 100; i++) { counter.TryAdd(1, "M"); counter[1] = "M"; } var c = counter.Count; this.Assert(c == 1); tcs.SetResult(true); } } private class N3 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var tcs = (e as E).Tcs; for (int i = 0; i < 100; i++) { counter.TryAdd(1, "N"); counter[1] = "N"; } tcs.SetResult(true); } } private class M4 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { this.CreateActor(typeof(N4), e); } } private class N4 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var tcs = (e as E).Tcs; counter.TryAdd(1, "N"); var b = counter.TryGetValue(2, out string _); this.Assert(!b); b = counter.TryGetValue(1, out string v); this.Assert(b); this.Assert(v == "N"); tcs.SetResult(true); } } private class M5 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; this.CreateActor(typeof(N5), e); for (int i = 0; i <= 100000; i++) { counter[i] = i.ToString(); } } } private class N5 : StateMachine { [Start] [OnEntry(nameof(InitOnEntry))] private class Init : State { } private void InitOnEntry(Event e) { var counter = (e as E).Counter; var tcs = (e as E).Tcs; while (!counter.TryGetValue(100000, out _)) { } for (int i = 100000; i >= 0; i--) { var b = counter.TryGetValue(i, out string v); this.Assert(b && v == i.ToString()); } tcs.SetResult(true); } } [Fact(Timeout = 5000)] public void TestProductionSharedDictionary1() { var runtime = RuntimeFactory.Create(); var counter = SharedDictionary.Create<int, string>(runtime); var tcs1 = new TaskCompletionSource<bool>(); var failed = false; runtime.OnFailure += (ex) => { failed = true; tcs1.SetResult(true); }; var m1 = runtime.CreateActor(typeof(M1), new E(counter, tcs1)); Task.WaitAll(tcs1.Task); Assert.False(failed); } [Fact(Timeout = 5000)] public void TestProductionSharedDictionary2() { var runtime = RuntimeFactory.Create(); var counter = SharedDictionary.Create<int, string>(runtime); var tcs1 = new TaskCompletionSource<bool>(); var failed = false; runtime.OnFailure += (ex) => { failed = true; tcs1.SetResult(true); }; var m1 = runtime.CreateActor(typeof(M2), new E(counter, tcs1)); Task.WaitAll(tcs1.Task); Assert.True(failed); } [Fact(Timeout = 5000)] public void TestProductionSharedDictionary3() { var runtime = RuntimeFactory.Create(); var counter = SharedDictionary.Create<int, string>(runtime); var tcs1 = new TaskCompletionSource<bool>(); var tcs2 = new TaskCompletionSource<bool>(); var failed = false; runtime.OnFailure += (ex) => { failed = true; tcs1.SetResult(true); tcs2.SetResult(true); }; var m1 = runtime.CreateActor(typeof(M3), new E(counter, tcs1)); var m2 = runtime.CreateActor(typeof(N3), new E(counter, tcs2)); Task.WaitAll(tcs1.Task, tcs2.Task); Assert.False(failed); } [Fact(Timeout = 5000)] public void TestProductionSharedDictionary4() { var runtime = RuntimeFactory.Create(); var counter = SharedDictionary.Create<int, string>(runtime); var tcs1 = new TaskCompletionSource<bool>(); var failed = false; runtime.OnFailure += (ex) => { failed = true; tcs1.SetResult(true); }; var m1 = runtime.CreateActor(typeof(M4), new E(counter, tcs1)); Task.WaitAll(tcs1.Task); Assert.False(failed); } [Fact(Timeout = 5000)] public void TestProductionSharedDictionary5() { var runtime = RuntimeFactory.Create(); var counter = SharedDictionary.Create<int, string>(runtime); var tcs1 = new TaskCompletionSource<bool>(); var failed = false; runtime.OnFailure += (ex) => { failed = true; tcs1.SetResult(true); }; var m1 = runtime.CreateActor(typeof(M5), new E(counter, tcs1)); Task.WaitAll(tcs1.Task); Assert.False(failed); } } }
26.616715
91
0.446947
[ "MIT" ]
Bhaskers-Blu-Org2/coyote
Tests/Production.Tests/Actors/SharedObjects/SharedDictionaryTests.cs
9,238
C#
//auto generated, do not modify it //限制:命名不能以下划线结尾(可能冲突) //限制:map的key只支持基础类型和string;list/map不能optional,list/map不能嵌套 //兼容限制:字段只能添加,添加后不能删除,添加字段只能添加到最后,添加消息类型只能添加到最后 //兼容限制:不能修改字段类型(如从bool改为long) //兼容限制:消息类型(含msdId)不能作为其他消息的成员类型 using Geek.Server; using System.Collections.Generic; ///<summary></summary> namespace Geek.Server.Proto { public class Test3 : BaseMessage { static readonly NLog.Logger LOGGER = NLog.LogManager.GetCurrentClassLogger(); /*********************************************************/ public string UserId {get;set;} public string Platform {get;set;} public List<Geek.Server.Proto.Test1> List = new List<Geek.Server.Proto.Test1>(); public Dictionary<int, int> Map = new Dictionary<int, int>(); public Dictionary<int, Geek.Server.Proto.Test1> Map2 = new Dictionary<int, Geek.Server.Proto.Test1>(); public Dictionary<int, List<Test1>> Map3 = new Dictionary<int, List<Test1>>(); public Dictionary<int, HashSet<Test1>> Map4 = new Dictionary<int, HashSet<Test1>>(); public Dictionary<int, Dictionary<long, Geek.Server.Proto.Test1>> Map5 = new Dictionary<int, Dictionary<long, Geek.Server.Proto.Test1>>(); public Geek.Server.Proto.Test1 T1 {get;set;} public Geek.Server.Proto.Test1 T2 {get;set;} /*********************************************************/ public const int MsgID = SID; public override int Sid { get;} = 111103; public const int SID = 111103; public const bool IsState = false; public override T Create<T>(int sid) { return Geek.Server.Proto.SClassFactory.Create<T>(sid); } ///<summary>反序列化,读取数据</summary> public override int Read(byte[] _buffer_, int _offset_) { UniId = XBuffer.ReadInt(_buffer_, ref _offset_); _offset_ = base.Read(_buffer_, _offset_); //字段个数,最多支持255个 var _fieldNum_ = XBuffer.ReadByte(_buffer_, ref _offset_); do { if(_fieldNum_ > 0) { //UserId = SerializeTool.Read_string(false, _buffer_, ref _offset_); UserId = XBuffer.ReadString(_buffer_, ref _offset_); }else break; if(_fieldNum_ > 1) { //Platform = SerializeTool.Read_string(false, _buffer_, ref _offset_); Platform = XBuffer.ReadString(_buffer_, ref _offset_); }else break; if(_fieldNum_ > 2) { /*********************************************************/ int count2 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int i = 0; i < count2; ++i) { var sid = XBuffer.ReadInt(_buffer_, ref _offset_); if (sid <= 0) { List.Add(default); continue; } var val = Create<Geek.Server.Proto.Test1>(sid); _offset_ = val.Read(_buffer_, _offset_); List.Add(val); } /*********************************************************/ }else break; if(_fieldNum_ > 3) { /*********************************************************/ int count3 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int i = 0; i < count3; ++i) { var key = XBuffer.ReadInt(_buffer_, ref _offset_); var val = XBuffer.ReadInt(_buffer_, ref _offset_); Map.Add(key, val); } /*********************************************************/ }else break; if(_fieldNum_ > 4) { /*********************************************************/ //SerializeTool.Read_int_CustomMap<Geek.Server.Proto.Test1>(Map2, _buffer_, ref _offset_); int count4 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int i = 0; i < count4; ++i) { var key = XBuffer.ReadInt(_buffer_, ref _offset_); var sid = XBuffer.ReadInt(_buffer_, ref _offset_); if (sid <= 0) { Map2[key] = default; continue; } var val = Create<Geek.Server.Proto.Test1>(sid); _offset_ = val.Read(_buffer_, _offset_); Map2.Add(key, val); } /*********************************************************/ }else break; if(_fieldNum_ > 5) { /*********************************************************/ int count5 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int i = 0; i < count5; ++i) { var key = XBuffer.ReadInt(_buffer_, ref _offset_); var val = new List<Test1>(); //TODO:类型处理 int count52 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int j = 0; j < count52; ++j) { var sid = XBuffer.ReadInt(_buffer_, ref _offset_); if (sid <= 0) { val.Add(default); continue; } var val2 = Create<Test1>(sid); _offset_ = val2.Read(_buffer_, _offset_); val.Add(val2); } Map3.Add(key, val); } /*********************************************************/ }else break; if(_fieldNum_ > 6) { /*********************************************************/ int count6 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int i = 0; i < count6; ++i) { var key = XBuffer.ReadInt(_buffer_, ref _offset_); var val = new HashSet<Test1>(); //TODO:类型处理 int count62 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int j = 0; j < count62; ++j) { var sid = XBuffer.ReadInt(_buffer_, ref _offset_); if (sid <= 0) { val.Add(default); continue; } var val2 = Create<Test1>(sid); _offset_ = val2.Read(_buffer_, _offset_); val.Add(val2); } Map4.Add(key, val); } /*********************************************************/ }else break; if(_fieldNum_ > 7) { /*********************************************************/ //SerializeTool.Read_int_long_NestCustomMap<Geek.Server.Proto.Test1>(Map5, _buffer_, ref _offset_); int count7 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int i = 0; i < count7; ++i) { var key = XBuffer.ReadInt(_buffer_, ref _offset_); var val = new Dictionary<long, Geek.Server.Proto.Test1>(); //TODO:类型处理 //ReadCustomMap(val, buffer, ref offset); int count72 = XBuffer.ReadInt(_buffer_, ref _offset_); for (int j = 0; j < count72; ++j) { var key2 = XBuffer.ReadLong(_buffer_, ref _offset_); var sid = XBuffer.ReadInt(_buffer_, ref _offset_); if (sid <= 0) { val[key2] = default; continue; } var val2 = Create<Geek.Server.Proto.Test1>(sid); _offset_ = val2.Read(_buffer_, _offset_); val.Add(key2, val2); } Map5.Add(key, val); } /*********************************************************/ }else break; if(_fieldNum_ > 8) { T1 = ReadCustom<Geek.Server.Proto.Test1>(T1,true, _buffer_, ref _offset_); }else break; if(_fieldNum_ > 9) { T2 = ReadCustom<Geek.Server.Proto.Test1>(T2,true, _buffer_, ref _offset_); }else break; }while(false); return _offset_; } ///<summary>序列化,写入数据</summary> public override int Write(byte[] _buffer_, int _offset_) { XBuffer.WriteInt(UniId, _buffer_, ref _offset_); _offset_ = base.Write(_buffer_, _offset_); //写入字段数量,最多支持255个 XBuffer.WriteByte(10, _buffer_, ref _offset_); //写入数据 XBuffer.WriteString(UserId, _buffer_, ref _offset_); XBuffer.WriteString(Platform, _buffer_, ref _offset_); /*********************************************************/ XBuffer.WriteInt(List.Count, _buffer_, ref _offset_); for (int i=0; i<List.Count; i++) { if (List[i] == null) { LOGGER.Error("App.Proto.Test3.List has null item, idx == " + i); XBuffer.WriteInt(0, _buffer_, ref _offset_); } else { XBuffer.WriteInt(List[i].Sid, _buffer_, ref _offset_); _offset_ = List[i].Write(_buffer_, _offset_); } } /*********************************************************/ /*********************************************************/ //_offset_ = SerializeTool.WritePrimitiveMap(Map, _buffer_, ref _offset_); XBuffer.WriteInt(Map.Count, _buffer_, ref _offset_); foreach (var kv in Map) { XBuffer.WriteInt(kv.Key, _buffer_, ref _offset_); XBuffer.WriteInt(kv.Value, _buffer_, ref _offset_); } /*********************************************************/ /*********************************************************/ XBuffer.WriteInt(Map2.Count, _buffer_, ref _offset_); foreach (var kv in Map2) { XBuffer.WriteInt(kv.Key, _buffer_, ref _offset_); if (kv.Value == null) { LOGGER.Error($"{this.GetType().FullName}.Map2 has null item: {kv.Key}"); XBuffer.WriteInt(0, _buffer_, ref _offset_); } else { XBuffer.WriteInt(kv.Value.Sid, _buffer_, ref _offset_); _offset_ = kv.Value.Write(_buffer_, _offset_); } } /*********************************************************/ /*********************************************************/ XBuffer.WriteInt(Map3.Count, _buffer_, ref _offset_); foreach (var kv in Map3) { XBuffer.WriteInt(kv.Key, _buffer_, ref _offset_); XBuffer.WriteInt(kv.Value.Count, _buffer_, ref _offset_); foreach (var item in kv.Value) { if (item == null) { LOGGER.Error($"{this.GetType().FullName}.Map3.{kv.Key} has null item"); XBuffer.WriteInt(0, _buffer_, ref _offset_); } else { XBuffer.WriteInt(item.Sid, _buffer_, ref _offset_); _offset_ = item.Write(_buffer_, _offset_); } } } /*********************************************************/ /*********************************************************/ XBuffer.WriteInt(Map4.Count, _buffer_, ref _offset_); foreach (var kv in Map4) { XBuffer.WriteInt(kv.Key, _buffer_, ref _offset_); XBuffer.WriteInt(kv.Value.Count, _buffer_, ref _offset_); foreach (var item in kv.Value) { if (item == null) { LOGGER.Error($"{this.GetType().FullName}.Map4.{kv.Key} has null item"); XBuffer.WriteInt(0, _buffer_, ref _offset_); } else { XBuffer.WriteInt(item.Sid, _buffer_, ref _offset_); _offset_ = item.Write(_buffer_, _offset_); } } } /*********************************************************/ /*********************************************************/ //_offset_ = SerializeTool.WriteNestCustomMap(Map5, _buffer_, ref _offset_); XBuffer.WriteInt(Map5.Count, _buffer_, ref _offset_); foreach (var kv in Map5) { XBuffer.WriteInt(kv.Key, _buffer_, ref _offset_); XBuffer.WriteInt(kv.Value.Count, _buffer_, ref _offset_); foreach (var kv2 in kv.Value) { XBuffer.WriteLong(kv2.Key, _buffer_, ref _offset_); if (kv.Value == null) { LOGGER.Error($"{this.GetType().FullName}.Map5 has null item: {kv2.Key.ToString()}"); XBuffer.WriteInt(0, _buffer_, ref _offset_); } else { XBuffer.WriteInt(kv2.Value.Sid, _buffer_, ref _offset_); _offset_ = kv2.Value.Write(_buffer_, _offset_); } } } /*********************************************************/ _offset_ = WriteCustom<Geek.Server.Proto.Test1>(T1,true, _buffer_, ref _offset_); _offset_ = WriteCustom<Geek.Server.Proto.Test1>(T2,true, _buffer_, ref _offset_); return _offset_; } } }
25.787746
140
0.503946
[ "MIT" ]
leeveel/GeekProto
Geek.Generate/Proto/Test3.cs
12,135
C#
using System; using System.Collections.Generic; #nullable disable namespace DatabaseModels { public partial class Cat4 { public Cat4() { Cat34s = new HashSet<Cat34>(); } public int Cat4id { get; set; } public string Category4 { get; set; } public virtual ICollection<Cat34> Cat34s { get; set; } } }
17.904762
62
0.585106
[ "MIT" ]
06012021-dotnet-uta/GregoryAgnewP1
P1/Models/DatabaseModels/Cat4.cs
378
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 // // THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES // OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, // INCLUDING WITHOUT LIMITATION ANY IMPLIED WARRANTIES // OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR // PURPOSE, MERCHANTABILITY OR NON-INFRINGEMENT. // // See the Apache 2 License for the specific language // governing permissions and limitations under the License. // // ********************************************************* using System.Composition; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.Text; namespace Roslyn.Samples.CodeAction.CopyPasteWithUsing { [Export, Shared] internal class CopyDataService { private readonly object syncLock = new object(); private CopyData data; [ImportingConstructor] public CopyDataService() { this.data = null; #if false Workspace.PrimaryWorkspace.WorkspaceChanged += (sender, args) => { SaveData(null); }; #endif } public void SaveData(CopyData data) { lock (this.syncLock) { this.data = data; } } public CopyData Data { get { lock (this.syncLock) { return this.data; } } } } }
25.632353
76
0.551922
[ "Apache-2.0" ]
ElanHasson/roslyn
src/Samples/CSharp/CopyPasteWithUsing/CopyDataService.cs
1,746
C#
using System; using OpenQA.Selenium; using Xunit; namespace Algenic.FunctionalTests.Setup { public abstract class BaseFunctionalTest : IDisposable, IClassFixture<DriverFixture> { protected readonly IWebDriver _driver; protected readonly Uri _indexUrl; public BaseFunctionalTest(DriverFixture driverFixture) { _driver = driverFixture.WebDriver; _indexUrl = new Uri(driverFixture.IndexUrl); } public void Dispose() { _driver.Quit(); _driver.Dispose(); } } }
23.36
88
0.633562
[ "BSD-3-Clause" ]
marax27/Algenic
Algenic.FunctionalTests/Setup/BaseFunctionalTest.cs
586
C#
using OPSMBackend.DataEntities; using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; namespace OPSMBackend.Services.Other { public interface IOtherService { IEnumerable<Initials> GetInitials(); IEnumerable<Genders> GetGenders(); IEnumerable<FieldOptions> GetFieldOptions(); IEnumerable<RegistrationTypes> GetReferredByTypes(); void InsertInitial(Initials initial); void InserGenders(Genders gender); void UpdateInitial(Initials initial); void UpdateGender(Genders genders); void DeleteInitial(int id); void DeleteGender(int id); } }
29.217391
60
0.709821
[ "MIT" ]
shrungBhatt/PathologyLabServer
OPSMBackend/Services/Other/IOtherService.cs
674
C#
using System; using System.IO.Abstractions.TestingHelpers; using FluentAssertions; using NUnit.Framework; using Toscana.Exceptions; namespace Toscana.Tests { [TestFixture] public class ToscaFileSystemSaverTests { [Test] public void It_Is_Possible_To_Save_Service_Template_To_File() { var mockFileSystem = new MockFileSystem(); var serviceTemplateSaver = new ToscaFileSystemSaver<ToscaServiceTemplate>(mockFileSystem, DependencyResolver.GetToscaServiceTemplateSerializer()); var serviceTemplate = new ToscaServiceTemplate { ToscaDefinitionsVersion = "tosca_simple_yaml_1_0" }; serviceTemplateSaver.Save(@"c:\files\service_template.yml", serviceTemplate); mockFileSystem.FileExists(@"c:\files\service_template.yml").Should().BeTrue(); } [Test] public void Saving_Smaller_File_After_Reading_It_Works_Properly() { var mockFileSystem = new MockFileSystem(); mockFileSystem.AddDirectory(@"C:\Dir\SubDir"); var filePath = @"C:\Dir\SubDir\service_template.yml"; DependencyResolver.Current.Replace(mockFileSystem); var serviceTemplateSaver = DependencyResolver.GetToscaServiceTemplateSaver(); var serviceTemplateLoader = DependencyResolver.GetToscaServiceTemplateLoader(); #region Prepare a YAML file with some definitions var serviceTemplate = new ToscaServiceTemplate { ToscaDefinitionsVersion = "tosca_simple_yaml_1_0" }; var nodeType = new ToscaNodeType(); nodeType.Properties.Add("name", new ToscaProperty {Type = "string"}); nodeType.Properties.Add("age", new ToscaProperty {Type = "integer"}); nodeType.Properties.Add("gender", new ToscaProperty {Type = "boolean"}); serviceTemplate.NodeTypes.Add("tosca.nodes.Simple", nodeType); serviceTemplateSaver.Save(filePath, serviceTemplate); #endregion // Act var loadedServiceTemplate = serviceTemplateLoader.Load(filePath); loadedServiceTemplate.NodeTypes.Clear(); serviceTemplateSaver.Save(filePath, loadedServiceTemplate); Action action = () => serviceTemplateLoader.Load(filePath); action.ShouldNotThrow<ToscaBaseException>(); } } }
37.560606
101
0.655103
[ "Apache-2.0" ]
QualiSystems/Toscana
Toscana.Tests/ToscaFileSystemSaverTests.cs
2,481
C#
using Xamarin.Forms; namespace MonkeyHub { public partial class App : Application { public App() { InitializeComponent(); MainPage = new NavigationPage(new MonkeyHubPage()); } protected override void OnStart() { // Handle when your app starts } protected override void OnSleep() { // Handle when your app sleeps } protected override void OnResume() { // Handle when your app resumes } } }
14.566667
54
0.665904
[ "MIT" ]
miltoncamara/mokeyhub-app
MonkeyHub/App.xaml.cs
439
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; using Aliyun.Acs.Core.Http; using Aliyun.Acs.Core.Transform; using Aliyun.Acs.Core.Utils; using Aliyun.Acs.Smartag.Transform; using Aliyun.Acs.Smartag.Transform.V20180313; namespace Aliyun.Acs.Smartag.Model.V20180313 { public class DeleteQosPolicyRequest : RpcAcsRequest<DeleteQosPolicyResponse> { public DeleteQosPolicyRequest() : base("Smartag", "2018-03-13", "DeleteQosPolicy", "smartag", "openAPI") { if (this.GetType().GetProperty("ProductEndpointMap") != null && this.GetType().GetProperty("ProductEndpointType") != null) { this.GetType().GetProperty("ProductEndpointMap").SetValue(this, Endpoint.endpointMap, null); this.GetType().GetProperty("ProductEndpointType").SetValue(this, Endpoint.endpointRegionalType, null); } } private long? resourceOwnerId; private string qosPolicyId; private string qosId; private string resourceOwnerAccount; private string ownerAccount; private long? ownerId; public long? ResourceOwnerId { get { return resourceOwnerId; } set { resourceOwnerId = value; DictionaryUtil.Add(QueryParameters, "ResourceOwnerId", value.ToString()); } } public string QosPolicyId { get { return qosPolicyId; } set { qosPolicyId = value; DictionaryUtil.Add(QueryParameters, "QosPolicyId", value); } } public string QosId { get { return qosId; } set { qosId = value; DictionaryUtil.Add(QueryParameters, "QosId", value); } } public string ResourceOwnerAccount { get { return resourceOwnerAccount; } set { resourceOwnerAccount = value; DictionaryUtil.Add(QueryParameters, "ResourceOwnerAccount", value); } } public string OwnerAccount { get { return ownerAccount; } set { ownerAccount = value; DictionaryUtil.Add(QueryParameters, "OwnerAccount", value); } } public long? OwnerId { get { return ownerId; } set { ownerId = value; DictionaryUtil.Add(QueryParameters, "OwnerId", value.ToString()); } } public override DeleteQosPolicyResponse GetResponse(UnmarshallerContext unmarshallerContext) { return DeleteQosPolicyResponseUnmarshaller.Unmarshall(unmarshallerContext); } } }
24.253623
134
0.662683
[ "Apache-2.0" ]
AxiosCros/aliyun-openapi-net-sdk
aliyun-net-sdk-smartag/Smartag/Model/V20180313/DeleteQosPolicyRequest.cs
3,347
C#
// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. namespace Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301 { using Microsoft.Azure.PowerShell.Cmdlets.DataBox.Runtime.PowerShell; /// <summary>Request body to get the availability for scheduling orders.</summary> [System.ComponentModel.TypeConverter(typeof(ScheduleAvailabilityRequestTypeConverter))] public partial class ScheduleAvailabilityRequest { /// <summary> /// <c>AfterDeserializeDictionary</c> will be called after the deserialization has finished, allowing customization of the /// object before it is returned. Implement this method in a partial class to enable this behavior /// </summary> /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param> partial void AfterDeserializeDictionary(global::System.Collections.IDictionary content); /// <summary> /// <c>AfterDeserializePSObject</c> will be called after the deserialization has finished, allowing customization of the object /// before it is returned. Implement this method in a partial class to enable this behavior /// </summary> /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param> partial void AfterDeserializePSObject(global::System.Management.Automation.PSObject content); /// <summary> /// <c>BeforeDeserializeDictionary</c> will be called before the deserialization has commenced, allowing complete customization /// of the object before it is deserialized. /// If you wish to disable the default deserialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter. /// Implement this method in a partial class to enable this behavior. /// </summary> /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param> /// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return /// instantly.</param> partial void BeforeDeserializeDictionary(global::System.Collections.IDictionary content, ref bool returnNow); /// <summary> /// <c>BeforeDeserializePSObject</c> will be called before the deserialization has commenced, allowing complete customization /// of the object before it is deserialized. /// If you wish to disable the default deserialization entirely, return <c>true</c> in the <see "returnNow" /> output parameter. /// Implement this method in a partial class to enable this behavior. /// </summary> /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param> /// <param name="returnNow">Determines if the rest of the serialization should be processed, or if the method should return /// instantly.</param> partial void BeforeDeserializePSObject(global::System.Management.Automation.PSObject content, ref bool returnNow); /// <summary> /// Deserializes a <see cref="global::System.Collections.IDictionary" /> into an instance of <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.ScheduleAvailabilityRequest" /// />. /// </summary> /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param> /// <returns> /// an instance of <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequest" /// />. /// </returns> public static Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequest DeserializeFromDictionary(global::System.Collections.IDictionary content) { return new ScheduleAvailabilityRequest(content); } /// <summary> /// Deserializes a <see cref="global::System.Management.Automation.PSObject" /> into an instance of <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.ScheduleAvailabilityRequest" /// />. /// </summary> /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param> /// <returns> /// an instance of <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequest" /// />. /// </returns> public static Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequest DeserializeFromPSObject(global::System.Management.Automation.PSObject content) { return new ScheduleAvailabilityRequest(content); } /// <summary> /// Creates a new instance of <see cref="ScheduleAvailabilityRequest" />, deserializing the content from a json string. /// </summary> /// <param name="jsonText">a string containing a JSON serialized instance of this model.</param> /// <returns>an instance of the <see cref="className" /> model class.</returns> public static Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequest FromJsonString(string jsonText) => FromJson(Microsoft.Azure.PowerShell.Cmdlets.DataBox.Runtime.Json.JsonNode.Parse(jsonText)); /// <summary> /// Deserializes a <see cref="global::System.Collections.IDictionary" /> into a new instance of <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.ScheduleAvailabilityRequest" /// />. /// </summary> /// <param name="content">The global::System.Collections.IDictionary content that should be used.</param> internal ScheduleAvailabilityRequest(global::System.Collections.IDictionary content) { bool returnNow = false; BeforeDeserializeDictionary(content, ref returnNow); if (returnNow) { return; } // actually deserialize ((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).StorageLocation = (string) content.GetValueForProperty("StorageLocation",((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).StorageLocation, global::System.Convert.ToString); ((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).SkuName = (Microsoft.Azure.PowerShell.Cmdlets.DataBox.Support.SkuName) content.GetValueForProperty("SkuName",((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).SkuName, Microsoft.Azure.PowerShell.Cmdlets.DataBox.Support.SkuName.CreateFrom); ((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).Country = (string) content.GetValueForProperty("Country",((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).Country, global::System.Convert.ToString); AfterDeserializeDictionary(content); } /// <summary> /// Deserializes a <see cref="global::System.Management.Automation.PSObject" /> into a new instance of <see cref="Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.ScheduleAvailabilityRequest" /// />. /// </summary> /// <param name="content">The global::System.Management.Automation.PSObject content that should be used.</param> internal ScheduleAvailabilityRequest(global::System.Management.Automation.PSObject content) { bool returnNow = false; BeforeDeserializePSObject(content, ref returnNow); if (returnNow) { return; } // actually deserialize ((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).StorageLocation = (string) content.GetValueForProperty("StorageLocation",((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).StorageLocation, global::System.Convert.ToString); ((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).SkuName = (Microsoft.Azure.PowerShell.Cmdlets.DataBox.Support.SkuName) content.GetValueForProperty("SkuName",((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).SkuName, Microsoft.Azure.PowerShell.Cmdlets.DataBox.Support.SkuName.CreateFrom); ((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).Country = (string) content.GetValueForProperty("Country",((Microsoft.Azure.PowerShell.Cmdlets.DataBox.Models.Api20210301.IScheduleAvailabilityRequestInternal)this).Country, global::System.Convert.ToString); AfterDeserializePSObject(content); } /// <summary>Serializes this instance to a json string.</summary> /// <returns>a <see cref="System.String" /> containing this model serialized to JSON text.</returns> public string ToJsonString() => ToJson(null, Microsoft.Azure.PowerShell.Cmdlets.DataBox.Runtime.SerializationMode.IncludeAll)?.ToString(); } /// Request body to get the availability for scheduling orders. [System.ComponentModel.TypeConverter(typeof(ScheduleAvailabilityRequestTypeConverter))] public partial interface IScheduleAvailabilityRequest { } }
71.323944
416
0.714159
[ "MIT" ]
Amrinder-Singh29/azure-powershell
src/DataBox/generated/api/Models/Api20210301/ScheduleAvailabilityRequest.PowerShell.cs
9,987
C#
using Signum.Utilities; using System; using System.IO; namespace Signum.Upgrade.Upgrades; class Upgrade_20210828_ExtensionsLoveFramework : CodeUpgradeBase { public override string Description => "Extensions ❤️ Framework"; public override void Execute(UpgradeContext uctx) { uctx.ForeachCodeFile(@"*.csproj", file => { file.Replace(@"\Extensions\", @"\Framework\"); }); uctx.ForeachCodeFile(@"*.sln", file => { file.Replace(@"""Extensions\", @"""Framework\"); }); uctx.ChangeCodeFile(@"Southwind.React\webpack.config.js", file => { file.Replace(@"/Extensions/", @"/Framework/"); }); uctx.ChangeCodeFile(@"Southwind.React/tsconfig.json", file => { file.Replace(@"/Extensions/", @"/Framework/"); }); uctx.ChangeCodeFile(@"Southwind.React/package.json", file => { file.Replace(@"/Extensions/", @"/Framework/"); }); uctx.ChangeCodeFile(@"Southwind.React/Dockerfile", file => { file.Replace(@"""Extensions/", @"""Framework/"); }); uctx.ChangeCodeFile(@".gitmodules", file => { file.RemoveAllLines(a => a.Contains("extensions", StringComparison.InvariantCultureIgnoreCase)); }); uctx.ForeachCodeFile(@"*.ts, *.tsx", file => { file.Replace(@"../../../../Extensions/Signum.React.Extensions/", @"@extensions/"); file.Replace(@"../../../Extensions/Signum.React.Extensions/", @"@extensions/"); file.Replace(@"../../Extensions/Signum.React.Extensions/", @"@extensions/"); file.Replace(@"../../../../Framework/Signum.React/Scripts/", @"@framework/"); file.Replace(@"../../../Framework/Signum.React/Scripts/", @"@framework/"); file.Replace(@"../../Framework/Signum.React/Scripts/", @"@framework/"); }); if (SafeConsole.Ask("Do you want to delete 'Extensions' folder with all his content?")) { Directory.Delete(Path.Combine(uctx.RootFolder, "Extensions"), true); Console.WriteLine("deleted"); } } }
33.647059
109
0.539336
[ "MIT" ]
Faridmehr/framework
Signum.Upgrade/Upgrades/Upgrade_20210828_ExtensionsLoveFramework.cs
2,292
C#
//系统名 : 通用Web框架 //-----------<类 说 明>-------------------------------------------------------------------------- //功能概况 : 缓存对象超时模式枚举和时间委托 //编写日期 : 2010-12-15 //-----------<修改记录>-------------------------------------------------------------------------- //修改日期 修改者 修改内容 // //----------------------------------------------------------------------------------------------- //Copyright (C) 2013,Shanghai Great Wisdom Co.,Ltd. All Rights Reserved. //----------------------------------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Text; namespace GW.Utils.Caching { /// <summary> /// 缓存对象超时模式枚举 /// </summary> public enum CacheExpireModeEnum : byte { /// <summary> /// 最后访问时间 /// </summary> IntervalAfterLastAccess = 0, /// <summary> /// 绝对时点 /// </summary> AbsoluteTimePoint = 1, /// <summary> /// 永不超时 /// </summary> Never = 2, /// <summary> /// 依赖于其他对象 /// </summary> Depend = 3 } /// <summary> /// 缓存对象被移除时的代理 /// 由缓存加载类提供,主要用于在该缓存对象被删除时重新加载该对象 /// </summary> /// <param name="key">键值</param> /// <param name="value">缓存的对象,如果此代理负责重新加载该对象,这把新加载的对象赋予此参数,否则赋予此参数为NULL</param> /// <param name="cache">当前缓存对象</param> /// <param name="reason">缓存过期原因</param> public delegate void CacheItemRemovedHandler(string key, object value, Cache cache, CacheExpireModeEnum reason); /// <summary> /// 缓存对象被移除时的代理 /// 由缓存管理类提供,主要用于记录日志信息 /// </summary> /// <param name="key">键值</param> public delegate void CacheRemoveHandler(string key); /// <summary> /// 缓存对象被加入时的代理 /// 由缓存管理类提供,主要用于记录日志 /// </summary> /// <param name="key">键值</param> public delegate void CacheAddedHandler(string key); }
29.8125
116
0.458595
[ "MIT" ]
erikzhouxin/CSharpSolution
TechTester/FamliyFinanceWebSI/App_Api/GW.Utils/Caching/CacheEnums.cs
2,388
C#
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 2.0.4 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ using System; using System.Runtime.InteropServices; namespace Noesis { public class Keyboard : BaseComponent { internal new static Keyboard CreateProxy(IntPtr cPtr, bool cMemoryOwn) { return new Keyboard(cPtr, cMemoryOwn); } internal Keyboard(IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn) { } internal static HandleRef getCPtr(Keyboard obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; } protected Keyboard() { } public void ResetState() { NoesisGUI_PINVOKE.Keyboard_ResetState(swigCPtr); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif } public uint GetModifiers() { uint ret = NoesisGUI_PINVOKE.Keyboard_GetModifiers(swigCPtr); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return ret; } public uint GetKeyStates(Key key) { uint ret = NoesisGUI_PINVOKE.Keyboard_GetKeyStates(swigCPtr, (int)key); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return ret; } public bool IsKeyDown(Key key) { bool ret = NoesisGUI_PINVOKE.Keyboard_IsKeyDown(swigCPtr, (int)key); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return ret; } public bool IsKeyUp(Key key) { bool ret = NoesisGUI_PINVOKE.Keyboard_IsKeyUp(swigCPtr, (int)key); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return ret; } public bool IsKeyToggled(Key key) { bool ret = NoesisGUI_PINVOKE.Keyboard_IsKeyToggled(swigCPtr, (int)key); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return ret; } public UIElement GetFocused() { IntPtr cPtr = NoesisGUI_PINVOKE.Keyboard_GetFocused(swigCPtr); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return (UIElement)Noesis.Extend.GetProxy(cPtr, false); } public UIElement Focus(UIElement element) { IntPtr cPtr = NoesisGUI_PINVOKE.Keyboard_Focus(swigCPtr, UIElement.getCPtr(element)); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return (UIElement)Noesis.Extend.GetProxy(cPtr, false); } new internal static IntPtr GetStaticType() { IntPtr ret = NoesisGUI_PINVOKE.Keyboard_GetStaticType(); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); #endif return ret; } } }
33.150943
112
0.713432
[ "MIT" ]
suggestbot-wearable-text-entry-system/SuggestBot_GazeAssistedTyping
Assets/Plugins/NoesisGUI/Scripts/Proxies/Keyboard.cs
3,514
C#
using System.IO; using System; using System.Data; using System.Drawing; using System.Web; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Collections; using System.Web.UI; using System.Web.UI.WebControls.WebParts; using System.Collections.Generic; using Umbraco.Core; using Umbraco.Core.Logging; using umbraco.BusinessLogic; namespace umbraco.presentation.developer.packages { public partial class LoadNitros : System.Web.UI.UserControl { private List<CheckBox> _nitroList = new List<CheckBox>(); private List<string> _selectedNitros = new List<string>(); protected void Page_Load(object sender, EventArgs e) { } public void installNitros(object sender, EventArgs e) { string repoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; //Hardcoded official package repo key. cms.businesslogic.packager.Installer p = new cms.businesslogic.packager.Installer(); cms.businesslogic.packager.repositories.Repository repo = cms.businesslogic.packager.repositories.Repository.getByGuid(repoGuid); foreach (CheckBox cb in _nitroList) { if (cb.Checked) { if (!_selectedNitros.Contains(cb.ID)) _selectedNitros.Add(cb.ID); } } foreach (string guid in _selectedNitros) { string tempFile = p.Import(repo.fetch(guid)); p.LoadConfig(tempFile); int pId = p.CreateManifest(tempFile, guid, repoGuid); //and then copy over the files. This will take some time if it contains .dlls that will reboot the system.. p.InstallFiles(pId, tempFile); //finally install the businesslogic p.InstallBusinessLogic(pId, tempFile); //cleanup.. p.InstallCleanUp(pId, tempFile); } ApplicationContext.Current.ApplicationCache.ClearAllCache(); library.RefreshContent(); loadNitros.Visible = false; RaiseBubbleEvent(new object(), new EventArgs()); } protected void onCategoryDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { cms.businesslogic.packager.repositories.Category cat = (cms.businesslogic.packager.repositories.Category)e.Item.DataItem; Literal _name = (Literal)e.Item.FindControl("lit_name"); Literal _desc = (Literal)e.Item.FindControl("lit_desc"); PlaceHolder _nitros = (PlaceHolder)e.Item.FindControl("ph_nitroHolder"); _name.Text = cat.Text; _desc.Text = cat.Description; e.Item.Visible = false; foreach (cms.businesslogic.packager.repositories.Package nitro in cat.Packages) { bool installed = cms.businesslogic.packager.InstalledPackage.isPackageInstalled(nitro.RepoGuid.ToString()); int localPackageID = 0; if (installed) localPackageID = cms.businesslogic.packager.InstalledPackage.GetByGuid(nitro.RepoGuid.ToString()).Data.Id; CheckBox cb_nitro = new CheckBox(); cb_nitro.ID = nitro.RepoGuid.ToString(); cb_nitro.Enabled = !installed; cb_nitro.CssClass = "nitroCB"; cb_nitro.Text = "<div class='nitro'><h3>" + nitro.Text; if (installed) { cb_nitro.CssClass = "nitroCB installed"; cb_nitro.Text += "<span><a href='#' onclick=\"openDemoModal('" + nitro.RepoGuid.ToString() + "','" + nitro.Text + "'); return false;\">Already installed</a></span>"; } cb_nitro.Text += "</h3><small>" + nitro.Description + "<br/>"; if (!string.IsNullOrEmpty(nitro.Demo)) { cb_nitro.Text += "<a href='#' onclick=\"openDemoModal('" + nitro.RepoGuid.ToString() + "','" + nitro.Text + "'); return false;\">Demonstration</a> &nbsp;"; } if (!string.IsNullOrEmpty(nitro.Documentation)) { cb_nitro.Text += "<a href='" + nitro.Documentation + "' target='_blank'>Documentation</a> &nbsp;"; } cb_nitro.Text += "</small></div><br style='clear: both'/>"; _nitros.Controls.Add(cb_nitro); _nitroList.Add(cb_nitro); e.Item.Visible = true; if (nitro.EditorsPick) { CheckBox cb_Recnitro = new CheckBox(); cb_Recnitro.ID = nitro.RepoGuid.ToString(); cb_Recnitro.CssClass = "nitroCB"; cb_Recnitro.Enabled = !installed; cb_Recnitro.Text = "<div class='nitro'><h3>" + nitro.Text; if (installed) { cb_Recnitro.CssClass = "nitroCB installed"; cb_Recnitro.Text += "<span><a href='' onclick=\"openDemoModal('" + nitro.RepoGuid.ToString() + "','" + nitro.Text + "'); return false;\">Already installed</a></span>"; } cb_Recnitro.Text += "</h3><small>" + nitro.Description + "<br/>"; if (!string.IsNullOrEmpty(nitro.Demo)) { cb_Recnitro.Text += "<a href='#' onclick=\"openDemoModal('" + nitro.RepoGuid.ToString() + "','" + nitro.Text + "'); return false;\">Demonstration</a> &nbsp;"; } if (!string.IsNullOrEmpty(nitro.Documentation)) { cb_Recnitro.Text += "<a href='" + nitro.Documentation + "' target='_blank'>Documentation</a> &nbsp;"; } cb_Recnitro.Text += "</small></div><br style='clear: both'/>"; _nitroList.Add(cb_Recnitro); ph_recommendedHolder.Controls.Add(cb_Recnitro); } } } } protected override void OnInit(EventArgs e) { base.OnInit(e); string repoGuid = "65194810-1f85-11dd-bd0b-0800200c9a66"; cms.businesslogic.packager.repositories.Repository repo = cms.businesslogic.packager.repositories.Repository.getByGuid(repoGuid); uicontrols.Feedback fb = new global::umbraco.uicontrols.Feedback(); fb.type = global::umbraco.uicontrols.Feedback.feedbacktype.error; fb.Text = "<strong>No connection to repository.</strong> Modules could not be fetched from the repository as there was no connection to: '" + repo.RepositoryUrl + "'"; if (repo.HasConnection()) { try { if (UmbracoSettings.UseLegacyXmlSchema) rep_nitros.DataSource = repo.Webservice.NitrosCategorizedByVersion(cms.businesslogic.packager.repositories.Version.Version4); else rep_nitros.DataSource = repo.Webservice.NitrosCategorizedByVersion(cms.businesslogic.packager.repositories.Version.Version41); rep_nitros.DataBind(); } catch (Exception ex) { LogHelper.Error<LoadNitros>("An error occurred", ex); loadNitros.Controls.Clear(); loadNitros.Controls.Add(fb); //nitroList.Visible = false; //lt_status.Text = "<div class='error'><p>Nitros could not be fetched from the repository. Please check your internet connection</p><p>You can always install Nitros later in the packages section</p><p>" + ex.ToString() + "</p></div>"; } } else { loadNitros.Controls.Clear(); loadNitros.Controls.Add(fb); } } } }
41.948187
240
0.561141
[ "MIT" ]
AndyButland/Umbraco-CMS
src/Umbraco.Web/umbraco.presentation/umbraco/developer/Packages/LoadNitros.ascx.cs
8,096
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.AddIn.Pipeline; namespace HostSideAdapter { /// <summary> /// Adapter use to talk to <see cref="HostView.NumberProcessorHostView">Host View</see> /// </summary> [HostAdapter] public class NumberProcessorContractToViewHostAdapter : HostView.NumberProcessorHostView { #region Data private Contract.INumberProcessorContract contract; private ContractHandle contractHandle; #endregion #region Ctor public NumberProcessorContractToViewHostAdapter(Contract.INumberProcessorContract contract) { this.contract = contract; contractHandle = new ContractHandle(contract); } #endregion #region Public Methods public override List<int> ProcessNumbers(int fromNumber, int toNumber) { return contract.ProcessNumbers(fromNumber, toNumber); } public override void Initialize(HostView.HostObject host) { HostObjectViewToContractHostAdapter hostAdapter = new HostObjectViewToContractHostAdapter(host); contract.Initialize(hostAdapter); } #endregion } /// <summary> /// Allows Host side adapter to talk back to HostView /// </summary> public class HostObjectViewToContractHostAdapter : ContractBase, Contract.IHostObjectContract { #region Data private HostView.HostObject view; #endregion #region Public Methods public HostObjectViewToContractHostAdapter(HostView.HostObject view) { this.view = view; } public void ReportProgress(int progressPercent) { view.ReportProgress(progressPercent); } #endregion } }
28.5
108
0.650186
[ "MIT" ]
ridgew/practicemakesperfect
MAF/AddInTest/HostSideAdapter/HostAdapters.cs
1,883
C#
using System; using System.Collections.Generic; using System.Text; using System.Linq; using SeoSchema; using SeoSchema.Enumerations; using SuperStructs; namespace SeoSchema.Entities { /// <summary> /// An auto parts store. /// <see cref="https://schema.org/AutoPartsStore"/> /// </summary> public class AutoPartsStore : IEntity { /// The currency accepted. /// /// Use standard formats: ISO 4217 currency format e.g. "USD"; Ticker symbol for cryptocurrencies e.g. "BTC"; well known names for Local Exchange Tradings Systems (LETS) and other currency types e.g. "Ithaca HOUR". public Or<string>? CurrenciesAccepted { get; set; } /// The general opening hours for a business. Opening hours can be specified as a weekly time range, starting with days, then times per day. Multiple days can be listed with commas ',' separating each day. Day or time ranges are specified using a hyphen '-'. /// /// /// Days are specified using the following two-letter combinations: Mo, Tu, We, Th, Fr, Sa, Su. /// Times are specified using 24:00 time. For example, 3pm is specified as 15:00. /// Here is an example: <time itemprop="openingHours" datetime="Tu,Th 16:00-20:00">Tuesdays and Thursdays 4-8pm</time>. /// If a business is open 7 days a week, then it can be specified as <time itemprop="openingHours" datetime="Mo-Su">Monday through Sunday, all day</time>. public Or<string>? OpeningHours { get; set; } /// Cash, Credit Card, Cryptocurrency, Local Exchange Tradings System, etc. public Or<string>? PaymentAccepted { get; set; } /// The price range of the business, for example $$$. public Or<string>? PriceRange { get; set; } /// For a NewsMediaOrganization or other news-related Organization, a statement about public engagement activities (for news media, the newsroom’s), including involving the public - digitally or otherwise -- in coverage decisions, reporting and activities after publication. public Or<CreativeWork, Uri>? ActionableFeedbackPolicy { get; set; } /// Physical address of the item. public Or<PostalAddress, string>? Address { get; set; } /// The overall rating, based on a collection of reviews or ratings, of the item. public Or<AggregateRating>? AggregateRating { get; set; } /// Alumni of an organization. Inverse property: alumniOf. public Or<Person>? Alumni { get; set; } /// The geographic area where a service or offered item is provided. Supersedes serviceArea. public Or<AdministrativeArea, GeoShape, Place, string>? AreaServed { get; set; } /// An award won by or for this item. Supersedes awards. public Or<string>? Award { get; set; } /// The brand(s) associated with a product or service, or the brand(s) maintained by an organization or business person. public Or<Brand, Organization>? Brand { get; set; } /// A contact point for a person or organization. Supersedes contactPoints. public Or<ContactPoint>? ContactPoint { get; set; } /// For an Organization (e.g. NewsMediaOrganization), a statement describing (in news media, the newsroom’s) disclosure and correction policy for errors. public Or<CreativeWork, Uri>? CorrectionsPolicy { get; set; } /// A relationship between an organization and a department of that organization, also described as an organization (allowing different urls, logos, opening hours). For example: a store with a pharmacy, or a bakery with a cafe. public Or<Organization>? Department { get; set; } /// The date that this organization was dissolved. public Or<SuperStructs.Date>? DissolutionDate { get; set; } /// Statement on diversity policy by an Organization e.g. a NewsMediaOrganization. For a NewsMediaOrganization, a statement describing the newsroom’s diversity policy on both staffing and sources, typically providing staffing data. public Or<CreativeWork, Uri>? DiversityPolicy { get; set; } /// For an Organization (often but not necessarily a NewsMediaOrganization), a report on staffing diversity issues. In a news context this might be for example ASNE or RTDNA (US) reports, or self-reported. public Or<Article, Uri>? DiversityStaffingReport { get; set; } /// The Dun & Bradstreet DUNS number for identifying an organization or business person. public Or<string>? Duns { get; set; } /// Email address. public Or<string>? Email { get; set; } /// Someone working for this organization. Supersedes employees. public Or<Person>? Employee { get; set; } /// Statement about ethics policy, e.g. of a NewsMediaOrganization regarding journalistic and publishing practices, or of a Restaurant, a page describing food source policies. In the case of a NewsMediaOrganization, an ethicsPolicy is typically a statement describing the personal, organizational, and corporate standards of behavior expected by the organization. public Or<CreativeWork, Uri>? EthicsPolicy { get; set; } /// Upcoming or past event associated with this place, organization, or action. Supersedes events. public Or<Event>? Event { get; set; } /// The fax number. public Or<string>? FaxNumber { get; set; } /// A person who founded this organization. Supersedes founders. public Or<Person>? Founder { get; set; } /// The date that this organization was founded. public Or<SuperStructs.Date>? FoundingDate { get; set; } /// The place where the Organization was founded. public Or<Place>? FoundingLocation { get; set; } /// A person or organization that supports (sponsors) something through some kind of financial contribution. public Or<Organization, Person>? Funder { get; set; } /// The Global Location Number (GLN, sometimes also referred to as International Location Number or ILN) of the respective organization, person, or place. The GLN is a 13-digit number used to identify parties and physical locations. public Or<string>? GlobalLocationNumber { get; set; } /// Indicates an OfferCatalog listing for this Organization, Person, or Service. public Or<OfferCatalog>? HasOfferCatalog { get; set; } /// Points-of-Sales operated by the organization or person. public Or<Place>? HasPOS { get; set; } /// The International Standard of Industrial Classification of All Economic Activities (ISIC), Revision 4 code for a particular organization, business person, or place. public Or<string>? IsicV4 { get; set; } /// Of a Person, and less typically of an Organization, to indicate a topic that is known about - suggesting possible expertise but not implying it. We do not distinguish skill levels here, or yet relate this to educational content, events, objectives or JobPosting descriptions. public Or<string, Thing, Uri>? KnowsAbout { get; set; } /// Of a Person, and less typically of an Organization, to indicate a known language. We do not distinguish skill levels or reading/writing/speaking/signing here. Use language codes from the IETF BCP 47 standard. public Or<Language, string>? KnowsLanguage { get; set; } /// The official name of the organization, e.g. the registered company name. public Or<string>? LegalName { get; set; } /// An organization identifier that uniquely identifies a legal entity as defined in ISO 17442. public Or<string>? LeiCode { get; set; } /// The location of for example where the event is happening, an organization is located, or where an action takes place. public Or<Place, PostalAddress, string>? Location { get; set; } /// An associated logo. public Or<ImageObject, Uri>? Logo { get; set; } /// A pointer to products or services offered by the organization or person. Inverse property: offeredBy. public Or<Offer>? MakesOffer { get; set; } /// A member of an Organization or a ProgramMembership. Organizations can be members of organizations; ProgramMembership is typically for individuals. Supersedes members, musicGroupMember. Inverse property: memberOf. public Or<Organization, Person>? Member { get; set; } /// An Organization (or ProgramMembership) to which this Person or Organization belongs. Inverse property: member. public Or<Organization, ProgramMembership>? MemberOf { get; set; } /// The North American Industry Classification System (NAICS) code for a particular organization or business person. public Or<string>? Naics { get; set; } /// The number of employees in an organization e.g. business. public Or<QuantitativeValue>? NumberOfEmployees { get; set; } /// For an Organization (often but not necessarily a NewsMediaOrganization), a description of organizational ownership structure; funding and grants. In a news/media setting, this is with particular reference to editorial independence. Note that the funder is also available and can be used to make basic funder information machine-readable. public Or<AboutPage, CreativeWork, string, Uri>? OwnershipFundingInfo { get; set; } /// Products owned by the organization or person. public Or<OwnershipInfo, Product>? Owns { get; set; } /// The larger organization that this organization is a subOrganization of, if any. Supersedes branchOf. Inverse property: subOrganization. public Or<Organization>? ParentOrganization { get; set; } /// The publishingPrinciples property indicates (typically via URL) a document describing the editorial principles of an Organization (or individual e.g. a Person writing a blog) that relate to their activities as a publisher, e.g. ethics or diversity policies. When applied to a CreativeWork (e.g. NewsArticle) the principles are those of the party primarily responsible for the creation of the CreativeWork. /// /// While such policies are most typically expressed in natural language, sometimes related information (e.g. indicating a funder) can be expressed using schema.org terminology. public Or<CreativeWork, Uri>? PublishingPrinciples { get; set; } /// A review of the item. Supersedes reviews. public Or<Review>? Review { get; set; } /// A pointer to products or services sought by the organization or person (demand). public Or<Demand>? Seeks { get; set; } /// A person or organization that supports a thing through a pledge, promise, or financial contribution. e.g. a sponsor of a Medical Study or a corporate sponsor of an event. public Or<Organization, Person>? Sponsor { get; set; } /// A relationship between two organizations where the first includes the second, e.g., as a subsidiary. See also: the more specific 'department' property. Inverse property: parentOrganization. public Or<Organization>? SubOrganization { get; set; } /// The Tax / Fiscal ID of the organization or person, e.g. the TIN in the US or the CIF/NIF in Spain. public Or<string>? TaxID { get; set; } /// The telephone number. public Or<string>? Telephone { get; set; } /// For an Organization (typically a NewsMediaOrganization), a statement about policy on use of unnamed sources and the decision process required. public Or<CreativeWork, Uri>? UnnamedSourcesPolicy { get; set; } /// The Value-added Tax ID of the organization or person. public Or<string>? VatID { get; set; } /// A property-value pair representing an additional characteristics of the entitity, e.g. a product feature or another characteristic for which there is no matching property in schema.org. /// /// Note: Publishers should be aware that applications designed to use specific schema.org properties (e.g. http://schema.org/width, http://schema.org/color, http://schema.org/gtin13, ...) will typically expect such data to be provided using those properties, rather than using the generic property/value mechanism. public Or<PropertyValue>? AdditionalProperty { get; set; } /// An amenity feature (e.g. a characteristic or service) of the Accommodation. This generic property does not make a statement about whether the feature is included in an offer for the main accommodation or available at extra costs. public Or<LocationFeatureSpecification>? AmenityFeature { get; set; } /// A short textual code (also called "store code") that uniquely identifies a place of business. The code is typically assigned by the parentOrganization and used in structured URLs. /// /// For example, in the URL http://www.starbucks.co.uk/store-locator/etc/detail/3047 the code "3047" is a branchCode for a particular branch. public Or<string>? BranchCode { get; set; } /// The basic containment relation between a place and one that contains it. Supersedes containedIn. Inverse property: containsPlace. public Or<Place>? ContainedInPlace { get; set; } /// The basic containment relation between a place and another that it contains. Inverse property: containedInPlace. public Or<Place>? ContainsPlace { get; set; } /// The geo coordinates of the place. public Or<GeoCoordinates, GeoShape>? Geo { get; set; } /// Represents a relationship between two geometries (or the places they represent), relating a containing geometry to a contained geometry. "a contains b iff no points of b lie in the exterior of a, and at least one point of the interior of b lies in the interior of a". As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyContains { get; set; } /// Represents a relationship between two geometries (or the places they represent), relating a geometry to another that covers it. As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyCoveredBy { get; set; } /// Represents a relationship between two geometries (or the places they represent), relating a covering geometry to a covered geometry. "Every point of b is a point of (the interior or boundary of) a". As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyCovers { get; set; } /// Represents a relationship between two geometries (or the places they represent), relating a geometry to another that crosses it: "a crosses b: they have some but not all interior points in common, and the dimension of the intersection is less than that of at least one of them". As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyCrosses { get; set; } /// Represents spatial relations in which two geometries (or the places they represent) are topologically disjoint: they have no point in common. They form a set of disconnected geometries." (a symmetric relationship, as defined in DE-9IM) public Or<GeospatialGeometry, Place>? GeospatiallyDisjoint { get; set; } /// Represents spatial relations in which two geometries (or the places they represent) are topologically equal, as defined in DE-9IM. "Two geometries are topologically equal if their interiors intersect and no part of the interior or boundary of one geometry intersects the exterior of the other" (a symmetric relationship) public Or<GeospatialGeometry, Place>? GeospatiallyEquals { get; set; } /// Represents spatial relations in which two geometries (or the places they represent) have at least one point in common. As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyIntersects { get; set; } /// Represents a relationship between two geometries (or the places they represent), relating a geometry to another that geospatially overlaps it, i.e. they have some but not all points in common. As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyOverlaps { get; set; } /// Represents spatial relations in which two geometries (or the places they represent) touch: they have at least one boundary point in common, but no interior points." (a symmetric relationship, as defined in DE-9IM ) public Or<GeospatialGeometry, Place>? GeospatiallyTouches { get; set; } /// Represents a relationship between two geometries (or the places they represent), relating a geometry to one that contains it, i.e. it is inside (i.e. within) its interior. As defined in DE-9IM. public Or<GeospatialGeometry, Place>? GeospatiallyWithin { get; set; } /// A URL to a map of the place. Supersedes map, maps. public Or<Map, Uri>? HasMap { get; set; } /// A flag to signal that the item, event, or place is accessible for free. Supersedes free. public Or<bool>? IsAccessibleForFree { get; set; } /// The total number of individuals that may attend an event or venue. public Or<int>? MaximumAttendeeCapacity { get; set; } /// The opening hours of a certain place. public Or<OpeningHoursSpecification>? OpeningHoursSpecification { get; set; } /// A photograph of this place. Supersedes photos. public Or<ImageObject, Photograph>? Photo { get; set; } /// A flag to signal that the Place is open to public visitors. If this property is omitted there is no assumed default boolean value public Or<bool>? PublicAccess { get; set; } /// Indicates whether it is allowed to smoke in the place, e.g. in the restaurant, hotel or hotel room. public Or<bool>? SmokingAllowed { get; set; } /// The special opening hours of a certain place. /// /// Use this to explicitly override general opening hours brought in scope by openingHoursSpecification or openingHours. public Or<OpeningHoursSpecification>? SpecialOpeningHoursSpecification { get; set; } /// An additional type for the item, typically used for adding more specific types from external vocabularies in microdata syntax. This is a relationship between something and a class that the thing is in. In RDFa syntax, it is better to use the native RDFa syntax - the 'typeof' attribute - for multiple types. Schema.org tools may have only weaker understanding of extra types, in particular those defined externally. public Or<Uri>? AdditionalType { get; set; } /// An alias for the item. public Or<string>? AlternateName { get; set; } /// A description of the item. public Or<string>? Description { get; set; } /// A sub property of description. A short description of the item used to disambiguate from other, similar items. Information from other properties (in particular, name) may be necessary for the description to be useful for disambiguation. public Or<string>? DisambiguatingDescription { get; set; } /// The identifier property represents any kind of identifier for any kind of Thing, such as ISBNs, GTIN codes, UUIDs etc. Schema.org provides dedicated properties for representing many of these, either as textual strings or as URL (URI) links. See background notes for more details. public Or<PropertyValue, string, Uri>? Identifier { get; set; } /// An image of the item. This can be a URL or a fully described ImageObject. public Or<ImageObject, Uri>? Image { get; set; } /// Indicates a page (or other CreativeWork) for which this thing is the main entity being described. See background notes for details. Inverse property: mainEntity. public Or<CreativeWork, Uri>? MainEntityOfPage { get; set; } /// The name of the item. public Or<string>? Name { get; set; } /// Indicates a potential Action, which describes an idealized action in which this thing would play an 'object' role. public Or<Action>? PotentialAction { get; set; } /// URL of a reference Web page that unambiguously indicates the item's identity. E.g. the URL of the item's Wikipedia page, Wikidata entry, or official website. public Or<Uri>? SameAs { get; set; } /// A CreativeWork or Event about this Thing.. Inverse property: about. public Or<CreativeWork, Event>? SubjectOf { get; set; } /// URL of the item. public Or<Uri>? Url { get; set; } } }
67.730263
427
0.70306
[ "MIT" ]
jefersonsv/SeoSchema
src/SeoSchema/Entities/AutoPartsStore.cs
20,596
C#
using BioEngine.Core.DB; using BioEngine.Core.Entities; using BioEngine.Core.Modules; using BioEngine.Core.Properties; using BioEngine.Core.Social; using BioEngine.Extra.Twitter.Service; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; namespace BioEngine.Extra.Twitter { public class TwitterModule : BaseBioEngineModule { public override void ConfigureServices(IServiceCollection services, IConfiguration configuration, IHostEnvironment environment) { services.AddSingleton<TwitterService>(); services.AddScoped<IContentPublisher<TwitterPublishConfig>, TwitterContentPublisher>(); services.AddScoped<TwitterContentPublisher>(); PropertiesProvider.RegisterBioEngineProperties<TwitterSitePropertiesSet, Site>("twittersite"); } } public class TwitterBioContextConfigurator: IBioContextModelConfigurator{ public void Configure(ModelBuilder modelBuilder, ILogger<BioContext> logger) { modelBuilder.RegisterEntity<TwitterPublishRecord>(); } } }
35.342857
106
0.755053
[ "MIT" ]
BioWareRu/BioEngine.Extra.Twitter
src/BioEngine.Extra.Twitter/TwitterModule.cs
1,237
C#
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; namespace kinemic_quickstart_uwp_app { /// <summary> /// Stellt das anwendungsspezifische Verhalten bereit, um die Standardanwendungsklasse zu ergänzen. /// </summary> sealed partial class App : Application { /// <summary> /// Initialisiert das Singletonanwendungsobjekt. Dies ist die erste Zeile von erstelltem Code /// und daher das logische Äquivalent von main() bzw. WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; } /// <summary> /// Wird aufgerufen, wenn die Anwendung durch den Endbenutzer normal gestartet wird. Weitere Einstiegspunkte /// werden z. B. verwendet, wenn die Anwendung gestartet wird, um eine bestimmte Datei zu öffnen. /// </summary> /// <param name="e">Details über Startanforderung und -prozess.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { Frame rootFrame = Window.Current.Content as Frame; // App-Initialisierung nicht wiederholen, wenn das Fenster bereits Inhalte enthält. // Nur sicherstellen, dass das Fenster aktiv ist. if (rootFrame == null) { // Frame erstellen, der als Navigationskontext fungiert und zum Parameter der ersten Seite navigieren rootFrame = new Frame(); rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Zustand von zuvor angehaltener Anwendung laden } // Den Frame im aktuellen Fenster platzieren Window.Current.Content = rootFrame; } if (e.PrelaunchActivated == false) { if (rootFrame.Content == null) { // Wenn der Navigationsstapel nicht wiederhergestellt wird, zur ersten Seite navigieren // und die neue Seite konfigurieren, indem die erforderlichen Informationen als Navigationsparameter // übergeben werden rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Sicherstellen, dass das aktuelle Fenster aktiv ist Window.Current.Activate(); } } /// <summary> /// Wird aufgerufen, wenn die Navigation auf eine bestimmte Seite fehlschlägt /// </summary> /// <param name="sender">Der Rahmen, bei dem die Navigation fehlgeschlagen ist</param> /// <param name="e">Details über den Navigationsfehler</param> void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); } /// <summary> /// Wird aufgerufen, wenn die Ausführung der Anwendung angehalten wird. Der Anwendungszustand wird gespeichert, /// ohne zu wissen, ob die Anwendung beendet oder fortgesetzt wird und die Speicherinhalte dabei /// unbeschädigt bleiben. /// </summary> /// <param name="sender">Die Quelle der Anhalteanforderung.</param> /// <param name="e">Details zur Anhalteanforderung.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); //TODO: Anwendungszustand speichern und alle Hintergrundaktivitäten beenden deferral.Complete(); } } }
41.188119
120
0.635577
[ "MIT" ]
kinemic/kinemic-quickstart-uwp-app
kinemic-quickstart-uwp-app/App.xaml.cs
4,174
C#
using System; using System.Collections.Generic; using System.Text; // HttpConnectionsEventSource => Microsoft.AspNetCore.Http.Connections // Microsoft-Extensions-Logging // Microsoft-System-Net-Quic ==> NetEventSource // Microsoft-System-Net-Http ==> NetEventSource // Microsoft-System-Net-Http-WinHttpHandler ==> NetEventSource // Microsoft-System-Net-Requests ==> NetEventSource // Microsoft-System-Net-WebHeaderCollection ==> NetEventSource // Microsoft-System-Net-WebSockets-Client ==> NetEventSource // Microsoft-System-Net-HttpListener ==> NetEventSource // Microsoft-AspNetCore-Server-Kestrel // Microsoft-System-Net-Http // Dotnet-dev-certs ==> CertificateManagerEventSource // // Microsoft-Extensions-DependencyInjection ==> DependencyInjectionEventSource // System.Collections.Concurrent.ConcurrentCollectionsEventSource => CDSCollectionETWBCLProvider // System.Buffers.ArrayPoolEventSource ==> ArrayPoolEventSource // Microsoft-System-Net-Security ==> NetEventSource // EventSource: // https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/EventSource.cs namespace ClrDiagnostics.Triggers { public enum KnownProviderName { /// <summary> /// "Microsoft-Windows-DotNETRuntime" /// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/NativeRuntimeEventSource.cs /// </summary> Microsoft_Windows_DotNETRuntime, /// <summary> /// "System.Runtime" /// https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/Diagnostics/Tracing/RuntimeEventSource.cs /// </summary> System_Runtime, Microsoft_DotNETCore_SampleProfiler, /// <summary> /// Microsoft-AspNetCore-Hosting /// https://github.com/aspnet/Hosting/blob/master/src/Microsoft.AspNetCore.Hosting/Internal/HostingEventSource.cs /// https://github.com/dotnet/aspnetcore/blob/master/src/Hosting/Hosting/src/Internal/HostingEventSource.cs /// </summary> Microsoft_AspNetCore_Hosting, } public static class KnownProviders { private static Dictionary<KnownProviderName, string> Map = new Dictionary<KnownProviderName, string>() { { KnownProviderName.Microsoft_Windows_DotNETRuntime, "Microsoft-Windows-DotNETRuntime" }, { KnownProviderName.System_Runtime, "System.Runtime" }, { KnownProviderName.Microsoft_DotNETCore_SampleProfiler, "Microsoft-DotNETCore-SampleProfiler" }, { KnownProviderName.Microsoft_AspNetCore_Hosting, "Microsoft.AspNetCore.Hosting" }, }; public static bool TryGetName(KnownProviderName provider, out string providerName) { return Map.TryGetValue(provider, out providerName); } } }
41.042254
153
0.725463
[ "MIT" ]
raffaeler/PowerDiagnostics
DiagExperimentsSolution/ClrDiagnostics/Triggers/KnownProviders.cs
2,916
C#
using System; using System.Collections.Generic; using System.CommandLine; using System.Text; using System.Threading; namespace NWheels.Microservices.Runtime.Cli { public class CompileCommand : CliCommandBase { public CompileCommand() : base("compile", "Create precompiled version of the service") { } public override void DefineArguments(ArgumentSyntax syntax) { //TBD } public override void ValidateArguments(ArgumentSyntax arguments) { //TBD } public override int Execute(CancellationToken cancellation) { throw new NotImplementedException(); } } }
22.28125
74
0.621318
[ "MIT" ]
felix-b/NWheels
Source/Core/Microservices/NWheels.Microservices/Runtime/Cli/CompileCommand.cs
715
C#
using System.Collections.Generic; namespace TopDownProteomics.Chemistry.Unimod { /// <summary> /// Atom provider with a lot of information hard coded. /// </summary> /// <seealso cref="IUnimodCompositionAtomProvider" /> public class UnimodHardCodedAtomProvider : IUnimodCompositionAtomProvider { private Dictionary<string, UnimodCompositionAtom> _atoms; /// <summary> /// Initializes a new instance of the <see cref="UnimodHardCodedAtomProvider"/> class. /// </summary> /// <param name="elementProvider">The element provider.</param> public UnimodHardCodedAtomProvider(IElementProvider elementProvider) { _atoms = this.CreateDictionary(elementProvider); } private Dictionary<string, UnimodCompositionAtom> CreateDictionary(IElementProvider elementProvider) { var atoms = new Dictionary<string, UnimodCompositionAtom>(); var h = elementProvider.GetElement(1); var c = elementProvider.GetElement(6); var n = elementProvider.GetElement(7); var o = elementProvider.GetElement(8); var s = elementProvider.GetElement(16); this.AddElement(atoms, elementProvider, "13C", "Carbon 13", "C", 13); this.AddElement(atoms, elementProvider, "15N", "Nitrogen 15", "N", 15); this.AddElement(atoms, elementProvider, "18O", "Oxygen 18", "O", 18); this.AddElement(atoms, elementProvider, "2H", "Deuterium", "H", 2); atoms.Add("Ac", new UnimodCompositionAtom("Ac", "Acetate", new[] { new EntityCardinality<IElement>(c, 2), new EntityCardinality<IElement>(h, 3), new EntityCardinality<IElement>(o, 2), })); this.AddElement(atoms, elementProvider, "Ag", "Silver"); this.AddElement(atoms, elementProvider, "Al", "Aluminium"); this.AddElement(atoms, elementProvider, "As", "Arsenic"); this.AddElement(atoms, elementProvider, "Au", "Gold"); this.AddElement(atoms, elementProvider, "B", "Boron"); this.AddElement(atoms, elementProvider, "Br", "Bromine"); this.AddElement(atoms, elementProvider, "C", "Carbon"); this.AddElement(atoms, elementProvider, "Ca", "Calcium"); this.AddElement(atoms, elementProvider, "Cd", "Cadmium"); this.AddElement(atoms, elementProvider, "Cl", "Chlorine"); this.AddElement(atoms, elementProvider, "Co", "Cobalt"); this.AddElement(atoms, elementProvider, "Cr", "Chromium"); this.AddElement(atoms, elementProvider, "Cu", "Copper"); atoms.Add("dHex", new UnimodCompositionAtom("dHex", "Deoxy-hexose", new[] { new EntityCardinality<IElement>(c, 6), new EntityCardinality<IElement>(h, 10), new EntityCardinality<IElement>(o, 4), })); this.AddElement(atoms, elementProvider, "F", "Fluorine"); this.AddElement(atoms, elementProvider, "Fe", "Iron"); this.AddElement(atoms, elementProvider, "H", "Hydrogen"); atoms.Add("Hep", new UnimodCompositionAtom("Hep", "Heptose", new[] { new EntityCardinality<IElement>(c, 7), new EntityCardinality<IElement>(h, 12), new EntityCardinality<IElement>(o, 6), })); atoms.Add("Hex", new UnimodCompositionAtom("Hex", "Hexose", new[] { new EntityCardinality<IElement>(c, 6), new EntityCardinality<IElement>(h, 10), new EntityCardinality<IElement>(o, 5), })); // Not sure about C6H8O6 atoms.Add("HexA", new UnimodCompositionAtom("HexA", "Hexuronic acid", new[] { new EntityCardinality<IElement>(c, 6), new EntityCardinality<IElement>(h, 8), new EntityCardinality<IElement>(o, 6), })); // Not sure about C6H11O4N atoms.Add("HexN", new UnimodCompositionAtom("HexN", "Hexosamine", new[] { new EntityCardinality<IElement>(c, 6), new EntityCardinality<IElement>(h, 11), new EntityCardinality<IElement>(o, 4), new EntityCardinality<IElement>(n, 1), })); atoms.Add("HexNAc", new UnimodCompositionAtom("HexNAc", "N-Acetyl Hexosamine", new[] { new EntityCardinality<IElement>(c, 8), new EntityCardinality<IElement>(h, 13), new EntityCardinality<IElement>(o, 5), new EntityCardinality<IElement>(n, 1), })); this.AddElement(atoms, elementProvider, "Hg", "Mercury"); this.AddElement(atoms, elementProvider, "I", "Iodine"); this.AddElement(atoms, elementProvider, "K", "Potassium"); // Should be Hex(2) + HexA atoms.Add("Kdn", new UnimodCompositionAtom("Kdn", "3-deoxy-d-glycero-D-galacto-nonulosonic acid", new[] { new EntityCardinality<IElement>(c, 18), new EntityCardinality<IElement>(h, 28), new EntityCardinality<IElement>(o, 16), })); // Never used //atoms.Add("Kdo", new UnimodCompositionAtom("13C", "2-keto-3-deoxyoctulosonic acid", new[] //{ // new EntityCardinality<IElement>(c, 0), // new EntityCardinality<IElement>(h, 0), // new EntityCardinality<IElement>(o, 0), //})); this.AddElement(atoms, elementProvider, "Li", "Lithium"); atoms.Add("Me", new UnimodCompositionAtom("Me", "Methyl", new[] { new EntityCardinality<IElement>(c, 1), new EntityCardinality<IElement>(h, 2), })); this.AddElement(atoms, elementProvider, "Mg", "Magnesium"); this.AddElement(atoms, elementProvider, "Mn", "Manganese"); this.AddElement(atoms, elementProvider, "Mo", "Molybdenum"); this.AddElement(atoms, elementProvider, "N", "Nitrogen"); this.AddElement(atoms, elementProvider, "Na", "Sodium"); atoms.Add("NeuAc", new UnimodCompositionAtom("NeuAc", "N-acetyl neuraminic acid", new[] { new EntityCardinality<IElement>(c, 11), new EntityCardinality<IElement>(h, 17), new EntityCardinality<IElement>(o, 8), new EntityCardinality<IElement>(n, 1), })); atoms.Add("NeuGc", new UnimodCompositionAtom("NeuGc", "N-glycoyl neuraminic acid", new[] { new EntityCardinality<IElement>(c, 11), new EntityCardinality<IElement>(h, 17), new EntityCardinality<IElement>(o, 9), new EntityCardinality<IElement>(n, 1), })); this.AddElement(atoms, elementProvider, "Ni", "Nickel"); this.AddElement(atoms, elementProvider, "O", "Oxygen"); this.AddElement(atoms, elementProvider, "P", "Phosphorous"); this.AddElement(atoms, elementProvider, "Pd", "Palladium"); atoms.Add("Pent", new UnimodCompositionAtom("Pent", "Pentose", new[] { new EntityCardinality<IElement>(c, 5), new EntityCardinality<IElement>(h, 8), new EntityCardinality<IElement>(o, 4), })); // Never used //atoms.Add("Phos", new UnimodCompositionAtom("13C", "Phosphate", new[] //{ // new EntityCardinality<IElement>(c, 0), // new EntityCardinality<IElement>(h, 0), // new EntityCardinality<IElement>(o, 0), // new EntityCardinality<IElement>(n, 0), //})); this.AddElement(atoms, elementProvider, "Pt", "Platinum"); this.AddElement(atoms, elementProvider, "Ru", "Ruthenium"); this.AddElement(atoms, elementProvider, "S", "Sulphur"); this.AddElement(atoms, elementProvider, "Se", "Selenium"); atoms.Add("Sulf", new UnimodCompositionAtom("Sulf", "Sulphate", new[] { new EntityCardinality<IElement>(s, 1), new EntityCardinality<IElement>(o, 3), })); atoms.Add("Water", new UnimodCompositionAtom("Water", "Water", new[] { new EntityCardinality<IElement>(h, 2), new EntityCardinality<IElement>(o, 1), })); this.AddElement(atoms, elementProvider, "Zn", "Zinc"); return atoms; } private void AddElement(Dictionary<string, UnimodCompositionAtom> atoms, IElementProvider elementProvider, string symbol, string name) { IElement element = elementProvider.GetElement(symbol); atoms.Add(symbol, new UnimodCompositionAtom(symbol, name, new[] { new EntityCardinality<IElement>(element, 1) })); } private void AddElement(Dictionary<string, UnimodCompositionAtom> atoms, IElementProvider elementProvider, string symbol, string name, string elementSymbol, int? fixedIsotopeNumber = null) { IElement element = elementProvider.GetElement(elementSymbol, fixedIsotopeNumber); atoms.Add(symbol, new UnimodCompositionAtom(symbol, name, new[] { new EntityCardinality<IElement>(element, 1) })); } /// <summary> /// Gets the unimod composition atom. /// </summary> /// <param name="symbol">The symbol.</param> /// <returns></returns> public UnimodCompositionAtom GetUnimodCompositionAtom(string symbol) { return _atoms[symbol]; } } }
44.277533
115
0.565217
[ "MIT" ]
acesnik/TestLib
src/TopDownProteomics/Chemistry/Unimod/UnimodHardCodedAtomProvider.cs
10,053
C#
using System; using System.Json; using VeritySDK.Protocols; using VeritySDK.Utils; namespace VeritySDK.Protocols.UpdateConfigs { /// <summary> /// A class for controlling a 0.6 UpdateConfigs protocol. /// </summary> public class UpdateConfigsV0_6 : AbstractProtocol { #region Protocol identificator /// <summary> /// The qualifier for the message family. Uses Evernym's qualifier. /// </summary> public override string qualifier() { return Util.EVERNYM_MSG_QUALIFIER; } /// <summary> /// The name for the message family. /// </summary> public override string family() { return "update-configs"; } /// <summary> /// The version for the message family. /// </summary> public override string version() { return "0.6"; } #endregion #region Constructors /// <summary> /// Constructor UpdateConfigsV0_6 object /// </summary> public UpdateConfigsV0_6() { } /// <summary> /// Constructor UpdateConfigsV0_6 object /// </summary> /// <param name="threadId">the thread id of the already started protocol</param> public UpdateConfigsV0_6(string threadId) : base(threadId) { } /// <summary> /// Constructor UpdateConfigsV0_6 object /// </summary> public UpdateConfigsV0_6(string name, string logoUrl) { this.name = name; this.logoUrl = logoUrl; } #endregion string UPDATE_CONFIGS = "update"; string GET_STATUS = "get-status"; string name; string logoUrl; /// <summary> /// Directs verity-application to update the configuration register with the verity-application /// </summary> /// <param name="context">an instance of the Context object initialized to a verity-application agent</param> public void update(Context context) { send(context, updateMsg(context)); } /// <summary> /// Directs verity-application to update the configuration register with the verity-application /// </summary> /// <param name="context">an instance of the Context object initialized to a verity-application agent</param> /// <returns>the constructed message (JSON object)</returns> public JsonObject updateMsg(Context context) { JsonObject message = new JsonObject(); message.Add("@type", messageType(UPDATE_CONFIGS)); message.Add("@id", getNewId()); JsonArray configs = new JsonArray(); JsonObject item1 = new JsonObject(); item1.Add("name", "name"); item1.Add("value", this.name); configs.Add(item1); JsonObject item2 = new JsonObject(); item2.Add("name", "logoUrl"); item2.Add("value", this.logoUrl); configs.Add(item2); message.Add("configs", configs); return message; } /// <summary> /// Directs verity-application to update the configuration register with the verity-application /// </summary> /// <param name="context">an instance of the Context object initialized to a verity-application agent</param> /// <returns>the byte array ready for transport</returns> public byte[] updateMsgPacked(Context context) { return packMsg(context, updateMsg(context)); } /// <summary> /// Ask for status from the verity-application agent /// </summary> /// <param name="context">an instance of the Context object initialized to a verity-application agent</param> public void status(Context context) { send(context, statusMsg(context)); } /// <summary> /// Ask for status from the verity-application agent /// </summary> /// <param name="context">an instance of the Context object initialized to a verity-application agent</param> /// <returns>the constructed message (JSON object)</returns> public JsonObject statusMsg(Context context) { JsonObject msg = new JsonObject(); msg.Add("@type", messageType(GET_STATUS)); msg.Add("@id", getNewId()); addThread(msg); return msg; } /// <summary> /// Creates and packages message without sending it. /// </summary> /// <param name="context">an instance of the Context object initialized to a verity-application agent</param> /// <returns>the byte array ready for transport</returns> public byte[] statusMsgPacked(Context context) { return packMsg(context, statusMsg(context)); } } }
35.115108
117
0.589428
[ "Apache-2.0" ]
ThinkWardCo/verity-sdk
sdk/dotnet-sdk/src/VeritySDK/Protocols/UpdateConfigs/v0_6/UpdateConfigsV0_6.cs
4,881
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Input; using Lada.Windows.Input; using Lada.Windows.MotionFlow; namespace Lada.Windows.Input { public class MouseWheelZoomClient : MouseWheelClient { #region Fields private MouseWheelSmoothing _smoothing; private ModifierKeys _modifiers; #endregion #region Initialization public MouseWheelZoomClient(IMouseWheelController controller) : base(controller) { } #endregion #region IMouseWheelClient public override double MotionIncrement { get { return ZoomElement.ZoomIncrement; } } #endregion #region MouseWheelClient protected override void OnLoading() { base.OnLoading(); var element = Controller.Element; _smoothing = MouseWheel.GetZoomSmoothing(element); _modifiers = MouseWheel.GetZoomModifiers(element); MouseWheel.ZoomSmoothingProperty.AddValueChanged(element, OnSmoothingChanged); MouseWheel.ZoomModifiersProperty.AddValueChanged(element, OnModifiersChanged); } protected override void OnUnloading() { var element = Controller.Element; MouseWheel.ZoomModifiersProperty.RemoveValueChanged(element, OnModifiersChanged); MouseWheel.ZoomSmoothingProperty.RemoveValueChanged(element, OnSmoothingChanged); base.OnUnloading(); } protected override IMouseWheelInputListener CreateBehavior() { if (Enhanced) { switch (Smoothing) { case MouseWheelSmoothing.None: return new MouseWheelZoomBehavior(this); case MouseWheelSmoothing.Linear: return new MouseWheelSmoothZoomBehavior(this, new MouseWheelLinearFilter()); case MouseWheelSmoothing.Smooth: return new MouseWheelSmoothZoomBehavior(this, new MouseWheelSmoothingFilter()); default: throw new NotSupportedException(); } } else return new MouseWheelNativeBehavior(this); } #endregion #region IMouseWheelClient public override MouseWheelSmoothing Smoothing { get { return _smoothing; } protected set { if (_smoothing == value) return; _smoothing = value; InvalidateBehavior(); } } public override ModifierKeys Modifiers { get { return _modifiers; } } #endregion #region IMotionTarget public override bool CanMove(IMotionInfo info, object context) { var z = ZoomElement; return info.Direction < 0 ? z.CanIncreaseZoom : z.CanDecreaseZoom; } public override double Coerce(IMotionInfo info, object context, double delta) { var z = ZoomElement; int direction = info.Direction; if (direction < 0) { // increasing zoom var zoomableDelta = z.Zoom - z.MaxZoom; return Math.Max(zoomableDelta, delta); } else { // decreasing zoom var zoomableDelta = z.Zoom - z.MinZoom; return Math.Min(zoomableDelta, delta); } } public override void Move(IMotionInfo info, object context, double delta) { ZoomElement.Zoom -= delta; } #endregion #region Helpers private IZoomElement ZoomElement { get { return (Controller as MouseWheelFrameworkLevelController).FrameworkLevelElement as IZoomElement; } } private void OnSmoothingChanged(object sender, EventArgs e) { Smoothing = MouseWheel.GetZoomSmoothing(sender as DependencyObject); } private void OnModifiersChanged(object sender, EventArgs e) { _modifiers = MouseWheel.GetZoomModifiers(sender as DependencyObject); } #endregion } }
31.101695
145
0.696185
[ "MIT" ]
Soletude/WpfMouseWheelLib
Lib/Windows/Input/MouseWheel/Zooming/MouseWheelZoomClient.cs
3,672
C#
using System.Collections.Generic; using System.IO; using System.Numerics; using NUnit.Framework; using Vts.Common; using Vts.IO; using Vts.MonteCarlo; using Vts.MonteCarlo.Detectors; using Vts.MonteCarlo.IO; using Vts.MonteCarlo.Tissues; namespace Vts.Test.MonteCarlo { [TestFixture] public class DetectorIOTests { /// <summary> /// list of temporary files created by these unit tests /// </summary> List<string> listOfTestDetectors = new List<string>() { // 0D detectors "testrdiffuse", "testrdiffuse_2", // TallySecondMoment is set to true for this detector "testtdiffuse", "testatotal", "testatotal_2", // TallySecondMoment is set to true for this detector // 1D detectors "testrofangle", "testrofrho", "testtofangle", "testtofrho", "testpmcrofrho", "testpmcrofrho_2", // TallySecondMoment is set to true for this detector // 2D detectors "testrofrhoandangle", "testrofrhoandtime", "testrofrhoandtime_2", // TallySecondMoment is set to true for this detector "testrofrhoandomega", "testrofrhoandomega_2", // TallySecondMoment is set to true for this detector "testrofxandy", "testtofrhoandangle", "testrofrhoandangle_2", // TallySecondMoment is set to true for this detector "testaofrhoandz", "testfluenceofrhoandz", "testreflectedmtofrhoandsubregionhist", "testreflectedmtofrhoandsubregionhist_2", // TallySecondMoment is set to true for this detector "testreflectedmtofrhoandsubregionhist_FractionalMT", // additional output for this detector "testpmcrofrhoandtime", "testpmcrofrhoandtime_2", // TallySecondMoment is set to true for this detector // 3D detectors "testfluenceofrhoandzandtime", "testfluenceofrhoandzandtime_2", // TallySecondMoment is set to true for this detector }; /// <summary> /// clear all previously generated files. /// </summary> [TestFixtureSetUp] public void clear_previously_generated_files() { // delete any previously generated files foreach (var testDetector in listOfTestDetectors) { if (File.Exists(testDetector)) { File.Delete(testDetector); } if (File.Exists(testDetector + ".txt")) { File.Delete(testDetector + ".txt"); } } } /// <summary> /// clear all newly generated files /// </summary> [TestFixtureTearDown] public void clear_newly_generated_files() { // delete any newly generated files foreach (var testDetector in listOfTestDetectors) { if (File.Exists(testDetector)) { File.Delete(testDetector); } if (File.Exists(testDetector + ".txt")) { File.Delete(testDetector + ".txt"); } } } /// <summary> /// test to verify that DetectorIO.WriteDetectorToFile and DetectorIO.ReadDetectorToFile /// are working correctly for 0D detectors. /// </summary> [Test] public void validate_RDiffuseDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrdiffuse"; IDetectorInput detectorInput = new RDiffuseDetectorInput() {TallySecondMoment = true, Name=detectorName}; var detector = (RDiffuseDetector) detectorInput.CreateDetector(); detector.Mean = 100; detector.SecondMoment = 50; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (RDiffuseDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean, 100); Assert.AreEqual(dcloned.SecondMoment, 50); // 0D detectors 2nd moment written to .txt file } [Test] public void validate_TDiffuseDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testtdiffuse"; IDetectorInput detectorInput = new TDiffuseDetectorInput() {TallySecondMoment = false, Name = detectorName}; var detector = (TDiffuseDetector) detectorInput.CreateDetector(); detector.Mean = 100; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (TDiffuseDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean, 100); } [Test] public void validate_ATotalDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testatotal"; IDetectorInput detectorInput = new ATotalDetectorInput() {TallySecondMoment = true, Name = detectorName}; var detector = (ATotalDetector) detectorInput.CreateDetector(); detector.Mean = 100; detector.SecondMoment = 50; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ATotalDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean, 100); Assert.AreEqual(dcloned.SecondMoment, 50); } /// <summary> /// test to verify that DetectorIO.WriteDetectorToFile and DetectorIO.ReadDetectorToFile /// are working correctly for 1D detector. /// </summary> /// [Test] public void validate_ROfAngleDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrofangle"; IDetectorInput detectorInput = new ROfAngleDetectorInput() { Angle = new DoubleRange(0, 10, 4), TallySecondMoment = false, Name = detectorName, }; var detector = (ROfAngleDetector)detectorInput.CreateDetector(); detector.Mean = new double[] { 100, 200, 300 }; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ROfAngleDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0], 100); Assert.AreEqual(dcloned.Mean[1], 200); Assert.AreEqual(dcloned.Mean[2], 300); } [Test] public void validate_ROfRhoDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrofrho"; IDetectorInput detectorInput = new ROfRhoDetectorInput() { Rho=new DoubleRange(0, 10, 4), TallySecondMoment = false, Name = detectorName }; var detector = (ROfRhoDetector) detectorInput.CreateDetector(); detector.Mean = new double[] {100, 200, 300}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ROfRhoDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0], 100); Assert.AreEqual(dcloned.Mean[1], 200); Assert.AreEqual(dcloned.Mean[2], 300); } [Test] public void validate_TOfAngleDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testtofangle"; IDetectorInput detectorInput = new TOfAngleDetectorInput() { Angle = new DoubleRange(0, 10, 4), TallySecondMoment = false, Name = detectorName, }; var detector = (TOfAngleDetector) detectorInput.CreateDetector(); detector.Mean = new double[] {100, 200, 300}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (TOfAngleDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0], 100); Assert.AreEqual(dcloned.Mean[1], 200); Assert.AreEqual(dcloned.Mean[2], 300); } [Test] public void validate_TOfRhoDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testtofrho"; IDetectorInput detectorInput = new TOfRhoDetectorInput() { Rho = new DoubleRange(0, 10, 4), TallySecondMoment = false, Name = detectorName, }; var detector = (TOfRhoDetector) detectorInput.CreateDetector(); detector.Mean = new double[] {100, 200, 300}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (TOfRhoDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0], 100); Assert.AreEqual(dcloned.Mean[1], 200); Assert.AreEqual(dcloned.Mean[2], 300); } [Test] public void validate_pMCROfRhoDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testpmcrofrho"; IDetectorInput detectorInput = new pMCROfRhoDetectorInput() { Rho = new DoubleRange(0, 10, 4), PerturbedOps = new List<OpticalProperties>() {new OpticalProperties()}, PerturbedRegionsIndices = new List<int>() {1}, TallySecondMoment = true, // tally SecondMoment Name = detectorName, }; var detector = (pMCROfRhoDetector) detectorInput.CreateDetector(); detector.Mean = new double[] {100, 200, 300}; detector.SecondMoment = new double[] {50, 150, 250}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (pMCROfRhoDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); // ckh: not sure how I would read in 2nd moment data in detector + "_2" Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0], 100); Assert.AreEqual(dcloned.Mean[1], 200); Assert.AreEqual(dcloned.Mean[2], 300); } /// <summary> /// test to verify that DetectorIO.WriteDetectorToFile and DetectorIO.ReadDetectorToFile /// are working correctly for 2D detector. /// </summary> [Test] public void validate_ROfRhoAndAngleDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrofrhoandangle"; IDetectorInput detectorInput = new ROfRhoAndAngleDetectorInput() { Rho = new DoubleRange(0, 10, 3), Angle = new DoubleRange(0, 1, 4), TallySecondMoment = true, // tally SecondMoment Name = detectorName, }; var detector = (ROfRhoAndAngleDetector)detectorInput.CreateDetector(); detector.Mean = new double[,] { { 1, 2, 3 }, { 4, 5, 6 } }; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ROfRhoAndAngleDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } [Test] public void validate_ROfRhoAndTimeDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrofrhoandtime"; IDetectorInput detectorInput = new ROfRhoAndTimeDetectorInput() { Rho = new DoubleRange(0, 10, 3), Time = new DoubleRange(0, 1, 4), TallySecondMoment = true, // tally SecondMoment Name = detectorName, }; var detector = (ROfRhoAndTimeDetector) detectorInput.CreateDetector(); detector.Mean = new double[,] {{1, 2, 3}, {4, 5, 6}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ROfRhoAndTimeDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } [Test] public void validate_ROfRhoAndOmegaDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrofrhoandomega"; IDetectorInput detectorInput = new ROfRhoAndOmegaDetectorInput() { Rho = new DoubleRange(0, 10, 3), Omega = new DoubleRange(0, 1, 4), TallySecondMoment = true, // tally Second Moment Name = detectorName, }; var detector = (ROfRhoAndOmegaDetector)detectorInput.CreateDetector(); detector.Mean = new Complex[,] { { 1 + Complex.ImaginaryOne*1, 2 + Complex.ImaginaryOne*2, 3 + Complex.ImaginaryOne*3, 4 + Complex.ImaginaryOne*4 }, { 5 + Complex.ImaginaryOne*5, 6 + Complex.ImaginaryOne*6, 7 + Complex.ImaginaryOne*7, 8 + Complex.ImaginaryOne*8 } }; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ROfRhoAndOmegaDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1 + Complex.ImaginaryOne * 1); Assert.AreEqual(dcloned.Mean[0, 1], 2 + Complex.ImaginaryOne * 2); Assert.AreEqual(dcloned.Mean[0, 2], 3 + Complex.ImaginaryOne * 3); Assert.AreEqual(dcloned.Mean[0, 3], 4 + Complex.ImaginaryOne * 4); Assert.AreEqual(dcloned.Mean[1, 0], 5 + Complex.ImaginaryOne * 5); Assert.AreEqual(dcloned.Mean[1, 1], 6 + Complex.ImaginaryOne * 6); Assert.AreEqual(dcloned.Mean[1, 2], 7 + Complex.ImaginaryOne * 7); Assert.AreEqual(dcloned.Mean[1, 3], 8 + Complex.ImaginaryOne * 8); } [Test] public void validate_ROfXAndYDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testrofxandy"; IDetectorInput detectorInput = new ROfXAndYDetectorInput() { X = new DoubleRange(0, 10, 3), Y = new DoubleRange(0, 1, 4), TallySecondMoment = false, Name = detectorName, }; var detector = (ROfXAndYDetector)detectorInput.CreateDetector(); detector.Mean = new double[,] { { 1, 2, 3 }, { 4, 5, 6 } }; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ROfXAndYDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } [Test] public void validate_TOfRhoAndAngleDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testtofrhoandangle"; IDetectorInput detectorInput = new TOfRhoAndAngleDetectorInput() { Rho = new DoubleRange(0, 10, 3), Angle = new DoubleRange(0, 1, 4), TallySecondMoment = false, Name = detectorName, }; var detector = (TOfRhoAndAngleDetector) detectorInput.CreateDetector(); detector.Mean = new double[,] {{1, 2, 3}, {4, 5, 6}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (TOfRhoAndAngleDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } [Test] public void validate_AOfRhoAndZDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testaofrhoandz"; IDetectorInput detectorInput = new AOfRhoAndZDetectorInput() { Rho = new DoubleRange(0, 10, 3), Z = new DoubleRange(0, 1, 4), TallySecondMoment = false, Name = detectorName, }; var detector = (AOfRhoAndZDetector) detectorInput.CreateDetector(); detector.Mean = new double[,] {{1, 2, 3}, {4, 5, 6}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (AOfRhoAndZDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } [Test] public void validate_FluenceOfRhoAndZDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testfluenceofrhoandz"; IDetectorInput detectorInput = new FluenceOfRhoAndZDetectorInput() { Rho = new DoubleRange(0, 10, 3), Z = new DoubleRange(0, 1, 4), TallySecondMoment = false, // tally SecondMoment Name = detectorName, }; var detector = (FluenceOfRhoAndZDetector)detectorInput.CreateDetector(); detector.Mean = new double[,] {{1, 2, 3}, {4, 5, 6}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (FluenceOfRhoAndZDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } [Test] public void validate_ReflectedMTOfRhoAndSubregionHistDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testreflectedmtofrhoandsubregionhist"; var tissue = new MultiLayerTissue( new ITissueRegion[] { new LayerTissueRegion( new DoubleRange(double.NegativeInfinity, 0.0), new OpticalProperties(0.0, 1e-10, 1.0, 1.0)), new LayerTissueRegion( new DoubleRange(0.0, 100.0), new OpticalProperties(0.01, 1.0, 0.7, 1.33)), new LayerTissueRegion( new DoubleRange(100.0, double.PositiveInfinity), new OpticalProperties(0.0, 1e-10, 1.0, 1.0)) } ); IDetectorInput detectorInput = new ReflectedMTOfRhoAndSubregionHistDetectorInput() { Rho = new DoubleRange(0, 10, 3), MTBins = new DoubleRange(0, 10, 3), FractionalMTBins = new DoubleRange(0, 1, 2), TallySecondMoment = true, // tally SecondMoment Name = detectorName, }; var detector = (ReflectedMTOfRhoAndSubregionHistDetector)detectorInput.CreateDetector(); // need to initialize detector so that NumSubregions gets set detector.Initialize(tissue, null); // Mean has dimensions [Rho.Count - 1, MTBins.Count - 1] detector.Mean = new double[,] {{1, 2}, {3, 4}}; // FractionalMT has dimensions [Rho.Count - 1, MTBins.Count - 1, NumSubregions, FractionalMTBins.Count + 1]=[2,2,3,3] detector.FractionalMT = new double[,,,] {{{{1,2,3},{4,5,6},{7,8,9}},{{10,11,12},{13,14,15},{16,17,18}}}, {{{19,20,21},{22,23,24},{25,26,27}},{{28,29,30},{31,32,33},{34,35,36}}}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (ReflectedMTOfRhoAndSubregionHistDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[1, 0], 3); Assert.AreEqual(dcloned.Mean[1, 1], 4); Assert.AreEqual(dcloned.FractionalMT[0, 0, 0 ,0], 1); Assert.AreEqual(dcloned.FractionalMT[0, 0, 0, 1], 2); Assert.AreEqual(dcloned.FractionalMT[0, 0, 0, 2], 3); Assert.AreEqual(dcloned.FractionalMT[0, 0, 1, 0], 4); Assert.AreEqual(dcloned.FractionalMT[0, 0, 1, 1], 5); Assert.AreEqual(dcloned.FractionalMT[0, 0, 1, 2], 6); Assert.AreEqual(dcloned.FractionalMT[0, 0, 2, 0], 7); Assert.AreEqual(dcloned.FractionalMT[0, 0, 2, 1], 8); Assert.AreEqual(dcloned.FractionalMT[0, 0, 2, 2], 9); Assert.AreEqual(dcloned.FractionalMT[0, 1, 0, 0], 10); Assert.AreEqual(dcloned.FractionalMT[0, 1, 0, 1], 11); Assert.AreEqual(dcloned.FractionalMT[0, 1, 0, 2], 12); Assert.AreEqual(dcloned.FractionalMT[0, 1, 1, 0], 13); Assert.AreEqual(dcloned.FractionalMT[0, 1, 1, 1], 14); Assert.AreEqual(dcloned.FractionalMT[0, 1, 1, 2], 15); Assert.AreEqual(dcloned.FractionalMT[0, 1, 2, 0], 16); Assert.AreEqual(dcloned.FractionalMT[0, 1, 2, 1], 17); Assert.AreEqual(dcloned.FractionalMT[0, 1, 2, 2], 18); Assert.AreEqual(dcloned.FractionalMT[1, 0, 0, 0], 19); Assert.AreEqual(dcloned.FractionalMT[1, 0, 0, 1], 20); Assert.AreEqual(dcloned.FractionalMT[1, 0, 0, 2], 21); Assert.AreEqual(dcloned.FractionalMT[1, 0, 1, 0], 22); Assert.AreEqual(dcloned.FractionalMT[1, 0, 1, 1], 23); Assert.AreEqual(dcloned.FractionalMT[1, 0, 1, 2], 24); Assert.AreEqual(dcloned.FractionalMT[1, 0, 2, 0], 25); Assert.AreEqual(dcloned.FractionalMT[1, 0, 2, 1], 26); Assert.AreEqual(dcloned.FractionalMT[1, 0, 2, 2], 27); Assert.AreEqual(dcloned.FractionalMT[1, 1, 0, 0], 28); Assert.AreEqual(dcloned.FractionalMT[1, 1, 0, 1], 29); Assert.AreEqual(dcloned.FractionalMT[1, 1, 0, 2], 30); Assert.AreEqual(dcloned.FractionalMT[1, 1, 1, 0], 31); Assert.AreEqual(dcloned.FractionalMT[1, 1, 1, 1], 32); Assert.AreEqual(dcloned.FractionalMT[1, 1, 1, 2], 33); Assert.AreEqual(dcloned.FractionalMT[1, 1, 2, 0], 34); Assert.AreEqual(dcloned.FractionalMT[1, 1, 2, 1], 35); Assert.AreEqual(dcloned.FractionalMT[1, 1, 2, 2], 36); } [Test] public void validate_pMCROfRhoAndTimeDetector_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testpmcrofrhoandtime"; IDetectorInput detectorInput = new pMCROfRhoAndTimeDetectorInput() { Rho = new DoubleRange(0, 10, 3), Time = new DoubleRange(0, 1, 4), PerturbedOps = new List<OpticalProperties>() {new OpticalProperties()}, PerturbedRegionsIndices = new List<int>() {1}, TallySecondMoment = true, // tally SecondMoment Name = detectorName, }; var detector = (pMCROfRhoAndTimeDetector)detectorInput.CreateDetector(); detector.Mean = new double[,] {{1, 2, 3}, {4, 5, 6}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (pMCROfRhoAndTimeDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 2], 3); Assert.AreEqual(dcloned.Mean[1, 0], 4); Assert.AreEqual(dcloned.Mean[1, 1], 5); Assert.AreEqual(dcloned.Mean[1, 2], 6); } /// <summary> /// test to verify that DetectorIO.WriteDetectorToFile and DetectorIO.ReadDetectorToFile /// are working correctly for 3D detector. /// </summary> [Test] public void validate_FluenceOfRhoAndZAndTime_deserialized_class_is_correct_when_using_WriteReadDetectorToFile() { string detectorName = "testfluenceofrhoandzandtime"; IDetectorInput detectorInput = new FluenceOfRhoAndZAndTimeDetectorInput() { Rho = new DoubleRange(0, 10, 3), Z = new DoubleRange(0, 10, 3), Time = new DoubleRange(0, 1, 4), TallySecondMoment = true, Name = detectorName, }; var detector = (FluenceOfRhoAndZAndTimeDetector)detectorInput.CreateDetector(); detector.Mean = new double[,,] {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}}; DetectorIO.WriteDetectorToFile(detector, ""); var dcloned = (FluenceOfRhoAndZAndTimeDetector)DetectorIO.ReadDetectorFromFile(detectorName, ""); Assert.AreEqual(dcloned.Name, detectorName); Assert.AreEqual(dcloned.Mean[0, 0, 0], 1); Assert.AreEqual(dcloned.Mean[0, 0, 1], 2); Assert.AreEqual(dcloned.Mean[0, 0, 2], 3); Assert.AreEqual(dcloned.Mean[0, 1, 0], 4); Assert.AreEqual(dcloned.Mean[0, 1, 1], 5); Assert.AreEqual(dcloned.Mean[0, 1, 2], 6); Assert.AreEqual(dcloned.Mean[1, 0, 0], 7); Assert.AreEqual(dcloned.Mean[1, 0, 1], 8); Assert.AreEqual(dcloned.Mean[1, 0, 2], 9); Assert.AreEqual(dcloned.Mean[1, 1, 0], 10); Assert.AreEqual(dcloned.Mean[1, 1, 1], 11); Assert.AreEqual(dcloned.Mean[1, 1, 2], 12); } //private static Time Clone<Time>(Time myObject) //{ // using (MemoryStream ms = new MemoryStream(1024)) // { // var dcs = new DataContractSerializer(typeof(Time)); // dcs.WriteObject(ms, myObject); // ms.Seek(0, SeekOrigin.Begin); // return (Time)dcs.ReadObject(ms); // } //} } }
48.458404
190
0.586399
[ "MIT" ]
VirtualPhotonics/Vts.Silverlight
src/Vts.Test/MonteCarlo/IO/DetectorIOTests.cs
28,542
C#
#region License // FreeBSD License // Copyright (c) 2010 - 2013, Andrew Trevarrow and Derek Wilson // 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. // // 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. #endregion using System.Windows; using PodcastUtilities.Common.Tests; namespace PodcastUtilities.Presentation.Tests.DataObjectUriExtractorTests { public abstract class WhenTestingDataObjectUriExtractor : WhenTestingBehaviour { protected DataObjectUriExtractor Extractor { get; set; } protected IDataObject DataObject { get; set; } protected string ExtractedUri { get; set; } protected override void GivenThat() { base.GivenThat(); Extractor = new DataObjectUriExtractor(); DataObject = GenerateMock<IDataObject>(); } protected override void When() { ExtractedUri = Extractor.GetUri(DataObject); } } }
44.857143
206
0.722475
[ "BSD-2-Clause" ]
derekwilson/PodcastUtilities
PodcastUtilities.Presentation.Tests/DataObjectUriExtractorTests/WhenTestingDataObjectUriExtractor.cs
2,198
C#
// SPDX-License-Identifier: Apache-2.0 // Licensed to the Ed-Fi Alliance under one or more agreements. // The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0. // See the LICENSE and NOTICES files in the project root for more information. using System.ComponentModel.DataAnnotations.Schema; using MappingEdu.Core.Domain; namespace MappingEdu.Core.DataAccess.Entities.Mappings { internal class MappedSystemExtensionMapping : EntityMappingBase<MappedSystemExtension> { public MappedSystemExtensionMapping() { HasKey(x => x.MappedSystemExtensionId); ToTable("MappedSystemExtension"); Property(t => t.MappedSystemExtensionId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity); Property(t => t.ShortName).HasMaxLength(5); HasRequired(t => t.MappedSystem) .WithMany(t => t.Extensions) .HasForeignKey(t => t.MappedSystemId) .WillCascadeOnDelete(false); HasOptional(t => t.ExtensionMappedSystem) .WithMany(t => t.ExtensionOfs) .HasForeignKey(t => t.ExtensionMappedSystemId) .WillCascadeOnDelete(false); } } }
40.322581
114
0.6688
[ "Apache-2.0" ]
Ed-Fi-Exchange-OSS/MappingEDU
src/MappingEdu.Core.DataAccess/Entities/Mappings/MappedSystemExtensionMapping.cs
1,252
C#
using AdjustSdk; using System; using System.Diagnostics; using Windows.ApplicationModel; using Windows.ApplicationModel.Activation; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Navigation; // The Blank Application template is documented at http://go.microsoft.com/fwlink/?LinkId=234227 namespace AdjustWSExample { /// <summary> /// Provides application-specific behavior to supplement the default Application class. /// </summary> sealed partial class App : Application { /// <summary> /// Initializes the singleton application object. This is the first line of authored code /// executed, and as such is the logical equivalent of main() or WinMain(). /// </summary> public App() { this.InitializeComponent(); this.Suspending += OnSuspending; } /// <summary> /// Invoked when the application is launched normally by the end user. Other entry points /// will be used such as when the application is launched to open a specific file. /// </summary> /// <param name="e">Details about the launch request and process.</param> protected override void OnLaunched(LaunchActivatedEventArgs e) { // deprecated way of logging setup, use AdjustConfig constructor instead Adjust.SetupLogging( logDelegate: msg => System.Diagnostics.Debug.WriteLine(msg), logLevel: LogLevel.Verbose); // configure Adjust - without logging //var config = new AdjustConfig("{yourAppToken}", AdjustConfig.EnvironmentSandbox); // configure Adjust - with logging (Sandox env & Verbose log level) string appToken = "2fm9gkqubvpc"; string environment = AdjustConfig.EnvironmentSandbox; var config = new AdjustConfig(appToken, environment, msg => Debug.WriteLine(msg), LogLevel.Verbose); // configure app secret (available since v4.12) // config.SetAppSecret(0, 1000, 3000, 4000, 5000); // enable event buffering //config.EventBufferingEnabled = true; // set default tracker //config.DefaultTracker = "{YourDefaultTracker}"; ExampleOfVariousCallbacksSetup(config); // signal Adjust that the application was launched Adjust.ApplicationLaunching(config); // put the SDK in offline mode //Adjust.SetOfflineMode(offlineMode: true); // disable the SDK //Adjust.SetEnabled(enabled: false); #if DEBUG if (System.Diagnostics.Debugger.IsAttached) { this.DebugSettings.EnableFrameRateCounter = true; } #endif Frame rootFrame = Window.Current.Content as Frame; // Do not repeat app initialization when the Window already has content, // just ensure that the window is active if (rootFrame == null) { // Create a Frame to act as the navigation context and navigate to the first page rootFrame = new Frame(); // Set the default language rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0]; rootFrame.NavigationFailed += OnNavigationFailed; if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) { //TODO: Load state from previously suspended application } // Place the frame in the current Window Window.Current.Content = rootFrame; } if (rootFrame.Content == null) { // When the navigation stack isn't restored navigate to the first page, // configuring the new page by passing required information as a navigation // parameter rootFrame.Navigate(typeof(MainPage), e.Arguments); } // Ensure the current window is active Window.Current.Activate(); } private void ExampleOfVariousCallbacksSetup(AdjustConfig config) { // set event success tracking delegate config.EventTrackingSucceeded = adjustEventSuccess => { // ... //Debug.WriteLine("adjustEventSuccess: " + adjustEventSuccess); }; // set event failure tracking delegate config.EventTrackingFailed = adjustEventFailure => { // ... //Debug.WriteLine("adjustEventFailure: " + adjustEventFailure); }; // set session success tracking delegate config.SesssionTrackingSucceeded = adjustSessionSuccess => { // ... //Debug.WriteLine("adjustSessionSuccess: " + adjustSessionSuccess); }; // set session failure tracking delegate config.SesssionTrackingFailed = adjustSessionFailure => { // ... //Debug.WriteLine("adjustSessionFailure: " + adjustSessionFailure); }; // set attribution delegate config.AttributionChanged = attribution => { // ... Debug.WriteLine("attribution: " + attribution); }; // deferred deep linking scenario config.DeeplinkResponse = deepLinkUri => { //Debug.WriteLine("deeplink response: " + deepLinkUri); if (ShouldAdjustSdkLaunchTheDeeplink(deepLinkUri)) { return true; } return false; }; } /// <summary> /// Example Dummy method used in Deferred deep linking - within AdjustConfig.DeeplinkResponse delegate /// </summary> /// <param name="deepLinkUri"></param> /// <returns></returns> private bool ShouldAdjustSdkLaunchTheDeeplink(Uri deepLinkUri) { // dummy-example method // ... return true; } /// <summary> /// The OnActivated event handler receives all activation events. /// The Kind property indicates the type of activation event. /// This example is set up to handle Protocol activation events. /// NEEDED FOR DeepLinks /// </summary> /// <param name="args"></param> protected override void OnActivated(IActivatedEventArgs args) { if (args.Kind == ActivationKind.Protocol) { var eventArgs = args as ProtocolActivatedEventArgs; if (eventArgs != null) { Adjust.AppWillOpenUrl(eventArgs.Uri); } } base.OnActivated(args); } /// <summary> /// Invoked when Navigation to a certain page fails /// </summary> /// <param name="sender">The Frame which failed navigation</param> /// <param name="e">Details about the navigation failure</param> void OnNavigationFailed(object sender, NavigationFailedEventArgs e) { throw new Exception("Failed to load Page " + e.SourcePageType.FullName); } /// <summary> /// Invoked when application execution is being suspended. Application state is saved /// without knowing whether the application will be terminated or resumed with the contents /// of memory still intact. /// </summary> /// <param name="sender">The source of the suspend request.</param> /// <param name="e">Details about the suspend request.</param> private void OnSuspending(object sender, SuspendingEventArgs e) { var deferral = e.SuspendingOperation.GetDeferral(); //TODO: Save application state and stop any background activity deferral.Complete(); } } }
37.768519
110
0.57747
[ "MIT" ]
adjust/windows_sdk
Adjust/AdjustWSExample/App.xaml.cs
8,160
C#
namespace StripeTests { using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Threading.Tasks; using Stripe; using Xunit; public class AccountServiceTest : BaseStripeTest { private const string AccountId = "acct_123"; private readonly AccountService service; private readonly AccountCreateOptions createOptions; private readonly AccountUpdateOptions updateOptions; private readonly AccountListOptions listOptions; private readonly AccountRejectOptions rejectOptions; public AccountServiceTest(MockHttpClientFixture mockHttpClientFixture) : base(mockHttpClientFixture) { this.service = new AccountService(); this.createOptions = new AccountCreateOptions { Type = AccountType.Custom, BusinessProfile = new AccountBusinessProfileOptions { Name = "business name", }, BusinessType = "company", Company = new AccountCompanyOptions { Address = new AddressOptions { State = "CA", City = "City", Line1 = "Line1", Line2 = "Line2", PostalCode = "90210", Country = "US", }, Name = "Company name", }, ExternalAccountId = "tok_visa_debit", RequestedCapabilities = new List<string> { "card_payments", "platform_payments", }, Settings = new AccountSettingsOptions { Branding = new AccountSettingsBrandingOptions { LogoFileId = "file_123", }, CardPayments = new AccountSettingsCardPaymentsOptions { DeclineOn = new AccountSettingsDeclineOnOptions { AvsFailure = true, CvcFailure = true, }, StatementDescriptorPrefix = "STR", }, Dashboard = new AccountSettingsDashboardOptions { DisplayName = "dashboard_name", }, Payments = new AccountSettingsPaymentsOptions { StatementDescriptor = "STRIPE 123", }, Payouts = new AccountSettingsPayoutsOptions { DebitNegativeBalances = true, Schedule = new AccountSettingsPayoutsScheduleOptions { Interval = "monthly", MonthlyAnchor = "10", }, }, }, TosAcceptance = new AccountTosAcceptanceOptions { Date = DateTime.Parse("Mon, 01 Jan 2001 00:00:00Z"), Ip = "127.0.0.1", UserAgent = "User-Agent", }, }; this.updateOptions = new AccountUpdateOptions { Metadata = new Dictionary<string, string> { { "key", "value" }, }, }; this.rejectOptions = new AccountRejectOptions { Reason = "terms_of_service" }; this.listOptions = new AccountListOptions { Limit = 1, }; } [Fact] public void Create() { var account = this.service.Create(this.createOptions); this.AssertRequest(HttpMethod.Post, "/v1/accounts"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public async Task CreateAsync() { var account = await this.service.CreateAsync(this.createOptions); this.AssertRequest(HttpMethod.Post, "/v1/accounts"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public void Delete() { var deleted = this.service.Delete(AccountId); this.AssertRequest(HttpMethod.Delete, "/v1/accounts/acct_123"); Assert.NotNull(deleted); } [Fact] public async Task DeleteAsync() { var deleted = await this.service.DeleteAsync(AccountId); this.AssertRequest(HttpMethod.Delete, "/v1/accounts/acct_123"); Assert.NotNull(deleted); } [Fact] public void Get() { var account = this.service.Get(AccountId); this.AssertRequest(HttpMethod.Get, "/v1/accounts/acct_123"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public async Task GetAsync() { var account = await this.service.GetAsync(AccountId); this.AssertRequest(HttpMethod.Get, "/v1/accounts/acct_123"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public void GetSelf() { var account = this.service.GetSelf(); this.AssertRequest(HttpMethod.Get, "/v1/account"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public async Task GetSelfAsync() { var account = await this.service.GetSelfAsync(); this.AssertRequest(HttpMethod.Get, "/v1/account"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public void List() { var accounts = this.service.List(this.listOptions); this.AssertRequest(HttpMethod.Get, "/v1/accounts"); Assert.NotNull(accounts); Assert.Equal("list", accounts.Object); Assert.Single(accounts.Data); Assert.Equal("account", accounts.Data[0].Object); } [Fact] public async Task ListAsync() { var accounts = await this.service.ListAsync(this.listOptions); this.AssertRequest(HttpMethod.Get, "/v1/accounts"); Assert.NotNull(accounts); Assert.Equal("list", accounts.Object); Assert.Single(accounts.Data); Assert.Equal("account", accounts.Data[0].Object); } [Fact] public void ListAutoPaging() { var accounts = this.service.ListAutoPaging(this.listOptions).ToList(); Assert.NotNull(accounts); Assert.Equal("account", accounts[0].Object); } [Fact] public void Reject() { var account = this.service.Reject(AccountId, this.rejectOptions); this.AssertRequest(HttpMethod.Post, "/v1/accounts/acct_123/reject"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public async Task RejectAsync() { var account = await this.service.RejectAsync(AccountId, this.rejectOptions); this.AssertRequest(HttpMethod.Post, "/v1/accounts/acct_123/reject"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public void Update() { var account = this.service.Update(AccountId, this.updateOptions); this.AssertRequest(HttpMethod.Post, "/v1/accounts/acct_123"); Assert.NotNull(account); Assert.Equal("account", account.Object); } [Fact] public async Task UpdateAsync() { var account = await this.service.UpdateAsync(AccountId, this.updateOptions); this.AssertRequest(HttpMethod.Post, "/v1/accounts/acct_123"); Assert.NotNull(account); Assert.Equal("account", account.Object); } } }
33.804781
88
0.504537
[ "Apache-2.0" ]
Franklin89/stripe-dotnet
src/StripeTests/Services/Accounts/AccountServiceTest.cs
8,485
C#
/* * Copyright © 2012-2016 VMware, Inc. 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. 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 RestSsoAdminSnapIn { // Should subclass AppKit.NSView [Foundation.Register ("GroupDetailsView")] public partial class GroupDetailsView { } }
32.375
78
0.746461
[ "Apache-2.0" ]
WestCope/lightwave
tools/mac/VMRestSsoSnapIn/VMRestSsoSnapIn/Views/GroupDetailsView.designer.cs
788
C#
namespace Mono.GetOptions { using System; [AttributeUsage(AttributeTargets.Method)] public class ArgumentProcessorAttribute : Attribute { // Methods public ArgumentProcessorAttribute() { } } }
15.5
55
0.625
[ "MIT" ]
Chr0n0AP/flashdevelop
External/Tools/FDBuild/Mono/GetOptions/ArgumentProcessorAttribute.cs
248
C#
 namespace DLH { partial class MainForm { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm)); this.entryList = new System.Windows.Forms.ListView(); this.linkName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.linkType = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.linkNotes = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader())); this.dataGroup = new System.Windows.Forms.GroupBox(); this.editButton = new System.Windows.Forms.Button(); this.saveButton = new System.Windows.Forms.Button(); this.newButton = new System.Windows.Forms.Button(); this.copyButton = new System.Windows.Forms.Button(); this.linkBox = new System.Windows.Forms.TextBox(); this.label4 = new System.Windows.Forms.Label(); this.deleteButton = new System.Windows.Forms.Button(); this.typeBox = new System.Windows.Forms.ComboBox(); this.label3 = new System.Windows.Forms.Label(); this.notesBox = new System.Windows.Forms.TextBox(); this.label2 = new System.Windows.Forms.Label(); this.nameBox = new System.Windows.Forms.TextBox(); this.label1 = new System.Windows.Forms.Label(); this.label5 = new System.Windows.Forms.Label(); this.lookNameBox = new System.Windows.Forms.TextBox(); this.lookButton = new System.Windows.Forms.Button(); this.aboutButton = new System.Windows.Forms.Button(); this.dataGroup.SuspendLayout(); this.SuspendLayout(); // // entryList // this.entryList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { this.linkName, this.linkType, this.linkNotes}); this.entryList.HideSelection = false; this.entryList.Location = new System.Drawing.Point(12, 12); this.entryList.Name = "entryList"; this.entryList.Size = new System.Drawing.Size(512, 328); this.entryList.TabIndex = 0; this.entryList.UseCompatibleStateImageBehavior = false; this.entryList.View = System.Windows.Forms.View.Details; // // linkName // this.linkName.Text = "Name"; this.linkName.Width = 146; // // linkType // this.linkType.Text = "Type"; this.linkType.Width = 95; // // linkNotes // this.linkNotes.Text = "Notes"; this.linkNotes.Width = 265; // // dataGroup // this.dataGroup.Controls.Add(this.aboutButton); this.dataGroup.Controls.Add(this.editButton); this.dataGroup.Controls.Add(this.saveButton); this.dataGroup.Controls.Add(this.newButton); this.dataGroup.Controls.Add(this.copyButton); this.dataGroup.Controls.Add(this.linkBox); this.dataGroup.Controls.Add(this.label4); this.dataGroup.Controls.Add(this.deleteButton); this.dataGroup.Controls.Add(this.typeBox); this.dataGroup.Controls.Add(this.label3); this.dataGroup.Controls.Add(this.notesBox); this.dataGroup.Controls.Add(this.label2); this.dataGroup.Controls.Add(this.nameBox); this.dataGroup.Controls.Add(this.label1); this.dataGroup.Location = new System.Drawing.Point(12, 372); this.dataGroup.Name = "dataGroup"; this.dataGroup.Size = new System.Drawing.Size(512, 182); this.dataGroup.TabIndex = 1; this.dataGroup.TabStop = false; this.dataGroup.Text = "Data"; // // editButton // this.editButton.Location = new System.Drawing.Point(171, 150); this.editButton.Name = "editButton"; this.editButton.Size = new System.Drawing.Size(98, 23); this.editButton.TabIndex = 12; this.editButton.Text = "Save"; this.editButton.UseVisualStyleBackColor = true; this.editButton.Click += new System.EventHandler(this.editButton_Click); // // saveButton // this.saveButton.Location = new System.Drawing.Point(366, 150); this.saveButton.Name = "saveButton"; this.saveButton.Size = new System.Drawing.Size(75, 23); this.saveButton.TabIndex = 11; this.saveButton.Text = "Save JSON"; this.saveButton.UseVisualStyleBackColor = true; this.saveButton.Click += new System.EventHandler(this.saveButton_Click); // // newButton // this.newButton.Location = new System.Drawing.Point(90, 150); this.newButton.Name = "newButton"; this.newButton.Size = new System.Drawing.Size(75, 23); this.newButton.TabIndex = 10; this.newButton.Text = "New Entry"; this.newButton.UseVisualStyleBackColor = true; this.newButton.Click += new System.EventHandler(this.newButton_Click); // // copyButton // this.copyButton.Location = new System.Drawing.Point(285, 150); this.copyButton.Name = "copyButton"; this.copyButton.Size = new System.Drawing.Size(75, 23); this.copyButton.TabIndex = 9; this.copyButton.Text = "Copy"; this.copyButton.UseVisualStyleBackColor = true; this.copyButton.Click += new System.EventHandler(this.copyButton_Click); // // linkBox // this.linkBox.Location = new System.Drawing.Point(285, 75); this.linkBox.Multiline = true; this.linkBox.Name = "linkBox"; this.linkBox.Size = new System.Drawing.Size(212, 69); this.linkBox.TabIndex = 8; // // label4 // this.label4.AutoSize = true; this.label4.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label4.Location = new System.Drawing.Point(282, 57); this.label4.Name = "label4"; this.label4.Size = new System.Drawing.Size(31, 15); this.label4.TabIndex = 7; this.label4.Text = "Link"; // // deleteButton // this.deleteButton.Location = new System.Drawing.Point(9, 150); this.deleteButton.Name = "deleteButton"; this.deleteButton.Size = new System.Drawing.Size(75, 23); this.deleteButton.TabIndex = 6; this.deleteButton.Text = "Delete"; this.deleteButton.UseVisualStyleBackColor = true; this.deleteButton.Click += new System.EventHandler(this.deleteButton_Click); // // typeBox // this.typeBox.FormattingEnabled = true; this.typeBox.Items.AddRange(new object[] { "Video", "GIF"}); this.typeBox.Location = new System.Drawing.Point(285, 33); this.typeBox.Name = "typeBox"; this.typeBox.Size = new System.Drawing.Size(212, 21); this.typeBox.TabIndex = 5; // // label3 // this.label3.AutoSize = true; this.label3.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label3.Location = new System.Drawing.Point(282, 16); this.label3.Name = "label3"; this.label3.Size = new System.Drawing.Size(33, 15); this.label3.TabIndex = 4; this.label3.Text = "Type"; // // notesBox // this.notesBox.Location = new System.Drawing.Point(9, 75); this.notesBox.Multiline = true; this.notesBox.Name = "notesBox"; this.notesBox.Size = new System.Drawing.Size(260, 69); this.notesBox.TabIndex = 3; // // label2 // this.label2.AutoSize = true; this.label2.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label2.Location = new System.Drawing.Point(6, 57); this.label2.Name = "label2"; this.label2.Size = new System.Drawing.Size(40, 15); this.label2.TabIndex = 2; this.label2.Text = "Notes"; // // nameBox // this.nameBox.Location = new System.Drawing.Point(9, 34); this.nameBox.Name = "nameBox"; this.nameBox.Size = new System.Drawing.Size(260, 20); this.nameBox.TabIndex = 1; // // label1 // this.label1.AutoSize = true; this.label1.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label1.Location = new System.Drawing.Point(6, 16); this.label1.Name = "label1"; this.label1.Size = new System.Drawing.Size(40, 15); this.label1.TabIndex = 0; this.label1.Text = "Name"; // // label5 // this.label5.AutoSize = true; this.label5.Font = new System.Drawing.Font("Arial", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.label5.Location = new System.Drawing.Point(12, 349); this.label5.Name = "label5"; this.label5.Size = new System.Drawing.Size(40, 15); this.label5.TabIndex = 2; this.label5.Text = "Name"; // // lookNameBox // this.lookNameBox.Location = new System.Drawing.Point(64, 346); this.lookNameBox.Name = "lookNameBox"; this.lookNameBox.Size = new System.Drawing.Size(379, 20); this.lookNameBox.TabIndex = 3; // // lookButton // this.lookButton.Location = new System.Drawing.Point(449, 344); this.lookButton.Name = "lookButton"; this.lookButton.Size = new System.Drawing.Size(75, 23); this.lookButton.TabIndex = 5; this.lookButton.Text = "Search"; this.lookButton.UseVisualStyleBackColor = true; this.lookButton.Click += new System.EventHandler(this.lookButton_Click); // // aboutButton // this.aboutButton.Location = new System.Drawing.Point(447, 150); this.aboutButton.Name = "aboutButton"; this.aboutButton.Size = new System.Drawing.Size(50, 23); this.aboutButton.TabIndex = 13; this.aboutButton.Text = "About"; this.aboutButton.UseVisualStyleBackColor = true; this.aboutButton.Click += new System.EventHandler(this.aboutButton_Click); // // MainForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(536, 566); this.Controls.Add(this.lookButton); this.Controls.Add(this.lookNameBox); this.Controls.Add(this.label5); this.Controls.Add(this.dataGroup); this.Controls.Add(this.entryList); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.MaximizeBox = false; this.Name = "MainForm"; this.Text = "Discord Link Helper"; this.dataGroup.ResumeLayout(false); this.dataGroup.PerformLayout(); this.ResumeLayout(false); this.PerformLayout(); } #endregion private System.Windows.Forms.ListView entryList; private System.Windows.Forms.ColumnHeader linkName; private System.Windows.Forms.ColumnHeader linkType; private System.Windows.Forms.ColumnHeader linkNotes; private System.Windows.Forms.GroupBox dataGroup; private System.Windows.Forms.Button newButton; private System.Windows.Forms.Button copyButton; private System.Windows.Forms.TextBox linkBox; private System.Windows.Forms.Label label4; private System.Windows.Forms.Button deleteButton; private System.Windows.Forms.ComboBox typeBox; private System.Windows.Forms.Label label3; private System.Windows.Forms.TextBox notesBox; private System.Windows.Forms.Label label2; private System.Windows.Forms.TextBox nameBox; private System.Windows.Forms.Label label1; private System.Windows.Forms.Button saveButton; private System.Windows.Forms.Label label5; private System.Windows.Forms.TextBox lookNameBox; private System.Windows.Forms.Button lookButton; private System.Windows.Forms.Button editButton; private System.Windows.Forms.Button aboutButton; } }
45.628125
147
0.577769
[ "MIT" ]
AestheticalZ/dlh
Form1.Designer.cs
14,603
C#
using System; using R5T.T0126; namespace R5T.T0127 { public interface IClassSyntaxContext { ClassDeclarationAnnotation ClassAnnotation { get; } INamespaceSyntaxContext NamespaceContext { get; } } }
16.428571
59
0.7
[ "MIT" ]
SafetyCone/R5T.T0127
source/R5T.T0127/Code/Contexts/Interfaces/IClassSyntaxContext.cs
232
C#
/* * Copyright 2018 JDCLOUD.COM * * 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. * * Monitoring Rules APIs * 云监控规则相关接口,提供创建、查询、修改、删除监控规则等功能 * * OpenAPI spec version: v2 * Contact: * * NOTE: This class is auto generated by the jdcloud code generator program. */ using System; using System.Collections.Generic; using System.Text; using JDCloudSDK.Core.Service; using JDCloudSDK.Monitor.Model; namespace JDCloudSDK.Monitor.Apis { /// <summary> /// 查询规则列表 /// </summary> public class DescribeAlarmsResult : JdcloudResult { ///<summary> /// 规则列表 ///</summary> public List<DescribeGroupAlarm> AlarmList{ get; set; } ///<summary> /// 总页数 ///</summary> public long? NumberPages{ get; set; } ///<summary> /// 总记录数 ///</summary> public long? NumberRecords{ get; set; } ///<summary> /// 当前页码 ///</summary> public long? PageNumber{ get; set; } ///<summary> /// 分页大小 ///</summary> public long? PageSize{ get; set; } } }
25.777778
76
0.622537
[ "Apache-2.0" ]
jdcloud-api/jdcloud-sdk-net
sdk/src/Service/Monitor/Apis/DescribeAlarmsResult.cs
1,734
C#
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; namespace Sweeper.Controls.Entities { public class CarouselPage { #region ::Fields & Properties:: private readonly string _title = string.Empty; public string Title { get { return _title; } } private readonly Page _content = null; public Page Content { get { return _content; } } #endregion #region ::Constructors:: public CarouselPage() { } public CarouselPage(string title, Page content) { _title = title; _content = content; } #endregion } }
17.076923
55
0.510135
[ "MIT" ]
chungjongsu/Sweeper
source/Sweeper/Controls/Entities/CarouselPage.cs
890
C#
using System; using System.IO; using System.Reflection; namespace ServiceStack.Razor.VirtualPath { public class ResourceVirtualFile : AbstractVirtualFileBase { protected Assembly BackingAssembly; protected string FileName; public override string Name { get { return FileName; } } public override string VirtualPath { get { return GetVirtualPathToRoot(); } } public override string RealPath { get { return GetRealPathToRoot(); } } public override DateTime LastModified { get { return GetLastWriteTimeOfBackingAsm(); } } public ResourceVirtualFile(IVirtualPathProvider owningProvider, ResourceVirtualDirectory parentDirectory, string fileName) : base(owningProvider, parentDirectory) { if (string.IsNullOrEmpty(fileName)) throw new ArgumentException("fileName"); if (parentDirectory.BackingAssembly == null) throw new ArgumentException("parentDirectory"); this.FileName = fileName; this.BackingAssembly = parentDirectory.BackingAssembly; } public override Stream OpenRead() { var fullName = RealPath; return BackingAssembly.GetManifestResourceStream(fullName); } private DateTime GetLastWriteTimeOfBackingAsm() { var fInfo = new FileInfo(BackingAssembly.Location); return fInfo.LastWriteTime; } } }
28.051724
131
0.601106
[ "BSD-3-Clause" ]
froyke/ServiceStack
src/ServiceStack.Razor/VirtualPath/ResourceVirtualFile.cs
1,629
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. using System.Linq; using Xunit; namespace System.IO.Tests.Enumeration { public abstract class MatchTypesTests : FileSystemTest { protected abstract string[] GetPaths(string directory, string pattern, EnumerationOptions options); [Fact] public void QuestionMarkBehavior() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); FileInfo fileOne = new FileInfo(Path.Combine(testDirectory.FullName, "a.one")); FileInfo fileTwo = new FileInfo(Path.Combine(testDirectory.FullName, "ab.two")); FileInfo fileThree = new FileInfo(Path.Combine(testDirectory.FullName, "abc.three")); fileOne.Create().Dispose(); fileTwo.Create().Dispose(); fileThree.Create().Dispose(); // Question marks collapse to periods in Win32 string[] paths = GetPaths(testDirectory.FullName, "a??.*", new EnumerationOptions { MatchType = MatchType.Win32 }); FSAssert.EqualWhenOrdered(new string[] { fileOne.FullName, fileTwo.FullName, fileThree.FullName }, paths); paths = GetPaths(testDirectory.FullName, "*.?????", new EnumerationOptions { MatchType = MatchType.Win32 }); FSAssert.EqualWhenOrdered(new string[] { fileOne.FullName, fileTwo.FullName, fileThree.FullName }, paths); // Simple, one question mark is one character paths = GetPaths(testDirectory.FullName, "a??.*", new EnumerationOptions { MatchType = MatchType.Simple }); FSAssert.EqualWhenOrdered(new string[] { fileThree.FullName }, paths); paths = GetPaths(testDirectory.FullName, "*.?????", new EnumerationOptions { MatchType = MatchType.Simple }); FSAssert.EqualWhenOrdered(new string[] { fileThree.FullName }, paths); } [Fact] public void StarDotBehavior() { DirectoryInfo testDirectory = Directory.CreateDirectory(GetTestFilePath()); FileInfo fileOne = new FileInfo(Path.Combine(testDirectory.FullName, "one")); FileInfo fileTwo = new FileInfo(Path.Combine(testDirectory.FullName, "one.two")); string fileThree = Path.Combine(testDirectory.FullName, "three."); fileOne.Create().Dispose(); fileTwo.Create().Dispose(); // Need extended device syntax to create a name with a trailing dot. File.Create(PlatformDetection.IsWindows ? @"\\?\" + fileThree : fileThree).Dispose(); // *. means any file without an extension string[] paths = GetPaths(testDirectory.FullName, "*.", new EnumerationOptions { MatchType = MatchType.Win32 }); FSAssert.EqualWhenOrdered(new string[] { fileOne.FullName, fileThree }, paths); // Simple, anything with a trailing period paths = GetPaths(testDirectory.FullName, "*.", new EnumerationOptions { MatchType = MatchType.Simple }); FSAssert.EqualWhenOrdered(new string[] { fileThree }, paths); } } public class MatchTypesTests_Directory_GetFiles : MatchTypesTests { protected override string[] GetPaths(string directory, string pattern, EnumerationOptions options) { return Directory.GetFiles(directory, pattern, options); } } public class MatchTypesTests_DirectoryInfo_GetFiles : MatchTypesTests { protected override string[] GetPaths(string directory, string pattern, EnumerationOptions options) { return new DirectoryInfo(directory).GetFiles(pattern, options).Select(i => i.FullName).ToArray(); } } }
47.592593
127
0.66096
[ "MIT" ]
06needhamt/runtime
src/libraries/System.IO.FileSystem/tests/Enumeration/MatchTypesTests.cs
3,857
C#
namespace Lykke.Service.TemplateFormatter.TemplateModels { public class CashInTemplate { public string Year { get; set; } public string Multisig { get; set; } public string AssetName { get; set; } } }
23.8
57
0.638655
[ "MIT" ]
LykkeCity/Lykke.Service.TemplateFormatter
src/Lykke.Service.TemplateFormatter/TemplateModels/CashInTemplate.cs
240
C#
namespace Faactory.Channels.Buffers; public enum Endianness { BigEndian, LittleEndien }
12.125
36
0.752577
[ "Apache-2.0" ]
goncalo-oliveira/channels
src/buffers/Endianness.cs
97
C#
using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using Wilson.Web.Events.Handlers; using Wilson.Web.Events.Interfaces; namespace Wilson.Web.Events { public class EventsFactory : IEventsFactory { [ThreadStatic] private List<Delegate> actions; public EventsFactory(IServiceProvider serviceProvider) { this.ServiceProvider = serviceProvider; } public IServiceProvider ServiceProvider { get; set; } public void Register<T>(Action<T> callback) where T : IDomainEvent { if (actions == null) { actions = new List<Delegate>(); } actions.Add(callback); } public void ClearCallbacks() { actions = null; } public void Raise<T>(T args) where T : IDomainEvent { //TODO How I can get only the handlers that handles "T"?!? At the moment I am getting all the handlers then passing // "T args" to each one and if the cast is succeed then the args are processed. foreach (var handler in this.GetHandlers()) { handler.Handle(args); } if (actions != null) { foreach (var action in actions) { if (action is Action<T>) { ((Action<T>)action)(args); } } } } private IEnumerable<Handler> GetHandlers() { var types = Assembly.Load(new AssemblyName("Wilson.Web")).GetTypes().Where( type => type.GetTypeInfo().BaseType != null && !type.GetTypeInfo().IsAbstract && typeof(Handler).IsAssignableFrom(type)); var handlers = new List<Handler>(); foreach (var type in types) { handlers.Add((Handler)Activator.CreateInstance(type, this.ServiceProvider)); } return handlers; } } }
28.48
127
0.521536
[ "BSD-2-Clause" ]
AsimKhan2019/ERP-Construction
Web/Wilson.Web/Events/EventsFactory.cs
2,138
C#
using System; namespace LibGit2Sharp.Core.Compat { /// <summary> /// Provides information about, and means to manipulate, the current environment and platform. /// </summary> public static class Environment { /// <summary> /// Determines whether the current process is a 64-bit process. /// </summary> public static bool Is64BitProcess { get { return IntPtr.Size == 8; } } } }
24.315789
98
0.590909
[ "MIT" ]
aroben/libgit2sharp
LibGit2Sharp/Core/Compat/Environment.cs
462
C#
using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Windows.Input; using DynamicData; using DynamicData.Binding; using Prism.Commands; using Prism.Mvvm; using WDE.Common.Managers; using WDE.Common.Types; using WDE.MVVM.Observable; namespace WoWDatabaseEditorCore.Services.CreatureEntrySelectorService { public class GenericSelectorDialogViewModel<T> : BindableBase, IDialog { private readonly Func<T, int> entryGetter; private readonly Func<T, string> index; private SourceList<T> items; private string search = ""; public GenericSelectorDialogViewModel(IEnumerable<ColumnDescriptor> columns, IEnumerable<T> collection, Func<T, int> entryGetter, Func<T, string> index) { this.entryGetter = entryGetter; this.index = index; items = new SourceList<T>(); ReadOnlyObservableCollection<T> l; var currentFilter = this.WhenValueChanged(t => t.SearchText).Select<string?, Func<T, bool>>(val => { if (string.IsNullOrEmpty(val)) return model => true; var lowerCase = val.ToLower(); return model => index(model).ToLower().Contains(lowerCase); }); items .Connect() .Filter(currentFilter, ListFilterPolicy.ClearAndReplace) .Sort(Comparer<T>.Create((x, y) => entryGetter(x).CompareTo(entryGetter(y)))) .Bind(out l) .Subscribe(); FilteredItems = l; Columns = new ObservableCollection<ColumnDescriptor>(); foreach (var column in columns) Columns.Add(column); items.AddRange(collection); Accept = new DelegateCommand(() => { if (SelectedItem == null && FilteredItems.Count == 1) SelectedItem = FilteredItems[0]; CloseOk?.Invoke(); }, () => SelectedItem != null || FilteredItems.Count == 1 || int.TryParse(SearchText, out _)); Cancel = new DelegateCommand(() => CloseCancel?.Invoke()); FilteredItems.ObserveCollectionChanges().Subscribe(_ => Accept.RaiseCanExecuteChanged()); this.WhenPropertyChanged(t => t.SearchText).Subscribe(_ => Accept.RaiseCanExecuteChanged()); this.WhenPropertyChanged(t => t.SelectedItem).Subscribe(_ => Accept.RaiseCanExecuteChanged()); } public ObservableCollection<ColumnDescriptor> Columns { get; set; } public ReadOnlyObservableCollection<T> FilteredItems { get; } private T? selectedItem; public T? SelectedItem { get => selectedItem; set => SetProperty(ref selectedItem, value); } public string SearchText { get => search; set => SetProperty(ref search, value); } public int GetEntry() { if (SelectedItem != null) return entryGetter(SelectedItem); int res; int.TryParse(SearchText, out res); return res; } public DelegateCommand Accept { get; } public ICommand Cancel { get; } public int DesiredWidth => 380; public int DesiredHeight => 500; public string Title => "Picker"; public bool Resizeable => true; public event Action? CloseCancel; public event Action? CloseOk; } }
35.425743
110
0.586641
[ "Unlicense" ]
BAndysc/WoWDatabaseEditor
WoWDatabaseEditor/Services/CreatureEntrySelectorService/GenericSelectorDialogViewModel.cs
3,580
C#
using System.Collections.Generic; using Umbraco.Core.Models; namespace Umbraco.Core.Persistence.Repositories { public interface IMemberGroupRepository : IRepositoryQueryable<int, IMemberGroup> { /// <summary> /// Gets a member group by it's name /// </summary> /// <param name="name"></param> /// <returns></returns> IMemberGroup GetByName(string name); /// <summary> /// Creates the new member group if it doesn't already exist /// </summary> /// <param name="roleName"></param> IMemberGroup CreateIfNotExists(string roleName); /// <summary> /// Returns the member groups for a given member /// </summary> /// <param name="memberId"></param> /// <returns></returns> IEnumerable<IMemberGroup> GetMemberGroupsForMember(int memberId); /// <summary> /// Returns the member groups for a given member /// </summary> /// <param name="username"></param> /// <returns></returns> IEnumerable<IMemberGroup> GetMemberGroupsForMember(string username); void AssignRoles(string[] usernames, string[] roleNames); void DissociateRoles(string[] usernames, string[] roleNames); void AssignRoles(int[] memberIds, string[] roleNames); void DissociateRoles(int[] memberIds, string[] roleNames); int[] GetMemberIds(string[] names); } }
31.73913
85
0.612329
[ "MIT" ]
AzzA-D/Umbraco-CMS
src/Umbraco.Core/Persistence/Repositories/Interfaces/IMemberGroupRepository.cs
1,462
C#
using System; namespace ShareFile.Api.Client.Exceptions { public class EntityNotFoundException : Exception { } }
14.111111
52
0.716535
[ "MIT" ]
Dan-Avel/ShareFile-NET
src/ShareFile.Api.Client/Exceptions/EntityNotFoundException.cs
129
C#
using Captura.Models; namespace Captura.Console { class FakeWindowProvider : IMainWindow { public bool IsVisible { get => true; set { } } public bool IsMinimized { get => false; set { } } } }
15.15
42
0.448845
[ "MIT" ]
jayderfranca/Captura
src/Captura.Console/Fakes/FakeWindowProvider.cs
305
C#
using System; using System.Collections.Generic; using DynamicData.Binding; namespace DynamicData.ReactiveUI.Tests.Domain { public class Person :AbstractNotifyPropertyChanged, IEquatable<Person> { private int _age; public Person(string firstname, string lastname, int age, string gender = "F") : this(firstname + " " + lastname, age, gender) { } public Person(string name, int age, string gender = "F") { Name = name; _age = age; Gender = gender; } public string Name { get; } public string Gender { get; } public int Age { get => _age; set => SetAndRaise(ref _age, value); } public override string ToString() { return $"{Name}. {Age}"; } #region Equality Members public static bool operator ==(Person left, Person right) { return Equals(left, right); } public static bool operator !=(Person left, Person right) { return !Equals(left, right); } public bool Equals(Person other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return string.Equals(Gender, other.Gender) && _age == other._age; } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; if (obj.GetType() != GetType()) return false; return Equals((Person)obj); } public override int GetHashCode() { unchecked { return ((Gender != null ? Gender.GetHashCode() : 0) * 397) ^ _age; } } private sealed class NameAgeEqualityComparer : IEqualityComparer<Person> { public bool Equals(Person x, Person y) { if (ReferenceEquals(x, y)) return true; if (ReferenceEquals(x, null)) return false; if (ReferenceEquals(y, null)) return false; if (x.GetType() != y.GetType()) return false; return string.Equals(x.Name, y.Name) && x.Age == y.Age; } public int GetHashCode(Person obj) { unchecked { return ((obj.Name != null ? obj.Name.GetHashCode() : 0) * 397) ^ obj.Age; } } } private static readonly IEqualityComparer<Person> NameAgeComparerInstance = new NameAgeEqualityComparer(); public static IEqualityComparer<Person> NameAgeComparer { get { return NameAgeComparerInstance; } } #endregion } }
25.535088
114
0.521127
[ "MIT" ]
Didovgopoly/DynamicData
DynamicData.ReactiveUI.Tests/Domain/Person.cs
2,911
C#
using System; using System.Collections.Generic; using System.Text; namespace ConfigServer.Server { internal class UserPermissions { public bool CanAccessClientAdmin { get; set; } public bool CanEditClients { get; set; } public bool CanEditGroups { get; set; } public bool CanDeleteArchives { get; set; } public string[] ClientConfiguratorClaims { get; set; } } }
26.0625
62
0.671463
[ "MIT" ]
geffzhang/ConfigServer
src/ConfigServer.Server/Hosting/EndpointModels/UserPermissions.cs
419
C#
namespace WebApplication2.Controllers { public class ResourceService : IHiService { public string SayHi() { return "Hi from Resource Service"; } } }
18
46
0.580808
[ "MIT" ]
filipw/aspnetcore-parallel-pipelines
WebApplication2/Services/ResourceService.cs
200
C#
// ------------------------------------------------------------ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License (MIT). See License.txt in the repo root for license information. // ------------------------------------------------------------ namespace System.Fabric { using System.Fabric.Interop; /// <summary> /// The enum passed into the RestartPartition API to specify what replicas need to be restarted /// </summary> [Serializable] public enum RestartPartitionMode { /// <summary> /// Reserved. Do not pass into API. /// </summary> Invalid = NativeTypes.FABRIC_RESTART_PARTITION_MODE.FABRIC_RESTART_PARTITION_MODE_INVALID, /// <summary> /// All replicas or instances in the partition are restarted at once /// </summary> AllReplicasOrInstances = NativeTypes.FABRIC_RESTART_PARTITION_MODE.FABRIC_RESTART_PARTITION_MODE_ALL_REPLICAS_OR_INSTANCES, /// <summary> /// Only the secondary replicas are restarted. This option can only be used for stateful services and avoids data loss /// </summary> OnlyActiveSecondaries = NativeTypes.FABRIC_RESTART_PARTITION_MODE.FABRIC_RESTART_PARTITION_MODE_ONLY_ACTIVE_SECONDARIES } }
42.483871
131
0.630979
[ "MIT" ]
AlkisFortuneFish/service-fabric
src/prod/src/managed/Api/src/System/Fabric/RestartPartitionMode.cs
1,317
C#
using System; using System.Xml.Serialization; using System.Collections.Generic; namespace Aop.Api.Domain { /// <summary> /// TemplateOpenCardConfDTO Data Structure. /// </summary> [Serializable] public class TemplateOpenCardConfDTO : AopObject { /// <summary> /// 领卡权益信息 /// </summary> [XmlArray("card_rights")] [XmlArrayItem("template_rights_content_d_t_o")] public List<TemplateRightsContentDTO> CardRights { get; set; } /// <summary> /// 配置,预留字段,暂时不用 /// </summary> [XmlElement("conf")] public string Conf { get; set; } /// <summary> /// ISV:外部系统 MER:直连商户 /// </summary> [XmlElement("open_card_source_type")] public string OpenCardSourceType { get; set; } /// <summary> /// 开卡连接,必须http、https开头 /// </summary> [XmlElement("open_card_url")] public string OpenCardUrl { get; set; } /// <summary> /// 渠道APPID,提供领卡页面的服务提供方 /// </summary> [XmlElement("source_app_id")] public string SourceAppId { get; set; } } }
25.6
70
0.560764
[ "Apache-2.0" ]
Varorbc/alipay-sdk-net-all
AlipaySDKNet/Domain/TemplateOpenCardConfDTO.cs
1,258
C#
// Copyright © Tanner Gooding and Contributors. Licensed under the MIT License (MIT). See License.md in the repository root for more information. // Ported from um/sapi.h in the Windows SDK for Windows 10.0.20348.0 // Original source is Copyright © Microsoft. All rights reserved. using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace TerraFX.Interop { [Guid("A372ACD1-3BEF-4BBD-8FFB-CB3E2B416AF8")] [NativeTypeName("struct _ISpeechVoiceEvents : IDispatch")] [NativeInheritance("IDispatch")] public unsafe partial struct _ISpeechVoiceEvents { public void** lpVtbl; [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(0)] [return: NativeTypeName("HRESULT")] public int QueryInterface([NativeTypeName("const IID &")] Guid* riid, void** ppvObject) { return ((delegate* unmanaged<_ISpeechVoiceEvents*, Guid*, void**, int>)(lpVtbl[0]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this), riid, ppvObject); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(1)] [return: NativeTypeName("ULONG")] public uint AddRef() { return ((delegate* unmanaged<_ISpeechVoiceEvents*, uint>)(lpVtbl[1]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(2)] [return: NativeTypeName("ULONG")] public uint Release() { return ((delegate* unmanaged<_ISpeechVoiceEvents*, uint>)(lpVtbl[2]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(3)] [return: NativeTypeName("HRESULT")] public int GetTypeInfoCount([NativeTypeName("UINT *")] uint* pctinfo) { return ((delegate* unmanaged<_ISpeechVoiceEvents*, uint*, int>)(lpVtbl[3]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this), pctinfo); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(4)] [return: NativeTypeName("HRESULT")] public int GetTypeInfo([NativeTypeName("UINT")] uint iTInfo, [NativeTypeName("LCID")] uint lcid, ITypeInfo** ppTInfo) { return ((delegate* unmanaged<_ISpeechVoiceEvents*, uint, uint, ITypeInfo**, int>)(lpVtbl[4]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this), iTInfo, lcid, ppTInfo); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(5)] [return: NativeTypeName("HRESULT")] public int GetIDsOfNames([NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("LPOLESTR *")] ushort** rgszNames, [NativeTypeName("UINT")] uint cNames, [NativeTypeName("LCID")] uint lcid, [NativeTypeName("DISPID *")] int* rgDispId) { return ((delegate* unmanaged<_ISpeechVoiceEvents*, Guid*, ushort**, uint, uint, int*, int>)(lpVtbl[5]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this), riid, rgszNames, cNames, lcid, rgDispId); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [VtblIndex(6)] [return: NativeTypeName("HRESULT")] public int Invoke([NativeTypeName("DISPID")] int dispIdMember, [NativeTypeName("const IID &")] Guid* riid, [NativeTypeName("LCID")] uint lcid, [NativeTypeName("WORD")] ushort wFlags, DISPPARAMS* pDispParams, VARIANT* pVarResult, EXCEPINFO* pExcepInfo, [NativeTypeName("UINT *")] uint* puArgErr) { return ((delegate* unmanaged<_ISpeechVoiceEvents*, int, Guid*, uint, ushort, DISPPARAMS*, VARIANT*, EXCEPINFO*, uint*, int>)(lpVtbl[6]))((_ISpeechVoiceEvents*)Unsafe.AsPointer(ref this), dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); } } }
50.407895
302
0.673714
[ "MIT" ]
DaZombieKiller/terrafx.interop.windows
sources/Interop/Windows/um/sapi/_ISpeechVoiceEvents.cs
3,833
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 lightsail-2016-11-28.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.Lightsail.Model; using Amazon.Runtime; using Amazon.Runtime.Internal; using Amazon.Runtime.Internal.Transform; using Amazon.Runtime.Internal.Util; using ThirdParty.Json.LitJson; namespace Amazon.Lightsail.Model.Internal.MarshallTransformations { /// <summary> /// CookieObject Marshaller /// </summary> public class CookieObjectMarshaller : IRequestMarshaller<CookieObject, JsonMarshallerContext> { /// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="requestObject"></param> /// <param name="context"></param> /// <returns></returns> public void Marshall(CookieObject requestObject, JsonMarshallerContext context) { if(requestObject.IsSetCookiesAllowList()) { context.Writer.WritePropertyName("cookiesAllowList"); context.Writer.WriteArrayStart(); foreach(var requestObjectCookiesAllowListListValue in requestObject.CookiesAllowList) { context.Writer.Write(requestObjectCookiesAllowListListValue); } context.Writer.WriteArrayEnd(); } if(requestObject.IsSetOption()) { context.Writer.WritePropertyName("option"); context.Writer.Write(requestObject.Option); } } /// <summary> /// Singleton Marshaller. /// </summary> public readonly static CookieObjectMarshaller Instance = new CookieObjectMarshaller(); } }
33.986301
107
0.662636
[ "Apache-2.0" ]
Hazy87/aws-sdk-net
sdk/src/Services/Lightsail/Generated/Model/Internal/MarshallTransformations/CookieObjectMarshaller.cs
2,481
C#
/* _BEGIN_TEMPLATE_ { "id": "EX1_607e", "name": [ "怒火中烧", "Inner Rage" ], "text": [ "+2攻击力。", "+2 Attack." ], "cardClass": "WARRIOR", "type": "ENCHANTMENT", "cost": null, "rarity": null, "set": "EXPERT1", "collectible": null, "dbfId": 320 } _END_TEMPLATE_ */ namespace HREngine.Bots { class Sim_EX1_607e : SimTemplate { } }
13.925926
36
0.539894
[ "MIT" ]
chi-rei-den/Silverfish
cards/EXPERT1/EX1/Sim_EX1_607e.cs
392
C#
using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using NetOffice; using NetOffice.Attributes; namespace NetOffice.AccessApi.Events { #pragma warning disable #region SinkPoint Interface [SupportByVersion("Access", 12,14,15,16)] [InternalEntity(InternalEntityKind.ComEventInterface)] [ComImport, Guid("2E70527B-92D1-43CC-A57B-ED48BCCC711D"), InterfaceType(ComInterfaceType.InterfaceIsIDispatch), TypeLibType((short)0x1010)] public interface DispSectionEvents { [SupportByVersion("Access", 12,14,15,16)] [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-600)] void Click(); [SupportByVersion("Access", 12,14,15,16)] [SinkArgument("cancel", SinkArgumentType.Int16)] [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-601)] void DblClick([In] [Out] ref object cancel); [SupportByVersion("Access", 12,14,15,16)] [SinkArgument("button", SinkArgumentType.Int16)] [SinkArgument("shift", SinkArgumentType.Int16)] [SinkArgument("x", SinkArgumentType.Single)] [SinkArgument("y", SinkArgumentType.Single)] [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-605)] void MouseDown([In] [Out] ref object button, [In] [Out] ref object shift, [In] [Out] ref object x, [In] [Out] ref object y); [SupportByVersion("Access", 12,14,15,16)] [SinkArgument("button", SinkArgumentType.Int16)] [SinkArgument("shift", SinkArgumentType.Int16)] [SinkArgument("x", SinkArgumentType.Single)] [SinkArgument("y", SinkArgumentType.Single)] [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-606)] void MouseMove([In] [Out] ref object button, [In] [Out] ref object shift, [In] [Out] ref object x, [In] [Out] ref object y); [SupportByVersion("Access", 12,14,15,16)] [SinkArgument("button", SinkArgumentType.Int16)] [SinkArgument("shift", SinkArgumentType.Int16)] [SinkArgument("x", SinkArgumentType.Single)] [SinkArgument("y", SinkArgumentType.Single)] [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(-607)] void MouseUp([In] [Out] ref object button, [In] [Out] ref object shift, [In] [Out] ref object x, [In] [Out] ref object y); [SupportByVersion("Access", 12,14,15,16)] [PreserveSig, MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime), DispId(2486)] void Paint(); } #endregion #region SinkHelper [InternalEntity(InternalEntityKind.SinkHelper)] [ComVisible(true), ClassInterface(ClassInterfaceType.None), TypeLibType(TypeLibTypeFlags.FHidden)] public class DispSectionEvents_SinkHelper : SinkHelper, DispSectionEvents { #region Static public static readonly string Id = "2E70527B-92D1-43CC-A57B-ED48BCCC711D"; #endregion #region Ctor public DispSectionEvents_SinkHelper(ICOMObject eventClass, IConnectionPoint connectPoint): base(eventClass) { SetupEventBinding(connectPoint); } #endregion #region DispSectionEvents public void Click() { if (!Validate("Click")) { return; } object[] paramsArray = new object[0]; EventBinding.RaiseCustomEvent("Click", ref paramsArray); } public void DblClick([In] [Out] ref object cancel) { if (!Validate("DblClick")) { Invoker.ReleaseParamsArray(cancel); return; } object[] paramsArray = new object[1]; paramsArray.SetValue(cancel, 0); EventBinding.RaiseCustomEvent("DblClick", ref paramsArray); cancel = ToInt16(paramsArray[0]); } public void MouseDown([In] [Out] ref object button, [In] [Out] ref object shift, [In] [Out] ref object x, [In] [Out] ref object y) { if (!Validate("MouseDown")) { Invoker.ReleaseParamsArray(button, shift, x, y); return; } object[] paramsArray = new object[4]; paramsArray.SetValue(button, 0); paramsArray.SetValue(shift, 1); paramsArray.SetValue(x, 2); paramsArray.SetValue(y, 3); EventBinding.RaiseCustomEvent("MouseDown", ref paramsArray); button = ToInt16(paramsArray[0]); shift = ToInt16(paramsArray[1]); x = ToSingle(paramsArray[2]); y = ToSingle(paramsArray[3]); } public void MouseMove([In] [Out] ref object button, [In] [Out] ref object shift, [In] [Out] ref object x, [In] [Out] ref object y) { if (!Validate("MouseMove")) { Invoker.ReleaseParamsArray(button, shift, x, y); return; } object[] paramsArray = new object[4]; paramsArray.SetValue(button, 0); paramsArray.SetValue(shift, 1); paramsArray.SetValue(x, 2); paramsArray.SetValue(y, 3); EventBinding.RaiseCustomEvent("MouseMove", ref paramsArray); button = ToInt16(paramsArray[0]); shift = ToInt16(paramsArray[1]); x = ToSingle(paramsArray[2]); y = ToSingle(paramsArray[3]); } public void MouseUp([In] [Out] ref object button, [In] [Out] ref object shift, [In] [Out] ref object x, [In] [Out] ref object y) { if (!Validate("MouseUp")) { Invoker.ReleaseParamsArray(button, shift, x, y); return; } object[] paramsArray = new object[4]; paramsArray.SetValue(button, 0); paramsArray.SetValue(shift, 1); paramsArray.SetValue(x, 2); paramsArray.SetValue(y, 3); EventBinding.RaiseCustomEvent("MouseUp", ref paramsArray); button = ToInt16(paramsArray[0]); shift = ToInt16(paramsArray[1]); x = ToSingle(paramsArray[2]); y = ToSingle(paramsArray[3]); } public void Paint() { if (!Validate("Paint")) { return; } Delegate[] recipients = EventBinding.GetEventRecipients("Paint"); if( (true == EventClass.IsCurrentlyDisposing) || (recipients.Length == 0) ) { Invoker.ReleaseParamsArray(); return; } object[] paramsArray = new object[0]; EventBinding.RaiseCustomEvent("Paint", ref paramsArray); } #endregion } #endregion #pragma warning restore }
35.405128
143
0.621958
[ "MIT" ]
DominikPalo/NetOffice
Source/Access/Events/DispSectionEvents.cs
6,906
C#
using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace AttendanceTracker_Web.Models.Web { public class RegisterStudentResponse { public long CWID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } } }
23.866667
45
0.664804
[ "MIT" ]
AttendanceTracker/AttendanceTracker
AttendanceTracker-Web/AttendanceTracker-Web/Models/Web/DTOs/RegisterStudentResponse.cs
360
C#
using System; namespace MyWasteGame.UI.Pages { public partial class LevelIntroPage : BasePage { public LevelIntroPage() { InitializeComponent(); } public async void GoToLevelClicked(object sender, EventArgs e) { await Navigation.PushAsync(new FirstLevelPage()); } public async void ViewReferenceClicked(object sender, EventArgs e) { await Navigation.PushAsync(new ReferencePage()); } } }
25.75
70
0.747573
[ "MIT" ]
binwell-university/berserks
MyWasteGame/UI/Pages/LevelIntroPage.xaml.cs
412
C#
using System; public enum SkillLineId { NONE, AGILITY, STRENGTH, TOUGHNESS, LEADERSHIP_LEADER, LEADERSHIP, INTELLIGENCE_HENCHMAN = 7, INTELLIGENCE, ALERTNESS, WEAPON_SKILL, BALLISTIC_SKILL, ACCURACY, RESTRICTED, SKAVENS, HUMAN_MERCENARIES, SISTERS_OF_SIGMAR, POSSESSED, INTELLIGENCE_CASTER_ARCANE, INTELLIGENCE_CASTER_DIVINE, SPELL_SKAVEN, SPELL_MERCENARIES, SPELL_SISTERS, SPELL_POSSESSED, CLASS_SPECIFIC_SKILLS = 28, WARBAND, SPELL, LEADERSHIP_HEROES, WITCH_HUNTERS, SPELL_WITCH_HUNTERS, GLOBADIER, SMUGGLER, PRIEST_OF_ULRIC, DOOMWEAVER, SPELL_PRIEST_OF_ULRIC, SPELL_DOOMWEAVER, UNDEAD, SPELL_UNDEAD, MAX_VALUE }
14.886364
28
0.8
[ "CC0-1.0" ]
FreyaFreed/mordheim
Assembly-CSharp/SkillLineId.cs
657
C#
namespace SKIT.FlurlHttpClient.Wechat.Work.Models { /// <summary> /// <para>表示 [POST] /cgi-bin/externalcontact/batch/get_by_user 接口的响应。</para> /// </summary> public class CgibinExternalContactBatchGetByUserResponse : WechatWorkResponse { public static class Types { public class ExternalContactUser { public static class Types { public class ExternalContact : CgibinExternalContactGetResponse.Types.ExternalContact { } public class FollowUser { /// <summary> /// 获取或设置该成员对外部联系人的备注。 /// </summary> [Newtonsoft.Json.JsonProperty("remark")] [System.Text.Json.Serialization.JsonPropertyName("remark")] public string Remark { get; set; } = default!; /// <summary> /// 获取或设置该成员对外部联系人的备注企业名称。 /// </summary> [Newtonsoft.Json.JsonProperty("remark_corp_name")] [System.Text.Json.Serialization.JsonPropertyName("remark_corp_name")] public string? RemarkCompany { get; set; } /// <summary> /// 获取或设置该成员对外部联系人的备注手机号码列表。 /// </summary> [Newtonsoft.Json.JsonProperty("remark_mobiles")] [System.Text.Json.Serialization.JsonPropertyName("remark_mobiles")] public string[]? RemarkMobileNumberList { get; set; } /// <summary> /// 获取或设置该成员对外部联系人的描述。 /// </summary> [Newtonsoft.Json.JsonProperty("description")] [System.Text.Json.Serialization.JsonPropertyName("description")] public string Description { get; set; } = default!; /// <summary> /// 获取或设置该成员添加外部联系人所打企业标签 ID 列表。 /// </summary> [Newtonsoft.Json.JsonProperty("tag_id")] [System.Text.Json.Serialization.JsonPropertyName("tag_id")] public string[] TagIdList { get; set; } = default!; /// <summary> /// 获取或设置该成员添加外部联系人的来源。 /// </summary> [Newtonsoft.Json.JsonProperty("add_way")] [System.Text.Json.Serialization.JsonPropertyName("add_way")] public int AddWay { get; set; } /// <summary> /// 获取或设置该成员添加外部联系人的时间戳。 /// </summary> [Newtonsoft.Json.JsonProperty("createtime")] [System.Text.Json.Serialization.JsonPropertyName("createtime")] public long CreateTimestamp { get; set; } /// <summary> /// 获取或设置企业自定义渠道参数。 /// </summary> [Newtonsoft.Json.JsonProperty("state")] [System.Text.Json.Serialization.JsonPropertyName("state")] public string? State { get; set; } /// <summary> /// 获取或设置发起添加的成员账号。 /// </summary> [Newtonsoft.Json.JsonProperty("oper_userid")] [System.Text.Json.Serialization.JsonPropertyName("oper_userid")] public string? OperateUserId { get; set; } } } /// <summary> /// 获取或设置外部联系人信息。 /// </summary> [Newtonsoft.Json.JsonProperty("external_contact")] [System.Text.Json.Serialization.JsonPropertyName("external_contact")] public Types.ExternalContact ExternalContact { get; set; } = default!; /// <summary> /// 获取或设置添加了此外部联系人的企业成员信息。 /// </summary> [Newtonsoft.Json.JsonProperty("follow_info")] [System.Text.Json.Serialization.JsonPropertyName("follow_info")] public Types.FollowUser FollowUser { get; set; } = default!; } } /// <summary> /// 获取或设置外部联系人列表。 /// </summary> [Newtonsoft.Json.JsonProperty("external_contact_list")] [System.Text.Json.Serialization.JsonPropertyName("external_contact_list")] public Types.ExternalContactUser[] ExternalContactList { get; set; } = default!; /// <summary> /// 获取或设置翻页标记。 /// </summary> [Newtonsoft.Json.JsonProperty("next_cursor")] [System.Text.Json.Serialization.JsonPropertyName("next_cursor")] public string? NextCursor { get; set; } } }
43.844828
105
0.475029
[ "MIT" ]
ZUOXIANGE/DotNetCore.SKIT.FlurlHttpClient.Wechat
src/SKIT.FlurlHttpClient.Wechat.Work/Models/CgibinExternalContact/CgibinExternalContactBatchGetByUserResponse.cs
5,570
C#