public void Emit() { var descriptor = GetTypeIIDDescriptor(Type.Generator, originalType); var iidName = "IID_" + Regex.Replace(originalType.FullName.Substring(Type.Namespace.Length + 1), @"[\.`<>,]", "_").TrimEnd('_'); var guid = Utility.GuidUtility.Create(Namespace, descriptor); var guidStr = Regex.Replace(guid.ToString("X"), @"[\{\}]", ""); var dependsOnAssemblies = new List <string>(ForeignAssemblyDependencies.GroupBy(t => t.Module.Assembly.Name.Name).Select(g => g.Key)); var features = new FeatureConditions(dependsOnAssemblies); Module.Append($@" { features.GetAttribute() }RT_PINTERFACE!{{ for { Name } => [{ guidStr }] as { iidName } }}"); }
public FeatureConditions GetFeatureCondition() { var dependsOnAssemblies = new List <string>(ForeignAssemblyDependencies.GroupBy(t => t.Module.Assembly.Name.Name).Select(g => g.Key)); return(new FeatureConditions(dependsOnAssemblies)); }
public override void Emit() { var classType = DefinitionName; bool needClassID = false; if (Type.Interfaces.Count > 0) { var dependsOnAssemblies = new List <string>(ForeignAssemblyDependencies.GroupBy(t => t.Module.Assembly.Name.Name).Select(g => g.Key)); var features = new FeatureConditions(dependsOnAssemblies); Module.Append($@" { features.GetAttribute() }RT_CLASS!{{class { DefinitionName }: { aliasedType }}}"); if (!features.IsEmpty) { // if the aliased type is from a different assembly that is not included, just use IInspectable instead // otherwise types depending on this class would transitively depend on the aliased type Module.Append($@" { features.GetInvertedAttribute() }RT_CLASS!{{class { DefinitionName }: IInspectable}}"); } foreach (var factory in factories.OrderBy(f => f)) { needClassID = true; Module.Append($@" impl RtActivatable<{ factory }> for { classType } {{}}"); } } else { Assert(!factories.Any()); Module.Append($@" RT_CLASS!{{static class { DefinitionName }}}"); } foreach (var staticType in statics.OrderBy(t => t.FullName)) { var staticName = Generator.GetTypeDefinition(staticType).DefinitionName; needClassID = true; Module.Append($@" impl RtActivatable<{ staticName }> for { classType } {{}}"); } if (IsDefaultActivatable()) { needClassID = true; Module.Append($@" impl RtActivatable<IActivationFactory> for { classType } {{}}"); } if (methodWrappers.Any()) { Module.Append($@" impl { DefinitionName } {{ { String.Join("\r\n ", methodWrappers.Select(m => m.Emit())) } }}"); } if (needClassID) { Module.Append($@" DEFINE_CLSID!({ classType }(&[{ NameHelpers.StringToUTF16WithZero(Type.FullName) }]) [CLSID_{ classType }]);"); } }