建议122:以<Company>.<Component>为命名空间命名

本文讨论了在.NET项目中如何合理地定义命名空间,提出了一种有效的命名方式:使用&lt;Company&gt;.&lt;Component&gt;作为命名空间的基础,并探讨了这种命名方式的优势和必要性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

建议122:以<Company>.<Component>为命名空间命名

建议以<Company>.<Component>为程序集命名,比如Microsoft.Windows.Design。这有助于唯一地标识我们的命名空间。

另外一种有效且肯定是唯一的表示命名空间的方式是使用域名。假设我们的域名是www.microsoft.com,那么命名空间应该命名为Com.Microsoft.<Component>。使用域名命名自己的程序的方法在Java世界中一直很流行,现在不妨把这种习惯带到.NET世界中来。如果是个人在开发软件,则更建议采用这种方式。去申请一个域名吧,这很有意义。

单纯以<Component>为命名空间名很容易造成混淆。假设我们的应用程序中存在一个Utility模块,若命名为Utility,现在恰巧我们使用一个第三方的dll也是单纯以Utility为模块命名,那么极有可能造成模块下命名冲突。

不要将眼界局限在团队内部,应该考虑到代码会和别的代码交互。所以,好的命名空间规范会为我们规避这方面的限制。

 

 

转自:《编写高质量代码改善C#程序的157个建议》陆敏技

<?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://wixtoolset.org/schemas/v6/wxs"> <Package Id="AcmeCorp.QuickStartExample" Name="MyApp" Manufacturer="MyCompany" Version="1.0.0.0" InstallerVersion="600" Compressed="yes" InstallScope="perMachine"> <!-- 主程序文件 --> <File Source="MyApp.exe" /> <!-- 目录结构 --> <StandardDirectory Id="ProgramFiles64Folder"> <Directory Id="INSTALLDIR" Name="MyApp"> <Component> <File Source="MyApp.exe" /> </Component> </Directory> </StandardDirectory> <!-- 桌面快捷方式 --> <StandardDirectory Id="DesktopFolder"> <Component> <Shortcut Id="DesktopShortcut" Name="MyApp" Target="[INSTALLDIR]MyApp.exe" WorkingDirectory="INSTALLDIR"/> <RegistryValue Root="HKCU" Key="Software\MyCompany\MyApp" Name="DesktopShortcutInstalled" Type="integer" Value="1" KeyPath="yes"/> </Component> </StandardDirectory> <!-- 功能定义 --> <Feature Id="MainFeature" Title="Main Application" Level="1"> <ComponentRef Id="Component_INSTALLDIR" /> <ComponentRef Id="Component_DesktopFolder" /> </Feature> <!-- 平台条件:仅64位系统 --> <Condition Message="This installer requires a 64-bit version of Windows."> <![CDATA[Installed OR VersionNT64]]> </Condition> </Package> </Wix> 报错:D:\QuickStart>dotnet build 还原完成(0.4) QuickStart 失败,出现 2 错误 (1.6 秒) D:\QuickStart\Package.wxs(2): error WIX0199: The Wix element has an incorrect namespace of 'http://wixtoolset.org/schemas/v6/wxs'. Please make the Wix element look like the following: <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">. D:\QuickStart\Package.wxs(2): error WIX0199: The Wix element has an incorrect namespace of 'http://wixtoolset.org/schemas/v6/wxs'. Please make the Wix element look like the following: <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">. 在 2.2 秒内生成 失败,出现 2 错误 怎么解决,输出修改后的完整代码
07-29
<ArcGIS defaultAssembly="ProAppModule2.dll" defaultNamespace="ProAppModule2" xmlns="http://schemas.esri.com/DADF/Registry" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.esri.com/DADF/Registry file:///D:/ArcGISPRO/bin/ArcGIS.Desktop.Framework.xsd"> <AddInInfo id="{892d4f6b-b97e-488f-aca1-f58934786604}" version="1.0" desktopVersion="3.0.36056"> <Name>ProAppModule2</Name> <Description>ProAppModule2 description</Description> <Image>Images\AddinDesktop32.png</Image> <Author>Administrator</Author> <Company>微软中国</Company> <Date>2025/8/11 11:08:31</Date> <Subject>Framework</Subject> <!-- Note subject can be one or more of these topics: Content, Framework, Editing, Geodatabase, Geometry, Geoprocessing, Layouts, Map Authoring, Map Exploration --> </AddInInfo> <modules> <insertModule id="UIManager_Module" className="Module1" autoLoad="false" caption="Module1"> <!-- uncomment to have the control hosted on a separate tab--> <tabs> <tab id="UIManager_Tab_UI" caption="UI管理器"> <group refID="UIManager_Group_UI" /> <group refID="UIManager_Group_Test" /> </tab> <tab id="UIManager_Tab_Test" caption="示例选项卡"> </tab> </tabs> <groups> <!-- comment this out if you have no controls on the Addin tab to avoid an empty group--> <group id="UIManager_Group_UI" caption="UI管理组" appearsOnAddInTab="false"> <!-- host controls within groups --> <button refID="UIManager_Show_Button" size="large" /> <button refID="UIManager_Show_Tab" size="large" /> <button refID="UIManager_Show_Group" size="large" /> </group> <group id="UIManager_Group_Test" caption="示例组" appearsOnAddInTab="false"> <button refID="UIManager_Text_Button" size="large" /> </group> </groups> <controls> <!-- add your controls here --> <button id="UIManager_Show_Button" caption="显示按钮" className="Button1" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png"> <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip> </button> <button id="UIManager_Show_Tab" caption="显示选项卡" className="Button2" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png"> <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip> </button> <button id="UIManager_Show_Group" caption="显示组" className="Button3" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png"> <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip> </button> <button id="UIManager_Text_Button" caption="示例按钮" className="Button4" loadOnClick="true" smallImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue16.png" largeImage="pack://application:,,,/ArcGIS.Desktop.Resources;component/Images/GenericButtonBlue32.png"> <tooltip heading="Tooltip Heading">Tooltip text<disabledText /></tooltip> </button> </controls> </insertModule> </modules> </ArcGIS>代码中的错误有哪些
最新发布
08-13
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:cc="http://java.sun.com/jsf/composite" xmlns:lkmcc="http://java.sun.com/jsf/composite/lkmComponent" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core"> <cc:interface/> <cc:implementation> <p:dialog header="周达成率记录" id="weekSummaryLogDia" widgetVar="weekSummaryLogDia" position="center" modal="true"> <p:dataTable id="summaryLog" widgetVar="summaryLog" value="#{wtWeekSummaryBean.showWeekSummaryLogs}" var="entity" currentPageReportTemplate="{startRecord}-{endRecord} of {totalRecords} records" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" emptyMessage="没有数据" rows="10" resizableColumns="true" style="width:450px;" rowHover="true" rowIndexVar="rowvar"> <p:column headerText="序号" style="width:15px;text-align: center;"> <h:outputText value="#{rowvar+1}"/> </p:column> <p:column headerText="周id" style="width:60px;text-align:center;"> <h:outputText value="#{entity.weekId}"/> </p:column> <p:column headerText="工号" sortBy="#{empNo}" style="width:60px;text-align:center;"> <h:outputText value="#{entity.empNo}"/> </p:column> <p:column headerText="姓名" width="50" style="text-align:center;"> <h:outputText value="#{entity.empName}"/> </p:column> <p:column headerText="网页工时" style="width:60px;text-align:right"> <h:outputText value="#{entity.webWt}"> <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/> </h:outputText> </p:column> <p:column headerText="OPT工时" style="width:60px;text-align:right"> <h:outputText value="#{entity.optWt}"> <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/> </h:outputText> </p:column> <p:column headerText="品质扣分" style="width:60px;text-align:right"> <h:outputText value="#{entity.deductWt}"> <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/> </h:outputText> </p:column> <p:column headerText="合计产出" style="width:60px;text-align:right"> <h:outputLabel value="#{entity.totalWt}"> <f:convertNumber maxFractionDigits="2" minFractionDigits="2"/> </h:outputLabel> </p:column> <p:column headerText="实际出勤" style="width:60px;text-align:right"> <h:outputText value="#{entity.onDutyHour}"/> </p:column> <p:column headerText="出勤率" sortBy="#{onDutyRate}" style="width:50px;text-align:right"> <h:outputText value="#{entity.onDutyRate}"> <f:convertNumber type="percent" maxFractionDigits="1"/> </h:outputText> </p:column> <p:column headerText="达标率" sortBy="#{uptoStandareRate}" style="width:50px;text-align:right"> <h:outputText value="#{entity.uptoStandardRate}"> <f:convertNumber type="percent" maxFractionDigits="2" /> </h:outputText> </p:column> <p:column headerText="创建时间" style="display:none;"> <h:outputText value="#{entity.createTime}"> <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8"/> </h:outputText> </p:column> <p:column headerText="更新时间" style="display:none;"> <h:outputText value="#{entity.updateTime}"> <f:convertDateTime pattern="yyyy-MM-dd HH:mm:ss" timeZone="GMT+8"/> </h:outputText> </p:column> </p:dataTable> </p:dialog> </cc:implementation> </html> 我新写的jsf碎片 别的项目要引用 这样写有没有问题
08-08
QuickStart 失败,出现 1 错误 (1.4 秒) D:\QuickStart\Package.wxs(2): error WIX0199: The Wix element has an incorrect namespace of 'http://schemas.microsoft.com/wix/2006/wi'. Please make the Wix element look like the following: <Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">. 在 2.0 秒内生成 失败,出现 1 错误 <?xml version="1.0" encoding="UTF-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> <Product Id="*" Name="MyApp" Language="1033" Version="1.0.0.0" Manufacturer="MyCompany" UpgradeCode="d79c2c0d-5eef-4a1d-ba2c-123456789abc"> <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Manufacturer="MyCompany"/> <!-- 目录结构 --> <Directory Id="TARGETDIR" Name="SourceDir"> <Directory Id="ProgramFilesFolder"> <Directory Id="INSTALLDIR" Name="MyApp"> <Component Id="MainAppFiles" Guid="*"> <File Source="MyApp.exe" KeyPath="yes" /> </Component> </Directory> </Directory> <Directory Id="DesktopFolder" Name="Desktop" /> </Directory> <!-- 桌面快捷方式 --> <Component Id="DesktopShortcutComp" Directory="DesktopFolder" Guid="a1b2c3d4-5e6f-7a8b-9c0d-ef1234567890"> <Shortcut Id="DesktopShortcut" Name="MyApp" Target="[INSTALLDIR]MyApp.exe" WorkingDirectory="INSTALLDIR"/> <RegistryValue Root="HKCU" Key="Software\MyApp" Name="Installed" Type="integer" Value="1" KeyPath="yes"/> </Component> <!-- 功能与UI --> <Feature Id="MainFeature" Title="Main Application" Level="1"> <ComponentRef Id="MainAppFiles" /> <ComponentRef Id="DesktopShortcutComp" /> </Feature> <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" /> <UIRef Id="WIXUI_InstallDir" /> </Product> </Wix> 请你再修改一下
07-29
/* * Tencent is pleased to support the open source community by making xLua available. * Copyright (C) 2016 THL A29 Limited, a Tencent company. All rights reserved. * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at * http://opensource.org/licenses/MIT * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ using System.Collections.Generic; using System; using UnityEngine; using XLua; //配置的详细介绍请看Doc下《XLua的配置.doc》 public static class ExampleGenConfig { //lua中要使用到C#库的配置,比如C#标准库,或者Unity API,第三方库等。 [LuaCallCSharp] public static List<Type> LuaCallCSharp = new List<Type>() { typeof(System.Object), typeof(UnityEngine.Object), typeof(Vector2), typeof(Vector3), typeof(Vector4), typeof(Quaternion), typeof(Color), typeof(Ray), typeof(Bounds), typeof(Ray2D), typeof(Time), typeof(GameObject), typeof(Component), typeof(Behaviour), typeof(Transform), typeof(Resources), typeof(TextAsset), typeof(Keyframe), typeof(AnimationCurve), typeof(AnimationClip), typeof(Animation), typeof(Animator), typeof(MonoBehaviour), typeof(ParticleSystem), typeof(SkinnedMeshRenderer), typeof(Renderer), typeof(WWW), typeof(System.Collections.Generic.List<int>), typeof(Action<string>), typeof(UnityEngine.Debug), typeof(BoxCollider), typeof(Mathf), typeof(UnityEngine.Random), //typeof(Input), typeof(Screen), typeof(Shader), typeof(Material), typeof(SpriteRenderer), }; //C#静态调用Lua的配置(包括事件的原型),仅可以配delegate,interface [CSharpCallLua] public static List<Type> CSharpCallLua = new List<Type>() { typeof(Action), typeof(Func<double, double, double>), typeof(Action<string>), typeof(Action<double>), typeof(UnityEngine.Events.UnityAction), }; //黑名单 [BlackList] public static List<List<string>> BlackList = new List<List<string>>() { new List<string>(){"UnityEngine.WWW", "movie"}, new List<string>(){ "UnityEngine.MonoBehaviour", "runInEditMode"}, new List<string>(){ "UnityEngine.MonoBehaviour", "useGUILayout"}, new List<string>(){"UnityEngine.Texture2D", "alphaIsTransparency"}, new List<string>(){"UnityEngine.Security", "GetChainOfTrustValue"}, new List<string>(){"UnityEngine.CanvasRenderer", "onRequestRebuild"}, new List<string>(){"UnityEngine.Light", "areaSize"}, new List<string>(){"UnityEngine.AnimatorOverrideController", "PerformOverrideClipListCleanup"}, new List<string>(){"UnityEngine.Input", "IsJoystickPreconfigured"}, #if !UNITY_WEBPLAYER new List<string>(){"UnityEngine.Application", "ExternalEval"}, #endif new List<string>(){"UnityEngine.GameObject", "networkView"}, //4.6.2 not support new List<string>(){"UnityEngine.Component", "networkView"}, //4.6.2 not support new List<string>(){"System.IO.FileInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, new List<string>(){"System.IO.FileInfo", "SetAccessControl", "System.Security.AccessControl.FileSecurity"}, new List<string>(){"System.IO.DirectoryInfo", "GetAccessControl", "System.Security.AccessControl.AccessControlSections"}, new List<string>(){"System.IO.DirectoryInfo", "SetAccessControl", "System.Security.AccessControl.DirectorySecurity"}, new List<string>(){"System.IO.DirectoryInfo", "CreateSubdirectory", "System.String", "System.Security.AccessControl.DirectorySecurity"}, new List<string>(){"System.IO.DirectoryInfo", "Create", "System.Security.AccessControl.DirectorySecurity"}, }; }
07-07
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值