Skip to content

Instantly share code, notes, and snippets.

View KirillOsenkov's full-sized avatar

Kirill Osenkov KirillOsenkov

View GitHub Profile
(MSBuild, 8087, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(CheckIfPackageReferenceShouldBeFrameworkReference, 4724, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(ResolveAssemblyReference, 4587, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(Microsoft.SourceLink.GitHub.GetSourceLinkUrl, 4062, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(Microsoft.SourceLink.AzureRepos.Git.GetSourceLinkUrl, 4062, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(GenerateDepsFile, 3957, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(ApplyImplicitVersions, 2962, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(Csc, 2554, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(RemoveDuplicates, 2497, Microsoft.Build.Logging.StructuredLogger.Parameter[])
(ProcessFrameworkReferences, 2473, Microsoft.Build.Logging.StructuredLogger.Parameter[])
Output Item(s):
ReferenceCopyLocalPaths=
F:\workspace\_work\1\s\artifacts\bin\ApiExplorerWebSite\Release\netcoreapp5.0\ApiExplorerWebSite.dll
BuildReference=true
CopyLocal=true
CopyUpToDateMarker=F:\workspace\_work\1\s\artifacts\obj\ApiExplorerWebSite\Release\netcoreapp5.0\ApiExplorerWebSite.csproj.CopyComplete
FusionName=ApiExplorerWebSite, Version=5.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
HasSingleTargetFramework=true
ImageRuntime=v4.0.30319
IsRidAgnostic=true
(ResolveAssemblyReference, 481763219, 4142, System.Collections.Generic.List`1[System.String])
(Copy, 170029945, 3995, System.Collections.Generic.List`1[System.String])
(ConvertToAbsolutePath, 160853435, 686, System.Collections.Generic.List`1[System.String])
(ResolvePackageFileConflicts, 119475640, 2308, System.Collections.Generic.List`1[System.String])
(ResolvePackageAssets, 78412896, 4800, System.Collections.Generic.List`1[System.String])
(ResolveTargetingPackAssets, 63086568, 2608, System.Collections.Generic.List`1[System.String])
(RemoveDuplicates, 54251475, 2567, System.Collections.Generic.List`1[System.String])
(MSBuild, 54184363, 4225, System.Collections.Generic.List`1[System.String])
(FindUnderPath, 28355450, 1455, System.Collections.Generic.List`1[System.String])
(MsBuild, 19543733, 20, System.Collections.Generic.List`1[System.String])
(GenerateDepsFile, 334253712, 10660, System.Collections.Generic.List`1[System.String])
(Csc, 198884194, 25690, System.Collections.Generic.List`1[System.String])
(Hash, 185495696, 2564, System.Collections.Generic.List`1[System.String])
(Copy, 168462918, 17588, System.Collections.Generic.List`1[System.String])
(ConvertToAbsolutePath, 162084255, 2641, System.Collections.Generic.List`1[System.String])
(ResolvePackageFileConflicts, 150844605, 3762, System.Collections.Generic.List`1[System.String])
(FindUnderPath, 116987954, 7579, System.Collections.Generic.List`1[System.String])
(ResolveAssemblyReference, 114441190, 14794, System.Collections.Generic.List`1[System.String])
(RemoveDuplicates, 72216043, 2567, System.Collections.Generic.List`1[System.String])
(MSBuild, 52024344, 37867, System.Collections.Generic.List`1[System.String])
var virtualStream = new ReadVirtualStream((ulong address, byte[] buffer, int byteCount, out int bytesRead) =>
{
process.ReadMemory(address, (uint)byteCount, buffer, out var bytesReadIntPtr);
bytesRead = bytesReadIntPtr.ToInt32();
return true;
}, module.BaseAddress, module.Size);
var moduleDefinition = ModuleDefinition.ReadModule(virtualStream, new ReaderParameters(ReadingMode.Deferred)
{
InMemory = true,
@KirillOsenkov
KirillOsenkov / AddGeneratedFile.csproj
Last active April 17, 2025 05:12
Sample of generating a .cs file during build and adding it to the compilation
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<GeneratedText><![CDATA[
using System%3B
@KirillOsenkov
KirillOsenkov / RoslynToMonoDevelopIVT.txt
Created April 12, 2019 20:57
IVT usage from Roslyn to MonoDevelop
C:\xmd\main\build\bin\Microsoft.CodeAnalysis.dll
================================================
Consumed in: C:\xmd\main\build\bin\MonoDevelop.Ide.dll
Microsoft.CodeAnalysis.Text.TextLineCollection Microsoft.CodeAnalysis.Text.SourceText::GetLinesCore()
System.Void Microsoft.CodeAnalysis.Diagnostics.AnalyzerReference::.ctor()
System.Void Microsoft.CodeAnalysis.DocumentationProvider::.ctor()
System.Void Microsoft.CodeAnalysis.PortableExecutableReference::.ctor(Microsoft.CodeAnalysis.MetadataReferenceProperties,System.String,Microsoft.CodeAnalysis.DocumentationProvider)
System.Void Microsoft.CodeAnalysis.Text.SourceText::.ctor(System.Collections.Immutable.ImmutableArray`1<System.Byte>,Microsoft.CodeAnalysis.Text.SourceHashAlgorithm,Microsoft.CodeAnalysis.Text.SourceTextContainer)
System.Void Microsoft.CodeAnalysis.Text.TextLineCollection::.ctor()
@KirillOsenkov
KirillOsenkov / Directory.Build.props
Created April 12, 2019 16:56
SDK-style Directory.Build.props for common output directory
<Project>
<PropertyGroup>
<SrcRoot>$(MSBuildThisFileDirectory)</SrcRoot>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(SrcRoot)\</SolutionDir>
<Configuration Condition="$(Configuration) == ''">Debug</Configuration>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net472</TargetFramework>
@KirillOsenkov
KirillOsenkov / AssemblyLoadFile.md
Created June 2, 2017 22:36 — forked from davkean/AssemblyLoadFile.md
Why Assembly.LoadFile is not the right API to call

Assembly.LoadFile is almost always the wrong API to call inside an application. It says to the CLR “hands off, this assembly will live in its own little universe and don’t you apply any of your normal rules for loading assemblies”. Below you’ve effectively loaded two of these universes and one doesn’t see the other. LoadFile also forces you to hook onto AssemblyResolve (like you’ve done below[1]) and tell the CLR about every dependency that assembly needs to resolve. It also opts you out of other things such as binding redirects, retargeting (v1 portable won’t load below) and a few other things.

Assembly.LoadFile is used by designers, and should be called Assembly.LoadFile_ForDesignerUseOnly, it’s unfortunate it has such as tempting name.

If this is inside of VS, it is most definitely not the correct API to call. You want to use Assembly.Load, Assembly.LoadFrom and/or use VS related APIs for registering binding paths. It already has an assembly resolve, and no one else should be hooking onto it.

[1] That

using System.IO;
using System.Linq;
class FileRangeRenamer
{
static void Main(string[] args)
{
var folder = @"D:\Photos\June12\Clouds1";
var files = Directory.GetFiles(folder, "*.CR2").OrderBy(f => f).ToArray();
foreach (var file in files)