Skip to content

Instantly share code, notes, and snippets.

View benvillalobos's full-sized avatar

Ben Villalobos benvillalobos

View GitHub Profile
@benvillalobos
benvillalobos / logger-output.md
Last active May 10, 2024 18:38
C# Unit Testing: Verifying ILogger Output with Moq

Context

Using the Moq framework, it's non-trivial in some cases to verify "Did my logger actually log X message?" The first important note is you can't use Moq on extension methods, so you can't directly check LogWarning for example. The workaround is to mock the method that the extension method calls..

For example, I want to verify that LogWarning(mymsg) was logged, but LogWarning is an extension method. So instead of checking that LogWarning was called, we check that Log was called because LogWarning eventually calls Log.

Finally, this SO post showed me how to verify that specific message was l

@benvillalobos
benvillalobos / timetrialinvestigation.md
Last active February 20, 2024 16:22
gravitorium-2-20

Investigation Notes

Time Trial object is the following:

  1. An object that is anchored at the bottom
  2. A background that has an image
  3. Text which is constantly being modified ----
  4. Note it also exists in a separate canvas
  5. Also note: It exists within DontDestroyOnLoad

References

@benvillalobos
benvillalobos / foo.md
Last active February 15, 2024 18:48
vscode-webview-copy

There is a CopyToClipboard message that the webview sends.

This means the webview needs to send the copy to clipboard message, while sending the contents to copy within the message.

So within a react file I might have access to the window! <- confirmed

Extension sees the rightclick -> Copy command

Extension tells webview to copy via CopyToClipboard

@benvillalobos
benvillalobos / response-header-override.md
Created December 8, 2023 22:00
Overriding Response Headers in Chrome or Edge

‎‎​

@benvillalobos
benvillalobos / default.code-profile
Last active August 21, 2023 20:34
default.code-profile
{
"name": "education",
"settings": "{\"settings\":\"{\\n \\\"workbench.statusBar.visible\\\": false,\\n\\t\\\"workbench.layoutControl.enabled\\\": false,\\n \\\"window.title\\\": \\\"VS Code for Education\\\",\\n \\\"window.menuBarVisibility\\\": \\\"toggle\\\",\\n \\\"breadcrumbs.enabled\\\": false,\\n \\\"editor.minimap.enabled\\\": false,\\n \\\"extensions.ignoreRecommendations\\\": true,\\n \\\"editor.inlineSuggest.enabled\\\": true,\\n \\\"editor.fontSize\\\": 15,\\n \\\"editor.lineHeight\\\": 1.75,\\n \\\"python.wasm.runtime\\\": \\\"vscode-edu-py:///\\\"\\n}\"}",
"globalState": "{\"storage\":{\"menu.hiddenCommands\": {\"EditorTitle\":[\"workbench.action.splitEditor\"]},\"workbench.panel.markers.hidden\":\"[{\\\"id\\\":\\\"workbench.panel.markers.view\\\",\\\"isHidden\\\":false}]\",\"workbench.panel.output.hidden\":\"[{\\\"id\\\":\\\"workbench.panel.output\\\",\\\"isHidden\\\":false}]\",\"terminal.hidden\":\"[{\\\"id\\\":\\\"terminal\\\",\\\"isHidden\\\":fals
@benvillalobos
benvillalobos / binlog-spelunking.md
Last active September 7, 2022 23:39
Spelunking Through Binlogs

Spelunking Through Binlogs

This stuff ain't easy, so here's a WIP "get you up to speed" doc.

Setup

@benvillalobos
benvillalobos / custom-task-system-memory.md
Last active August 25, 2022 19:13
MSBuild Custom Task: Can't Find System.Memory

Custom MSBuild Task Can't Find System.Memory?

Why is this happening?

Your task is probably on .NET Core, meanwhile you're building with the net472-targeted MSBuild.exe. To fix this: either switch from using MSBuild.exe to using dotnet build, or change the TargetFramework of your task.

The long answer

Workarounds

  • Set the TargetFramework property in your task's project to net472.
@benvillalobos
benvillalobos / make-msbuild-short-lived.md
Last active August 25, 2022 18:50
Stop MSBuild From Holding Files

Stop MSBuild From Locking Files

Stop MSBuild from locking your files! Also, consider that the problem could be MSBuild or something your build is doing.

Note: Use Visual Studio Developer Command Prompt.

In Visual Studio

  1. set MSBUILDDISABLENODEREUSE=1
  2. devenv yourproject.csproj

In CLI

@benvillalobos
benvillalobos / debugging-custom-msbuild-tasks.md
Last active March 31, 2024 00:08
Debugging Custom MSBuild Tasks

Debugging Custom MSBuild Tasks

A brief explanation on debugging msbuild tasks. Anything done on CLI (command-line interface) should be done in a Visual Studio Developer Command Prompt. If you have VS installed, search for "Developer command prompt."

This also works for dotnet builds.

Steps

  1. Have VS open & breakpoint into your custom task.
  2. Open up a developer command prompt.
  3. cd your/project/directory
  4. set MSBUILDDEBUGONSTART=1
@benvillalobos
benvillalobos / Debugging-An-MSBuild-Build.md
Last active August 25, 2022 18:18
Debugging An MSBuild Build

Debugging An MSBuild Build

MSBuild is open-source, which means you should be able to step through the execution of a build by following these steps.

Sync Up With Your Installed MSBuild

  1. Developer Command Prompt: msbuild --version You should see something like MSBuild version 17.3.1+362d18ee6 for .NET Framework
    • Everything after the + is the hash. Copy that
  2. git clone https://github.com/dotnet/msbuild
  3. git checkout 362d18ee6
  4. VS -> MSBuild.Dev.slnf
  5. VS -> Tools -> Options -> Disable Just My Code