I have a project that does some file and data manipulation using several classes generated from elsewhere. I'm trying to use those generated classes in one place, but I'm running into issues when I add references in ProcessorProject
to more than one of the "Item" projects because the object names conflict with each other.
I know that this could be easily solved by wrapping the generated code within the "Item" classes in their projects' namespace, but I'm trying to avoid modifying those generated files in any way.
Is there any other way around this that I'm not thinking of? A way to add that generated code to the project namespace without actually modifying the files themselves? Something else?
Very simplified model:
ProcessorProject
Processor.cs
switch (color)
case "Blue":
BlueUtility.DoSomething();
break;
case "Red":
RedUtility.DoSomething();
break;
BlueItemProject
BlueUtility.cs
namespace BlueItem
class BlueUtility
BlueItem.cs [generated]
partial class BlueItemInfo
public ItemInfo Information
public SomeOtherInformation MoreInformation
partial class ItemInfo
partial class SomeOtherInformation
RedItemProject
RedUtility.cs
namespace RedItem
class RedUtility
RedItem.cs [generated]
partial class RedItemInfo
public ItemInfo Information
public SomeOtherInformation MoreInformation
partial class ItemInfo
partial class SomeOtherInformation
CodePudding user response:
Create an alias for each reference in the References properties window. Then on the file where you use them write something like this at the top
extern alias NewAliasOfProject;
using NewAliasOfProject::NamespaceName;