Comments (2)
The failures I observe are all connected to Windows.Foundation.GuidHelper.Equals.
I made these changes to allow it to continue in case of error:
diff --git a/Generator/Types/ClassDef.cs b/Generator/Types/ClassDef.cs
index 69a8ddc..0daec82 100644
--- a/Generator/Types/ClassDef.cs
+++ b/Generator/Types/ClassDef.cs
@@ -60,7 +60,14 @@ namespace Generator.Types
}
foreach (var m in staticMethods)
{
- methodWrappers.Add(new ClassMethodDef(m, this, false));
+ try
+ {
+ methodWrappers.Add(new ClassMethodDef(m, this, false));
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Failed class static method, skipping: " + this + "→" + m);
+ }
}
// fix name clashes in method wrappers (caused by overloads from different interfaces)
diff --git a/Generator/Types/InterfaceDef.cs b/Generator/Types/InterfaceDef.cs
index 9d6cc7f..536a33e 100644
--- a/Generator/Types/InterfaceDef.cs
+++ b/Generator/Types/InterfaceDef.cs
@@ -59,8 +59,30 @@ namespace Generator.Types
InterfaceKind = GetInterfaceKind(Generator, this, exclusiveToType);
- rawMethodDeclarations = methods.Select(m => m.GetRawDeclaration()).ToList();
- wrapperMethodDeclarations = methods.Select(m => m.GetWrapperDefinition()).ToList();
+ rawMethodDeclarations = new List<string>();
+ foreach (var m in methods)
+ {
+ try
+ {
+ rawMethodDeclarations.Add(m.GetRawDeclaration());
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Failed interface raw method declaration, skipping: " + this + "→" + m);
+ }
+ }
+ wrapperMethodDeclarations = new List<string>();
+ foreach (var m in methods)
+ {
+ try
+ {
+ wrapperMethodDeclarations.Add(m.GetWrapperDefinition());
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("Failed interface wrapper method declaration, skipping: " + this + "→" + m);
+ }
+ }
}
public override void Emit()
This causes it to seem to run successfully, with the following console output which confirms the problem to be localised to one method (and its variants):
Failed class static method, skipping: Windows.Foundation.GuidHelper→Equals
Failed interface raw method declaration, skipping: Windows.Foundation.IGuidHelperStatics→Equals
Failed interface wrapper method declaration, skipping: Windows.Foundation.IGuidHelperStatics→Equals
from winrt-rust.
This is interesting! This method has two parameters that are apparently typed as const references. They have this additional modifier System.Runtime.CompilerServices.IsConst
, which I've never seen before.
MSDN says: (https://docs.microsoft.com/de-de/dotnet/api/system.runtime.compilerservices.isconst)
The Microsoft C++ compiler emits this modifier into metadata for any parameter, return type, or object declaration declared as const in the source code.
The ECMA Partition II documentation for CLI says:
The CLI itself shall treat required and optional modifiers in the same manner. Two signatures that differ only by the addition of a custom modifier (required or optional) shall not be considered to match. Custom modifiers have no other effect on the operation of the VES.
[Rationale: The distinction between required and optional modifiers is important to tools other than the CLI that deal with the metadata, typically compilers and program analysers. A required modifier indicates that there is a special semantics to the modified item that should not be ignored, while an optional modifier can simply be ignored.
For example, the const qualifier in the C programming language can be modelled with an optional modifier since the caller of a method that has a const-qualified parameter need not treat it in any special way. On the other hand, a parameter that shall be copy-constructed in C++ shall be marked with a required custom attribute since it is the caller who makes the copy. end rationale]
So this means that in this case I can emit a *const Guid
instead of a *mut Guid
(or simply ignore it, because there's not really a difference between *const
and *mut
).
Update:
Actually, there never have been reference input parameters before: *mut Guid
previously only existed as an output parameter, but now we have *const Guid
as input, which maps to &Guid
in the wrapper. Every other method before that took a value type parameter did receive it by value.
Also, ILSpy shows this signature as bool Equals([In] ref Guid target, [In] ref Guid value);
.
I have a fix for the generator ready, just need to test if the generated code actually is correct and works.
from winrt-rust.
Related Issues (20)
- HString should implement Send
- `RuntimeContext` should not be `Send` or `Sync` HOT 2
- RO_INIT_MULTITHREADED doesn’t work for everything HOT 14
- Why does AsyncOperationCompletedHandler::new require Send? HOT 3
- Some special cases are needed for the snake case conversion HOT 3
- Use ptr::NonNull in ComPtr
- Reconsider error handling HOT 4
- [Idea] On-demand code generation
- Implement std::error::Error for winrt::Error HOT 2
- Provide the IInitializeWithWindow interface
- Figure out the story around Send and Sync
- Use main() -> Result<...> in the examples
- Fix type for `HttpProgress` struct
- Implement support for weak references
- Can we hide `ComPtr` from the public API? HOT 5
- Using COM components? HOT 2
- Generator can't access WinMD files anymore
- COM library for Rust being built under Microsoft GitHub organization
- How to create API parameter `foundation::collections::IIterable<HString>` ? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from winrt-rust.