Skip to content

Instantly share code, notes, and snippets.

[CmdletBinding()]
param (
[string[]]
$ReferenceFrom,
[string]
$Assembly,
[string]
$TargetFrameworkVersion,
using System;
using System.IO;
using System.Reflection;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
namespace NetDataContractSerializerTest
{
class Program
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization;
using System.Text;
using System.Xml;
namespace DataContractSerializerTest
{
class Program
@urasandesu
urasandesu / CoCreateInstance_without_CoInitialize.cpp
Last active August 29, 2015 14:00
Code snippet for same work as CoCreateInstance without CoInitialize. See also the reference [Registration-free COM - Mikhail Arkhipov (MSFT)'s WebLog - Site Home - MSDN Blogs](http://blogs.msdn.com/b/mikhailarkhipov/archive/2005/04/01/404433.aspx). In Profiling API, timing to call CoInitialize is basically unknown. This hack will enable that you…
#include "stdafx.h"
#ifndef URASANDESU_CPPANONYM_CPPANONYMNOTIMPLEMENTEDEXCEPTION_H
#include <Urasandesu/CppAnonym/CppAnonymNotImplementedException.h>
#endif
#ifndef URASANDESU_CPPANONYM_CPPANONYMCOMEXCEPTION_H
#include <Urasandesu/CppAnonym/CppAnonymCOMException.h>
#endif
namespace System
{
public struct DateTime
{
public static DateTime Now
{
get
{
// スタブでやっていたことの逆が挿入される。
var holder = default(IndirectionHolder<IndirectionFunc<DateTime>>);
namespace System
{
public struct DateTime
{
public static DateTime Now
{
get
{
return DateTime.UtcNow.ToLocalTime();
}
using NUnit.Framework;
using program1.MyLibrary;
using System;
using System.Prig;
using Urasandesu.Prig.Framework;
namespace Test.program1.MyLibraryTest
{
[TestFixture]
public class LifeInfoTest
using Urasandesu.Prig.Framework;
// IndirectableAttribute を使い、スタブに入れ替えたい Assembly にメタデータトークンを付与します。
// このメタデータトークンですが、問題になっている DateTime.Now の getter メソッドは get_Now という
// 名前の静的メソッドですので、そのトークンである 0x060002D2 を指定します。
// ※メタデータトークンは、対象の dll を ildasm 等で逆コンパイルしたり、MethodInfo.MetadataToken を
// 参照することによって確認することができます。
[assembly: Indirectable(0x060002D2)]
namespace System.Prig
using System;
namespace program1.MyLibrary
{
public static class LifeInfo
{
public static bool IsLunchBreak()
{
var now = DateTime.Now;
return 12 <= now.Hour && now.Hour < 13;
using System;
using System.Prig;
using Urasandesu.Prig.Framework;
namespace program1
{
class Program
{
static void Main(string[] args)
{