命名空间中的特殊字符 [英] Special characters in a Namespace

查看:29
本文介绍了命名空间中的特殊字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑在自定义框架的命名空间中使用带有变音符号(例如,ō)的字符.这个想法是作为区分产品的一种方式出现的,但我想确保这不是一个坏主意,如果有任何关于它的东西,以后会回来咬我.我在搜索中没有看到使用特殊字符的命名空间的其他示例,也没有关于该主题的任何类似讨论,这让我停下来继续沿着这条路走下去.

I am considering using a character with a diacritical mark (e.g., ō) in a namespace for a custom framework. This idea has come up as a way to distinguish a product, but I want to to be sure this isn't a bad idea, and if there is anything about it that will come back to bite me later. I have not seen other examples of namespaces that use special characters in my searching, nor any similar discussion on this topic, which gives me pause in continuing down this path.

我最初也考虑用变音符号命名程序集,但我遇到的第一个阻碍是尝试对程序集进行数字签名.我无法让特殊字符出现在命令提示符中,所以我收到了 No valid input 错误.也许还有其他解决方法?

I was initially considering naming the assembly with a diacritical mark as well, but the first showstopper I ran into was in trying to digitally sign the assembly. I could not get the special character to appear in the command prompt, so I got a No valid input error. Perhaps there is another workaround for this?

我意识到的一个问题是,它使得在 Visual Studio 中输入命名空间更具挑战性.但是,我不认为这是一个主要问题,因为字符将出现在我使用的词的末尾,这个词将是相当独特的,并且使用 IntelliSense 这应该不是什么大问题.

One gotcha I realize is that it makes typing out the namespace in Visual Studio more challenging. I'm not seeing this as a major issue, however, since the character will come near the end of the word I am using, the word will be rather unique, and with IntelliSense this shouldn't be too big of a problem.

考虑以下示例,包含在程序集 Macron.dll 中:

Consider the following example, contained in assembly Macron.dll:

namespace Macrōn.Library
{
    public class MyLibrary
    {
        public string MyProperty { get; set; }
    }
}

生成和使用此 Macron.dll 似乎没有问题,也没有区分此示例 Macrōn.Library 命名空间的问题.文件、文件夹、项目和解决方案名称 Macrōn 似乎没有引起任何问题,一切似乎都与源代码控制相吻合,没有任何问题.

There appears to be no issues with generating and using this Macron.dll, and there are no issues distinguishing this example Macrōn.Library namespace. The file, folder, project & solution names Macrōn do not seem to cause any issues, and everything seems to jibe with source control without any issues.

在程序集和命名空间中使用变音符号时,还有什么其他注意事项或我遗漏的东西吗?关于解决我签署程序集的问题有什么想法吗?这种方法一定会失败吗?是否真的不值得实施,因为它可能会令人困惑或难以/难以使用?

Any other considerations or things I am missing when using a diacritical mark in an assembly and namespace? Any thoughts on getting around my issue signing the assembly? Is this approach bound to fail? Is it really just not worth implementing, as it may be confusing or otherwise difficult/obscure to use?

这将变成以后要撤消的大量工作,所以我想知道我是否在深入了解这个问题之前向自己开枪.

This will turn into a lot of work to undo later, so I want to know if I'm shooting myself in the foot before I get too deep into this.

谢谢.

推荐答案

我想确定这不是一个坏主意,如果有什么事情以后会回来咬我.

I want to to be sure this isn't a bad idea, and if there is anything about it that will come back to bite me later.

这是有效的.许多混淆器将命名空间/类型更改为具有 unicode 字符,其中一些甚至不可打印,从而使逆向工程更加困难.

It is valid. Many obfuscators change namespaces / types to have unicode characters, some of them even non-printable, to make reverse engineering more difficult.

话虽如此,如果这是其他人会使用的公共框架,我会劝阻它.这将强制任何使用命名空间的人将他们的源文件保存为 Unicode/UTF8,如果他们不这样做,那么 ō 字符可能会被替换为 ?.然后它就不再编译了.

That being said, if this is a public framework that others will consume, I'd discourage it. That would force anyone using the namespace to save their source file as Unicode / UTF8, and if they don't, the ō character will likely be replaced with a ?. Then it'd no longer compile.

Alexei 也发表了非常好的评论.除了复制和粘贴之外,我不知道如何输入 ō 字符.那肯定会让我慢下来.

Alexei made a very good comment as well. I have no idea how to type the ō character other than copy and paste it. That would certainly slow me down.

这篇关于命名空间中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆