repo_name
stringlengths
2
55
dataset
stringclasses
1 value
owner
stringlengths
3
31
lang
stringclasses
10 values
func_name
stringlengths
1
104
code
stringlengths
20
96.7k
docstring
stringlengths
1
4.92k
url
stringlengths
94
241
sha
stringlengths
40
40
NetAdmin
github_2023
nsnail
csharp
ExampleService.BulkDeleteAsync
public async Task<int> BulkDeleteAsync(BulkReq<DelReq> req) { req.ThrowIfInvalid(); var ret = 0; // ReSharper disable once LoopCanBeConvertedToQuery foreach (var item in req.Items) { ret += await DeleteAsync(item).ConfigureAwait(false); } return ret; ...
/// <inheritdoc />
https://github.com/nsnail/NetAdmin/blob/72cc3c42fded6f2d5a8cc43244746493c346d8f8/src/backend/NetAdmin/NetAdmin.Application/Services/Tpl/ExampleService.cs#L15-L26
72cc3c42fded6f2d5a8cc43244746493c346d8f8
NetAdmin
github_2023
nsnail
csharp
IApplicationBuilderExtensions.UseEndpoints
public static IApplicationBuilder UseEndpoints(this IApplicationBuilder me) { return me.UseEndpoints(endpoints => { _ = endpoints.MapControllers(); #if !DEBUG _ = endpoints.MapMetrics(); #endif }); }
/// <summary> /// 执行匹配的端点 /// </summary>
https://github.com/nsnail/NetAdmin/blob/72cc3c42fded6f2d5a8cc43244746493c346d8f8/src/backend/NetAdmin/NetAdmin.Host/Extensions/IApplicationBuilderExtensions.cs#L22-L30
72cc3c42fded6f2d5a8cc43244746493c346d8f8
LANCommander
github_2023
LANCommander
csharp
RemoveDeprecatedServerHttpOptions.BuildTargetModel
protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "7.0.13") .HasAnnotation("Proxies:ChangeTracking", false) .HasAnnotation("Proxies:CheckEquality", false...
/// <inheritdoc />
https://github.com/LANCommander/LANCommander/blob/51bc43ac93e3008391a2c78f958cbfc1d108bd80/LANCommander.Server.Data.SQLite/Migrations/20231105210731_RemoveDeprecatedServerHttpOptions.Designer.cs#L18-L1689
51bc43ac93e3008391a2c78f958cbfc1d108bd80
LANCommander
github_2023
LANCommander
csharp
AddGameCustomFields.BuildTargetModel
protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder.HasAnnotation("ProductVersion", "8.0.10"); modelBuilder.Entity("CategoryGame", b => { b.Property<Guid>("CategoriesId") ...
/// <inheritdoc />
https://github.com/LANCommander/LANCommander/blob/51bc43ac93e3008391a2c78f958cbfc1d108bd80/LANCommander.Server.Data.SQLite/Migrations/20250131011110_AddGameCustomFields.Designer.cs#L18-L2792
51bc43ac93e3008391a2c78f958cbfc1d108bd80
LANCommander
github_2023
LANCommander
csharp
AddRedistributables.Up
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.AlterColumn<Guid>( name: "GameId", table: "Scripts", type: "TEXT", nullable: true, oldClrType: typeof(Guid), oldType: "TEXT...
/// <inheritdoc />
https://github.com/LANCommander/LANCommander/blob/51bc43ac93e3008391a2c78f958cbfc1d108bd80/LANCommander.Server.Data.SQLite/Migrations/20231018060152_AddRedistributables.cs#L12-L105
51bc43ac93e3008391a2c78f958cbfc1d108bd80
LANCommander
github_2023
LANCommander
csharp
AddStorageLocations.BuildTargetModel
protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.8") .HasAnnotation("Proxies:ChangeTracking", false) .HasAnnotation("Proxies:CheckEquality", false)...
/// <inheritdoc />
https://github.com/LANCommander/LANCommander/blob/51bc43ac93e3008391a2c78f958cbfc1d108bd80/LANCommander.Server.Data.SQLite/Migrations/20241011014752_AddStorageLocations.Designer.cs#L18-L2573
51bc43ac93e3008391a2c78f958cbfc1d108bd80
LANCommander
github_2023
LANCommander
csharp
AddCollections.Up
protected override void Up(MigrationBuilder migrationBuilder) { migrationBuilder.CreateTable( name: "Collections", columns: table => new { Id = table.Column<Guid>(type: "TEXT", nullable: false), Name = table.Colu...
/// <inheritdoc />
https://github.com/LANCommander/LANCommander/blob/51bc43ac93e3008391a2c78f958cbfc1d108bd80/LANCommander.Server.Data.SQLite/Migrations/20231204044928_AddCollections.cs#L12-L109
51bc43ac93e3008391a2c78f958cbfc1d108bd80
handy
github_2023
Shopify
csharp
CylinderSurface.TransformScale
private float TransformScale(float val) { return val * _cylinder.transform.lossyScale.x; }
/// <summary> /// Local to world transformation of a float, assuming uniform scale. /// </summary>
https://github.com/Shopify/handy/blob/fa8686c291b1fe80e695bd8ad2474e2e852fd58b/Handy/Assets/Oculus/Interaction/Runtime/Scripts/Interaction/Surfaces/CylinderSurface.cs#L225-L228
fa8686c291b1fe80e695bd8ad2474e2e852fd58b
handy
github_2023
Shopify
csharp
VoipOptions.SetBitrateForNewConnections
public void SetBitrateForNewConnections(VoipBitrate value) { CAPI.ovr_VoipOptions_SetBitrateForNewConnections(Handle, value); }
/// Sets the maximum average bitrate the audio codec should use. Higher /// bitrates will increase audio quality at the expense of increased network /// usage. Use a lower bitrate if you think the quality is good but the network /// usage is too much. Use a higher bitrate if you think the quality is bad and /// you can...
https://github.com/Shopify/handy/blob/fa8686c291b1fe80e695bd8ad2474e2e852fd58b/Handy/Assets/Oculus/Platform/Scripts/VoipOptions.cs#L22-L24
fa8686c291b1fe80e695bd8ad2474e2e852fd58b
handy
github_2023
Shopify
csharp
AdvancedAbuseReportOptions.SetObjectType
public void SetObjectType(string value) { CAPI.ovr_AdvancedAbuseReportOptions_SetObjectType(Handle, value); }
/// If report_type is content, a string representing the type of content being /// reported. This should correspond to the object_type string used in the UI
https://github.com/Shopify/handy/blob/fa8686c291b1fe80e695bd8ad2474e2e852fd58b/Handy/Assets/Oculus/Platform/Scripts/AdvancedAbuseReportOptions.cs#L27-L29
fa8686c291b1fe80e695bd8ad2474e2e852fd58b
handy
github_2023
Shopify
csharp
OVRExtensions.ToTrackingSpacePose
public static OVRPose ToTrackingSpacePose(this Transform transform, Camera camera) { // Initializing to identity, but for all Oculus headsets, down below the pose will be initialized to the runtime's pose value, so identity will never be returned. OVRPose headPose = OVRPose.identity; Vector3 pos; Quaternion r...
/// <summary> /// Converts the given world-space transform to an OVRPose in tracking space. /// </summary>
https://github.com/Shopify/handy/blob/fa8686c291b1fe80e695bd8ad2474e2e852fd58b/Handy/Assets/Oculus/VR/Scripts/OVRCommon.cs#L52-L67
fa8686c291b1fe80e695bd8ad2474e2e852fd58b
handy
github_2023
Shopify
csharp
WitEditorUI.LayoutHeaderButton
public static void LayoutHeaderButton(Texture2D headerTexture, string headerURL) { if (headerTexture != null) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); float maxWidth = EditorGUIUtility.currentViewWidth - WitStyles.WindowPad...
// Layout header button
https://github.com/Shopify/handy/blob/fa8686c291b1fe80e695bd8ad2474e2e852fd58b/Handy/Assets/Oculus/Voice/Lib/Wit.ai/Scripts/Editor/WitEditorUI.cs#L115-L135
fa8686c291b1fe80e695bd8ad2474e2e852fd58b
handy
github_2023
Shopify
csharp
AssetDatabaseUtility.FindUnityAsset
public static T FindUnityAsset<T>(string filter) where T : UnityEngine.Object { T[] results = FindUnityAssets<T>(filter, true); if (results != null && results.Length > 0) { return results[0]; } return null; }
// Find Unity asset
https://github.com/Shopify/handy/blob/fa8686c291b1fe80e695bd8ad2474e2e852fd58b/Handy/Assets/Oculus/Voice/Lib/Wit.ai/Scripts/Editor/Utility/AssetDatabaseUtility.cs#L17-L25
fa8686c291b1fe80e695bd8ad2474e2e852fd58b
oni_multiplayer
github_2023
onimp
csharp
DisablePopUpEffects.TargetMethods
private static IEnumerable<MethodBase> TargetMethods() => typeof(PopFXManager).GetMethods() .Where(it => it.Name.StartsWith("SpawnFX"));
// ReSharper disable once UnusedMember.Local
https://github.com/onimp/oni_multiplayer/blob/926abd3b5f177b12ab4cc6d6aa537dcdb09684b7/src/MultiplayerMod/Game/Effects/DisablePopUpEffects.cs#L15-L17
926abd3b5f177b12ab4cc6d6aa537dcdb09684b7
NectarRCON
github_2023
zkhssb
csharp
DNSHelperTests.ATest
[TestMethod] public void ATest() { string? ip = DNSHelpers.AQuery("hypixel.net"); Console.WriteLine(ip); Assert.IsNotNull(string.IsNullOrEmpty(ip)); }
/// <summary> /// A解析测试 /// </summary>
https://github.com/zkhssb/NectarRCON/blob/e7349a9bd8533522b7c105fe3e0ab79325ad8e05/NectarRCON.Tests/DNSHelperTests.cs#L10-L16
e7349a9bd8533522b7c105fe3e0ab79325ad8e05
NectarRCON
github_2023
zkhssb
csharp
GithubUpdater.GetLatestVersion
private AppVersion? GetLatestVersion(bool enablePre) { if (_version is null) return null; using(HttpRequestMessage request = new(HttpMethod.Get, "releases/latest")) { request.Headers.Add("User-Agent", $"{_version.AppName}-AppUpdater"); ...
/// <summary> /// 获取最新版本, null为没找到 /// </summary> /// <param name="enablePre">是否允许pre版本</param>
https://github.com/zkhssb/NectarRCON/blob/e7349a9bd8533522b7c105fe3e0ab79325ad8e05/NectarRCON.Updater/GithubUpdater.cs#L24-L63
e7349a9bd8533522b7c105fe3e0ab79325ad8e05
SmartObjectSync
github_2023
MMMaellon
csharp
UniTaskExtensions.AsUniTask
public static UniTask<T> AsUniTask<T>(this Task<T> task, bool useCurrentSynchronizationContext = true) { var promise = new UniTaskCompletionSource<T>(); task.ContinueWith((x, state) => { var p = (UniTaskCompletionSource<T>)state; switch (x.St...
/// <summary> /// Convert Task[T] -> UniTask[T]. /// </summary>
https://github.com/MMMaellon/SmartObjectSync/blob/f600f5a5df125ac4e01d35c43ed60d0d2b3c0594/Packages/com.vrchat.base/Runtime/VRCSDK/Plugins/UniTask/Runtime/UniTaskExtensions.cs#L17-L42
f600f5a5df125ac4e01d35c43ed60d0d2b3c0594
SmartObjectSync
github_2023
MMMaellon
csharp
UnityBindingExtensions.BindTo
public static void BindTo<TSource, TObject>(this IUniTaskAsyncEnumerable<TSource> source, TObject monoBehaviour, Action<TObject, TSource> bindAction, bool rebindOnError = true) where TObject : MonoBehaviour { BindToCore(source, monoBehaviour, bindAction, monoBehaviour.GetCancellationToke...
// <T> -> Action
https://github.com/MMMaellon/SmartObjectSync/blob/f600f5a5df125ac4e01d35c43ed60d0d2b3c0594/Packages/com.vrchat.base/Runtime/VRCSDK/Plugins/UniTask/Runtime/UnityBindingExtensions.cs#L190-L194
f600f5a5df125ac4e01d35c43ed60d0d2b3c0594
SmartObjectSync
github_2023
MMMaellon
csharp
AsyncUniTaskVoid.GetStatus
UniTaskStatus IUniTaskSource.GetStatus(short token) { return UniTaskStatus.Pending; }
// dummy interface implementation for TaskTracker.
https://github.com/MMMaellon/SmartObjectSync/blob/f600f5a5df125ac4e01d35c43ed60d0d2b3c0594/Packages/com.vrchat.base/Runtime/VRCSDK/Plugins/UniTask/Runtime/CompilerServices/StateMachineRunner.cs#L109-L112
f600f5a5df125ac4e01d35c43ed60d0d2b3c0594
SmartObjectSync
github_2023
MMMaellon
csharp
WeakGenericCollectionFormatter.GetUninitializedObject
protected override object GetUninitializedObject() { return Activator.CreateInstance(this.SerializedType); }
/// <summary> /// Gets a new object of type <see cref="T" />. /// </summary> /// <returns> /// A new object of type <see cref="T" />. /// </returns>
https://github.com/MMMaellon/SmartObjectSync/blob/f600f5a5df125ac4e01d35c43ed60d0d2b3c0594/Packages/com.vrchat.worlds/Runtime/Udon/Serialization/OdinSerializer/Core/Formatters/GenericCollectionFormatter.cs#L229-L232
f600f5a5df125ac4e01d35c43ed60d0d2b3c0594
SmartObjectSync
github_2023
MMMaellon
csharp
MethodInfoFormatter.DeserializeImplementation
protected override void DeserializeImplementation(ref T value, IDataReader reader) { #if false //vrc security patch string name; EntryType entry; entry = reader.PeekEntry(out name); if (entry == EntryType.StartOfArray) { ...
/// <summary> /// Provides the actual implementation for deserializing a value of type <see cref="!:T" />. /// </summary> /// <param name="value">The uninitialized value to serialize into. This value will have been created earlier using <see cref="M:OdinSerializer.BaseFormatter`1.GetUninitializedObject" />.</param> ///...
https://github.com/MMMaellon/SmartObjectSync/blob/f600f5a5df125ac4e01d35c43ed60d0d2b3c0594/Packages/com.vrchat.worlds/Runtime/Udon/Serialization/OdinSerializer/Core/Formatters/MethodInfoFormatter.cs#L46-L227
f600f5a5df125ac4e01d35c43ed60d0d2b3c0594
SmartObjectSync
github_2023
MMMaellon
csharp
PrefabDeserializeUtility.GetSceneObjectsToKeepSet
public static HashSet<object> GetSceneObjectsToKeepSet(UnityEngine.Object unityObject, bool createIfDoesntExist) { HashSet<object> keep; if (!SceneObjectsToKeepOnApply.TryGetValue(unityObject, out keep)) { keep = new HashSet<object>(Refere...
/// <summary> /// Note: it is assumed that code calling this is holding the DeserializePrefabCaches_LOCK lock, and will continue to hold it while the returned hashset is being modified /// </summary>
https://github.com/MMMaellon/SmartObjectSync/blob/f600f5a5df125ac4e01d35c43ed60d0d2b3c0594/Packages/com.vrchat.worlds/Runtime/Udon/Serialization/OdinSerializer/Unity Integration/UnitySerializationUtility.cs#L137-L148
f600f5a5df125ac4e01d35c43ed60d0d2b3c0594
CFScanner
github_2023
MortezaBashsiz
csharp
CustomConfigInfo.isDefaultConfig
public bool isDefaultConfig() { return fileName == content && content == "Default"; }
// is default config?
https://github.com/MortezaBashsiz/CFScanner/blob/bcb96dd437e9cf90350ee5581df613b92380827f/windows/Classes/Config/CustomConfigs.cs#L115-L118
bcb96dd437e9cf90350ee5581df613b92380827f
CFScanner
github_2023
MortezaBashsiz
csharp
ScanResults.load
public bool load() { try { if (!File.Exists(resultsFileName)) { return false; } string jsonString = File.ReadAllText(resultsFileName); loadedInstance = JsonSerializer.Deserialize<ScanResu...
// load app config
https://github.com/MortezaBashsiz/CFScanner/blob/bcb96dd437e9cf90350ee5581df613b92380827f/windows/Classes/Config/ScanResults.cs#L45-L65
bcb96dd437e9cf90350ee5581df613b92380827f
FluentStorage
github_2023
robinrodricks
csharp
FtpFixture.InitializeAsync
public async Task InitializeAsync() { await FtpContainer.StartAsync().ConfigureAwait(false); }
///<inheritdoc/>
https://github.com/robinrodricks/FluentStorage/blob/7bac0df391a5d8df1abe19d965e2e9b476aa37e5/FluentStorage.Tests.FTP/FtpFixture.cs#L55-L57
7bac0df391a5d8df1abe19d965e2e9b476aa37e5
FluentStorage
github_2023
robinrodricks
csharp
GenericValidation.CheckBlobPrefix
public static void CheckBlobPrefix(string prefix) { if (prefix == null) return; string[] parts = prefix.Split('/'); foreach (string part in parts) { if (part.Length > MaxBlobPrefixLength) throw new ArgumentException( string.Format("blob prefix cannot exceed {0} characters", MaxBlobPrefixLeng...
/// <summary> /// Validates blob prefix search /// </summary> /// <param name="prefix"></param>
https://github.com/robinrodricks/FluentStorage/blob/7bac0df391a5d8df1abe19d965e2e9b476aa37e5/FluentStorage/GenericValidation.cs#L18-L29
7bac0df391a5d8df1abe19d965e2e9b476aa37e5
ThrottlingTroll
github_2023
ThrottlingTroll
csharp
ThrottlingTrollExtensions.UseThrottlingTroll
public static IApplicationBuilder UseThrottlingTroll(this IApplicationBuilder builder, Action<ThrottlingTrollOptions> options = null) { // Need to create this instance here, so that Assemblies are correctly initialized. var opt = new ThrottlingTrollOptions { A...
/// <summary> /// Configures ThrottlingTroll ingress throttling /// </summary>
https://github.com/ThrottlingTroll/ThrottlingTroll/blob/ae518fcb7b4a24633a806f389599e68457ff05fe/ThrottlingTroll.AspNet/ThrottlingTrollExtensions.cs#L24-L49
ae518fcb7b4a24633a806f389599e68457ff05fe
ThrottlingTroll
github_2023
ThrottlingTroll
csharp
ThrottlingTrollHandlerExtensions.AddThrottlingTrollMessageHandler
public static IHttpClientBuilder AddThrottlingTrollMessageHandler(this IHttpClientBuilder builder, Action<ThrottlingTrollOptions> options = null) { return builder.AddThrottlingTrollMessageHandler(options == null ? null : (provider, opt) => options(opt)); }
/// <summary> /// Appends <see cref="ThrottlingTrollHandler"/> to the given HttpClient. /// Optionally allows to configure options. /// </summary>
https://github.com/ThrottlingTroll/ThrottlingTroll/blob/ae518fcb7b4a24633a806f389599e68457ff05fe/ThrottlingTroll.Core/ThrottlingTrollHandler.cs#L533-L536
ae518fcb7b4a24633a806f389599e68457ff05fe
VRTRAKILL
github_2023
whateverusername0
csharp
HapticRack.Awake
void Awake() { if ( linearMapping == null ) { linearMapping = GetComponent<LinearMapping>(); } }
//-------------------------------------------------
https://github.com/whateverusername0/VRTRAKILL/blob/74dd472bf13baf273a8e2793712174050ff415be/VRTRAKILL.Plugin/New Unity Project/Assets/SteamVR/InteractionSystem/Core/Scripts/HapticRack.cs#L36-L42
74dd472bf13baf273a8e2793712174050ff415be
VRTRAKILL
github_2023
whateverusername0
csharp
LinearAnimator.Awake
void Awake() { if ( animator == null ) { animator = GetComponent<Animator>(); } animator.speed = 0.0f; if ( linearMapping == null ) { linearMapping = GetComponent<LinearMapping>(); } }
//-------------------------------------------------
https://github.com/whateverusername0/VRTRAKILL/blob/74dd472bf13baf273a8e2793712174050ff415be/VRTRAKILL.Plugin/New Unity Project/Assets/SteamVR/InteractionSystem/Core/Scripts/LinearAnimator.cs#L23-L36
74dd472bf13baf273a8e2793712174050ff415be
VRTRAKILL
github_2023
whateverusername0
csharp
SoundPlayOneshot.Awake
void Awake() { thisAudioSource = GetComponent<AudioSource>(); if ( playOnAwake ) { Play(); } }
//-------------------------------------------------
https://github.com/whateverusername0/VRTRAKILL/blob/74dd472bf13baf273a8e2793712174050ff415be/VRTRAKILL.Plugin/New Unity Project/Assets/SteamVR/InteractionSystem/Core/Scripts/SoundPlayOneshot.cs#L28-L36
74dd472bf13baf273a8e2793712174050ff415be
VRTRAKILL
github_2023
whateverusername0
csharp
ArrowHand.Awake
void Awake() { allowTeleport = GetComponent<AllowTeleportWhileAttachedToHand>(); //allowTeleport.teleportAllowed = true; allowTeleport.overrideHoverLock = false; arrowList = new List<GameObject>(); }
//-------------------------------------------------
https://github.com/whateverusername0/VRTRAKILL/blob/74dd472bf13baf273a8e2793712174050ff415be/VRTRAKILL.Plugin/New Unity Project/Assets/SteamVR/InteractionSystem/Longbow/Scripts/ArrowHand.cs#L46-L53
74dd472bf13baf273a8e2793712174050ff415be
VRTRAKILL
github_2023
whateverusername0
csharp
PlatformerMovementP.Update
[HarmonyPrefix] [HarmonyPatch(nameof(PlatformerMovement.Update))] static bool Update(PlatformerMovement __instance) { if (MonoSingleton<OptionsManager>.Instance.paused) return false; Vector2 vector = Vector2.zero; if (__instance.activated) { vecto...
// change movement vector to vr one
https://github.com/whateverusername0/VRTRAKILL/blob/74dd472bf13baf273a8e2793712174050ff415be/VRTRAKILL.Plugin/Plugin/ULTRAKILL/Movement/Patches/PlatformerMovementP.cs#L12-L218
74dd472bf13baf273a8e2793712174050ff415be
VRTRAKILL
github_2023
whateverusername0
csharp
HUDOptionsP.FlashImageTweak
[HarmonyPostfix] [HarmonyPatch(typeof(FlashImage), nameof(FlashImage.Flash))] static void FlashImageTweak(FlashImage __instance) { if (__instance.gameObject.name.Contains("White") || __instance.gameObject.name.Contains("Black")) __instance.transform.localScale *= 20; }
/// <summary> /// Fuck you /// </summary>
https://github.com/whateverusername0/VRTRAKILL/blob/74dd472bf13baf273a8e2793712174050ff415be/VRTRAKILL.Plugin/Plugin/ULTRAKILL/UI/Patches/HUDOptionsP.cs#L70-L74
74dd472bf13baf273a8e2793712174050ff415be
Bloatynosy
github_2023
builtbybel
csharp
ExperienceView.CreateRoundRectRgn
[System.Runtime.InteropServices.DllImport("gdi32.dll")] private static extern IntPtr CreateRoundRectRgn(int nLeftRect, int nTopRect, int nRightRect, int nBottomRect, int nWidthEllipse, int nHeightEllipse);
// Import rounded corners
https://github.com/builtbybel/Bloatynosy/blob/48d27896be3557e1878094b86362514b8ab6cbca/src/Bloatynosy/Views/ExperienceView.cs#L137-L138
48d27896be3557e1878094b86362514b8ab6cbca
Ursa.Avalonia
github_2023
irihitech
csharp
CalendarView.OnHeaderButtonClick
private void OnHeaderButtonClick(object? sender, RoutedEventArgs e) { // Header button should be hidden in Month mode. if (Mode == CalendarViewMode.Month) return; if (Mode == CalendarViewMode.Year) { Mode = CalendarViewMode.Decade; var range = DateTimeHelper.G...
/// <summary> /// Rule: /// </summary> /// <param name="sender"></param> /// <param name="e"></param>
https://github.com/irihitech/Ursa.Avalonia/blob/ada538555472f8d623efda22a48c3d2ee7ed7e37/src/Ursa/Controls/DateTimePicker/CalendarView.cs#L246-L270
ada538555472f8d623efda22a48c3d2ee7ed7e37
UnityFigmaBridge
github_2023
simonoliver
csharp
EffectManager.ApplyAllFigmaEffectsToUnityNode
public static void ApplyAllFigmaEffectsToUnityNode(GameObject nodeGameObject,Node node, FigmaImportProcessData figmaImportProcessData) { foreach (var effect in node.effects) ApplyEffectToUnityNode(nodeGameObject,node,effect,figmaImportProcessData); }
/// <summary> /// Apply all effects to a given node /// </summary> /// <param name="nodeGameObject"></param> /// <param name="node"></param> /// <param name="figmaImportProcessData"></param>
https://github.com/simonoliver/UnityFigmaBridge/blob/dbd12bff29e8bc84e2682bb19495899711651455/UnityFigmaBridge/Editor/Nodes/EffectManager.cs#L20-L25
dbd12bff29e8bc84e2682bb19495899711651455
SubmersedVR
github_2023
Okabintaro
csharp
OffsetCalibrationTool.UnparentTarget
public void UnparentTarget(SteamVR_Action_Boolean fromAction, SteamVR_Input_Sources fromSource) { parent = target.parent; Mod.logger.LogInfo($"Unparenting {target.name}, remembering {parent.name}"); target.SetParent(null, true); }
// Unparent Target, so we can finetune the position
https://github.com/Okabintaro/SubmersedVR/blob/726867165cc602ba929477d1f02991fd1b1ded9a/SubmersedVR/VR/OffsetCalibrationTool.cs#L58-L63
726867165cc602ba929477d1f02991fd1b1ded9a
devhome
github_2023
microsoft
csharp
CardProperty.ConvertMsResourceToIcon
public static unsafe BitmapImage ConvertMsResourceToIcon(Uri iconPathUri, string packageFullName) { try { var indirectPathToResource = "@{" + packageFullName + "? " + iconPathUri.AbsoluteUri + "}"; Span<char> outputBuffer = new char[MaxBufferLength]; fixed (char*...
/// <summary> /// Converts a passed in ms-resource URI and package full name to a BitmapImage. /// </summary> /// <param name="iconPathUri">the ms-resource:// path to an image resource in an app packages pri file.</param> /// <returns>The bitmap image that represents the icon.</returns>
https://github.com/microsoft/devhome/blob/d52734ce0e33a82af3313d24c3c2979c37b68bab/common/Environments/Models/CardProperty.cs#L115-L149
d52734ce0e33a82af3313d24c3c2979c37b68bab
devhome
github_2023
microsoft
csharp
ExperimentalFeaturesViewModel.IsFeaturePresent
private bool IsFeaturePresent(ExperimentalFeature experimentalFeature) { if (string.Equals(experimentalFeature.Id, "FileExplorerSourceControlIntegration", StringComparison.OrdinalIgnoreCase)) { try { return ExtraFolderPropertiesWrapper.IsSupported(); ...
/// <summary> /// Checks if the specified experimental feature is present on the machine. /// This method should be extended to handle new features by adding the corresponding /// feature check logic. If a feature is supported on the current machine, it should /// return false here. /// </summary>
https://github.com/microsoft/devhome/blob/d52734ce0e33a82af3313d24c3c2979c37b68bab/settings/DevHome.Settings/ViewModels/ExperimentalFeaturesViewModel.cs#L39-L54
d52734ce0e33a82af3313d24c3c2979c37b68bab
devhome
github_2023
microsoft
csharp
TelemetryFactory.Get
public static T Get<T>() where T : ITelemetry { return (T)(object)GetTelemetryInstance(); }
/// <summary> /// Gets a singleton instance of Telemetry /// This would be useful for the future when interfaces have been updated for logger like ITelemetry2, ITelemetry3 and so on
https://github.com/microsoft/devhome/blob/d52734ce0e33a82af3313d24c3c2979c37b68bab/telemetry/DevHome.Telemetry/TelemetryFactory.cs#L32-L36
d52734ce0e33a82af3313d24c3c2979c37b68bab
devhome
github_2023
microsoft
csharp
TestSystems.ShutDownAsync
public IAsyncOperation<ComputeSystemOperationResult> ShutDownAsync(string options) => throw new NotImplementedException();
// Unimplemented APIs
https://github.com/microsoft/devhome/blob/d52734ce0e33a82af3313d24c3c2979c37b68bab/tools/Environments/DevHome.Environments/TestModels/TestSystems.cs#L123-L123
d52734ce0e33a82af3313d24c3c2979c37b68bab
devhome
github_2023
microsoft
csharp
WindowsDriverExtensions.Wait
public static DefaultWait<WindowsDriver<WindowsElement>> Wait( this WindowsDriver<WindowsElement> driver, TimeSpan timeout, TimeSpan pollingInterval) { return new(driver) { Timeout = timeout, PollingInterval = pollingInterval, }; }
/// <summary> /// Create an instance of <see cref="DefaultWait{T}"/> /// </summary> /// <param name="driver">Driver instance</param> /// <param name="timeout">Wait timeout</param> /// <param name="pollingInterval">Action interval</param> /// <returns>Instance of <see cref="DefaultWait{T}"/></returns>
https://github.com/microsoft/devhome/blob/d52734ce0e33a82af3313d24c3c2979c37b68bab/uitest/Extensions/WindowsDriverExtensions.cs#L22-L32
d52734ce0e33a82af3313d24c3c2979c37b68bab
whisper.net
github_2023
sandrohanea
csharp
Program.Main
public static async Task Main(string[] args) { // We declare for variables which we will use later, ggmlType, modelFileName, wavFileName and coreMlModelcName var ggmlType = GgmlType.Base; var modelFileName = "ggml-base.bin"; var wavFileName = "kennedy.wav"; var coreMlModelcNa...
// This examples shows how to use Whisper.net to create a transcription from an audio file with 16Khz sample rate, using CoreML
https://github.com/sandrohanea/whisper.net/blob/eae8f62164799288329b48c3cafd9644c295ed24/examples/CoreML/Program.cs#L13-L57
eae8f62164799288329b48c3cafd9644c295ed24
whisper.net
github_2023
sandrohanea
csharp
Program.Main
public static async Task Main(string[] args) { // We declare three variables which we will use later, ggmlType, modelFileName and wavFileName var ggmlType = GgmlType.LargeV3Turbo; var modelFileName = "ggml-largev3.bin"; var wavFileName = "kennedy.wav"; using var whisperLogge...
// This examples shows how to use Whisper.net to create a transcription from an audio file with 16Khz sample rate. // It uses both Cuda (NVidia GPU) or CPU, and loads the first one that is available.
https://github.com/sandrohanea/whisper.net/blob/eae8f62164799288329b48c3cafd9644c295ed24/examples/Vulkan/Program.cs#L14-L44
eae8f62164799288329b48c3cafd9644c295ed24
iMES-Factory
github_2023
zmrid
csharp
ServerExtension.MapPath
public static string MapPath(this string path) { return MapPath(path, false); }
/// <summary> /// 返回的路径后面不带/,拼接时需要自己加上/ /// </summary> /// <param name="path"></param> /// <returns></returns>
https://github.com/zmrid/iMES-Factory/blob/d301552bd0e953882ea0b2162c0e17b36dd3a2a9/iMES.Net/iMES.Core/Extensions/ServerExtension.cs#L16-L19
d301552bd0e953882ea0b2162c0e17b36dd3a2a9
iMES-Factory
github_2023
zmrid
csharp
MailHelper.Send
public static void Send(string title, string content, params string[] list) { Console.WriteLine(AppSetting.GetSection("ModifyMember")["DateUTCField"]); MailMessage message = new MailMessage { From = new MailAddress(address, name)//发送人邮箱 }; ...
/// <summary> /// 发送邮件 /// </summary> /// <param name="title">标题</param> /// <param name="content">内容</param> /// <param name="list">收件人</param>
https://github.com/zmrid/iMES-Factory/blob/d301552bd0e953882ea0b2162c0e17b36dd3a2a9/iMES.Net/iMES.Core/Utilities/MailHelper.cs#L37-L62
d301552bd0e953882ea0b2162c0e17b36dd3a2a9
iMES-Factory
github_2023
zmrid
csharp
WorkFlowManager.AddProcese
public static void AddProcese<T>(T entity, bool rewrite = false,bool changeTableStatus=true) where T:class { string workTable = typeof(T).GetEntityTableName(); Sys_WorkFlow workFlow = DBServerProvider.DbContext.Set<Sys_WorkFlow>() .Where(x => x.WorkTable == workTable) ...
/// <summary> /// 写入流程 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="entity"></param> /// <param name="rewrite">是否重新生成流程</param> /// <param name="changeTableStatus">是否修改原表的审批状态</param>
https://github.com/zmrid/iMES-Factory/blob/d301552bd0e953882ea0b2162c0e17b36dd3a2a9/iMES.Net/iMES.Core/WorkFlow/WorkFlowManager.cs#L106-L156
d301552bd0e953882ea0b2162c0e17b36dd3a2a9
shesha-framework
github_2023
shesha-io
csharp
FilterCriteria.AppendCriteria
public void AppendCriteria([NotNull]FilterCriteria criteria) { if (criteria.FilteringMethod != this.FilteringMethod) throw new Exception("The filtering method used is incompatible and may cause problems due to differences in syntax."); FilterClauses.AddRange(criteria.Fil...
/// <summary> /// Copies all the <paramref name="criteria"/>'s FilterClauses and FilterParameters to this /// FilterCriteria. /// </summary> /// <param name="criteria"></param>
https://github.com/shesha-io/shesha-framework/blob/bb69efce02d772f166ce621f6993a795f94c35df/shesha-core/src/Shesha.Framework/Domain/FilterCriteria.cs#L37-L48
bb69efce02d772f166ce621f6993a795f94c35df
shesha-framework
github_2023
shesha-io
csharp
SwaggerOperationFilter.GetSingleAttributeOfMemberOrDeclaringTypeOrDefault
public static TAttribute GetSingleAttributeOfMemberOrDeclaringTypeOrDefault<TAttribute>(MemberInfo memberInfo, TAttribute defaultValue = default, bool inherit = true) where TAttribute : class { return memberInfo.GetCustomAttributes(true).OfType<TAttribute>().FirstOrDefault() ...
/// <summary> /// Copied from ABP /// Tries to gets an of attribute defined for a class member and it's declaring type including inherited attributes. /// Returns default value if it's not declared at all. /// </summary> /// <typeparam name="TAttribute">Type of the attribute</typeparam> /// <param name="memberInfo">Mem...
https://github.com/shesha-io/shesha-framework/blob/bb69efce02d772f166ce621f6993a795f94c35df/shesha-core/src/Shesha.Framework/Swagger/SwaggerOperationFilter.cs#L144-L150
bb69efce02d772f166ce621f6993a795f94c35df
shesha-framework
github_2023
shesha-io
csharp
CodeNamingHelper.ValidateCodeIdentifier
public static void ValidateCodeIdentifier(string identifier) { if (!CSharpSyntaxHelper.IsValidIdentifier(identifier)) throw new IdentifierIsNotValidException(identifier); }
/// <summary> /// Validate specified <paramref name="identifier"/>, throws <see cref="IdentifierIsNotValidException"/> if identifier is not valid /// </summary> /// <param name="identifier"></param> /// <exception cref="IdentifierIsNotValidException"></exception>
https://github.com/shesha-io/shesha-framework/blob/bb69efce02d772f166ce621f6993a795f94c35df/shesha-core/src/Shesha.Framework/Utilities/CodeNamingHelper.cs#L25-L29
bb69efce02d772f166ce621f6993a795f94c35df
shesha-framework
github_2023
shesha-io
csharp
ModuleLocator.GetModuleName
public string GetModuleName(Type migrationType) { return migrationType.GetConfigurableModuleName(); }
/// inheritedDoc
https://github.com/shesha-io/shesha-framework/blob/bb69efce02d772f166ce621f6993a795f94c35df/shesha-core/src/Shesha.NHibernate/NHibernate/ModuleLocator.cs#L14-L17
bb69efce02d772f166ce621f6993a795f94c35df
shesha-framework
github_2023
shesha-io
csharp
M20230516104216.Up
public override void Up() { Create.Table("SheshaFunctionalTests_Books") .WithIdAsGuid() .WithFullAuditColumns() .WithColumn("Frwk_Discriminator").AsString(SheshaDatabaseConsts.DiscriminatorMaxSize).NotNullable() .WithColumn("Name").AsString().Null...
/// <summary> /// /// </summary>
https://github.com/shesha-io/shesha-framework/blob/bb69efce02d772f166ce621f6993a795f94c35df/shesha-functional-tests/backend/src/Module/Boxfusion.SheshaFunctionalTests.Common.Domain/Migrations/M20230516104216.cs#L14-L53
bb69efce02d772f166ce621f6993a795f94c35df
shesha-framework
github_2023
shesha-io
csharp
M20240219144300.Up
public override void Up() { Alter.Table("SheshaFunctionalTests_MembershipPayments").AddColumn("PaymentTypeLkp").AsInt64().Nullable(); }
/// <summary> /// /// </summary>
https://github.com/shesha-io/shesha-framework/blob/bb69efce02d772f166ce621f6993a795f94c35df/shesha-functional-tests/backend/src/Module/Boxfusion.SheshaFunctionalTests.Common.Domain/Migrations/M20240219144300.cs#L14-L17
bb69efce02d772f166ce621f6993a795f94c35df
g-helper
github_2023
seerge
csharp
AppConfig.SwappedBrightness
public static bool SwappedBrightness() { return ContainsModel("FA506IEB") || ContainsModel("FA506IH") || ContainsModel("FA506IC") || ContainsModel("FX506LU") || ContainsModel("FX506IC") || ContainsModel("FX506LH") || ContainsModel("FA506IV") || ContainsModel("FA706IC") || ContainsModel("FA706IH"); }
// Devices with bugged bios command to change brightness
https://github.com/seerge/g-helper/blob/b5428ff2e8485e95a9ac29541dcb961337bd663c/app/AppConfig.cs#L408-L411
b5428ff2e8485e95a9ac29541dcb961337bd663c
GDTask
github_2023
Fractural
csharp
GDTaskPlayerLoopAutoload.LocalAddContinuation
public void LocalAddContinuation(PlayerLoopTiming timing, Action continuation) { var q = yielders[(int)timing]; if (q == null) { ThrowInvalidLoopTiming(timing); } q.Enqueue(continuation); }
// NOTE: Continuation means a asynchronous task invoked by another task after the other task finishes.
https://github.com/Fractural/GDTask/blob/661244bba9839c8633d2106457ef5be2faa228df/addons/GDTask/Autoload/GDTaskPlayerLoopAutoload.cs#L48-L56
661244bba9839c8633d2106457ef5be2faa228df
minishop-composer
github_2023
nichealpham
csharp
EventFlags.MatchesWeekOfMonth
public static bool MatchesWeekOfMonth(this DateTime date, int recurrence) => Matches(recurrence, 1 << (date.Day / 8));
// since day is [1,31], becomes [0,30]
https://github.com/nichealpham/minishop-composer/blob/68d2f4e875a2bd9d7c3c2c9226795d25c239ecd0/api/AppGlobal/Commons/Helpers.cs
68d2f4e875a2bd9d7c3c2c9226795d25c239ecd0
DNSveil
github_2023
msasanmh
csharp
NetworkTool.IpToHostAsync
public static async Task<(string Host, string BaseHost)> IpToHostAsync(string ip) { string result = string.Empty; string baseHost = string.Empty; if (!OperatingSystem.IsWindows()) return (result, baseHost); if (!await IsInternetAliveByNicAsync()) return (result, baseHost); // nslooku...
/// <summary> /// IP to Host using Nslookup (Windows Only) /// </summary> /// <param name="ip"></param> /// <returns></returns>
https://github.com/msasanmh/DNSveil/blob/3f107516dddb1f4eba472665b925994f06a29162/MsmhToolsClass/MsmhToolsClass/NetworkTool.cs#L79-L105
3f107516dddb1f4eba472665b925994f06a29162
DNSveil
github_2023
msasanmh
csharp
WebAPI.Github_Latest_Release_Async
public static async Task<List<string>> Github_Latest_Release_Async(string owner, string repo, int timeoutMs = 5000) { List<string> relaeseURLs = new(); try { Uri apiMain = new($"https://api.github.com/repos/{owner}/{repo}/releases/latest"); HttpRequest hr = new() ...
/// <summary> /// Github Latest Release /// </summary> /// <returns>Returns Download Links</returns>
https://github.com/msasanmh/DNSveil/blob/3f107516dddb1f4eba472665b925994f06a29162/MsmhToolsClass/MsmhToolsClass/WebAPI.cs#L37-L72
3f107516dddb1f4eba472665b925994f06a29162
toon-rp
github_2023
Delt06
csharp
ToonMeshUtility.IntersectRayMesh
public static bool IntersectRayMesh(Ray ray, Mesh mesh, Matrix4x4 matrix, out RaycastHit hit) { object[] parameters = { ray, mesh, matrix, null }; bool result = (bool) MethodIntersectRayMesh.Invoke(null, parameters); hit = (RaycastHit) parameters[3]; return result...
// Adapted from https://gist.github.com/MattRix/9205bc62d558fef98045
https://github.com/Delt06/toon-rp/blob/687b7b26747a8bd6b0905299e5248bbca0285a77/Packages/com.deltation.toon-rp/Editor/VertexColorPaint/ToonMeshUtility.cs#L82-L88
687b7b26747a8bd6b0905299e5248bbca0285a77
Avalonia.Labs
github_2023
AvaloniaUI
csharp
Application.Main
static void Main(string[] args) { // if you want to use a different Application Delegate class from "AppDelegate" // you can specify it here. UIApplication.Main(args, null, typeof(AppDelegate)); }
// This is the main entry point of the application.
https://github.com/AvaloniaUI/Avalonia.Labs/blob/81ee313436d2305f7c169e0a099fe84d33d50624/samples/Avalonia.Labs.Catalog.iOS/Main.cs#L8-L13
81ee313436d2305f7c169e0a099fe84d33d50624
Avalonia.Labs
github_2023
AvaloniaUI
csharp
ContentDialog.ShowAsync
public async Task<ContentDialogResult> ShowAsync() => await ShowAsyncCore(null);
/// <summary> /// Begins an asynchronous operation to show the dialog. /// </summary>
https://github.com/AvaloniaUI/Avalonia.Labs/blob/81ee313436d2305f7c169e0a099fe84d33d50624/src/Avalonia.Labs.Controls/ContentDialog/ContentDialog.cs#L113-L113
81ee313436d2305f7c169e0a099fe84d33d50624
Avalonia.Labs
github_2023
AvaloniaUI
csharp
ReedSolomonEncoder.Encode
internal static byte[] Encode(byte[] dataBytes, int numECBytes, GeneratorPolynomial generatorPoly) { int dataLength = dataBytes.Length; if (generatorPoly == null) throw new ArgumentNullException(nameof(generatorPoly)); if (dataLength == 0) { throw new ArgumentException("There is no ...
/// <summary> /// Encode an array of data codeword with GaloisField 256. /// </summary> /// <param name="dataBytes">Array of data codewords for a single block.</param> /// <param name="numECBytes">Number of error correction codewords for data codewords</param> /// <param name="generatorPoly">Cached or newly create Gene...
https://github.com/AvaloniaUI/Avalonia.Labs/blob/81ee313436d2305f7c169e0a099fe84d33d50624/src/Avalonia.Labs.Qr/Encoding/ReedSolomon/ReedSolomonEncoder.cs#L14-L41
81ee313436d2305f7c169e0a099fe84d33d50624
com.doji.genesis
github_2023
julienkay
csharp
UrlUtility.AppendQuerytoUrl
public static void AppendQuerytoUrl(ref string url, string parameterName, string query) { if (query == null) { return; } url += parameterName + "=" + query + "&"; }
/// <summary> /// Appends <paramref name="appendix"/> to <paramref name="url"/>. /// </summary>
https://github.com/julienkay/com.doji.genesis/blob/696728293c8ccf78eb5114f58dfcac2516ce1c70/Packages/com.doji.genesis/Runtime/Scripts/Utils/UrlUtility.cs#L11-L16
696728293c8ccf78eb5114f58dfcac2516ce1c70
semantic-kernel
github_2023
microsoft
csharp
OpenAIAssistant_Streaming.InvokeAgentAsync
private async Task InvokeAgentAsync(OpenAIAssistantAgent agent, string threadId, string input) { ChatMessageContent message = new(AuthorRole.User, input); await agent.AddChatMessageAsync(threadId, message); this.WriteAgentChatMessage(message); ChatHistory history = []; bool...
// Local function to invoke agent and display the conversation messages.
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/Concepts/Agents/OpenAIAssistant_Streaming.cs#L109-L152
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
ChatHistoryExtensions.GetSystemMessage
internal static ChatMessageContent? GetSystemMessage(this IReadOnlyList<ChatMessageContent> chatHistory) { return chatHistory.FirstOrDefault(m => m.Role == AuthorRole.System); }
/// <summary> /// Returns the system prompt from the chat history. /// </summary> /// <remarks> /// For simplicity only a single system message is supported in these examples. /// </remarks>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/Concepts/ChatCompletion/ChatHistoryReducers/ChatHistoryExtensions.cs#L22-L25
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
AutoFunctionInvocationFiltering.AutoFunctionInvocationFilterAsync
[Fact] public async Task AutoFunctionInvocationFilterAsync() { var builder = Kernel.CreateBuilder(); builder.AddOpenAIChatCompletion("gpt-4", TestConfiguration.OpenAI.ApiKey); // This filter outputs information about auto function invocation and returns overridden result. build...
/// <summary> /// Shows how to use <see cref="IAutoFunctionInvocationFilter"/>. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/Concepts/Filtering/AutoFunctionInvocationFiltering.cs#L14-L44
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
MethodFunctions_Advanced.MethodFunctionsChainingAsync
[Fact] public async Task MethodFunctionsChainingAsync() { Console.WriteLine("Running Method Function Chaining example..."); var kernel = new Kernel(); var functions = kernel.ImportPluginFromType<FunctionsChainingPlugin>(); var customType = await kernel.InvokeAsync<MyCustomType...
/// <summary> /// This example executes Function1, which in turn executes Function2. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/Concepts/Functions/MethodFunctions_Advanced.cs#L18-L31
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
VectorStore_VectorSearch_MultiVector.CreateProductRecords
private static IEnumerable<Product> CreateProductRecords() { yield return new Product { Key = 1, Description = "Premium coffee maker that allows you to make up to 20 types of drinks with one machine.", FeatureList = ["Milk Frother", "Easy to use", "One button oper...
/// <summary> /// Create some sample product records. /// </summary> /// <returns>A list of sample product records.</returns>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/Concepts/Memory/VectorStore_VectorSearch_MultiVector.cs#L92-L121
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
LegacyMenuPlugin.GetSpecials
[KernelFunction, Description("Provides a list of specials from the menu.")] [System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1024:Use properties where appropriate", Justification = "Too smart")] public string[] GetSpecials(KernelArguments? arguments) { return [ ...
/// <summary> /// Returns a mock item menu. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/Concepts/Resources/Plugins/LegacyMenuPlugin.cs#L13-L23
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
Step7_Observability.ObservabilityWithFiltersAsync
[Fact] public async Task ObservabilityWithFiltersAsync() { // Create a kernel with OpenAI chat completion IKernelBuilder kernelBuilder = Kernel.CreateBuilder(); kernelBuilder.AddOpenAIChatCompletion( modelId: TestConfiguration.OpenAI.ChatModelId, apiKey: T...
/// <summary> /// Shows how to observe the execution of a <see cref="KernelPlugin"/> instance with filters. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/GettingStarted/Step7_Observability.cs#L15-L38
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
LearnBaseTest.ReadLine
public string? ReadLine() { if (SimulatedInputTextIndex < SimulatedInputText.Count) { return SimulatedInputText[SimulatedInputTextIndex++]; } return null; }
/// <summary> /// Simulates reading input strings from a user for the purpose of running tests. /// </summary> /// <returns>A simulate user input string, if available. Null otherwise.</returns>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/samples/LearnResources/MicrosoftLearn/LearnBaseTest.cs#L23-L31
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
OpenAIAssistantChannel.ReceiveAsync
protected override async Task ReceiveAsync(IEnumerable<ChatMessageContent> history, CancellationToken cancellationToken) { foreach (ChatMessageContent message in history) { await AssistantThreadActions.CreateMessageAsync(this._client, this._threadId, message, cancellationToken).Configure...
/// <inheritdoc/>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Agents/OpenAI/OpenAIAssistantChannel.cs#L20-L26
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
OpenAIAssistantAgentLogMessages.LogOpenAIAssistantAgentCreatingChannel
[LoggerMessage( EventId = 0, Level = LogLevel.Debug, Message = "[{MethodName}] Creating assistant thread for {ChannelType}.")] public static partial void LogOpenAIAssistantAgentCreatingChannel( this ILogger logger, string methodName, string channelType);
/// <summary> /// Logs <see cref="OpenAIAssistantAgent"/> creating channel (started). /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Agents/OpenAI/Logging/OpenAIAssistantAgentLogMessages.cs#L22-L29
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
AssistantMessageFactoryTests.VerifyAssistantMessageAdapterCreateOptionsDefault
[Fact] public void VerifyAssistantMessageAdapterCreateOptionsDefault() { // Arrange (Setup message with null metadata) ChatMessageContent message = new(AuthorRole.User, "test"); // Act: Create options MessageCreationOptions options = AssistantMessageFactory.CreateOptions(message...
/// <summary> /// Verify options creation. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Agents/UnitTests/OpenAI/Internal/AssistantMessageFactoryTests.cs#L21-L33
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
HuggingFaceServiceCollectionExtensions.AddHuggingFaceTextGeneration
public static IServiceCollection AddHuggingFaceTextGeneration( this IServiceCollection services, string model, Uri? endpoint = null, string? apiKey = null, string? serviceId = null, HttpClient? httpClient = null) { Verify.NotNull(services); return ser...
/// <summary> /// Adds an Hugging Face text generation service with the specified configuration. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> instance to augment.</param> /// <param name="model">The name of the Hugging Face model.</param> /// <param name="endpoint">The endpoint URL for...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Connectors/Connectors.HuggingFace/HuggingFaceServiceCollectionExtensions.cs#L31-L48
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
PineconeServiceCollectionExtensions.AddPineconeVectorStore
public static IServiceCollection AddPineconeVectorStore(this IServiceCollection services, PineconeVectorStoreOptions? options = default, string? serviceId = default) { // If we are not constructing the PineconeClient, add the IVectorStore as transient, since we // cannot make assumptions about how P...
/// <summary> /// Register a Pinecone <see cref="IVectorStore"/> with the specified service ID and where <see cref="Sdk.PineconeClient"/> is retrieved from the dependency injection container. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> to register the <see cref="IVectorStore"/> on.</p...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Connectors/Connectors.Memory.Pinecone/PineconeServiceCollectionExtensions.cs#L22-L39
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
PostgresVectorStoreUtils.WrapAsyncEnumerableAsync
public static async IAsyncEnumerable<T> WrapAsyncEnumerableAsync<T>(IAsyncEnumerable<T> asyncEnumerable, string operationName, string? collectionName = null) { var enumerator = asyncEnumerable.ConfigureAwait(false).GetAsyncEnumerator(); var nextResult = await GetNextAsync<T>(enumerator, operationNa...
/// <summary> /// Wraps an <see cref="IAsyncEnumerable{T}"/> in an <see cref="IAsyncEnumerable{T}"/> that will throw a <see cref="VectorStoreOperationException"/> /// if an exception is thrown while iterating over the original enumerator. /// </summary> /// <typeparam name="T">The type of the items in the async enumera...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Connectors/Connectors.Memory.Postgres/PostgresVectorStoreUtils.cs#L22-L32
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
WeaviateVectorStoreCollectionCreateMapping.MapToSchema
public static WeaviateCollectionSchema MapToSchema( string collectionName, IEnumerable<VectorStoreRecordDataProperty> dataProperties, IEnumerable<VectorStoreRecordVectorProperty> vectorProperties, IReadOnlyDictionary<string, string> storagePropertyNames) { var schema = new We...
/// <summary> /// Maps record type properties to Weaviate collection schema for collection creation. /// </summary> /// <param name="collectionName">The name of the vector store collection.</param> /// <param name="dataProperties">Collection of record data properties.</param> /// <param name="vectorProperties">Collecti...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Connectors/Connectors.Memory.Weaviate/WeaviateVectorStoreCollectionCreateMapping.cs#L25-L60
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
OnnxRuntimeGenAIPromptExecutionSettings.FromExecutionSettings
[RequiresUnreferencedCode("This method uses reflection to serialize and deserialize the execution settings, making it incompatible with AOT scenarios.")] [RequiresDynamicCode("This method uses reflection to serialize and deserialize the execution settings, making it incompatible with AOT scenarios.")] public st...
/// <summary> /// Convert PromptExecutionSettings to OnnxRuntimeGenAIPromptExecutionSettings /// </summary> /// <param name="executionSettings">The <see cref="PromptExecutionSettings"/> to convert to <see cref="OnnxRuntimeGenAIPromptExecutionSettings"/>.</param> /// <returns>Returns the <see cref="OnnxRuntimeGenAIPromp...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Connectors/Connectors.Onnx/OnnxRuntimeGenAIPromptExecutionSettings.cs#L22-L39
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
QdrantVectorStoreRecordCollectionTests.CanCreateCollectionWithMismatchedDefinitionAndType
[Fact] public void CanCreateCollectionWithMismatchedDefinitionAndType() { // Arrange. var definition = new VectorStoreRecordDefinition() { Properties = new List<VectorStoreRecordProperty> { new VectorStoreRecordKeyProperty("Id", typeof(ulong)), ...
/// <summary> /// Tests that the collection can be created even if the definition and the type do not match. /// In this case, the expectation is that a custom mapper will be provided to map between the /// schema as defined by the definition and the different data model. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Connectors/Connectors.Qdrant.UnitTests/QdrantVectorStoreRecordCollectionTests.cs#L530-L549
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
PromptTemplateConfigExtensions.SetMaxTokens
internal static void SetMaxTokens(this PromptTemplateConfig config, int maxTokens) { var executionSettings = config.ExecutionSettings; foreach (var setting in executionSettings) { if (setting.Value.ExtensionData is not null) { setting.Value.ExtensionDa...
/// <summary> /// Set the max_tokens request setting to be used by OpenAI models /// </summary> /// <param name="config">PromptTemplateConfig instance</param> /// <param name="maxTokens">Value of max tokens to set</param>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Experimental/Orchestration.Flow/Extensions/PromptTemplateConfigExtensions.cs#L15-L25
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
DaprKernelProcessFactory.StartAsync
public static async Task<DaprKernelProcessContext> StartAsync(this KernelProcess process, KernelProcessEvent initialEvent, string? processId = null) { Verify.NotNull(process); Verify.NotNullOrWhiteSpace(process.State?.Name); Verify.NotNull(initialEvent); // Assign the process Id if ...
/// <summary> /// Starts the specified process. /// </summary> /// <param name="process">Required: The <see cref="KernelProcess"/> to start running.</param> /// <param name="initialEvent">Required: The initial event to start the process.</param> /// <param name="processId">Optional: Used to specify the unique Id of the...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Experimental/Process.Runtime.Dapr/DaprKernelProcessFactory.cs#L18-L33
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
XunitLogger.Log
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter) { this._output.WriteLine(state?.ToString()); }
/// <inheritdoc/>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/IntegrationTests/XunitLogger.cs#L17-L20
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
MixedAgentTests.OpenAIMixedAgentTestAsync
[Theory(Skip = "OpenAI will often throttle requests. This test is for manual verification.")] [InlineData(false)] [InlineData(true)] public async Task OpenAIMixedAgentTestAsync(bool useNewFunctionCallingModel) { OpenAIConfiguration openAISettings = this._configuration.GetSection("OpenAI").Get<Op...
/// <summary> /// Integration test for <see cref="OpenAIAssistantAgent"/> using function calling /// and targeting Open AI services. /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/IntegrationTests/Agents/MixedAgentTests.cs#L36-L50
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
QdrantTextSearchTests.CreateTextSearchAsync
public override Task<ITextSearch> CreateTextSearchAsync() { if (this.VectorStore is null) { this.EmbeddingGenerator = fixture.EmbeddingGenerator; this.VectorStore = new QdrantVectorStore(fixture.QdrantClient); } var options = new QdrantVectorStoreRecordCollec...
/// <inheritdoc/>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/IntegrationTests/Connectors/Memory/Qdrant/QdrantTextSearchTests.cs#L20-L39
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
ClientResultExceptionExtensions.ToHttpOperationException
public static HttpOperationException ToHttpOperationException(this ClientResultException exception) { const int NoResponseReceived = 0; string? responseContent = null; try { responseContent = exception.GetRawResponse()?.Content.ToString(); } #pragma warning disa...
/// <summary> /// Converts a <see cref="ClientResultException"/> to an <see cref="HttpOperationException"/>. /// </summary> /// <param name="exception">The original <see cref="ClientResultException"/>.</param> /// <returns>An <see cref="HttpOperationException"/> instance.</returns>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/InternalUtilities/openai/Extensions/ClientResultExceptionExtensions.cs#L19-L38
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
ProcessStateMetadataFactory.KernelProcessToProcessStateMetadata
public static KernelProcessStateMetadata KernelProcessToProcessStateMetadata(KernelProcess kernelProcess) { KernelProcessStateMetadata metadata = new() { Name = kernelProcess.State.Name, Id = kernelProcess.State.Id, VersionInfo = kernelProcess.State.Version, ...
/// <summary> /// Captures Kernel Process State into <see cref="KernelProcessStateMetadata"/> /// </summary> /// <returns><see cref="KernelProcessStateMetadata"/></returns>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/InternalUtilities/process/Abstractions/KernelProcessStateMetadataFactory.cs#L14-L30
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
Verify.NotNull
[MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void NotNull([NotNull] object? obj, [CallerArgumentExpression(nameof(obj))] string? paramName = null) { #if NET ArgumentNullException.ThrowIfNull(obj, paramName); #else if (obj is null) { ThrowArgumentNullExce...
/// <summary> /// Equivalent of ArgumentNullException.ThrowIfNull /// </summary>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/InternalUtilities/src/Diagnostics/Verify.cs#L33-L44
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
MathPlugin.Add
[KernelFunction, Description("Adds an amount to a value")] [return: Description("The sum")] public int Add( [Description("The value to add")] int value, [Description("Amount to add")] int amount) => value + amount;
/// <summary> /// Returns the addition result of initial and amount values provided. /// </summary> /// <param name="value">Initial value to which to add the specified amount.</param> /// <param name="amount">The amount to add as a string.</param> /// <returns>The resulting sum as a string.</returns>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Plugins/Plugins.Core/MathPlugin.cs#L18-L23
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
GoogleTextSearch.DefaultTextSearchResultMapper.MapFromResultToTextSearchResult
public TextSearchResult MapFromResultToTextSearchResult(object result) { if (result is not global::Google.Apis.CustomSearchAPI.v1.Data.Result googleResult) { throw new ArgumentException("Result must be a Google Result", nameof(result)); } return n...
/// <inheritdoc />
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/Plugins/Plugins.Web/Google/GoogleTextSearch.cs#L288-L296
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
TextGenerationExtensions.GetTextContentAsync
public static async Task<TextContent> GetTextContentAsync( this ITextGenerationService textGenerationService, string prompt, PromptExecutionSettings? executionSettings = null, Kernel? kernel = null, CancellationToken cancellationToken = default) => (await textGenerationSe...
/// <summary> /// Get a single text generation result for the prompt and settings. /// </summary> /// <param name="textGenerationService">Text generation service</param> /// <param name="prompt">The standardized prompt input.</param> /// <param name="executionSettings">The AI execution settings (optional).</param> /// ...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/SemanticKernel.Abstractions/AI/TextGeneration/TextGenerationExtensions.cs#L27-L34
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
RestApiOperationResponseConverter.CanConvertTo
public override bool CanConvertTo(ITypeDescriptorContext? context, Type? destinationType) { return destinationType == typeof(string) || base.CanConvertTo(context, destinationType); }
/// <inheritdoc/>
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/SemanticKernel.Abstractions/Functions/RestApiOperationResponseConverter.cs#L15-L18
cd84e877980187e62d86bb5bc6086d264e62ee83
semantic-kernel
github_2023
microsoft
csharp
PromptTemplateFactoryExtensions.Create
public static IPromptTemplate Create(this IPromptTemplateFactory factory, PromptTemplateConfig templateConfig) { Verify.NotNull(factory); Verify.NotNull(templateConfig); if (!factory.TryCreate(templateConfig, out IPromptTemplate? result)) { throw new KernelException($"Pr...
/// <summary> /// Creates an instance of <see cref="IPromptTemplate"/> from a <see cref="PromptTemplateConfig"/>. /// </summary> /// <param name="factory">The factory with which to create the template.</param> /// <param name="templateConfig">Prompt template configuration</param> /// <returns>The created template.</ret...
https://github.com/microsoft/semantic-kernel/blob/cd84e877980187e62d86bb5bc6086d264e62ee83/dotnet/src/SemanticKernel.Abstractions/PromptTemplate/PromptTemplateFactoryExtensions.cs#L17-L28
cd84e877980187e62d86bb5bc6086d264e62ee83
Intellenum
github_2023
SteveDunn
csharp
IEnumerableExtensions.HasExactly
public static bool HasExactly<TSource>(this IEnumerable<TSource> source, int count) { if (source is null) { throw new ArgumentNullException(nameof(source)); } if (source is ICollection<TSource> collectionoft) { return collectionoft.Count == count; ...
/// <summary>
https://github.com/SteveDunn/Intellenum/blob/d3cdb8826f3af62856a41a6974c76a7c5288f326/src/Intellenum/Extensions/IEnumerableExtensions.cs#L110-L137
d3cdb8826f3af62856a41a6974c76a7c5288f326
Software-Architecture-with-C-Sharp-12-and-.NET-8-4E
github_2023
PacktPublishing
csharp
initial.BuildTargetModel
protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder .HasAnnotation("ProductVersion", "8.0.0-preview.6.23329.4") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExt...
/// <inheritdoc />
https://github.com/PacktPublishing/Software-Architecture-with-C-Sharp-12-and-.NET-8-4E/blob/bb5f06a93c7a6ca281f88b0e3e16fb1302ebf943/ch09/PackagesManagementWithTests/PackagesManagementDB/Migrations/20230717141854_initial.Designer.cs#L19-L401
bb5f06a93c7a6ca281f88b0e3e16fb1302ebf943
node-api-dotnet
github_2023
microsoft
csharp
Benchmarks.Clr.DynamicCallDotnetMethod
[Benchmark] public void DynamicCallDotnetMethod() { _jsFunctionCallMethodDynamic.CallAsStatic(_jsHost); }
// CLR-only (non-AOT) benchmarks
https://github.com/microsoft/node-api-dotnet/blob/956d1b14426f3c41c3464d60544c5ee486241d3f/bench/Benchmarks.cs#L263-L267
956d1b14426f3c41c3464d60544c5ee486241d3f
node-api-dotnet
github_2023
microsoft
csharp
NodeWorker.MessagePort.Unref
public void Unref() { _portRef.Run((port) => port.CallMethod("unref")); }
/// <summary>
https://github.com/microsoft/node-api-dotnet/blob/956d1b14426f3c41c3464d60544c5ee486241d3f/src/NodeApi/Interop/NodeWorker.cs#L299-L302
956d1b14426f3c41c3464d60544c5ee486241d3f
Polyfill
github_2023
SimonCropp
csharp
EnumPolyfill.GetValues
public static TEnum[] GetValues<TEnum>() where TEnum : struct, Enum { #if NETCOREAPPX || NETFRAMEWORK || NETSTANDARD var values = Enum.GetValues(typeof(TEnum)); var result = new TEnum[values.Length]; Array.Copy(values, result, values.Length); return result; #else retu...
/// <summary>
https://github.com/SimonCropp/Polyfill/blob/b3fc2b19ec553e6971f8bb688d0116c8b61f6788/src/Polyfill/EnumPolyfill.cs#L23-L34
b3fc2b19ec553e6971f8bb688d0116c8b61f6788
Polyfill
github_2023
SimonCropp
csharp
Polyfill.GetStreamAsync
public static async Task<Stream> GetStreamAsync( this HttpClient target, string requestUri, CancellationToken cancellationToken = default) { try { // Must not be disposed for the stream to be usable var response = await target.GetAsync( ...
/// <summary>
https://github.com/SimonCropp/Polyfill/blob/b3fc2b19ec553e6971f8bb688d0116c8b61f6788/src/Polyfill/Polyfill_HttpClient.cs#L23-L48
b3fc2b19ec553e6971f8bb688d0116c8b61f6788