Table of Contents: File Operations Debug and Trace Classes Conditional Compilation MethodImpl Attribute CLSComplianceAttribute Custom Type Aliases When Necessary I have recently been reading the source code of .NET Core Runtime, referencing the code of experts…

2020年12月15日 1条评论 1182点热度 2人点赞 痴者工良 阅读全文

目录: 1,文件操作 2,Debug、Trace类 3,条件编译 4,MethodImpl 特性 5,CLSComplianAttribute 6,必要时自定义类型别名 最近在阅读 .NET Core Runtime 的源码,参考大佬的代码,学习编写技巧和提高代码水平。学习过程中将学习心得和值得应用到项目中的代码片段记录下来,供日后查阅。 1,文件操作 这段代码在 System.Private.CoreLib 下,对 System.IO.File 中的代码进行精简,供 CLR 使用。 当使用文件时,要提前判断文件路…

2020年12月15日 1条评论 5302点热度 2人点赞 痴者工良 阅读全文

Microsoft's official Docker images cannot run EFCore directly, resulting in the following exception: System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvoc…

2020年12月10日 0条评论 1124点热度 3人点赞 痴者工良 阅读全文

Microsoft 官方的 Docker 镜像不能直接运行 EFCore,会出现异常: System.TypeInitializationException: The type initializer for 'Microsoft.Data.Sqlite.SqliteConnection' threw an exception. ---> System.Reflection.TargetInvocationException: Exception has been thrown by th…

2020年12月10日 0条评论 8997点热度 3人点赞 痴者工良 阅读全文

1. Available Versions and References 2. ValueTask<TResult> and Task 3. How the Compiler Compiles 4. What Are the Advantages of ValueTask 5. Creating Asynchronous Tasks with ValueTask 6. IValueTaskSource and Custom Wrapping of ValueTask About IValueTaskSo…

2020年12月3日 10条评论 1877点热度 0人点赞 痴者工良 阅读全文

1,可用版本与参考资料 2,ValueTask<TResult> 和 Task 3,编译器如何编译 4,ValueTask 有什么优势 5,ValueTask 创建异步任务 6,IValueTaskSource 和自定义包装 ValueTask 关于 IValueTaskSource 什么是 IValueTaskSource 再说 ValueTask 优势 不要自己全部实现 IValueTaskSource ValueTaskSourceOnCompletedFlags ValueTaskSourceS…

2020年12月3日 10条评论 9477点热度 0人点赞 痴者工良 阅读全文

Distinguishing Debug and Release Environments It is well known that Debug is the compilation constant that is automatically available when developing in VS, while the code released uses Release. To create different compilation conditions in Debug and Release e…

2020年11月23日 3条评论 1156点热度 1人点赞 痴者工良 阅读全文

区分 调试和发布环境 众所周知,Debug 是在开发、在 VS 中时,自动会有的编译常量,而代码发布后则是 Release。 为了在 Debug、Release 环境下出现不同的编译条件。 .NET Core 项目添加条件编译变量,可在 .csproj 中加上 <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> <DefineConstants>AAAA</DefineConstants&…

2020年11月23日 3条评论 8030点热度 1人点赞 痴者工良 阅读全文

Parallelism through simple threads Every year, parallelism and concurrency become more important as processors tend to have more and more physical cores. In most languages, writing parallel code is tricky. Very tricky. Not so in Rust, as it has been designed a…

2020年11月23日 0条评论 1072点热度 0人点赞 痴者工良 阅读全文

Parallelism through simple threads Every year, parallelism and concurrency become more important as processors tend to have more and more physical cores. In most languages, writing parallel code is tricky. Very tricky. Not so in Rust, as it has been designed a…

2020年11月23日 0条评论 5944点热度 0人点赞 痴者工良 阅读全文

Using the builder pattern Sometimes you need something between the customization of the constructor and the implicitness of the default implementation. Enter the builder pattern, another technique frequently used by the Rust standard library, as it allows a ca…

2020年11月23日 0条评论 1004点热度 0人点赞 痴者工良 阅读全文

Using the builder pattern Sometimes you need something between the customization of the constructor and the implicitness of the default implementation. Enter the builder pattern, another technique frequently used by the Rust standard library, as it allows a ca…

2020年11月23日 0条评论 3854点热度 0人点赞 痴者工良 阅读全文

Using the constructor pattern You may have asked yourself how to idiomatically initialize complex structs in Rust, considering it doesn't have constructors. The answer is simple, there is a constructor, it's just a convention rather than a rule. Rust's standar…

2020年11月23日 0条评论 946点热度 0人点赞 痴者工良 阅读全文

Using the constructor pattern You may have asked yourself how to idiomatically initialize complex structs in Rust, considering it doesn't have constructors. The answer is simple, there is a constructor, it's just a convention rather than a rule. Rust's standar…

2020年11月23日 0条评论 3453点热度 0人点赞 痴者工良 阅读全文

Providing a default implementation Often, when dealing with structures that represent configurations, you don't care about certain values and just want to silently assign them a standard value. Usually, when processing structures that represent configurations,…

2020年11月23日 0条评论 1186点热度 0人点赞 痴者工良 阅读全文

Providing a default implementation Often, when dealing with structures that represent configurations, you don't care about certain values and just want to silently assign them a standard value. 通常,当处理表示配置的结构时,你并不关心某些值,只想为其默默分配一个标准值。 Rust 使用 Default::default();…

2020年11月23日 0条评论 4370点热度 0人点赞 痴者工良 阅读全文

Using the format! macro format! is a Rust macro that is essentially similar to the usage of String.Format() in C#. There is an additional way to combine strings, which can also be used to combine them with other data types, such as numbers. It provides another…

2020年11月23日 0条评论 1066点热度 2人点赞 痴者工良 阅读全文

Using the format! macro format! 是一个 rust 宏,跟 C# 的 String.Format() 用法基本一致。 There is an additional way to combine strings, which can also be used to combine them with other data types, such as numbers. 能够以另一种方式去组合字符串,也可以组合不同的数据类型,例如数字。 其定义如下: #[macro_export] #[s…

2020年11月23日 0条评论 4713点热度 2人点赞 痴者工良 阅读全文

How to convert pfx to other types of certificates. Convert pfx to pem openssl pkcs12 -in ssl.pfx -nodes -out ssl.pem Convert pem to cer openssl x509 -in ssl.pem -inform PEM -out ssl.der -outform DER Output all information of the pem certificate: openssl x509 -…

2020年11月23日 2条评论 1290点热度 2人点赞 痴者工良 阅读全文

pfx 转换为其他类型证书的方法。 pfx 转 pem openssl pkcs12 -in ssl.pfx -nodes -out ssl.pem pem 转 cer openssl x509 -in ssl.pem -inform PEM -out ssl.der -outform DER 输出 pem 证书的所有信息: openssl x509 -in ss.pem -noout -text Certificate: Data: Version: 3 (0x2) Serial Number: 86900348…

2020年11月23日 2条评论 7638点热度 2人点赞 痴者工良 阅读全文
1262728293054